maxman
Well-known member
I have a problem with knocking out an opponent with player type entity in 1 player mode. I have a script which calls out certain opponent's health to 0 and it's supposed to stop the timer. However, it doesn't play the same way as 2 players. Pay attention to the opponent's health number. When players die, it becomes true for the timer to stop running. When enemies die, it becomes false. How can I stop the timer from running after knocking him/her out?
timer.txt:
timer.txt:
C:
name Timer
type obstacle
health 60
speed 10
nomove 1 1
stealth 350
antigravity 100
subject_to_wall 0
subject_to_minz 0
#offscreenkill 3000
nodrop 2
defense normal9 0 2000 #defense {type} {factor} {pain} {knockdown} {blockpower} {blockthreshold} {blockratio} {blocktype}
ondrawscript data/scripts/timer.c
#animationscript data/scripts/scenefx.c
#animationscript data/scripts/wasitS.c
animationscript data/scripts/special.c
#diesound data/sounds/timeover.wav
anim spawn
delay 463
offset 1 1
frame data/chars/misc/empty.gif
#anim respawn
#delay 463
#offset 1 1
#frame data/chars/misc/empty.gif
anim idle
@script
void self = getlocalvar("self");
int Health = getentityproperty(self, "health");
int P1 = getplayerproperty(0, "entity"); // Player 1
int P2 = getplayerproperty(1, "entity"); // Player 2
void T1 = findtarget(P1); // Enemy 1
void T2 = findtarget(P2); // Enemy 2
int HP1 = getentityproperty(P1, "health");
int HP2 = getentityproperty(P2, "health");
int THP1 = getentityproperty(T1, "health");
int THP2 = getentityproperty(T2, "health");
void TAni1 = getentityproperty(T1, "animationid");
void TAni2 = getentityproperty(T2, "animationid");
int CountP = openborvariant("count_players");
if(HP1 <= 0 || HP2 <= 0 || THP1 <= 0 || THP2 <= 0){ // Who loses first before time runs out?
performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
}
if(HP1 <= 0 && HP2 <= 0){ // Both fighters (player 1 and 2) lose their respective health?
performattack(self, openborconstant("ANI_DIE")); // Does the timer detect a draw according to both players' health meters
}
if(CountP == 1){
if(HP1 <= 0 && THP1 <= 0){ // Both fighters (player 1 and enemy 1) lose their respective health?
performattack(self, openborconstant("ANI_DIE"));
}
else if(HP2 <= 0 && THP2 <= 0){ // Both fighters (player 2 and enemy 2) lose their respective health?
performattack(self, openborconstant("ANI_DIE"));
}
else if(HP1 <= 0 || HP2 <= 0){ // Who loses first before time runs out?
performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
}
else if(THP1 <= 0 || THP2 <= 0){ // Who loses first before time runs out?
performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
}
}
if(frame==1){
changeentityproperty(self, "health", Health-1);
if (Health <= 0){
performattack(self, openborconstant("ANI_DIE"));
}
}
@end_script
loop 1 1
delay 1
offset 1 1
frame data/chars/misc/empty.gif
delay 105
frame data/chars/misc/empty.gif
delay 1
frame data/chars/misc/empty.gif
anim follow1 #Stop running timer
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
anim follow2 #Save room for setting it as no timer
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
anim death # Time Out
@script
if(frame == 0){
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
void T1 = findtarget(P1);
void T2 = findtarget(P2);
//void T1 = getentityproperty(P1, "opponent");
//void T2 = getentityproperty(P2, "opponent");
int p1y = getentityproperty(P1, "y");
int p1base = getentityproperty(P1, "base");
int p2y = getentityproperty(P2, "y");
int p2base = getentityproperty(P2, "base");
int T1y = getentityproperty(T1, "y");
int T1base = getentityproperty(T1, "base");
int T2y = getentityproperty(T2, "y");
int T2base = getentityproperty(T2, "base");
void P1ani = getentityproperty(P1, "animationid");
void P2ani = getentityproperty(P2, "animationid");
void T1ani = getentityproperty(T1, "animationid");
void T2ani = getentityproperty(T2, "animationid");
void P1atk = getentityproperty(P1, "attacking");
void P2atk = getentityproperty(P2, "attacking");
void T1atk = getentityproperty(T1, "attacking");
void T2atk = getentityproperty(T2, "attacking");
changeopenborvariant("lasthitc", 0);
if(P1){
changeentityproperty(P1, "noaicontrol", 1);
}
if(P2){
changeentityproperty(P2, "noaicontrol", 1);
}
if(T1){
changeentityproperty(T1, "noaicontrol", 1);
}
if(T2){
changeentityproperty(T2, "noaicontrol", 1);
}
if(P1atk == NULL() && p1y == p1base || P1ani == openborconstant("ANI_WALK") || P1ani == openborconstant("ANI_BACKWALK") ){
changeentityproperty(P1, "velocity", 0, 0, 0);
changeentityproperty(P1, "noaicontrol", 1);
changeentityproperty(P1, "animation", openborconstant("ANI_IDLE"));
}
if(p2y == p2base || P2ani == openborconstant("ANI_WALK") || P2ani == openborconstant("ANI_BACKWALK") ){
//changeentityproperty(P2, "velocity", 0, 0, 0);
changeentityproperty(P2, "noaicontrol", 1);
changeentityproperty(P2, "animation", openborconstant("ANI_IDLE"));
}
if(P1atk != NULL() && p1y == p1base){
changeentityproperty(P1, "velocity", 0, 0, 0);
}
if(P1atk != NULL() && p1base){
changeentityproperty(P1, "velocity", 0, 0, 0);
}
}
if(frame == 1){
void self = getlocalvar("self");
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
int HP1 = getentityproperty(P1, "health");
int HP2 = getentityproperty(P2, "health");
void target = findtarget(P1);
void target2 = findtarget(P2);
//void target = getentityproperty(P1, "opponent");
//void target2 = getentityproperty(P2, "opponent");
int THP1 = getentityproperty(target, "health");
int THP2 = getentityproperty(target2, "health");
int CountP = openborvariant("count_players");
//void subent;
if(CountP == 2){
if(HP1 > HP2){ // Player 1 wins and player 2 loses?
performattack(P1, openborconstant("ANI_FOLLOW61"));
performattack(P2, openborconstant("ANI_FOLLOW15"));
}
if(HP1 == HP2){ // Draw?
//subent = spawn();
//clearspawnentry();
performattack(P1, openborconstant("ANI_FOLLOW15"));
performattack(P2, openborconstant("ANI_FOLLOW15"));
}if(HP1 < HP2){ // Player 2 wins?
performattack(P1, openborconstant("ANI_FOLLOW15"));
performattack(P2, openborconstant("ANI_FOLLOW61"));
}
}
if(CountP == 1){
if(HP1 > THP1){
performattack(P1, openborconstant("ANI_FOLLOW61"));
performattack(target, openborconstant("ANI_FOLLOW15"));
}
else if(HP1 == THP1){
performattack(P1, openborconstant("ANI_FOLLOW15"));
performattack(target, openborconstant("ANI_FOLLOW15"));
}else if(HP1 < THP1){
performattack(P1, openborconstant("ANI_FOLLOW15"));
performattack(target, openborconstant("ANI_FOLLOW61"));
}
else if(HP2 > THP2){
performattack(P2, openborconstant("ANI_FOLLOW61"));
performattack(target2, openborconstant("ANI_FOLLOW15"));
}
else if(HP2 == THP2){
performattack(P2, openborconstant("ANI_FOLLOW15"));
performattack(target2, openborconstant("ANI_FOLLOW15"));
}else if(HP2 < THP2){
performattack(P2, openborconstant("ANI_FOLLOW15"));
performattack(target2, openborconstant("ANI_FOLLOW61"));
}
}
}
@end_script
delay 200
offset 1 1
@cmd setindexedvar "fightStarted" 0
@cmd DeControl 0 1
@cmd DeControl 1 1
sound data/sounds/SND_COM2_8.wav
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
Last edited: