Solved Spawn exit doors after enemies defeated

Question that is answered or resolved.

kimono

Well-known member
Hi, is there a possibility to make appear some doors exits when all enemies are killed in a level?
I tried to put a wait or a group and declare after the doors but it's not the correct solution.
Doors are item touch type.
A level example here:
Code:
music		data/music/Horror_dance.ogg

panel		data/bgs/nightmare/hallway_up/hallway_up.gif
order		a
notime 1
scrollspeed 10
	
stagenumber 0
type		1 0 0

spawn1		1030 40 300
spawn2		1030 40 300
spawn3		120 20 300
spawn4		150 40 300

direction both
#---------------------
spawnscript data/scripts/spawnlevel/clockOff.c
at			0
#---------------------
wall 0 308 69 0 99 33 63 240
wall 199 279 157 118 212 193 33 240
wall 1590 308 -66 0 -41 26 66 237
hole 266 268 17 0 80 61 20
#---------------------
spawn		sidm
flip		1
coords		200 280 0
at			100

spawn		sidm
flip		1
map 		3
coords		840 280 0
at			200

spawn		mannequin_room_entry
@script
void main()
{
    setglobalvar("Room", 4);
}
@end_script
flip		1
coords		1 200 0
at			0

spawn		library_entry
flip		1
coords		1 200 0
at			0

spawn		hallway_up_exit
flip		1
coords		1 200 0
at			0

spawn		bedroom_entry
flip		1
coords		1 200 0
at			0

spawn		study_entry
flip		1
coords		1 200 0
at			0

spawn		trophy_room_entry
flip		1
coords		1 200 0
at			0

#---------------------
spawn		Bin
flip		1
coords		999 999 0
at			0

spawn	empty
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");
    int x = getentityproperty(P1,"x");
    int y = getentityproperty(P1,"y");

    changeopenborvariant("xpos", x-240);
    changeopenborvariant("ypos", 690-y);
}
@end_script
at 			0

I simply wish that after the death of the 2 sidm enemies, the doors appear :).
 
Hi kimono
You can use the exit door script in SOR2X stage 6 (SOR3 route). It will constantly count the enemies using the openborvariant "count_enemies" and will change the animation when the ammount limit is reached. I'm using it at the updateentity script because it has other tasks running, but you can use in animation scripts and check the enemy ammount at each frame.
 
I believe this is a matter of grouping + position preserve script.
Here's an example:
Code:
group 3 3
at		0

spawn		ellem
flip		1
map 		1
coords		340 280 0
at			0

spawn		ellem
flip		1
map 		2
coords		440 280 0
at			300

spawn		ellem
flip		1
map 		3
coords		540 280 0
at			300

group 1 1
at		0

spawn		mannequin_room_exit
@script
void main()
{
    void self = getlocalvar("self");

    changeentityproperty(self, "position", 1);
}
@end_script
flip		1
coords		1 200 0
at		0

Group 1 1 before exit spawn prevents exit from being spawned. IOW player must defeat all enemies before exit is opened.

Script in exit spawn preserve exit's position at 1 no matter where player is after all enemies are defeated.
 
Kratus: Thanks, this count_enemies may be useful to make some enemies wait until some of them are defeated :).
Thank you Bloodbane for this script in the exit spawn, it works perfectly :).
In the hallway, I've got several exits. I'll make some tests to spawn multiple exits after the enemies killed and come back here for feedback ;).
Edit: Ok, this method works well, the lone small problem is the enemy spawns its transformation that is counted as enemy too in the group.
Is group counts other spawns than enemies too like the doors item touch?
 
Thank you for this precision.  With this groups, I can make a system like "The door needs a certain number of souls to be opened" :).
Problem solved  8).
 
kimono said:
Thank you for this precision.  With this groups, I can make a system like "The door needs a certain number of souls to be opened" :).
Problem solved  8).

To be honest, Last time I relied on only group was not perfect - but I have some scripting involved.
My solution was to use a scrollpos check, so what I want just happens if there is no enemy and at the perfect scrollpos.
You can see it in action on Avengers United Battle Force at Hydra2 stage - the one where you fight Trapster.
That door uses the solution I am talking about.

Or on the most recent update of Hydra-5 stage, at 5:22
Notice that even if the camera is on the right position, I use a code to check the camera position and to check if there are enemies on the screen before the gate opens.
 
Back
Top Bottom