Aller au contenu

Photo

Weather changes module wide?


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

#1
Xeneize

Xeneize
  • Members
  • 133 messages

I am looking into trying to make it so it rains all day 24/7 throughout all outdoor (or non-interior!) areas in my module. What would be the best approach to accomplish this? Would putting such a script in the OnModuleLoad Script be a bad idea?

 

Thank you in advance.

 

 



#2
kamal_

kamal_
  • Members
  • 5 240 messages

Do you actually want to change the weather, or do you want it to just constantly be raining everywhere in the module?



#3
Xeneize

Xeneize
  • Members
  • 133 messages

Constantly raining in the module(all outdoor areas); if possible varying between light/medium/heavy/stormy.



#4
andysks

andysks
  • Members
  • 1 645 messages

I don't know if this is what you look for, but Lance did this a while ago. You could take a look.

 

http://neverwinterva...-system-lb-v105



#5
Xeneize

Xeneize
  • Members
  • 133 messages

Hmmm not exactly, no. We're speaking of a huge existing module with loads of areas. From what I'm seeing of that system I have to manually attach it to each area, and I am looking for a way to script something that directly affects the bunch of outdoor areas as a whole rather than moving area by area to do it. It's a temporary irregular and weather that should only last a few weeks, that is why I need to script something that will be temporarily make it rain across the module.



#6
kevL

kevL
  • Members
  • 4 056 messages

Would putting such a script in the OnModuleLoad Script be a bad idea?


no. it's good idea.
just remember to block off the new code with comments top and bottom, so you can remove it later (or disable it until the next rainy day)

additionally, strength of rain can change in the module HB.

#7
Xeneize

Xeneize
  • Members
  • 133 messages

Will this work?

 

object oMod = GetModule();

    {
    
    SetWeather(object oMod, int nWeatherType = WEATHER_TYPE_RAIN, int nPower = WEATHER_POWER_HEAVY);
    
    }



#8
kevL

kevL
  • Members
  • 4 056 messages
more like this
 
object oMod = GetModule();
SetWeather(oMod, WEATHER_TYPE_RAIN, WEATHER_POWER_HEAVY);
( don't confuse declarations with definitions (or something like that..) )

i guess your thinking was going this way
object oMod = GetModule();
int nWeatherType = WEATHER_TYPE_RAIN;
int nPower = WEATHER_POWER_HEAVY;

SetWeather(oMod, nWeatherType, nPower);
either way should be good for a test, methinks.

#9
Xeneize

Xeneize
  • Members
  • 133 messages

That works. Thanks for the fix!



#10
Xeneize

Xeneize
  • Members
  • 133 messages

Okay so the issue I have now is that it rains in all outdoors, and the problem is that I got underdark in that module too and clearly should not be raining down there.

 

Is there a way to first ask the module to verify if an area is an underground or interior, and if it isn't, to apply the 24/7 rain to the area?



#11
Tchos

Tchos
  • Members
  • 5 042 messages

There's a function:

int GetIsAreaAboveGround(object oArea);


#12
Xeneize

Xeneize
  • Members
  • 133 messages

I'm not sure how to employ that function. How would I go about it?

 

Thank you in advance for all the help so far.



#13
kevL

kevL
  • Members
  • 4 056 messages
loop areas:
 
object oArea = GetFirstArea();
while (GetIsObjectValid(oArea))
{
    if (GetIsAreaAboveGround(oArea) == AREA_ABOVEGROUND)
    {
        SetWeather(oArea, WEATHER_TYPE_RAIN, WEATHER_POWER_HEAVY);
    }

    oArea = GetNextArea();
}


#14
kevL

kevL
  • Members
  • 4 056 messages
edited.

#15
Tchos

Tchos
  • Members
  • 5 042 messages

Also, the constant AREA_ABOVEGROUND is equal to 1 (or TRUE).  I don't know why they decided it was necessary to define a separate constant for this purpose.



#16
kevL

kevL
  • Members
  • 4 056 messages
GetIsAreaAboveGround() actually has three possible returns: 1,0,-1 (AREA_INVALID / error)

at first i just assumed TRUE would be okay also, but defensive scripting (note that the underpinnings of NwScript probably wouldn't let anything segfault or whatever anyway, though)


---
constants don't have to be defined for anything; they're just numbers (in this case). But referencing them with strings avoids use of so-called magic numbers.

Eg, what does "1" mean?

and ofc TRUE doesn't mean "1" -- it means "any int not 0". That's why i changed TRUE to AREA_ABOVEGROUND, although "1" can be used identically. but, magic numbers

---
hm, i notice Nwscript.nss defines

int TRUE = 1;
/shrug. ( I don't trust that in all cases... )

#17
Tchos

Tchos
  • Members
  • 5 042 messages

I often use the number instead of the constant that the number represents, mainly due to needing to provide integers in conversation scripts or in local variables, so I look up the constant's definition in the script helper's Globals tab...  But I've never until this thread suggested using a different constant than the one called for in the script just because it has the same value!  I may be getting a little too libertine with my scripting.



#18
kevL

kevL
  • Members
  • 4 056 messages
the first time i noticed constant-substitution was with GetNearestCreature()

coders i knowed & loved & trusted were using this construction:

GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE)

but the function's description says it should be

GetNearestCreature(CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE)

ofc, TRUE == CREATURE_ALIVE_TRUE == 1

#19
Tchos

Tchos
  • Members
  • 5 042 messages

Betrayal, or the next level of Zen mastery?



#20
kevL

kevL
  • Members
  • 4 056 messages
edge case

#21
Tchos

Tchos
  • Members
  • 5 042 messages

Interesting term.



#22
kevL

kevL
  • Members
  • 4 056 messages
usually preceded by, wtf

as in,
wtf??!1

oh, edge case ...

#23
Xeneize

Xeneize
  • Members
  • 133 messages

Hmm thank you very much, that seems to work. But doesn't oArea actually use the settings of the specific area rather than apply something globally to all areas? I ask this because I now get the problem that some of the areas where it normally never rains(Set the rain specifics in that area to never rain) the script won't affect them, seeing as the oArea uses the area's specific climate setting.

 

That or I'm not understanding something.

 

 

Basically I need it to rain across all outdoors(must not be interior or underground) and if possible, needs to disregard an area's specific climate settings)



#24
kevL

kevL
  • Members
  • 4 056 messages
unfortunately i can't find functions for get/set Chance of Rain or Variation in Rain, only the function SetWeather() for Power of Rain ... try this,

// start Weather modification
//
// First set all areas to rain
SetWeather(GetModule(), WEATHER_TYPE_RAIN, WEATHER_POWER_HEAVY);

// Second set Underground and Interior areas to not rain
object oArea = GetFirstArea();
while (GetIsObjectValid(oArea))
{
    if (GetIsAreaAboveGround(oArea) == FALSE
        || GetIsAreaInterior(oArea) == TRUE)
    {
        SetWeather(oArea, WEATHER_TYPE_RAIN, WEATHER_POWER_OFF);
    }

    oArea = GetNextArea();
}
// end Weather modification.


#25
Xeneize

Xeneize
  • Members
  • 133 messages

Sadly that doesn't work. It still cycles through all areas and uses the default weather setting. Which makes it unable to rain on areas that are set to never rain.

Not sure what else to try. But thanks for all the help.