Damage all enemies BUG

dantedevil

Well-known member
I found a bug using this script:

void damage_all_enemies(int damage, int drop, int stay, void atk_type)
{
int  iEntity;
        void vEntity;
        void self        = getlocalvar("self");
        int  iMax        = openborvariant("ent_max");
    int Def;
             
        for(iEntity=0; iEntity<iMax; iEntity++)
        {     
        vEntity = getentity(iEntity);
        Def = getentityproperty(vEntity, "defense", openborconstant("ATK_NORMAL4"));
void EAnim = getentityproperty(vEntity, "animationID");

if(getentityproperty(vEntity, "type")==openborconstant("TYPE_enemy") && Def != 0 && EAnim != openborconstant("ANI_FALL7"))
{
damageentity(vEntity,self,damage,drop,openborconstant(atk_type));
changeentityproperty(vEntity, "staydown", "riseattack", stay);
}
}
}

The problem comes when the enemies have a weapon. All weapons have type none, so the script not affect this enemies and this looks really bad.
 
Are you sure the script doesn't work with weapon wielding enemies? I've tested this and I can use the script to either count all enemies with weapon or damage all enemies with weapon
 
First, don't use "ent_max". Use "count_entities" or even "count_enemies". Using ent_max will make the engine count 5000 times instead of just counting the active entities.

Second, I haven't tested the code against enemies with weapons but it should work. Even if th3 weapon is type none, the welder is still an enemy (like players with weapons are still players), or you won't be able to hurt them.

But if it not working, you can add a check for type none && weapomnum > 0.
 
Thanks both for the help my friends!

I was trying a little more and frankly I can not determine exactly when it happens.
But while I was recording the gameplays, this happened to me with different enemies that had weapons.
But I just tried it in training and everything works perfect. Apparently there are other factors that influence this to happen.
I will continue investigating until I have more information about it.

Thanks!
 
Last edited:
Back
Top Bottom