Author Topic: Weather  (Read 318 times)

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
Weather
« on: May 03, 2013, 03:14:13 am »


               Hello again! I'm trying to create a system that creates weather that is for a whole 'region'. This being, if it's rainy in City, it will be rainy in city outskirts. I've set strings on the areas called 'Region'. I don't want the weather to be permanent, though. I'd like to get it to be randomized, so that one day it's rainy in the areas with the value 'CITY' for the 'Region' string variable.

Currently, for my on area enter scripts I have..

       void main()
{

          object oPC = GetEnteringObject();
      

          string sAreaName = GetName(OBJECT_SELF);
          string sAreaTag = GetTag(OBJECT_SELF);
          string sAreaType = GetLocalString(OBJECT_SELF,"AREATYPE");
          string sRegion = GetLocalString(OBJECT_SELF,"Region");

         string sWeather = GetCampaignString("WEATHER",sRegion);
         SetWeather(OBJECT_SELF,StringToInt(sWeather));

}


I was going to make a placeable with a HB script that had the following..

void main()
{
int nDelay = GetLocalInt(OBJECT_SELF,"Delay");
float fDelay = IntToFloat(nDelay);

switch(Random(2))
{
case 1: DelayCommand(300.0 + fDelay,SetCampaignString("WEATHER","CITY","WEATHER_RAIN"));   SetLocalInt(OBJECT_SELF,"Delay", nDelay + 300); DelayCommand(300.0, SetLocalInt(OBJECT_SELF,"Delay", nDelay - 300));
case 2: DelayCommand(300.0 + fDelay,SetCampaignString("WEATHER","CITY","WEATHER_CLEAR"));
}

}

As you can see, it got messy.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Weather
« Reply #1 on: May 03, 2013, 01:25:48 pm »


               Take a look at http://nwvault.ign.c....Detail&id=3507.  It does pretty much
exactly what you describe out of the box.  It works on the OnEnter event.

I'm using a re-worked version of this but only because I wanted to add some more types of regions and features and clean it up.

It worked as described out of the box.

Cheers,
meaglyn
               
               

               
            

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
Weather
« Reply #2 on: May 03, 2013, 07:58:06 pm »


               The directions in the script say to call "void SetWeatherTemperate(object oPC)" in the temperate area on enter scripts. Doing so results in the following error: DUPLICATE FUNCTION IMPLEMENTATION (SetWeatherTemperate)

The script in total is..

#include "00_weather"
void SetWeatherTemperate(object oPC)
{

}

It's empty, as I'm using an execute script function from my entering scripts for all areas. It executes the script if the string variable for weather on it is 'Temperate.' Anyways, help?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Weather
« Reply #3 on: May 03, 2013, 08:39:12 pm »


               That's not calling the function, that's redeclaring it. That's why it's telling you you have a duplicate function - the same function is in the include as well. You need to put the function call in the main() function of the script being called, like so:
SetWeatherTemperate(oPC);

After having assigned oPC.

Funky
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Weather
« Reply #4 on: May 03, 2013, 08:48:20 pm »


               So... do not use ExecuteScript.

Put the function call within the Main "block" of your Area Enter Script.
Put the include at the top of this Script.

// Area Enter Script

#include "00_weather"
void main()
{
    object oPC  = GetEnteringObject();

    SetWeatherTemperate(oPC);
}


--- Not trying to steal anyone's thunder. I just thought this needed to be more explicit for the OP. Also, I do not know if this weather function is supposed to execute for every entering object in the area. Someone else will ahve to speak to this.
               
               

               


                     Modifié par henesua, 03 mai 2013 - 07:50 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Weather
« Reply #5 on: May 04, 2013, 12:45:54 am »


               I use it under "if(!GetIsPC(oPC)) return;"  since it doesn't make too much sense to bother changing the weather for other than PCs, but it won't really hurt anything if you don't. Just waste a few cycles. It doesn't bother to set anything if it's already set the weather within the timeout.

If you still want to use ExecuteScipt just put the code henesua showed in a new script and execute that from your area's onEnter script.

@henesua:  haha, thunder... weather script  '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Weather
« Reply #6 on: May 04, 2013, 01:07:29 am »


               

henesua wrote...

So... do not use ExecuteScript.

Whether or not ES is used is irrelevant. Whether it's the originally-called script, or an executed one, you'll still want to be including the weather function's include, and putting the function call in the main() of your script, instead of redeclaring it.

Funky
               
               

               


                     Modifié par FunkySwerve, 04 mai 2013 - 12:09 .