Entity spawns only when 2 players on screen

mtrain

New member
One question but very important for me. Imagine that two players fight a boss and after his death there might be appear an entity that must hit them both (both players), but if one player was killed in the middle of the boss fight and there is a delay before he respawns, or loose continue and must select new continue, all this time only one player on screen (in game) and defeat a boss, and spawned entity hits only him (1st player), so is it possible to force that entity spawn only until 2 players will be on screen (after second player will respawn). So the entity will check if there is 2 players on screen it will spawns, if one of them killed and is in the middle of respawning it will wait for him and spawn after that. It will help me a lot, because i am stuck on this moment, and this is the one of the game mechanics i want to add.
 
I could give a script for this but I need to confirm couple things :
1. Does this entity stops level from ending after death of boss?
2. How long this entity will wait? forever or just couple seconds?
 
I could give a script for this but I need to confirm couple things :
1. Does this entity stops level from ending after death of boss?

1. Yes, this entity must stop level from ending after death of level boss, until the entity removes. And this kind of entity must appear after defeating a middle level boss in the middle of the stage, so it must work same in the middle of the level. Middle boss was defeated - entity appears (but if 2 players on screen) and then we go to the next boss at this level.

2. How long this entity will wait? forever or just couple seconds?

2. This entity waits until both of players will be on screen, so it will not appear until one of the defeated players will respawn after regular death (life -1) or after continue selection.

Thank you for reply, BB!
 
Ah I see, now what will this entity do when both players are available?

It is only waits for both players, it should be simple but it it does something else, I need to know what it is
 
It is only waits for both players. And then hits them to play special pain animation. How to force it to hit both players i know. It is invisible entity, using just as trigger. You see, if one player will be dead (in 2p mode) or player dead (in 1p mode) entity appears and hits 1 player or no one, so i need make that entity awaits for all players who play at this moment (if it 1p mode awaits for 1 player, if 2p mode awaits for both players on screen).
 
I made a test entity for this purpose, it's like this:

name 2pOnly
type enemy
nomove 1 1
antigrab 200

anim idle
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");

    if(P1 && P2){
      performattack(self, openborconstant("ANI_FOLLOW1") );
    }
@end_script
loop 1
delay 5
offset 0 0
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

anim follow1
delay 50
offset 0 0
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

anim spawn
delay 1
offset 0 0
frame data/chars/misc/empty.gif

I have tested this and it works well, when spawned, it will wait for both players to be available before performing FOLLOW1.
You have to combine this with group 1 1 to prevent next spawns to be executed.

BTW I don't know what you are going to set for FOLLOW1 so I just leave it like this :).
This entity is type enemy so you might need to add suicide script to remove this.
 
Ah, thank you, BB! I will try this today!
beer.gif
 
I made a test entity for this purpose, it's like this:

Yes it is working perfectly in 2p mode! But in 1p mode entity dont perform follow1 :-[

And one more question: is it possible to disable player controls (disable key inputs) for, saying, 10 seconds? I have in mind a method with adding empty text entity with noskip subtype and lifespan 10? Maybe another chance to make that?
 
Well, that's what this entity does i.e don't do a thing until both players are available.

There's a way to disable player's control with script. I usually use this when forcing victory pose.

Anyways, what actually you want? I don't quite follow
 
Anyways, what actually you want? I don't quite follow

There's a way to disable player's control with script. I usually use this when forcing victory pose.

To make an entity work in 1p mode as well as in 2p mode. It will be using exactly for forcing players play "victory pose" (or another "cutscene" pose in the middle of the level) (and controls must be disabled at this moment). So if 1 player in game at all (on the 2nd player - press starts) entity will play follow1 animation, but if player 2 pressed start and there appears his character selection, that means that there is 2p mode from now, and entity will wait to play follow1 until player 2 will be chosen. Last part of this working well) but if i start a level in 1p mode entity will not play follow1 until 2nd player will appear.
 
Back
Top Bottom