Solved Knockdowncount issues and changeentityproperty

Question that is answered or resolved.

Crimsondeath

Well-known member
Hi to everyone, I want an NPC change its animation each time a specific enemy is knocked down.

I'm using 'knockdowncount 15' for all my entities, so I wrote this script:

Code:
anim    idle
    loop    1
    delay    1
    offset    1 1
    @script
if(frame == 1){
        void vEntity;
    int  iEntity;
    char iName;
    int  iMax = openborvariant("count_entities");
    int iKnockdowncount;
    void self = getlocalvar("self");

    for(iEntity=0; iEntity<iMax; iEntity++){

        vEntity = getentity(iEntity);
        iName   = getentityproperty(vEntity, "name");
        iKnockdowncount = getentityproperty(vEntity, "knockdowncount", "current");

            if (iName == "Loco_Mat" && iKnockdowncount < 15) {    // here is my issue x.x
           changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
        }
    }
}
    @end_script   
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

I don't know what I'm doing wrong, but when I use "iKnockdowncount == 15" (Which means that the specific enemy isn't knocked down) the condition is fulfilled (I test it an the NPC show it's animation), but applying any other operator : <, >, != (Which means that the specific enemy is knocked down) the NPC don't do anything (just keep idle).

So, what I want is that the NPC change its animation each time the specific enemy is knocked down :( .

Thanks.
 
Did you try out performattack or executeanimation?

performattack(entity, int anim, int resetable)

  • This method allow the entity to do an attack, not just give it attack animation.
  • anim - Optional. It stands for animation number, can be got by openborconstant.
  • resetable - Optional. If current animation number is same as this one, and resetable is 1, current animation will be reset or else, the anim will be ignored.
  • Notice: If you provide anim parameter, and this function is called in an animation script, you probably need to add a return behind it because the animation might be changed and the animation script will be re-called.
executeanimation(entity, int anim, int resetable)

  • it works like performattack() but just you play an animation without animation loop.
  • This function is useful to avoid changeentityproperty(entity,"animation",value) loop issue!
 
Did you try out performattack or executeanimation?
@maxman: Hi, thanks por reply, I tried that but it was the same result as "changeentityproperty".


In the end, I try this with "ANI_FALL" and works great:

Code:
if(frame == 0){
        void vEntity;
    int  iEntity;
    char iType;
    char iName;
    int  iMax = openborvariant("count_entities");
    int iAnim;   
    void self = getlocalvar("self");

    for(iEntity=0; iEntity<iMax; iEntity++){

        vEntity = getentity(iEntity);
        iType   = getentityproperty(vEntity, "type");
        iName   = getentityproperty(vEntity, "name");
        iAnim   = getentityproperty(vEntity, "animationid");

        if (iName == "Loco_Mat" && iAnim == openborconstant("ANI_FALL")) {
          executeanimation(self, openborconstant("ANI_FOLLOW1"), 1);
        }
    }
}

I don't know why "knockdowncount" didn't work but now the problem is solved, thanks.
 
Back
Top Bottom