Forum

> > Stranded II > Scripts > Set an object to explode without killing player.
Forums overviewStranded II overview Scripts overviewLog in to reply

English Set an object to explode without killing player.

6 replies
To the start Previous 1 Next To the start

old Set an object to explode without killing player.

aimeewilbury
User Off Offline

Quote
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?

old Re: Set an object to explode without killing player.

Hurri04
Super User Off Offline

Quote
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.

old Re: Set an object to explode without killing player.

aimeewilbury
User Off Offline

Quote
OK. Somehow I screwed up the script though as I got this in the console:

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


Heres the script:
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?

old Re: Set an object to explode without killing player.

Hurri04
Super User Off Offline

Quote
user aimeewilbury has written
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.


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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview