Please help with script

brodock101

New member
Hi there. I'm try write script to npc on did hit. In script, when npc caller attack enemy, and if enemy not blocking then npc heals 10hp.
Where's my error?
Sorry for my englsih) 

void main()
{
void NP = getlocalvar("self");
void target;
int i;
int iType;
int NoBlock;
int iHP = getentityproperty(NP, "health");
int iEnm = openborvariant("count_enemies");
for (i=0,i<iEnm, i++){
target = getentity(i);
iType  = getentityproperty(target, "type");
NoBlock  = getentityproperty(target, "animation");
if ((target = getentityproperty(NP, "opponent"))&&(iType == openborconstant("TYPE_ENEMY"))&&(NoBlock != openborconstant("ANI_BLOCK"))){
changeentityproperty(NP, "health", iHP+10);
        }
      }
    }
 
I can see another error in script however I rather discuss about the script as whole

If this script were run as a function in an animation, it is okay. However since it's run on didhitscript, I don't see a reason to check every single enemy to see which one NPC has attacked

I suggest removing the check and instead acquire attacked enemy directly using this:
Code:
void target =  getlocalvar("damagetaker");

Since you also need to know blocked status, you should get that with this:
Code:
int NoBlock = getlocalvar("blocked");

NoBlock = 1 if blocked or 0 if not blocked
 
Thank you, Bloodbane! It's working! How can i make a heal value dependent on damage value to damagetaker?
For example, npc use attack1 with damage 3, and when attack sucess, enemy lost 3 hp, npc heal, perhaps, 30% of inflicted damage i.e. 1 hp
 
Back
Top Bottom