Solved Super Armor only in certain animations?

Question that is answered or resolved.
Hello there, fellow developers!

I never meddled with takedamagescripts and what not, and I was wondering if there's a way to give Super Armor for a character only in certain animations, like a super punch that couldn't be interrupted (something like Ralf's Galtactic Phantom).
 
It's easier than you think, as long as you manage it properly.

In the animation where you want super armor to be active, put:
@cmd changeentityproperty getlocalvar("self") "Nopain" 1

In every other animation where "super armor" is inactive, put:
@cmd changeentityproperty getlocalvar("self") "Nopain" 0

As an example, here's an excerpt from Captain Falcon's txt file in my mod, Megaman Armada:
anim idle
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
offset  29  69
bbox  23  49  13  20
frame data/chars/capfal/1.png

anim walk
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
loop 1
delay 10
offset  30  69
bbox  23  50  14  18
frame data/chars/capfal/2.png
offset  34  69
bbox  27  48  12  20
frame data/chars/capfal/3.png
offset  33  69
bbox  25  49  13  19
frame data/chars/capfal/4.png
offset  34  69
bbox  27  47  13  21
frame data/chars/capfal/3.png

anim jump
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
offset  32  69
bbox  24  42  14  22
frame data/chars/capfal/8.png

anim walkoff
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
offset  32  69
bbox  24  42  14  22
frame data/chars/capfal/8.png

anim jumpland
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
delay 2
sound data/chars/megaman/land.wav
offset  29  69
bbox  23  49  13  20
frame data/chars/capfal/1.png


anim pain
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
delay 5
jumpframe 0 1.5 -0.5
#move -10
offset  32  68
frame data/chars/capfal/5.png
frame data/chars/capfal/5.png
frame data/chars/capfal/5.png
frame data/chars/capfal/5.png
#move 0
frame data/chars/capfal/5.png



#------------------------------------------

anim attack1
@cmd changeentityproperty getlocalvar("self") "Nopain" 1
delay 7
offset  29  69
bbox  23  49  13  20
frame data/chars/capfal/10.png
frame data/chars/capfal/11.png
frame data/chars/capfal/12.png
frame data/chars/capfal/13.png
frame data/chars/capfal/14.png
move 2
attack1  32  53  17  14  55  0  0  1
frame data/chars/capfal/15.png
attack1  32  50  20  15  55  0  0  1
frame data/chars/capfal/16.png
attack1  32  50  23  16  55  0  0  1
frame data/chars/capfal/17.png
move 0
delay 11
Attack1  0
frame data/chars/capfal/17a.png

#-----------------------------------------


anim run
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
subentity dust
spawnframe 0 0 0 0 0
loop 1
delay 7
offset  30  69
bbox  23  50  14  18
frame data/chars/capfal/2.png
offset  34  69
bbox  27  48  12  20
frame data/chars/capfal/3.png
offset  33  69
bbox  25  49  13  19
frame data/chars/capfal/4.png
offset  34  69
bbox  27  47  13  21
frame data/chars/capfal/3.png


anim jumpattack
@cmd changeentityproperty getlocalvar("self") "Nopain" 1
jumpframe 5 0.2 0.5
delay 7
offset  32  69
bbox  24  42  14  22
frame data/chars/capfal/8.png
frame data/chars/capfal/18.png
frame data/chars/capfal/19.png
frame data/chars/capfal/20.png
frame data/chars/capfal/21.png
#
offset  29  69
bbox  23  49  13  20
attack1  32  53  17  14  55  0  0  1
frame data/chars/capfal/15.png
attack1  32  50  20  15  55  0  0  1
frame data/chars/capfal/16.png
attack1  32  50  23  16  55  0  0  1
frame data/chars/capfal/17.png
attack 0
delay 11
frame data/chars/capfal/17a.png

anim duck
@cmd changeentityproperty getlocalvar("self") "Nopain" 0
delay 10
offset  29  69
bbox  23  49  13  20
frame data/chars/capfal/1.png
 
NickyP said:

NickyP & Paulo HP Bender,

It's even eaiser than that. Why go through every animation (and make the engine do the same) when you don't have to? Do this instead:

1. Make a new script file, and add it to the takedamage script for the model.

C:
takedamagescript    data/chars/terry/scripts/event_takedamage.c

2. The takedamage script should look something like this:

C:
void main()
{
    void ent = getlocalvar("self");
    int animation = getentityproperty(ent, "animationid");

    if(animation != openborconstant("ANI_IDLE"))
    {
        changeentityproperty(ent, "nopain", 0);
    }
    else
    {
        changeentityproperty(ent, "nopain", 1);
    }
}

The takedamage event runs when you take a hit, but right before the engine processes hit reaction. So if you turn off pain, there's no pain. :)

In the example I provided, if the model is in any animation other than Idle, it doesn't have super armor. Otherwise it does. All you need to do is replace the ANI_IDLE constant with the animation of your choice. If you want, it's also super easy to add the armor to more than one animation, or make it only work during certain times (like high/low MP, jumping, etc.).

DC
 
You are a lifesaver, Damon Caskey! I'm gonna adapt this code of yours (giving it a few parameters to be changeable in the character's takedamagescript), and post here as solution! Thanks A LOT!

EDIT: Here's the edited code, that now can be reusable as many times as needed in the character's takedamagescript.c

Code:
void SuperArmorOnAnim (void ParamAnim)
{
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == openborconstant(ParamAnim))
		{changeentityproperty(ent, "nopain", 1);}
	else
		{changeentityproperty(ent, "nopain", 0);}
}
 
Paulo HP Bender,

I love your willingess to build functions and run with the code, and you're on the right track. There is one snag though.

Code:
if(animation == openborconstant(ParamAnim))

This part violates the number 1 rule of script efficiency. You never, ever, want to send a variable to openborconstant(). This makes the engine work much harder than it needs to for what should be a simple task. Instead you should be sending the openborconstant() AS a variable. So your function would look like this:

Code:
void SuperArmorOnAnim (int ParamAnim)
{
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == ParamAnim)
		{changeentityproperty(ent, "nopain", 1);}
	else
		{changeentityproperty(ent, "nopain", 0);}
}

When you call your script, it looks like this:

Code:
SuperArmorOnAnim (openborconstant("ANI_IDLE"))

There are details why in this thread.

HTH,
DC
 
Yeah, you are right, and that's what I do most ot the time. I just forgot to optimize the code.

BTW, what if I wanted to register more than one animation per character, would I call it more than once, or would it conflict? Is there a way to store more than one animation on a single parameter?
 
From script's structure, you would need to expand script into this:
Code:
void SuperArmorOnAnim (int PAnim1, int PAnim2)
{
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2)
		{changeentityproperty(ent, "nopain", 1);}
	else
		{changeentityproperty(ent, "nopain", 0);}
}

That's for 2 animations. You'd need to expand the input for more animations

BTW you only set immunity against non knockdown attack with this script. You'd need to set nodrop 1 for knockdown attacks.
 
I'm reading this whole thread and wondering why didn't anyone simply recommend the OP to use counter 1 or disable the bbox while he is performing the Ralf like move.

Sorry,  maybe I'm not understanding the OP request.
 
PS VITA said:
I'm reading this whole thread and wondering why didn't anyone simply recommend the OP to use counter 1 or disable the bbox while he is performing the Ralf like move.

PS VITA because a super armor is different than a invincibility. He wants the player to receive the hit but not stop what he is doing on that specific animation. We can set this for all the animations natively, but for only some cases, you need script.

Disabling a bbox will render the entity invincible. Plus, the default OpenBOR Ai does a great work: it doesn't try to attack something which has no bbox.
 
O Ilusionista said:
PS VITA said:
I'm reading this whole thread and wondering why didn't anyone simply recommend the OP to use counter 1 or disable the bbox while he is performing the Ralf like move.

PS VITA because a super armor is different than a invincibility. He wants the player to receive the hit but not stop what he is doing on that specific animation. We can set this for all the animations natively, but for only some cases, you need script.

Disabling a bbox will render the entity invincible. Plus, the default OpenBOR Ai does a great work: it doesn't try to attack something which has no bbox.

Okay,  is all starting to make sense now.
Thanks
 
Oh, no it won't work as an animation script. Turning it into a function is fine - best practice in fact. But it needs to be called by takedamage script.

DC
 
Bloodbane said:
From script's structure, you would need to expand script into this:
Code:
void SuperArmorOnAnim (int PAnim1, int PAnim2)
{
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2)
		{changeentityproperty(ent, "nopain", 1);}
	else
		{changeentityproperty(ent, "nopain", 0);}
}

That's for 2 animations. You'd need to expand the input for more animations

BTW you only set immunity against non knockdown attack with this script. You'd need to set nodrop 1 for knockdown attacks.


Hi Bloodbane ,

I'm interested in adding both nopain and knockdown.

How would that generally lool like?
 
It'd look like this:
Code:
void SuperArmorOnAnim (int PAnim1, int PAnim2){
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2){
	  changeentityproperty(ent, "nopain", 1);
	  changeentityproperty(ent, "nodrop", 2);
	} else {
	  changeentityproperty(ent, "nopain", 0);
	  changeentityproperty(ent, "nodrop", 0);
	}
}
 
Bloodbane
Damon Caskey

Hi guys,

I put this inside the Billy's character Model .TXT

Code:
takedamagescript data/chars/billy/event_takedamage.c

and created a new script and placed it inside the folder of where Billy's character is
named it
Code:
event_takedamage.c

Inside the event_takedamage.c file

I put the following code : ( thanks to Bloodbane and Damon Caskey )

Code:
void SuperArmorOnAnim (int PAnim1, int PAnim2){
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2){
           changeentityproperty(ent, "nopain", 1);
           changeentityproperty(ent, "nodrop", 1);
}else{
           changeentityproperty(ent, "nopain", 0);
           changeentityproperty(ent, "nodrop", 0);
}

}

But now I don't know hot to make super armor work for say Anim follow or whatever animation?

Here's Billy's "super punch" animation code - What do I have to do in order to make super armor work?

Code:
anim follow81 #CHARGEATTACK mega punch part 1
	loop 1 3 6
	delay	12
	offset	77 170
        cancel 1 5 0 A2 freespecial  # (kick)
        cancel 1 5 0 A3 freespecial2 #(back kick)
        cancel 1 5 0 A4 freespecial2 #(back kick)
        cancel 1 5 0 S freespecial35 # (duck)
        cancel 4 5 0 J freespecial68 # (backflip)
        cancel 0 5 0 B freespecial18
        cancel 0 5 0 F freespecial18
        cancel 0 5 0 D freespecial18
        cancel 0 5 0 U freespecial18
        chargetime 1 
      bbox	60 55 40 100
      frame	data/chars/billy/hp1.png
      frame	data/chars/billy/hp2.png
      sound  data/sounds/slide.wav
@cmd aniNHoldSwitch "ANI_follow66" "A"
      frame	data/chars/billy/hp3.png
      delay	6
      frame	data/chars/billy/hp4.png
@cmd aniNHoldSwitch "ANI_follow82" "A"
      frame	data/chars/billy/hp5.png
      frame	data/chars/billy/hp6.png

and here's another piece of code where I want to add Super armor

Code:
anim freespecial35
	loop	0
	delay	7
	offset	77 170
	frame	data/chars/billy/j0.png
	frame	data/chars/billy/rise2.png
	delay	35
	frame	data/chars/billy/rise2.png
	idle 1
	frame	data/chars/billy/rise2.png
	frame	data/chars/billy/rise2.png
	frame	data/chars/billy/rise2.png
	delay	4
	frame	data/chars/billy/j0.png

Thank you.


 
Hmmm... you only declared that function inside event_takedamage.c?

Try updating it to this:
Code:
void main()
{
  SuperArmorOnAnim (openborconstant("ANI_FOLLOW81"), openborconstant("ANI_FREESPECIAL35"));
}

void SuperArmorOnAnim (int PAnim1, int PAnim2){
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2){
           changeentityproperty(ent, "nopain", 1);
           changeentityproperty(ent, "nodrop", 1);
	} else {
           changeentityproperty(ent, "nopain", 0);
           changeentityproperty(ent, "nodrop", 0);
	}
}
 
Bloodbane said:
Hmmm... you only declared that function inside event_takedamage.c?

Try updating it to this:
Code:
void main()
{
  SuperArmorOnAnim (openborconstant("ANI_FOLLOW81"), openborconstant("ANI_FREESPECIAL35"));
}

void SuperArmorOnAnim (int PAnim1, int PAnim2){
	void ent = getlocalvar("self");
	int animation = getentityproperty(ent, "animationid");

	if(animation == PAnim1 || animation == PAnim2){
           changeentityproperty(ent, "nopain", 1);
           changeentityproperty(ent, "nodrop", 1);
	} else {
           changeentityproperty(ent, "nopain", 0);
           changeentityproperty(ent, "nodrop", 0);
	}
}

This worked perfect!
Thank you!

The last thing I added was

changeentityproperty(ent, "nograb", 0);

because I forgot that some enemies can grab you and interrupt your "super armor"

 
Back
Top Bottom