Forum
Stranded II General ElectricutionElectricution
1 reply 1
First we want to know if there's a storm. Use if and getweather to only execute some commands on stormy days.
Now we have to know if the player is in water. 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 ( 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 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 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 freestate again.
2. Use damage to damage the player, play to play some spark sound effect and flash to get a flashing screen effect. You can also add some other stuff for additional effect, like 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 on:start to start a timer. Use a global timer with for example 1000 milliseconds to check the script every second.
1