Jump to content

Script help - Force weather on trigger box entry


Robinsage

Recommended Posts

Hi all,

 

I'm trying to put a script together that will force a weather type when the player enters a trigger box. Here is the (probably bad) layout of the script I want to attach to the trigger box:

 

---------------------------------------------------------------------------

Event OnTriggerEnter(ObjectReference Somebody)
String EnteredArea = "You take shelter from the weather"
Actor Player = GetPlayer()
If Somebody == Player
Debug.Notification(EnteredArea)
** Weather.ForceActive(true)
EndIf
EndEvent

 

Event OnTriggerLeave(ObjectReference Somebody)
String LeftArea = "You head back into the weather"
Actor Player = GetPlayer()
If Somebody == Player
Debug.Notification(LeftArea)

Weather.ReleaseOverride()
EndIf
EndEvent

---------------------------------------------------------------------------

 

** is where I'm struggling to get the weather I want to force in to work (can I work in a form ID for specific weather types?). Basically I want to change the weather to cloudy (ID 105f40).

 

Maybe I'm going about it all wrong. Any help would be greatly appreciated.

Link to comment
Share on other sites

Looks like what you have will work once you create a property for the weather you want. In the CK, where you've attached the script, double-click on it and click Add Property, then add a Weather property and call it something like CloudyWeather. Hit okay, then select it in the properties window and choose your weather from the drop-down list on the right.

 

You'll then have to change your

Weather.ForceActive(True)
and
Weather.ReleaseOverride()
lines to use your property instead of the type.
Link to comment
Share on other sites

I got it working thank you. I also had to add import game command to get the getplayer value to work.

 

Thank you!

 

This is how it turned out:

-------------------------------------------------------

Weather Property stormcloud Auto
import game

Event OnTriggerEnter(ObjectReference Somebody)
String EnteredArea = "You take shelter from the weather"
Actor Player = GetPlayer()
If Somebody == Player
Debug.Notification(EnteredArea)
stormcloud.ForceActive(true)
EndIf
EndEvent

Event OnTriggerLeave(ObjectReference Somebody)
String LeftArea = "You head back into the weather"
Actor Player = GetPlayer()
If Somebody == Player
Debug.Notification(LeftArea)
weather.ReleaseOverride()
EndIf
EndEvent

Link to comment
Share on other sites

If you use

Game.GetPlayer()
, you don't have to import game.

 

Also, if you use

Actor Property PlayerREF Auto
, and auto-fill it, and then use PlayerREF in your code instead of either form of GetPlayer(), that's actually a more efficient way of referencing the player -- a hundred times faster, by some benchmarks!

 

Anyway, glad you got it working. :)

Link to comment
Share on other sites

Great, I really appreciate the tips. I'll take efficiency any day. :happy:

 

Now I'm working on getting the script to run only in non-cloudy weather so I don't end up transitioning to cloudy weather during, cloudy weather >.< The weather types to transition from are propertied out but I'm not sure if it would be a Function if/else or something else.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...