kimono
Well-known member
Hello, dear Openbor experts.
I'm currently trying to replicate the 3.0 mechanic of a victory animation triggered when all enemies in the level are defeated.
I'm currently trying to count the number of enemies present and trigger animation freespecial5 if there are none left.
I use update.c for this, with the following lines of code:
The freespecial5 animation isn't triggering at the moment.
Am I on the right track, and would you follow these steps to activate the victory animation?
I'm currently trying to replicate the 3.0 mechanic of a victory animation triggered when all enemies in the level are defeated.
I'm currently trying to count the number of enemies present and trigger animation freespecial5 if there are none left.
I use update.c for this, with the following lines of code:
Code:
// ===== VICTORY ANIMATION (OpenBOR 4.0) =====
{
void ent;
void player;
int i;
int enemies_alive = 0;
// Check if at least one enemy is still alive
for(i = 0; i < openborvariant("count_entities"); i++) {
ent = getentity(i);
if(ent) {
if(getentityproperty(ent, "type") == openborconstant("TYPE_ENEMY") &&
getentityproperty(ent, "health") > 0) {
enemies_alive = 1;
break;
}
}
}
// All enemies are defeated → play victory animation
if(!enemies_alive && !getglobalvar("victory_done")) {
// Prevent the animation from triggering multiple times
setglobalvar("victory_done", 1);
// Play victory animation for each active player
for(i = 0; i < openborvariant("maxplayers"); i++) {
player = getplayerproperty(i, "entity");
if(player &&
getentityproperty(player, "health") > 0 &&
getentityproperty(player, "busy") == 0)
{
performattack(player, openborconstant("ATK_FREESPECIAL5"));
}
}
}
}
The freespecial5 animation isn't triggering at the moment.
Am I on the right track, and would you follow these steps to activate the victory animation?