Game Manager with Time and Weather
by Bil Simser · 07/23/2004 (9:42 am) · 89 comments
I wanted to build a nice, pluggable time and weather system into Torque for would-be RPG creators to use. I didn't see anything that I really liked already so I built this one.
NOTE: The resource link is at the end of this article due to size restrictions when uploading to GarageGames so it's hosted offline.

Features:
* configurable game time system that handles time and weather advancement (you can use it for any game management you want like bots, spell recharge times, whatever but this mod just gives you time and weather)
* completely scripted system and easy to modify, extend and add to
* you determine how fast (or slow) time advances (real time, 1 game time hour = 75 seconds, whatever)
* weather system tracks atmospheric pressure and changes accordingly (based on values and the time of year)
* time system is streamed out to the file system on the server and can be reloaded to keep a pseudo persistant world going (at least as far as keeping track of time goes)
* weather system initiates clouds, rain, fog, lightning and cleans up when the cycle stops (pressure builds and declines so it's not constant)
* time and weather system can be queried by user to get information (yes, they can look up into the sky but someone people like to know what's going on through messages).
* configurable time system uses whatever calendar you want (real, fantasy, etc.) with day and month names to give your users a rich experience.

QuickStart
So you want to get up and running with this. Easy! Here's the instructions to try out the no-hassle install:
1. Unzip the resource into your game directory. Any game will do (and this will work with an out-of-the-box starter.fps)
2. Go into the file server/game.cs and in the onServerCreated() function, add the following line:
Time and weather changes will start. There are two hotkeys setup for you.
F5 will display the current time and date
F6 will display the current weather conditions
The Mod
The mod is made up of the following files and their locations:
server/scripts/gameMgr.cs - The Game Manager class
server/scripts/time.cs - Time Manager class
server/scripts/weather.cs - Weather Manager class
data/environment/* - rain and lightning graphic files
data/sounds/environment/* - rain and lightning sound files
How it Works
The GameManager class runs everything. You call the ::init method from your own game.cs file to kick it off. It will then initialize any game managers you create and start its own ::update schedule.
The ::update method just calls the same method for each manager. In the same, the TimeManager.update method handles advancing the game calendar while the WeatherManager.update will change the conditions in the game, creating rain, lightning and fog when appropriate.
The GameManager.update method runs every second and tracks a variable called pulse. The pulse variable keeps track of our game clock ticks and is used to determine when a game event fires. You can have as many game events as you like (time, weather, hit point regen, etc.)
and have them fire at different periods. Pulse is updated once per pass through the update method so you just set the frequency of how often your own event handler fires. Think of pulse as a counter.
There's also a global variable called $GameManagerPrefs::SecsPerGameHour. This is the number of real seconds that pass in one game hour and determines when a "game" hour has passed. You can use it to fire events on an hourly basis (e.g. a player needs 1 hour to recharge a spell). The time and weather system update every game hour with this:
In the update method you can use the Pulse variable to fire an event every 30 seconds (using the Modulus operator) with this call:
So even though the TimeManager.update is happening every second, you don't have to do something every second (which might be taxing on your system). Just try to keep your events short and not too CPU intensive.
Tweaking the System
At the top of each file there are some global variables that can be tweaked. In the TimeManager for example, the number of days in a week, months in a year, etc. as well as the day and month names can be changed to suit your game. Just change whatever you want there and the rest will be updated.
Global Key bindings
The sample mod contains two global keybinding, F5 and F6 (which were unused so I chose them) to call the methods to display the time and weather information to to user. You can move these or rebind them to other keys as you see fit.
Utility Functions
I've added a min and max function which will return the minimum or maximum values of two numbers. I think every game needs this. There's also a handy function called dice(). Pass it the number of dice you want to roll and how many sides each die has and it will come back with a total. If you're from the old AD&D world, this is your typical 2d6, 4d8 and 3d10 rolls. Hope you find it handy.
Notes and Enhancements
A lot of extendability here but it's a fully working time keeper and weather system for someone to use in a single player or multiplayer game. For example you could build a calendar gui component to display on the screen and have it update as time advances in your game. Whatever your imagine takes you I guess.
The weather is driven by atmospheric pressure values, the current sky conditions and some random chance. It's all in one script function but parts of it could be externalized or become data driven. It's pretty basic so nothing really magical here, just easy to use.
I haven't plugged in a real day/night system as that involves engine changes and wanted to keep this as a scripting mod only so you're welcome to do that. The system keeps track of the hour of the game time day so you can still use it (like only allowing certain things to happen at night or the automatic opening and closing of stores during business hours).
With the system running, you can do some cool stuff like display the game time on the screen for players to see. As I mentioned, you can also query the TimeManager system about what the hour of the day is and do things like restrict access to areas, transform those infected with the lycanthrope disease when the moon is out, or otherwise just mess with your players lives when the sun rises and there's no coffin around to sleep in. The choices are yours.
This is, overall, pretty basic but it's a start. Read the source as there are many comments about how to expand or extend this. If you do create something better or add onto it, please let me know and I'll update this for everyone to share.
TorqueScript isn't OO but I did try to make it somewhat OO'ish. Personally I think there's too many global variables and maybe too many ScriptObjects being created so that could be improved. As well, perhaps putting the Managers into an array or list would be better. In any case, if you do improve on it or find a bug share it.
You can also find the resource here:
www.bilsimser.org/download/gamemgr.zip
Enjoy!
NOTE: The resource link is at the end of this article due to size restrictions when uploading to GarageGames so it's hosted offline.

Features:
* configurable game time system that handles time and weather advancement (you can use it for any game management you want like bots, spell recharge times, whatever but this mod just gives you time and weather)
* completely scripted system and easy to modify, extend and add to
* you determine how fast (or slow) time advances (real time, 1 game time hour = 75 seconds, whatever)
* weather system tracks atmospheric pressure and changes accordingly (based on values and the time of year)
* time system is streamed out to the file system on the server and can be reloaded to keep a pseudo persistant world going (at least as far as keeping track of time goes)
* weather system initiates clouds, rain, fog, lightning and cleans up when the cycle stops (pressure builds and declines so it's not constant)
* time and weather system can be queried by user to get information (yes, they can look up into the sky but someone people like to know what's going on through messages).
* configurable time system uses whatever calendar you want (real, fantasy, etc.) with day and month names to give your users a rich experience.

QuickStart
So you want to get up and running with this. Easy! Here's the instructions to try out the no-hassle install:
1. Unzip the resource into your game directory. Any game will do (and this will work with an out-of-the-box starter.fps)
2. Go into the file server/game.cs and in the onServerCreated() function, add the following line:
exec("./gameMgr.cs");3. In the same file add the following code to the startGame() function:// Start the GameManager new ScriptObject(GameManager); MissionCleanup.add(GameManager); GameManager.init();4. Add the following line to the endGame() function:
// Stop the GameManager GameManager.delete();5. Launch the game and wait.
Time and weather changes will start. There are two hotkeys setup for you.
F5 will display the current time and date
F6 will display the current weather conditions
The Mod
The mod is made up of the following files and their locations:
server/scripts/gameMgr.cs - The Game Manager class
server/scripts/time.cs - Time Manager class
server/scripts/weather.cs - Weather Manager class
data/environment/* - rain and lightning graphic files
data/sounds/environment/* - rain and lightning sound files
How it Works
The GameManager class runs everything. You call the ::init method from your own game.cs file to kick it off. It will then initialize any game managers you create and start its own ::update schedule.
The ::update method just calls the same method for each manager. In the same, the TimeManager.update method handles advancing the game calendar while the WeatherManager.update will change the conditions in the game, creating rain, lightning and fog when appropriate.
The GameManager.update method runs every second and tracks a variable called pulse. The pulse variable keeps track of our game clock ticks and is used to determine when a game event fires. You can have as many game events as you like (time, weather, hit point regen, etc.)
and have them fire at different periods. Pulse is updated once per pass through the update method so you just set the frequency of how often your own event handler fires. Think of pulse as a counter.
There's also a global variable called $GameManagerPrefs::SecsPerGameHour. This is the number of real seconds that pass in one game hour and determines when a "game" hour has passed. You can use it to fire events on an hourly basis (e.g. a player needs 1 hour to recharge a spell). The time and weather system update every game hour with this:
if((%this.Pulse % %this.SecsPerGameHour) == 0)
{
TimeManager.update();
WeatherManager.update();
}In the update method you can use the Pulse variable to fire an event every 30 seconds (using the Modulus operator) with this call:
if((%this.Pulse % 30) == 0)
{
// Do something every 30 seconds real-time
}So even though the TimeManager.update is happening every second, you don't have to do something every second (which might be taxing on your system). Just try to keep your events short and not too CPU intensive.
Tweaking the System
At the top of each file there are some global variables that can be tweaked. In the TimeManager for example, the number of days in a week, months in a year, etc. as well as the day and month names can be changed to suit your game. Just change whatever you want there and the rest will be updated.
Global Key bindings
The sample mod contains two global keybinding, F5 and F6 (which were unused so I chose them) to call the methods to display the time and weather information to to user. You can move these or rebind them to other keys as you see fit.
Utility Functions
I've added a min and max function which will return the minimum or maximum values of two numbers. I think every game needs this. There's also a handy function called dice(). Pass it the number of dice you want to roll and how many sides each die has and it will come back with a total. If you're from the old AD&D world, this is your typical 2d6, 4d8 and 3d10 rolls. Hope you find it handy.
Notes and Enhancements
A lot of extendability here but it's a fully working time keeper and weather system for someone to use in a single player or multiplayer game. For example you could build a calendar gui component to display on the screen and have it update as time advances in your game. Whatever your imagine takes you I guess.
The weather is driven by atmospheric pressure values, the current sky conditions and some random chance. It's all in one script function but parts of it could be externalized or become data driven. It's pretty basic so nothing really magical here, just easy to use.
I haven't plugged in a real day/night system as that involves engine changes and wanted to keep this as a scripting mod only so you're welcome to do that. The system keeps track of the hour of the game time day so you can still use it (like only allowing certain things to happen at night or the automatic opening and closing of stores during business hours).
With the system running, you can do some cool stuff like display the game time on the screen for players to see. As I mentioned, you can also query the TimeManager system about what the hour of the day is and do things like restrict access to areas, transform those infected with the lycanthrope disease when the moon is out, or otherwise just mess with your players lives when the sun rises and there's no coffin around to sleep in. The choices are yours.
This is, overall, pretty basic but it's a start. Read the source as there are many comments about how to expand or extend this. If you do create something better or add onto it, please let me know and I'll update this for everyone to share.
TorqueScript isn't OO but I did try to make it somewhat OO'ish. Personally I think there's too many global variables and maybe too many ScriptObjects being created so that could be improved. As well, perhaps putting the Managers into an array or list would be better. In any case, if you do improve on it or find a bug share it.
You can also find the resource here:
www.bilsimser.org/download/gamemgr.zip
Enjoy!
About the author
Recent Blogs
• Plan for Bil Simser• Plan for Bil Simser
• Plan for Bil Simser
• Plan for Bil Simser
• Plan for Bil Simser
#22
With some wrenching I got this in.
I have everything working fine except I have the same problem as Chip.
The rain appeared once but disappeared at certain angles and the graphic didn't show, just sqaures.
I checked the console, nada.
Any help?
Ari Rule (Programmer and Modeler)
08/06/2004 (1:51 am)
Thanks Bill!With some wrenching I got this in.
I have everything working fine except I have the same problem as Chip.
The rain appeared once but disappeared at certain angles and the graphic didn't show, just sqaures.
I checked the console, nada.
Any help?
Ari Rule (Programmer and Modeler)
#23
Sorry I spelled your name wrong Bil.
Chip, here is what I did to get the rain to kick in a little more.
//datablock PrecipitationData(HeavyRain)
//{
// soundProfile = "HeavyRainSound";
// dropTexture = "~/data/environment/rain";
// splashTexture = "~/data/environment/water_splash";
// dropSize = 0.75;
// splashSize = 0.2;
// useTrueBillboards = false;
// splashMS = 250;
//};
datablock PrecipitationData(HeavyRain)
{
type = 1;
materialList = "~/data/environment/rain.dml";
soundProfile = "HeavyRainSound";
sizeX = 0.1;
sizeY = 0.1;
movingBoxPer = 0.35;
divHeightVal = 1.5;
sizeBigBox = 1;
topBoxSpeed = 20;
frontBoxSpeed = 30;
topBoxDrawPer = 0.5;
bottomDrawHeight = 40;
skipIfPer = -0.3;
bottomSpeedPer = 1.0;
frontSpeedPer = 1.5;
frontRadiusPer = 0.5;
};
I just remmed out the original code and copied the datablock from the demo dir.
Now the rain texture works.
However, it seems to disapear at certain angles, the rain sound does not stop, and I am worried that the splashes don't show (I sill haven't seen them).
I am using a heavily modded version of the HEAD I downloaded sometime near April.
Does this require additional precipitation mods?
Please let me know, I try and get a feature a night, and it's 4am.
Hopefully the sun will be rising in TGE when it rises for me. :)
Any1 thought of using an online weather stream and the system clock to feed this?
I'll give it a wack tommorow.
Ari Rule (Programmer and Modeller)
08/06/2004 (2:37 am)
Ok,Sorry I spelled your name wrong Bil.
Chip, here is what I did to get the rain to kick in a little more.
//datablock PrecipitationData(HeavyRain)
//{
// soundProfile = "HeavyRainSound";
// dropTexture = "~/data/environment/rain";
// splashTexture = "~/data/environment/water_splash";
// dropSize = 0.75;
// splashSize = 0.2;
// useTrueBillboards = false;
// splashMS = 250;
//};
datablock PrecipitationData(HeavyRain)
{
type = 1;
materialList = "~/data/environment/rain.dml";
soundProfile = "HeavyRainSound";
sizeX = 0.1;
sizeY = 0.1;
movingBoxPer = 0.35;
divHeightVal = 1.5;
sizeBigBox = 1;
topBoxSpeed = 20;
frontBoxSpeed = 30;
topBoxDrawPer = 0.5;
bottomDrawHeight = 40;
skipIfPer = -0.3;
bottomSpeedPer = 1.0;
frontSpeedPer = 1.5;
frontRadiusPer = 0.5;
};
I just remmed out the original code and copied the datablock from the demo dir.
Now the rain texture works.
However, it seems to disapear at certain angles, the rain sound does not stop, and I am worried that the splashes don't show (I sill haven't seen them).
I am using a heavily modded version of the HEAD I downloaded sometime near April.
Does this require additional precipitation mods?
Please let me know, I try and get a feature a night, and it's 4am.
Hopefully the sun will be rising in TGE when it rises for me. :)
Any1 thought of using an online weather stream and the system clock to feed this?
I'll give it a wack tommorow.
Ari Rule (Programmer and Modeller)
#24
That helped me out and now I'm up there with you. Do we maybe have to have the new precipatation code that was put in the HEAD a month or so ago? I'll try that and update to the newest head (using the HEAD release from mid May I believe). Thanks though for getting me that far Ari :)
Back to the drawing board...
Chip
08/06/2004 (6:05 am)
Thanks Ari,That helped me out and now I'm up there with you. Do we maybe have to have the new precipatation code that was put in the HEAD a month or so ago? I'll try that and update to the newest head (using the HEAD release from mid May I believe). Thanks though for getting me that far Ari :)
Back to the drawing board...
Chip
#25
The resource doesn't require any additional mods, it just uses the default precipiation thats in the current HEAD. The datablocks were actually copied straight from the demo app so they should work fine. Not sure if splashes work as that's a C++ feature, not a scripting thing.
You can always put in some debugging messages to write out the state as it advances through it's cycles (that's what I did to ensure every state was hit and in a timely manner). There are a couple of bug fixes listed in this thread which I haven't updated in the resource yet, so that's another thing to check.
I think hooking up to an online weather and clock system would be pretty sweet, but would have to be appropriate for the game (this mod is more for games where it's not real-time but can be used for that).
Thanks.
08/06/2004 (9:15 am)
Hi guys,The resource doesn't require any additional mods, it just uses the default precipiation thats in the current HEAD. The datablocks were actually copied straight from the demo app so they should work fine. Not sure if splashes work as that's a C++ feature, not a scripting thing.
You can always put in some debugging messages to write out the state as it advances through it's cycles (that's what I did to ensure every state was hit and in a timely manner). There are a couple of bug fixes listed in this thread which I haven't updated in the resource yet, so that's another thing to check.
I think hooking up to an online weather and clock system would be pretty sweet, but would have to be appropriate for the game (this mod is more for games where it's not real-time but can be used for that).
Thanks.
#26
Are you still having problems? I updated to the newest HEAD (which had that new weather code in it from a month ago maybe) and it worked somewhat better. Still not "raining" all the time though when it says it is. Also I still do not see any lightning. I was curious if you had got yours completely worked out and what you did to make it so.
Thanks.
Chip
08/09/2004 (10:24 am)
Ari:Are you still having problems? I updated to the newest HEAD (which had that new weather code in it from a month ago maybe) and it worked somewhat better. Still not "raining" all the time though when it says it is. Also I still do not see any lightning. I was curious if you had got yours completely worked out and what you did to make it so.
Thanks.
Chip
#27
if($weather_info.pressure <= 980)
{
$weather_info.sky = $sky_lightning;
Sky.stormClouds(1, $time_to_storm); // added to start lightning, rain and clouds
Sky.stormFog(1, $time_to_storm);
%this.startRain();
%this.startLightning();
}
else if($weather_info.pressure <= 1000)
{
$weather_info.sky = $sky_raining;
Sky.stormClouds(1, $time_to_storm); // added to start rain and clouds
Sky.stormFog(1, $time_to_storm);
%this.startRain();
}
else if($weather_info.pressure <= 1020)
{
$weather_info.sky = $sky_cloudy;
Sky.stormClouds(1, $time_to_storm); // added to start clouds
Sky.stormFog(1, $time_to_storm);
}
else
$weather_info.sky = $sky_cloudless;
I also am now working on the rain only coming up white squares (know I came across this while testing precip before but can't recall the fix). If I figure it out before someone else tosses here I will update this thread with the fix for that also.
Good luck and happy scripting
08/16/2004 (12:07 am)
First, let me say thank you for the scripting work on this. It is a solid resource and I am glad to not have to start over from square one on some of these areas but rather enhance them here and there to fit a projects needs. On that note, I am currently integrating this into a project used in server mode so I can attest it works there with similar results others seem to be having. I did notice something (or perhaps I missed it happening in another way but it was not working on my build either way =)) that some changed code in the weathermanager::init() routine would allow the weather to startup with the initialize. Let me rephrase that as I just confused myself.... When you connect a client and the weather manager starts, it sets a flag for current status. However it does not seem to force a start if that status is cloudy/raining/lightning. I added a couple pieces of code and it works now if you enter the game and F5 reports rain it will be raining. Not sure if that helps others, but thought I would pass it along. Below is the code changed, only a couple pieces were added to each part but feel free to post if any questions.if($weather_info.pressure <= 980)
{
$weather_info.sky = $sky_lightning;
Sky.stormClouds(1, $time_to_storm); // added to start lightning, rain and clouds
Sky.stormFog(1, $time_to_storm);
%this.startRain();
%this.startLightning();
}
else if($weather_info.pressure <= 1000)
{
$weather_info.sky = $sky_raining;
Sky.stormClouds(1, $time_to_storm); // added to start rain and clouds
Sky.stormFog(1, $time_to_storm);
%this.startRain();
}
else if($weather_info.pressure <= 1020)
{
$weather_info.sky = $sky_cloudy;
Sky.stormClouds(1, $time_to_storm); // added to start clouds
Sky.stormFog(1, $time_to_storm);
}
else
$weather_info.sky = $sky_cloudless;
I also am now working on the rain only coming up white squares (know I came across this while testing precip before but can't recall the fix). If I figure it out before someone else tosses here I will update this thread with the fix for that also.
Good luck and happy scripting
#28
Anyhow, off to try a few more things before I leap to another resource and continue learning the engine. Good luck and thanks again all for the great script ideas and base
08/16/2004 (12:24 am)
Hmmm, I really gotta stop waiting so long to search the forums for answers. Anyone still getting white squares for rain, the HEAD changed sometime over the last couple months with new precip code and the old datablocks seem not to work. I haven't followed up completely yet as I am just happy it is working. However if your interested in trying, do a search on forums for 'precipitation' and should find the parts needed. I would post the link to one I hit, but it is under private and I am not sure of bounds there so avoiding for safety. :)Anyhow, off to try a few more things before I leap to another resource and continue learning the engine. Good luck and thanks again all for the great script ideas and base
#29
Really cool resource, man. I was reading through most of the code and besides some of the changes Tom pointed out, it looks pretty solid.. will probably work on getting that put in soon.
@Those getting white boxes instead of raindrops
It has to do with some versions of HEAD not liking the .dml Material List for some reason. If you go in and change rain.dml to rain.png for the texture, it will work. I had that same problem when I first started messing with PrecipitationData.
08/20/2004 (9:41 am)
@BilReally cool resource, man. I was reading through most of the code and besides some of the changes Tom pointed out, it looks pretty solid.. will probably work on getting that put in soon.
@Those getting white boxes instead of raindrops
It has to do with some versions of HEAD not liking the .dml Material List for some reason. If you go in and change rain.dml to rain.png for the texture, it will work. I had that same problem when I first started messing with PrecipitationData.
#30
Everthing is working fine except for 2 parts...
The rain sound continues after it stops raining. :(
I don't know much about the sound in the Torque engine but I'm sure it's just 1 line of code.
I also added the no rain in interiors/water code.
Now I am able to get the vector of the rain as it hits, particle splashes should be easy from here on out.
I also noted that the text messages are sometimes backwards, "The clouds dissapear" and then they roll in, lol!
They are not set with defaults that's all, no big deal.
It's not a problem since the text messages are only for debuggin and won't go into our game.
Oh wait!!!
Mark you fixed it!
Thanks man.
Chip: Glad I could help. I'm trying to give back when and where I can.
Ari Rule (Programmer and Modeler)
08/21/2004 (3:14 pm)
Hey guys,Everthing is working fine except for 2 parts...
The rain sound continues after it stops raining. :(
I don't know much about the sound in the Torque engine but I'm sure it's just 1 line of code.
I also added the no rain in interiors/water code.
Now I am able to get the vector of the rain as it hits, particle splashes should be easy from here on out.
I also noted that the text messages are sometimes backwards, "The clouds dissapear" and then they roll in, lol!
They are not set with defaults that's all, no big deal.
It's not a problem since the text messages are only for debuggin and won't go into our game.
Oh wait!!!
Mark you fixed it!
Thanks man.
Chip: Glad I could help. I'm trying to give back when and where I can.
Ari Rule (Programmer and Modeler)
#31
I was wondering when this resource might be updated with day/night cycles, the observed fixes, and perhaps the particle based cloud system I saw somewhere else.
Great Resource, I learned a lot from it, thanks!
08/22/2004 (10:07 am)
Hello All.I was wondering when this resource might be updated with day/night cycles, the observed fixes, and perhaps the particle based cloud system I saw somewhere else.
Great Resource, I learned a lot from it, thanks!
#32
I thank you all for your help and errata and most of all I thank you Bill.
08/22/2004 (8:09 pm)
Thanks guys, I finally got everything working beautifully. Now the task of getting day/night cycles integrated is at hand.I thank you all for your help and errata and most of all I thank you Bill.
#33
does anyone else have the rain start/stop instantly?
on another note: this + day night rocks :)
If you want to use the Day/night Clestials patch, with the defult time cycle(its 1 minut >.< ) you set, assuming your using 24 hours, the seconds per game hour value to 2.5;
also, set the starting time at about 13 hours, if you use the default sun position.
NOTE: this insturction will only work with the Celestial patch(haven tested the other day/night yet, may get back to you guys.
09/13/2004 (12:54 pm)
is it just me or does the rain stop and start instantanteously?does anyone else have the rain start/stop instantly?
on another note: this + day night rocks :)
If you want to use the Day/night Clestials patch, with the defult time cycle(its 1 minut >.< ) you set, assuming your using 24 hours, the seconds per game hour value to 2.5;
also, set the starting time at about 13 hours, if you use the default sun position.
NOTE: this insturction will only work with the Celestial patch(haven tested the other day/night yet, may get back to you guys.
#34
Finally got the rain working with a lot of tweaking and messing around. I am having diffictulty getting the right cloud sequence to preempt the rain.
Also, I am looking for a day/night mod rather then a patch, anything like that available?
09/18/2004 (8:45 pm)
Greetings,Finally got the rain working with a lot of tweaking and messing around. I am having diffictulty getting the right cloud sequence to preempt the rain.
Also, I am looking for a day/night mod rather then a patch, anything like that available?
#35
10/05/2004 (10:26 am)
I got his working with some screwin around, but i could not get day night patch working(any of them), and it would be great if someone could get day/night working with latest head without any problems, in script would be great but i think someone said it had to be done in c++ which means patch i guess. As long as the patch works totally with head then im fine with it.
#36
for those interested in smoother starting and stopping of rain.
1. fix the spelling of "setPercentange" -> setPercentage in precipitation.cc
2. in precipitation.cc in packUpdate get rid of this chunk of code
snip....!(mask & ~(DataMask | PercentageMask | StormMask)) && ...snip
and make it just
if (stream->writeFlag( mask & StormMask))
this lets you set the percentage and then modify the storm right after. I'm not sure if that code served some other purpose but I haven't seen any ill effects in the 2 minutes of testing so far :)
3. in weather.cs, in StartRain
after the new Precipitation object is created
add
this sets the starting percentage to be 10 % and it will reach 99% $time_to_full_rain seconds later.
4. in weather.cs in StopRain, change it to look like this
this will take the rain to 10% $time_to_stop_rain seconds later.
and then delete the rain object a half second after that is finished.
5. add to the top of weather.cs
fun fun.
02/22/2005 (4:05 pm)
great resource. nice scripting, clean and easy to understand.for those interested in smoother starting and stopping of rain.
1. fix the spelling of "setPercentange" -> setPercentage in precipitation.cc
2. in precipitation.cc in packUpdate get rid of this chunk of code
snip....!(mask & ~(DataMask | PercentageMask | StormMask)) && ...snip
and make it just
if (stream->writeFlag( mask & StormMask))
this lets you set the percentage and then modify the storm right after. I'm not sure if that code served some other purpose but I haven't seen any ill effects in the 2 minutes of testing so far :)
3. in weather.cs, in StartRain
after the new Precipitation object is created
add
$Rain.setPercentage(0.1); $Rain.modifyStorm(0.99, $time_to_full_rain);
this sets the starting percentage to be 10 % and it will reach 99% $time_to_full_rain seconds later.
4. in weather.cs in StopRain, change it to look like this
if(isObject($Rain))
{
$Rain.modifyStorm(0.1, $time_to_stop_rain);
$Rain.schedule($time_to_stop_rain*1000 + 500, delete);
}
$Rain = "";this will take the rain to 10% $time_to_stop_rain seconds later.
and then delete the rain object a half second after that is finished.
5. add to the top of weather.cs
//----------------------------------------------------------------------------- //time it will take the rain to start and reach 100 percent of it's storm power //Defualt: 10 seconds $time_to_full_rain = 10; //----------------------------------------------------------------------------- //time it will take the rain to stop and reach 0 percent of it's storm power //Defualt: 10 seconds $time_to_stop_rain = 10;
fun fun.
#37
in weather.cs there are quite a few places where 12 is hard coded, so any changes to $months_in_year will not effect that section of code.
02/22/2005 (4:10 pm)
one small 'bug'in weather.cs there are quite a few places where 12 is hard coded, so any changes to $months_in_year will not effect that section of code.
#38
this gets the average position of all human players and puts the lightning there.
03/10/2005 (11:44 am)
something I just added to the lightning section of code you might find usefulthis gets the average position of all human players and puts the lightning there.
//position the lightning in the middle of all human players
%pos = "0 0 0";
%numHumans = 0;
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() )
{
if(isObject(%cl.player))
{
%numHumans++;
%pos = VectorAdd(%pos, %cl.player.position);
}
}
}
// if(d4(1) < 2)//small chance the storm will be closer to 0,0,0
// %numHumans += 1; //add one extra to make the storm tend toward 0,0,0
%pos = VectorScale(%pos, 1.0 / (%numHumans ));
$Lightning = new Lightning()
{
position = %pos;
scale = "550 500 1000";
dataBlock = "LightningStorm";
strikesPerMinute = "30";
strikeWidth = "0.15";
chanceToHitTarget = "0.02";
strikeRadius = "500";
boltStartRadius = "20";
color = "1.000000 1.000000 1.000000 1.000000";
fadeColor = "0.800000 0.700000 0.8000000 1.000000";
useFog = "1";
locked = "false";
};
#39
03/14/2005 (8:28 pm)
Has anyone got it to go from day to night in the skybox?
#40
Open up the mission file (ie starter.fps\data\missions\stronghold.mis)
Scroll down to:
new Sky(Sky) {
....
...
...
}
Locate and change useSkyTextures = "1" to useSkyTextures = "0";
For SNOOBs (Super NOOBs): "1" means true and "0" means false.
This disables the rendering of skytexture and will use the colour defined in SkySolidColor. You can change the colour of the sky based on the hour, but that I will leave it to you to discover :)
To have the sun move across the sky, Scroll down to:
new fxSunLight(sunflare1) {
...
...
...
}
AND
new fxSunLight(sunflare2) {
...
...
...
}
Locate and change AnimElevation = "0" to AnimElevation = "1".
.... or alternatively use the resource "Day night cycles with seasons" written by Sam Iredale http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5417
04/08/2005 (11:28 am)
vince Gee > The lazy and quick way to do it:Open up the mission file (ie starter.fps\data\missions\stronghold.mis)
Scroll down to:
new Sky(Sky) {
....
...
...
}
Locate and change useSkyTextures = "1" to useSkyTextures = "0";
For SNOOBs (Super NOOBs): "1" means true and "0" means false.
This disables the rendering of skytexture and will use the colour defined in SkySolidColor. You can change the colour of the sky based on the hour, but that I will leave it to you to discover :)
To have the sun move across the sky, Scroll down to:
new fxSunLight(sunflare1) {
...
...
...
}
AND
new fxSunLight(sunflare2) {
...
...
...
}
Locate and change AnimElevation = "0" to AnimElevation = "1".
.... or alternatively use the resource "Day night cycles with seasons" written by Sam Iredale http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5417

Associate Chip Lambert
Crusader Games
Thanks.
Chip