Jump to content

(SE) Rain Barrel script


Recommended Posts

Hi,

I have a rain barrel outside a custom house (static object, open top, empty)

I want to create a quest/script where, when it rains, the rain barrel static object is replaced with an activator of the same model (allowing you to collect water from it), and a water surface is created/enabled at the top.

If possible, I want it so that if the player is in another cell, and it rains, then the rain barrel will be full upon returning to it.

I'm not sure how to create this. I was thinking that Raining would change a "Global" variable, and upon entering the cell the objects would check this variable and either load or not based on the Global value. Taking all the rain water out of the barrel would reset the Global variable so that it won't refill again until it rains.

 

Any ideas? Thanks

Link to comment
Share on other sites

You could let it just always be an activator. Attach a script to it to detect moisture. One way off the top of my head, is you could make a formlist with all the weather types that have rain involved. When detected that we are having rainy weather, you can have a visual effect play on the barrel to make it look slick and/or full of water

Bool IsRaining = OurFormlistWeMade.HasForm(Weather.GetCurrentWeather())

If IsRaining

 SomeRoutineToWaitABit()

 PlayWhateverWetVisualEffect()

Endif

Then an OnActivate() etc event to remove the effect, and give you water, after you activate the wet barrel

Interesting concept btw

Link to comment
Share on other sites

6 hours ago, Sphered said:

You could let it just always be an activator. Attach a script to it to detect moisture. One way off the top of my head, is you could make a formlist with all the weather types that have rain involved. When detected that we are having rainy weather, you can have a visual effect play on the barrel to make it look slick and/or full of water

Bool IsRaining = OurFormlistWeMade.HasForm(Weather.GetCurrentWeather())

If IsRaining

 SomeRoutineToWaitABit()

 PlayWhateverWetVisualEffect()

Endif

Then an OnActivate() etc event to remove the effect, and give you water, after you activate the wet barrel

Interesting concept btw

Thanks for your help.

I think this would work, except that (I think) it would only work if it was raining in the same cell as the rain barrel.

For example, if the rain barrel was in Riverwood, and one day I went to Whiterun and it started raining, I would expect the rain barrel to be full when I get back to Riverwood (assuming it rained there also).

That's why I need some way for the script to be active all the time, and for some way the rain barrel can "know" it rained when the player was in a different location.

 

I'm a beginner at scripting, but here's what I'm thinking:

1. There could be a script on the player, as a constant magic effect, that periodically checks if it's raining, say every five minutes.

2. If the script does detect rain, then it changes a global variable (my understanding is that these are used as persistent variables which stay constant unless changed)

3. Upon entering the rain barrel's cell, a script on the rain barrel activator would check the global variable.

4. If the Global = 0 (hasn't rained), no water would appear and the player wouldn't be able to collect rain water. If the global = 1 (has rained), there would be water and the player would be able to collect rain water.

5. Exhausting the rain water supply (e.g. using it x times) would reset the global variable to 0 and would disable water.

 

What do you think? I'll go about testing it now.

 

BTW, as for the water effect, I don't think I need to use a visual effect. The extra mesh should be fine ("rain barrel water" or something, in the Activators group). I think a good idea would also be to adjust the height of the water each time you use it.

Link to comment
Share on other sites

5 hours ago, xkkmEl said:

For water in the barrel, you could put a water mesh on a static object that you enable/disable.

I could not tell you how to create a water mesh, but perhaps this mod could provide ideas: Water in Wells LE -Mesh Only Animated Wells.

 

Thanks for your help. AFAIK I think my original idea of just having an extra mesh appear/disappear should be fine.

In fact I've just realised the same mechanic could be used to create puddles around the house when it's raining.

Link to comment
Share on other sites

The moisture detection routine def requires being relaxed mentally about how precise it will be, since the game only worries about one active weather at any given time: The player's immediate surroundings at the moment. If you are away from the barrel for a few hours, the weather is null aka none aka no rain since you aren't there for it to diceroll a random weather to use. So in that situation, when you return to that area, see if it happens to be raining. If not, you could do a random int chance regarding if it rained or not before you got there

Gotta make due with what you can. Good call on the puddles idea too. Same concept really

Link to comment
Share on other sites

A few thoughts. Papyrus Extender: https://www.nexusmods.com/skyrimspecialedition/mods/22854 has an event that detects weather change. I would use an int property rather than a global variable as it would be easier to create more than one barrel this way if you wish. You could also raise or lower the water mesh on the z position to show filling / emptying the barrel.

Link to comment
Share on other sites

Thanks for the replies everyone.

dylbill- I want it to be an Xbox mod as well as PC so I don't think I'll be able to use Papyrus Extender

 

I managed to get it working BUT there seems to be a bug which causes the game to crash. I think I've isolated it to the changing of the water position.

 

What I did was have a magic effect which detected the weather every 10 seconds. (Strangely, this magic effect always seemed to be operating even though I had attached it to a spell and spell tome).

Upon detecting rain, it would set a global variable to 5.

I used one activator for the rain barrel but attached a script which would give different outcomes depending on the global variable.

The rain barrel had some water but right at the bottom (stage 0)- trying to use it would display a message saying there wasn't enough water.

When it rains, the global variable is set to 5 and a trigger box raises the position of the water in the barrel to the max height (stage 5).

Using the rain barrel sets the global variable to 4, and lowers the position of the water a little. Using it again sets it to 3, and lowers the water again, and so on.

 

However, as I said, there's a bug and I don't know what's causing it. I'm thinking if I have the water as a quest alias it might solve the problem.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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