Author Topic: simplistic weather system  (Read 681 times)

Legacy_Jargh193

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
simplistic weather system
« on: August 12, 2010, 06:01:00 pm »


               I am working on a very simple Global weather system, but ran into a few things I need a little help with.


ATM my weather is changing on HB (put it there to test it out) Now I find I have no idea how to take it to the next step I need.


void main()
object oModule = GetModule();
{
if (d100()<=66)
   {
   SetWeather(oModule, WEATHER_CLEAR);
   SetSkyBox(SKYBOX_GRASS_CLEAR);
   }
else if (d100()>=33)
   {
   SetWeather(oModule, WEATHER_SNOW);
   SetSkyBox(SKYBOX_SKYBOX_ICY);
   }
else
   {
   SetWeather(oModule, WEATHER_RAIN);
   SetSkyBox(SKYBOX_GRASS_STORM);
   }
}

as you can see, I'm trying to keep it really simple, and no the skybox isn't working right.

But what I need it to do is to run this script once every 4 to 6 hours game time. I know I should try to get the weather to go with changing seasons, but that's for a later date. Also trying to keep the number of files down to a minimum. 

Anyone have a clue, all suggestions will be tried. I have used all other systems on the vault, but they just weren't right for my goal.

On a side note, but somewhat related, anyone know how I can make a placeable wander, namely "Cloud, Ambient shadow"  Never did figure that one out. Maybe even the birds placeable as well, would be the same idea either way.
               
               

               


                     Modifié par Jargh193, 12 août 2010 - 05:04 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
simplistic weather system
« Reply #1 on: August 12, 2010, 06:35:32 pm »


               object oModule = GetModule(); should be inside the brackets

void main()
{
object oModule = GetModule();

Also, SetSkyBox only works on an area, or the area that the caller of the script is in. So if this script is being called by the module's OnHeartbeat event nothing will happen.

As far as making it change every 4-6 hours you'll want to use a pseudo heartbeat script. That is, a script that uses DelayCommand to execute itself again.

Finally, the only way to "move" a placeable object is to destroy it and create it in a slightly different place.

-420
               
               

               


                     Modifié par 420, 12 août 2010 - 06:25 .
                     
                  


            

Legacy_Jargh193

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
simplistic weather system
« Reply #2 on: August 12, 2010, 06:40:39 pm »


               Odd,  in my script it is in the brackets, but I must have copied it wrong somehow.
               
               

               
            

Legacy_Jargh193

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
simplistic weather system
« Reply #3 on: August 12, 2010, 07:57:19 pm »


               Thanks for the idea, it works, including skyboxes now, next step is to do seasonal weather.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
simplistic weather system
« Reply #4 on: August 12, 2010, 08:24:47 pm »


               Just whipped this up as an example of how you could do this via a function. Could put it in the "OnModuleLoad" event or something.
You would need to place a Waypoint in every area and give each one the tag "WEATHER_WP_1", "WEATHER_WP_2", etc. Either that or you could alter this funtion to include the tags of every area in your mod.
But anyway:

const float TIMER = 480.0;//4 hours in game assuming you have 2 minute hour

void SetWeatherSkyBoxAllAreas()
{
object oModule = GetModule();
int iSkyBox;
int iRand = d3();
switch (iRand)
    {
    case 0: SetWeather(oModule, WEATHER_CLEAR);
            iSkyBox = SKYBOX_GRASS_CLEAR;break;
    case 1: SetWeather(oModule, WEATHER_SNOW);
            iSkyBox = SKYBOX_ICY;break;
    case 2: SetWeather(oModule, WEATHER_RAIN);
            iSkyBox = SKYBOX_GRASS_STORM;break;
    }

int iInt = 1;
object oWP;
object oArea;
oWP = GetWaypointByTag("WEATHER_WP_" + IntToString(iInt));
while (GetIsObjectValid(oWP))
    {
    oArea = GetArea(oWP);
    SetSkyBox(iSkyBox, oArea);
    iInt++;
    oWP = GetWaypointByTag("WEATHER_WP_" + IntToString(iInt));
    }
DelayCommand(TIMER, SetWeatherSkyBoxAllAreas());
}

/*void main()
{
SetWeatherSkyBoxAllAreas();
}*/


Hope that helps. Good Luck.

EDIT: Ok just saw you got it working so nevermind. '<img'>
               
               

               


                     Modifié par GhostOfGod, 12 août 2010 - 07:25 .
                     
                  


            

Legacy_Jargh193

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
simplistic weather system
« Reply #5 on: August 18, 2010, 01:23:39 am »


               OK, it's up and running, but just had a very odd thought, how could I...



Have a placeable in a weather control area (an area that has the bioware weather set) update the globalweather?, I think it might be the easiest (and less scripts) way, but this is for a future idea, maybe.
               
               

               
            

Legacy_Heatmiser

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
simplistic weather system
« Reply #6 on: August 25, 2010, 11:25:48 pm »


               Ghost- So you could do this and only place the Waypoints in, say outside areas where you want the weather to change right?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
simplistic weather system
« Reply #7 on: August 25, 2010, 11:37:25 pm »


               The way points in this case only effect which areas' Skyboxes will change. The actual weather is changed in the whole mod. But you can change it up a bit to only change the weather in the areas with those waypoints and not globaly. If you are looking for something specific just let us know.