Solved Forcing death animation not working, how do i convert to ondeathscript instead?

Question that is answered or resolved.

oldyz

Well-known member
This account is temporarily muted.
hopefully someone can help me figure out why its not working
i implemented @Bloodbane 's force death animatjon script

Code:
    ### 2023 fall fix  ####  
anim    fall
@script
  if( frame == 1 ){
    void self = getlocalvar("self");
    int Health = getentityproperty(self, "health");
    int Land = getentityproperty(self, "damage_on_landing");

    changeentityproperty(self, "damage_on_landing", 0);

    if( Health > Land ){
      changeentityproperty(self, "health", Health-Land);
    } else if( Health <= Land ){
      damageentity(self, self, 20, 1, openborconstant("ATK_NORMAL"));
    }
  }
@end_script
    delay    1000
    offset    99 149
    bbox    0 0 0 0
    landframe    3
    attack    56 63 36 43 6 1 0 0 20
    hitflash    bflash
    frame    data/chars/franken/039
    offset    109 149
    attack    0 0 0 0 0
    frame    data/chars/franken/115
    offset    99 149
    frame    data/chars/franken/042
    delay    20
    attack    0 0 0 0 0
    frame    data/chars/franken/041
    delay    15
    bbox    39 131 117 17
    frame    data/chars/franken/109 #og 115
    ### 2023 fall fix end ####  
   
anim    fall5
@script
  if( frame == 1 ){
    void self = getlocalvar("self");
    int Health = getentityproperty(self, "health");
    int Land = getentityproperty(self, "damage_on_landing");

    changeentityproperty(self, "damage_on_landing", 0);

    if( Health > Land ){
      changeentityproperty(self, "health", Health-Land);
    } else if( Health <= Land ){
      damageentity(self, self, 20, 1, openborconstant("ATK_NORMAL5"));
    }
  }
@end_script
    delay    1000
    offset    99 149
    bbox    56 63 36 43
    landframe    1
    attack    56 63 36 43 6 1 0 0 20
    hitflash    bflash
    frame    data/chars/franken/039
    delay    20
    attack    0 0 0 0 0
    bbox    0 0 0 0
    frame    data/chars/franken/041
    delay    30
    bbox    39 131 117 17
    frame    data/chars/franken/115
       
anim    fall8
@script
  if( frame == 1 ){
    void self = getlocalvar("self");
    int Health = getentityproperty(self, "health");
    int Land = getentityproperty(self, "damage_on_landing");

    changeentityproperty(self, "damage_on_landing", 0);

    if( Health > Land ){
      changeentityproperty(self, "health", Health-Land);
    } else if( Health <= Land ){
      damageentity(self, self, 20, 1, openborconstant("ATK_NORMAL8"));
    }
  }
@end_script
    delay    1000
    offset    99 149
    bbox    0 0 0 0
    landframe    3
    frame    data/chars/franken/037a
    frame    data/chars/franken/040
    attack    56 63 36 43 6 1 0 0 20
    hitflash    bflash
    frame    data/chars/franken/039
    delay    20
    attack    0 0 0 0 0
    frame    data/chars/franken/041
    delay    15
    bbox    39 131 117 17
    frame    data/chars/franken/115

so far the code has worked with other characters, but with this one i suspect that this script featured as the character's
animationscript data/scripts/boss.c
may be to blame:

Code:
Boss.c

#import "data/scripts/mutant2XMizer.c"
//#import "data/scripts/spawnbind.c"
#import "data/scripts/spawnMate.c"
#import "data/scripts/bindobject.c"
//#import "data/scripts/bindtoentity.c"

void velo001(float fX, float fZ, float fY){
    void vSelf = getlocalvar("self"); 
    if (getentityproperty(vSelf, "direction")==0){                  
        fX = -fX; 
    }changeentityproperty(vSelf, "velocity", fX, fZ, fY);
}void shoot(void Shot, float dx, float dy, float dz){
    void self = getlocalvar("self");
    int Direction = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    if (Direction == 0){            
        dx = -dx; 
    }projectile(Shot, x+dx, z+dz, y+dy, Direction, 0, 0, 0);
}void toss(void Bomb, float dx, float dy, float dz){
    void self = getlocalvar("self");
    int Direction = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    if (Direction == 0){           
        dx = -dx;
    }projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);

////// new antiwall 2023  /////////////
}void antiwall(int Dist, int Move, int Distz)
{// Checks if there is wall at defined distance
// If there is wall, entity will be moved away with defined movement
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   float H;
   float Hz;
   float Hw;


   if(Direction == 0){ //Is entity facing left?                 
      Dist = -Dist; //Reverse Dist to match facing
      Move = -Move; //Reverse Move to match facing
   }


   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);
   Hw = checkwall(x+Dist,z-Distz);


   if(Hz > y && Hw <= y)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }


   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
   }
////// new antiwall 2023 end  /////////////

}void death(){
    void vSelf = getlocalvar("self"); 
    float fY = getentityproperty(vSelf, "a");
    if (fY > 1){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_DIE3"));
    }
///// 2023.10.25 ////////
}void HealthSwitch(void Ani)
{// Changes Animation based on health
    void self = getlocalvar("self");
    int  Health = getentityproperty(self,"health");
   
    if(Health >= 1 && Health <30){ //Checks health range
    changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
    }
//// 2023.10.25  end /////
}void anti(){
    void self = getlocalvar("self");
    void target = getlocalvar("Target" + self);
    if(target==NULL()){
        bindentity(target, self, 0, 0, 0, 0, 0);
    }if(target!=NULL()){
        bindentity(target, NULL());
    }
}void hurt(int Damage, int AtNumber){
    void self = getlocalvar("self");
    void target = getlocalvar("Target" + self);
    if(target==NULL()){
        target = getentityproperty(self, "grabbing");
        setlocalvar("Target" + self, target);
    }
    if(target!=NULL()){
        if(AtNumber==0){
            damageentity(target, self, Damage, 0, openborconstant("ATK_NORMAL6")); 
        }if(AtNumber==1){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL6")); 
        }if(AtNumber==7){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL7")); 
        }if(AtNumber==8){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL8"));
        }
    }
}void finish(int Damage, int Type, int x, int y, int z, int Face){
    void self = getlocalvar("self");
    void target = getlocalvar("Target" + self);
    int SDir = getentityproperty(target,"direction");
    int MDir;
    if(Face==0){
        MDir = SDir;
    }if(Face==1){
        if(SDir==0){ 
            MDir = 1;
        } else { MDir = 0;}
    }if(target==NULL()){
        target = getentityproperty(self, "grabbing");
        setlocalvar("Target" + self, target);
    }if(target!=NULL()){
        int dir = getentityproperty(target,"direction");
        if(dir==0){
            x = -x;
        }if(Type==0){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL6")); 
        }if(Type==1){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL6")); 
        }if(Type==2){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL2")); 
        }if(Type==3){
            damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL3")); 
        }
        changeentityproperty(target, "direction", MDir);
        tossentity(target, y, x, z);
    }
}void depost(int Gr){
    void self = getlocalvar("self");
    void target = getlocalvar("Target" + self);
    if(target==NULL()){
        target = getentityproperty(self, "grabbing");
        setlocalvar("Target" + self, target);
    }if(target!=NULL()){
        bindentity(target, NULL());
        if(Gr == 1){
            int x = getentityproperty(target, "x");
            int z = getentityproperty(target, "z");
            changeentityproperty(target, "position", x, z, 0);
        }
    }
}void position(int Frame, float dx, float dy, float dz, int face){
    void self = getlocalvar("self");
    void target = getlocalvar("Target" + self);
    if(target==NULL()){
        target = getentityproperty(self, "grabbing");
        setlocalvar("Target" + self, target);
    }if(target!=NULL()){
        updateframe(target, Frame);
        bindentity(target, self, dx, dz, dy, face, 0);
    }
}void grabcheck(){
    void self = getlocalvar("self");
    void target = getentityproperty(self, "grabbing");
    if(target==NULL()){
        performattack(self, openborconstant("ANI_ATTACK2")); 
    }
}void ani001(void vAni, int iFrame){
    void vSelf = getlocalvar("self"); 
    changeentityproperty(vSelf, "animation", openborconstant(vAni)); 
    changeentityproperty(vSelf, "animpos", iFrame); 
}void clearL(){
    clearlocalvar();
}void targetL(float Vy, float dx, float dz){
    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    if (dir == 0){
        dx = -dx;
    }
    setlocalvar("T"+self, findtarget(self));
    if( getlocalvar("T"+self) != NULL()){
        void target = getlocalvar("T"+self);
        float Tx = getentityproperty(target, "x");
        float Tz = getentityproperty(target, "z");
        if(Tx < x){
            changeentityproperty(self, "direction", 0);
        } else {
            changeentityproperty(self, "direction", 1);
        }
        x = x+dx;
        z = z+dz;
        setlocalvar("x"+self, (Tx-x)/(22*Vy));
        setlocalvar("z"+self, (Tz-z)/(22*Vy));
    } else {
        setlocalvar("z"+self, 0);
        setlocalvar("x"+self, 0);
    }
}void leap(float Vely){
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    float Vz = getlocalvar("z"+self);
    if( Vx!=NULL() && Vz!=NULL() ){
        tossentity(self, Vely, Vx, Vz);
    }
}void teletarget(int dx, int dy, int dz){
    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    if(dir==0){
        dx = -dx ;
    }
    setlocalvar("T"+self, findtarget(self));
    if( getlocalvar("T"+self) != NULL()){
        void target = getlocalvar("T"+self);
        int Tx = getentityproperty(target, "x");
        int Tz = getentityproperty(target, "z");
        changeentityproperty(self, "position", Tx+dx, Tz+dz, dy); 
    } 
}void target(float Velx, float Velz){
    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    setlocalvar("T"+self, findtarget(self));
    if( getlocalvar("T"+self) != NULL()){
        void target = getlocalvar("T"+self);
        float Tx = getentityproperty(target, "x");
        float Tz = getentityproperty(target, "z");
        float Disx = Tx - x;
        float Disz = Tz - z;
        if(Disx < 0){
            Disx = -Disx;
            changeentityproperty(self, "direction", 0);
        } else {
            changeentityproperty(self, "direction", 1);
        }
        if(Disz < 0){
            Disz = -Disz;
        }
        if(Disz < Disx)
        {
            if(Tx < x){
                setlocalvar("x"+self, -Velx);
            } else { setlocalvar("x"+self, Velx); }
            setlocalvar("z"+self, Velx*(Tz-z)/Disx);
        } else {
            if(Tz < z){
                setlocalvar("z"+self, -Velz);
            } else { setlocalvar("z"+self, Velz); }
            setlocalvar("x"+self, Velz*(Tx-x)/Disz);
        }
    } else {
        setlocalvar("z"+self, 0);
        if(dir==0){
            setlocalvar("x"+self, -Velx);
        } else { setlocalvar("x"+self, Velx); }
    }
}void spawn01(void vName, float fX, float fY, float fZ){
    void self = getlocalvar("self");
    void vSpawn;
    int  iDirection = getentityproperty(self, "direction");
    clearspawnentry(); 
    setspawnentry("name", vName); 
    if (iDirection == 0){
        fX = -fX;
    }fX = fX + getentityproperty(self, "x");
    fY = fY + getentityproperty(self, "a");
    fZ = fZ + getentityproperty(self, "z");
    vSpawn = spawn();
    changeentityproperty(vSpawn, "position", fX, fZ, fY); 
    changeentityproperty(vSpawn, "direction", iDirection); 
    return vSpawn; 
}void flipdir(){
    void self = getlocalvar("self");
    changeentityproperty(self, "direction", !getentityproperty(self, "direction"));
}void hurt3(int Damage, int set){
    void self = getlocalvar("self");
    if(set==0){
        void target = getlocalvar("Target" + self);
        if(target==NULL()){
            target = getentityproperty(self, "grabbing");
            setlocalvar("Target" + self, target);
        }if(target!=NULL()){
            void THealth = getentityproperty(target,"health"); 
            changeentityproperty(target, "health", THealth - Damage); 
        }
    }else if(set==1){
        void SHealth = getentityproperty(self,"health"); 
        changeentityproperty(self, "health", SHealth + Damage);
    }
}
 
I don't think animationscript such as boss.c could conflict with animation script in FALL animation quoted above, especially with no function declared there.
So let us confirm this: what happen when this script isn't working?
 
@Bloodbane
basically , i tested it a bunch of times with the character, using its default "if animation frame = 1" thing, with other characters , pasting the code worked right away, but with franken it would not work
after many tests , tossing franken would result in no death animation....
im not sure what happened, after fixing other stuff , i came back
i matched the
" if( frame == 1 ){" to the animation's landframe (for fall is 3) and it worked,
then experimented by switching it back to frame =1 and it worked but wonky looking..

but thanks to the practice of applying it to a bunch of characters
with this script of yours i managed to fix the "recovery" landing bug too, no more game freezes...
 
Back
Top Bottom