English Set an object to explode without killing player.

6 replies
Goto Page
To the start Previous 1 Next To the start
Up
aimeewilbury
User
Offline Off
I created a "crashed airplane" object that will explode when on:kill. (In the map editor you can set it on fire and that, combined with electroshock and smoke, makes a pretty cool-looking effect).

But it'll kill the player when it explodes, which is crappy if the basis of your custom map is the player escaping a plane crash and it explodes before you can do anything. So how do you make it, either through the map editor or the object script, that the player is not killed?
26.07.11 11:08:40 pm
Up
Hurri04
Super User
Offline Off
mabye you could start a timer which is triggered 3 times, on the first time you give the player the invincible state, on the second time you let the plane explode and on the third time you remove the invincible state again.

you could make the timer trigger in 1 millisecond steps so it would just take 3 milliseconds in total and the player wouldnt even notice that he had the invincible state on him.
26.07.11 11:37:24 pm
Up
aimeewilbury
User
Offline Off
You mean to put a timer under on:kill?
27.07.11 12:13:17 am
Up
Hurri04
Super User
Offline Off
yes, for example.
but this only works when you kill the plane first via s2 cmd kill and then let the explosion happen with the command s2 cmd explosion.
27.07.11 12:39:28 am
Up
aimeewilbury
User
Offline Off
OK. Somehow I screwed up the script though as I got this in the console:

IMG:http://img121.imageshack.us/img121/9954/doesnotexist.png


Heres the script:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### Crashed Plane
id=298
name=Crashed Plane
group=vehicle
model=gfx\plane_wreck.b3d
icon=gfx\icons\plane_wreck.bmp
health=20
script=start
     on:kill {
          timer "self",$timer,1;
     }
     on:timer {
          $x1=(addstate "unit","invulnerability")
          $x2=(explosion $x,$y,$z,50,300)
          $x3=(freestate "unit","invulnerability")
          $x4=(free "self")
     }
script=end


I'm sure I just missed something somewhere, any suggestions?
27.07.11 01:06:26 am
Up
Hurri04
Super User
Offline Off
user aimeewilbury has written:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### Crashed Plane
id=298
name=Crashed Plane
group=vehicle
model=gfx\plane_wreck.b3d
icon=gfx\icons\plane_wreck.bmp
health=20
script=start
     on:kill {
          timer "self",$timer,1;
     }
     on:timer {
          $x1=(addstate "unit","invulnerability")
          $x2=(explosion $x,$y,$z,50,300)
          $x3=(freestate "unit","invulnerability")
          $x4=(free "self")
     }
script=end

the stuff you wrote into the on:timer script is totally wrong:
dunno which scripting language you mixed this up with but the brackets have to be set different in S2, also you forgot all the semicolons at the end of the lines.

further the timer command line should look a little different since I told you to run the timer 3 times and have an event at the end.

about the error in the picture you posted:
yeah, I think there has to be an extra event where you save the ID of the object into a local variable first.


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
### Crashed Plane
id=298
name=Crashed Plane
group=vehicle
model=gfx\plane_wreck.b3d
icon=gfx\icons\plane_wreck.bmp
health=20
script=start
on:start {
     local "$own_id";
     $own_id=currentid();
     $plane_x=getx("self");
     $plane_y=gety("self");
     $plane_z=getz("self");
}
on:kill {
     timer "unit", $own_id, 3, 1, "plane_explode";
}
on:plane_explode {
     if($plane_explode_step==0) {
          addstate "unit", 1, "invulnerability";
          $plane_explode_step++;
     }elseif($plane_explode_step==1) {
          explosion $plane_x, $plane_y, $plane_z, 50, 300;
          $plane_explode_step++;
     }elseif($plane_explode_step==2) {
          freestate "unit", 1;
     }
}
script=end


try this script, as you can see I changed quiete a few things.
edited 1×, last 27.07.11 01:31:44 am
27.07.11 01:19:05 am
Up
aimeewilbury
User
Offline Off
I'm real brilliant Really I have issues wrapping my head around scripts. Thanks
To the start Previous 1 Next To the start