Solved Enemy immune script attack

Question that is answered or resolved.

dantedevil

Well-known member
I want to know how make an enemy immune in specific animation when it attacked by this script:

Code:
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");  
              
        for(iEntity=0; iEntity<iMax; iEntity++)
        {

       
        vEntity = getentity(iEntity);
        if(getentityproperty(vEntity, "type")==openborconstant("TYPE_enemy"))
        {
       
        damageentity(vEntity,self,damage,drop,openborconstant(atk_type));
        changeentityproperty(vEntity, "staydown", "riseattack", stay);
   
        }

    }
       

}
 
Last edited:
Solution
I've just tried it myself and I don't understand why disabling immunity fails. It fails with attacktype 60 but not with attacktype 4

One suggestion I can give is to swap attacktype. Find any attacktype from 2 to 10 which is only used by attackbox (not by script) and swap it with attacktype used for immunity
This requires lot of work swapping everything but it's the best way I know for now  :-\
It's pretty simple really.

In the loop, look for X conditions, where X = whatever is unique about that entity to make it immune. If the entity does NOT match those conditions, then you damage them. Otherwise nothing happens.

Code:
...

if(getentityproperty(vEntity, "type") == openborconstant("TYPE_enemy"))
{

    if(<NOT immune>) 
    {
        damageentity(vEntity,self,damage,drop,openborconstant(atk_type));
        changeentityproperty(vEntity, "staydown", "riseattack", stay);
    }       

}

...

HTH

DC
 
Thanks DC!

Here my problem:

I want this immune for certain animations, because my enemies have a lot of custom spawns.

Ex:
y27X67W.png

As you can see in this screenshot, in the upper right there are 3 enemies (black hooded). These enemies are in their custom spawn.


CUSTOM SPAWN:
Code:
anim follow11
	loop	1 2 4
@script
    void self = getlocalvar("self");
    int Summon = getentityvar(self, 1);

    if(frame==0){
      setentityvar(self, 1, openborvariant("elapsed_time"));
    }
    if(Summon <= openborvariant("elapsed_time") - 3500){
      setentityvar(self, 1, NULL());
      performattack(self,openborconstant("ANI_FOLLOW12"));
    }
@end_script
	delay	10
	offset	82 348
	frame	data/chars/hunter/spawn.png
@script
void self = getlocalvar("self");

if(frame == 0){
  changeentityproperty(self, "setlayer", -1);
}

@end_script
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png

But the damage all enemies script, can damage the enemies in this animations.

So, what conditions should be added, so that the script can not damage enemies in these animations?
 
From looking at your script, couldn't it be like this?

Code:
anim follow11
	loop	1 2 4
@script
    void self = getlocalvar("self");
    int Summon = getentityvar(self, 1);

    if(frame==0){
      setentityvar(self, 1, openborvariant("elapsed_time"));
    }
    if(Summon <= openborvariant("elapsed_time") - 3500){
      setentityvar(self, 1, NULL());
      performattack(self,openborconstant("ANI_FOLLOW12"));
    }
    if(frame == 1){
      changeentityproperty(self, "setlayer", -1);
    }
@end_script
	delay	10
	offset	82 348
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png

Why are there 2 @script tags in one animation? I mean, one for the first frame, and the other one in second.
 
I see the problem Dantedevil, the solution is simply set some properties as Damon Caskey suggested like defense, aggression or antigrab.

From that three, defense is easiest to use as it won't have any effect in mod if there were no respective attacktype used anywhere. Not to mention, it defines immunity ;)
Here's an example from Tel'Erond's polymorph spell:

anim follow21 # Polymorph
@script
  if(frame==13){
    void vSelf    = getlocalvar("self");        //Caller
    void vEntity;                                //Target entity placeholder
    int  iEntity;                                //Entity enumeration holder
    int  iType;                                  //Entity type
    int  iMax      = openborvariant("ent_max");  //Entity count
    void e;                                      //Holder for effect
    int fX;
    int fY;
    int fZ;
    int Def;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){   
      vEntity = getentity(iEntity);                //Get target entity from loop
      iType  = getentityproperty(vEntity, "type"); //Get target type

      //Enemy type?
      if (iType == openborconstant("TYPE_ENEMY")){
        Def = getentityproperty(vEntity, "defense", openborconstant("ATK_NORMAL9"));

        if(Def != 0){
          clearspawnentry();
          setspawnentry("name", "Polymorph");
          e = spawn();
          fX = getentityproperty(vEntity, "x");
          fY = getentityproperty(vEntity, "a");
          fZ = getentityproperty(vEntity, "z");
          damageentity(vEntity, vEntity, 1000, 0, openborconstant("ATK_NORMAL9"));
  changeentityproperty(e, "position", fX, fZ+2, fY);
        }
      }
    }
  }
@end_script
...

I didn't quote the animation as it's not related to the script except for the setting that the script is run at 14th frame
Anyways, this script will hit all enemies except the ones with defense normal9 0 in their text. That's how I set the script to work on regular enemies but not on bosses
Attack type 9 isn't used any regular attacks making it stable to use

So for your mod, find an attacktype that you aren't using at all, set that as defense factor in special enemies text to exclude them from that attack you quoted above. Then update your script to check that defense value like my quote above

HTH
 
Thanks my friend, I think understand your method.

But here the problem:

If set certain parameters in this enemy, he can't  be hit by the "damage all enemies" during their custom  spawn.

But when the same enemy jump of their high position and come to fight,  the "damage all enemies" can't be hit them.

And that's not the idea.

I want the "damage all enemies" can't hit the enemy only during a specific animation.
I see the enemies can't be hit by the " damage all enemies" attack,  only during their "anim spawn".
So I think the best is create a script to make the character immune during the animation like in "anim spawn".

Something like this :

anim follow11
loop 1 2 4
@script
    void self = getlocalvar("self");
    int Summon = getentityvar(self, 1);

    if(frame==0){
      setentityvar(self, 1, openborvariant("elapsed_time"));
    }
    if(Summon <= openborvariant("elapsed_time") - 3500){
      setentityvar(self, 1, NULL());
      performattack(self,openborconstant("ANI_FOLLOW12"));
    }
    if(frame == 1){
      changeentityproperty(self, "setlayer", -1);
    }
@end_script
delay 10
offset 82 348
@cmd  immune
frame
data/chars/hunter/spawn.png
frame data/chars/hunter/spawn.png
frame data/chars/hunter/spawn.png
frame data/chars/hunter/spawn.png
frame data/chars/hunter/spawn.png

 
Keep in mind, the condition(s) need not be a static property like Defense. Example: You could get the entity's current animation and act accordingly. More than one condition can be used in combination too.

DC
 
That's easy to solve dantedevil  8)
At the end of SPAWN animation, change the value of that defense to allow that enemy to be hit by that attack

Here's an example:
anim spawn
@script
    if(frame==6){ // assuming 7th frame is the last frame
      void self = getlocalvar("self");
      changeentityproperty(self, "defense", openborconstant("ATK_NORMAL9"), 1);
    }
@end_script
...

Enemies using this script will lose its immunity to Polymorph (my example above) after SPAWN animation
 
I have different attack for some heros:

Batman - "damage all enemies"  "ATK_NORMAL35"
Carolina - "damage all enemies"  "ATK_BURN"
Kitana - "damage all enemies" "ATK_NORMAL17"
Kitana - "damage all enemies"  "ATK_NORMAL5"
Raiden - "damage all enemies"  "ATK_SHOCK"


Sou you can show me how use this script with all this attacks?
 
I'm still lost here  ???
Do you want an attack_all_enemies with all 5 attacktypes at same time (technically, it's not same time but consecutively and very quick)?
OR do you want to update the function your quoted above so some enemies are immune to all 5 attacktypes temporarily?
 
Bloodbane said:
I'm still lost here  ???
Do you want an attack_all_enemies with all 5 attacktypes at same time (technically, it's not same time but consecutively and very quick)?
OR do you want to update the function your quoted above so some enemies are immune to all 5 attacktypes temporarily?

Like say before, I want update the function so the enemiy are immune to all 5 attacktypes temporarily.
I try to make it work for myself,  but not working.
 
Well here's the updated function:
Code:
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_NORMAL50"));
		if(getentityproperty(vEntity, "type")==openborconstant("TYPE_enemy") && Def != 0)
		{		
		damageentity(vEntity,self,damage,drop,openborconstant(atk_type));
		changeentityproperty(vEntity, "staydown", "riseattack", stay);	
		}
	}	
}

This function won't hit enemies with defense normal50 0
You can remove this immunity with this script:

anim spawn
@script
    if(frame==6){ // assuming 7th frame is the last frame
      void self = getlocalvar("self");
      changeentityproperty(self, "defense", openborconstant("ATK_NORMAL50"), 1);
    }
@end_script
...

Oh that's the assumption that attacktype 50 is not used yet. If it is, just change it to other attacktype
 
Well my friend:

- First update the "damage all enemies" script using attack60 for my mod.
-Then set the line:
defense normal60 0
in the enemy.

Now the "damage all enemies" can't hit this enemy.

But here my problem:
My enemy has a custom anim spawn,  I put the script to remove this immunity, but not work. The "damage all enemies attack" still without hit the enemy.

Here the custom anim spawn with the script:

Code:
anim follow11
	loop	1 2 4
@script
    void self = getlocalvar("self");
    int Summon = getentityvar(self, 1);

    if(frame==0){
      setentityvar(self, 1, openborvariant("elapsed_time"));
    }
    if(Summon <= openborvariant("elapsed_time") - 3500){
      setentityvar(self, 1, NULL());
      performattack(self,openborconstant("ANI_FOLLOW12"));
    }
@end_script
	delay	10
	offset	82 348
	frame	data/chars/hunter/spawn.png
@script
void self = getlocalvar("self");

if(frame == 0){
  changeentityproperty(self, "setlayer", -1);
}

@end_script
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png



anim follow12
	loop	0
	delay	10
	offset	82 348
	bbox	0 0 0 0
@script
void self = getlocalvar("self");

if(frame == 5){
  changeentityproperty(self, "setlayer", 0);
}

@end_script
	frame	data/chars/hunter/spawn.png
	frame	data/chars/hunter/spawn.png
	delay	9
	frame	data/chars/hunter/w4.png
	frame	data/chars/hunter/w5.png
	delay	1
	offset	82 177
        @cmd    move 0 1 171
	frame	data/chars/hunter/w5.png
        @cmd    stop
	delay	10
        @cmd    leaper 2 1 -0.5
        sound   data/sounds/jump.wav
	frame	data/chars/hunter/runat02.png
        sound   data/chars/hunter/at0.wav
	attack  119 128 34 19 10 1 0 0 20
	frame	data/chars/hunter/runat02.png
        sound   data/chars/hunter/at2.wav
        landframe 8
	delay   999
	attack  118 149 34 19 10 1 0 0 20
	frame	data/chars/hunter/runat03.png
	attack  0 0 0 0
	delay   15
	frame	data/chars/hunter/w7.png
	delay   8
@script
    if(frame==9){ // assuming 10th frame is the last frame
      void self = getlocalvar("self");
      changeentityproperty(self, "defense", openborconstant("ATK_NORMAL60"), 1);
    }
@end_script
	frame	data/chars/hunter/spain1.png
 
Try typing it like this:

anim follow12
@script
    if(frame == 5){
      void self = getlocalvar("self");
      changeentityproperty(self, "setlayer", 0);
    }
    if(frame == 9){
      void self = getlocalvar("self");
      changeentityproperty(self, "defense", openborconstant("ATK_NORMAL60"), 1);
    }
@end_script
delay 10
offset 82 348
bbox 0 0 0 0
        landframe 8
frame data/chars/hunter/spawn.png
frame data/chars/hunter/spawn.png
delay 9
frame data/chars/hunter/w4.png
frame data/chars/hunter/w5.png
delay 1
offset 82 177
        @cmd    move 0 1 171
frame data/chars/hunter/w5.png
        @cmd    stop
delay 10
        @cmd    leaper 2 1 -0.5
        sound  data/sounds/jump.wav
frame data/chars/hunter/runat02.png
        sound  data/chars/hunter/at0.wav
attack  119 128 34 19 10 1 0 0 20
frame data/chars/hunter/runat02.png
        sound  data/chars/hunter/at2.wav
delay  999
attack  118 149 34 19 10 1 0 0 20
frame data/chars/hunter/runat03.png
attack  0 0 0 0
delay  15
frame data/chars/hunter/w7.png
delay  8
frame data/chars/hunter/spain1.png
 
Back
Top Bottom