So have you ever wanted to have day and night cycles while going along your business in quake? Sure you have! And now it will be possible!
Surprise, this is another tutorial that requires dpextensions.qc and DP or FTE.
So lets open up progs.src and place this in it:
Now lets make nightday.qc
In it place this:
This beauty will spawn an entity and will start the cycle. It will gradually change the lighting level of all world lights to the minimum light level of 1.5 and back to the max level of 15. It gives you a simulated night and day cycle. If you want it to be longer simply set a higher number for the autocvar nightdayinterval. 20 is a pretty good cycle. But if you want to change it just place set nightdayinterval 30 or whatever you want the cycle to be in an autoexec.cfg or similar. You can also change it from the console but you will need to restart for the changes to make effect.
So now we need to open up world.qc and scroll down to worldspawn() at the top place this:
Ok that's it. Compile and you have night and day cycles! You may want to make some skyboxes to match for night time but otherwise its pretty cool effect. Have fun!


So lets open up progs.src and place this in it:
Code:
items.qc weapons.qc [COLOR="Lime"]nightday.qc[/COLOR] Here is fine :) world.qc client.qc
In it place this:
Code:
[COLOR="lime"]// Night and Day Cycle Fields[/COLOR] entity nightdaychanger; .float daynightlightlevel; .string nightdaylightstring; .float lightchange; float min_lightlevel; float max_lightlevel; [COLOR="lime"]//Autocvar for time between day and night changes (Can be set in autoexec.cfg or default.cfg)[/COLOR] var float autocvar_nightdayinterval = 20; [COLOR="Lime"]// This function will change the time of day, basically every 20 seconds it will lower the lightlevel by 1 until it reaches the minimum light level and will start over again in reverse. [/COLOR] void() NightDayLightThink = { [COLOR="lime"]// If its time to be daylight again start increasing light[/COLOR] if(self.lightchange) { self.daynightlightlevel++; [COLOR="lime"] // If the light level gets too high its full daytime start getting darker soon[/COLOR] if(self.daynightlightlevel > max_lightlevel) { self.daynightlightlevel = max_lightlevel - 1; self.lightchange = FALSE; } } [COLOR="lime"] // Is it me or is it getting dark around here? [/COLOR] else { self.daynightlightlevel = self.daynightlightlevel - 1; if(self.daynightlightlevel < min_lightlevel) { [COLOR="lime"]//Make sure light level stays at min_lightlevel and restart[/COLOR] self.daynightlightlevel = min_lightlevel; self.lightchange = TRUE; } } [COLOR="lime"] // This changes all lights in the level except torches, etc or any lights that use on and off flags lightstyles 32+[/COLOR] lightstyle(0, substring(self.nightdaylightstring, self.daynightlightlevel, 1) ); self.nextthink = time + autocvar_nightdayinterval; // Repeat in 20 seconds }; [COLOR="lime"]// This will create our entity and start the cycle[/COLOR] void() NightDayLightChanger = { if(autocvar_nightdayinterval > 0) { [COLOR="Lime"]// Set up our light value min and max[/COLOR] max_lightlevel = 15; min_lightlevel = 1.5; [COLOR="lime"]//If we don't have a sun make one![/COLOR] if(!nightdaychanger) { nightdaychanger = spawn(); [COLOR="Lime"]// No need to send this to the client[/COLOR] nightdaychanger.effects = EF_NODRAW; nightdaychanger.think = NightDayLightThink; [COLOR="lime"]// Start it daylight because nighttime is scary[/COLOR] nightdaychanger.daynightlightlevel = max_lightlevel; [COLOR="Lime"] // We want the light to change gradually [/COLOR] nightdaychanger.nightdaylightstring = "abcdefghijklmnopqrstuvwxyz"; [COLOR="lime"]// Lets get started[/COLOR] nightdaychanger.nextthink = time + 0.5; } } };
So now we need to open up world.qc and scroll down to worldspawn() at the top place this:
Code:
void() worldspawn = { lastspawn = world; InitBodyQue (); [COLOR="lime"]// Here is fine :) [/COLOR] NightDayLightChanger();
Comment