Forum

> > Stranded II > General > Electricution
Forums overviewStranded II overviewGeneral overviewLog in to reply

English Electricution

1 reply
To the start Previous 1 Next To the start

old Electricution

Sish
User Off Offline

Quote
I want to make it that during a storm if you stand in the water there's a chance of electrocution. Can someone help me with the script?

old Re: Electricution

Nova
User Off Offline

Quote
Of course we can help you a bit, here are some useful commands to get going. If you have any further question, don't hesitate to ask!

First we want to know if there's a storm. Use s2 cmd if and s2 cmd getweather to only execute some commands on stormy days.
Now we have to know if the player is in water. s2 cmd gety to get the y coordinate (the altitude of some object on the map). Use it together with "unit", 1 to get the info about the player. Now compare (s2 cmd if) the value with for example 0 which would mean the player is around sea level. If you want to shock him only if he's a bit deeper in the water, use something like -0.2 or -0.5 - whatever you think feels good.
After that we only want a small random chance of electrocution, so we use s2 cmd random to get a random chance. You can use for example 200 as limit and than compare if the value is 0. That would result in a chance of 1 to 200 every time the script runs.
Now we actually want to give the player the shock - there are multiple ways of doing this:
1. Give the player the electroshock state. The page is not available in english yet, so rough translation: "state 8 Electroshock - the affected object sparks, looses energy and only moves half as fast. [...]" that sounds pretty much like what you want. You can use s2 cmd addstate to add the state to the character, but be careful: this is a permanent state, you have to manually check inside the script if the player left the water and remove the state with s2 cmd freestate again.
2. Use s2 cmd damage to damage the player, s2 cmd play to play some spark sound effect and s2 cmd flash to get a flashing screen effect. You can also add some other stuff for additional effect, like s2 cmd thunder.

Now you have to check these conditions every second or so. You can put all these commands in a custom event like on:checkelectrocution and then use s2 cmd on:start to start a s2 cmd timer. Use a global timer with for example 1000 milliseconds to check the script every second.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewStranded II overviewForums overview