English Unit getting state

3 replies
Goto Page
To the start Previous 1 Next To the start
16.03.14 12:59:09 pm
Up
MarteszHU
User
Offline Off
I am working on an unit called robot. It has 450 health. How to make it smoking at 250, burning at 150 and shocking at 50 health?
"True trolls never fail"
16.03.14 02:04:41 pm
Up
Hurri04
Super User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
on:hit {
     $health = health("self");
     if($health <= 50) {
          addstate "self", "electroshock";
     }elseif($health <= 150) {
          addstate "self", "smoke";
     }elseif($health <= 250) {
          addstate "self", "fire";
     }
}


note that 450 hp is very much in S2. the player's normal hit without anything in his hands does 3 damage. at least for testing purposes I'd recommend to lower it to 45 hp (and the values in the script respectively).

if you want to do something a bit more advanced >


Edit: fixed the spelling error in the script
edited 1×, last 16.03.14 06:07:20 pm
16.03.14 02:45:13 pm
Up
Nova
User
Offline Off
This script always adds the states when the hp is lower than the value and the robot gets hit, even if the robot already has them. Just keep that in mind, if you want to change the script.
Hexenverbrennung, Inquisition, Kreuzzüge... Wir wissen, wie man feiert! - Ihre Kirche
16.03.14 03:27:02 pm
Up
MarteszHU
User
Offline Off
Thanks for the help!

EDIT:I needed to fix the script, but its working fine. Thanks again.
edited 1×, last 16.03.14 03:52:26 pm
"True trolls never fail"
To the start Previous 1 Next To the start