Aller au contenu

Photo

Weather


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
WhenTheNightComes

WhenTheNightComes
  • Members
  • 27 messages
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.

#2
meaglyn

meaglyn
  • Members
  • 817 messages
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

#3
WhenTheNightComes

WhenTheNightComes
  • Members
  • 27 messages
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?

#4
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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

#5
henesua

henesua
  • Members
  • 3 883 messages
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 .


#6
meaglyn

meaglyn
  • Members
  • 817 messages
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 :)

#7
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

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 .