Victory Conditions for multiplayer

betterbold

Active member
I'm working on Splatoon mod and I think about Victory Conditions. ::)
Players toss the ink and get score in Splatoon game.
If player1's score is more than player2's score when time is up, player1 win the game.(and spawn the cutin ? )

Is it possible to compare players score ? I think it may need scripts. :)
 
You can either use a code in the "updated.c", under the "in_game" loop or use a fake entity which will check the time value and do the rest. Honestly speaking, on THIS case, I would use a fake entity.

You would need to use, at least, build 4456+

Code:
@script
int gametime = openborvariant(“game_time”); // get game time
int P1 = getplayerproperty(0, "entity"); // Get P1
int P2 = getplayerproperty(1, "entity"); // Get P2
int scoreP1 = getentityproperty(P1,"score"); // get P1 score
int scoreP2 = getentityproperty(P2,"score"); // get P2 score

if (gametime==0){ // if the time reaches 0

	if (scoreP1 > scoreP2){ // P1 win
	//insert your logic here

	} else if (scoreP1 == scoreP2){// Tie game
	//insert your logic here

	} else {// P2 win
	//insert your logic here
	}

}
@end_script

Then I would put this code into the fake entity idle animation

anim idle
loop 1
offset whatver
delay 59
@script
int gametime = openborvariant(“game_time”); // get game time
int P1 = getplayerproperty(0, "entity"); // Get P1
int P2 = getplayerproperty(1, "entity"); // Get P2
int scoreP1 = getentityproperty(P1,"score"); // get P1 score
int scoreP2 = getentityproperty(P2,"score"); // get P2 score

if (gametime==0){ // if the time reaches 0

if (scoreP1 > scoreP2){ // P1 win
//insert your logic here

} else if (scoreP1 == scoreP2){// Tie game
//insert your logic here

} else {// P2 win
//insert your logic here
}

}
@end_script
frame bla bla
frame bla bla

If you are using a more recent version, where VICTORY and LOSE were added, you could force the players to use those animations.

I haven't tested it yet, but it should work.
 
@O Ilusionista
OMG Really thanks for your help !! :D
What I add to logic in it, if I want to show "1P WIN" "DRAW" "2P WIN" cutins?
 
Do you use an entity for those messages, right?
Just spawn them in the desired animation.

I have customized an function for that, long time ago:
Code:
void spawnAni(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz)
{
	//spawnB (Generic spawner) + Specific animation + velocities
	//Damon Vaughn Caskey + Douglas Baldan
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fZ: Y location adjustment.
      //fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");

	clearspawnentry(); //Clear current spawn entry.
    setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
		  Vx = -Vx; //Reverse X velocity
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);
	performattack(vSpawn, openborconstant(Ani));	
    
	return vSpawn; //Return spawn.
}
Usage:
@CMD spawnAni "effect" 0 0 0 "ANI_FOLLOW1" 0 0 0
The last 3 values are velocities. If you don't want any velocity, use NULL() for each velocity. Otherwise, it will override the speed of the spawned entity.

Just remember that calling functions inside script has a different synthax, like this:

Code:
	if (scoreP1 > scoreP2){ // P1 win
	spawnAni("effect",0,0,0,"ANI_FOLLOW1",0,0,0);

	}

So follow1 would be P1WIN, follow2 would be P2WIN, etc...

I use it AT LOT on my mod. I have one entity with many animations (which are related each other) and I can spawn those entities using whatever animations I want to :)
 
After many tries, I think it almost worked.
But I don't think this is fully working yet.

Could you check my mod? :)
 
Back
Top Bottom