send enemy to script

danno

Yatta!
Staff member
I'm trying to write a script, basically the theory behind it is a send enemy to animation via attack

Code:
void changeaniondamage(int anim, int Damage, int Flag){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
	void ohealth = getentityproperty(target,"health");
     if(ohealth < Damage && Flag == 1){
	  changeentityproperty(target, "animation", anim);
}

So as players attack connects to enemy it sends enemy to any animation desired, I have the theory but trouble executing the code some help would be appreciated.
 
danno said:
I'm trying to write a script, basically the theory behind it is a send enemy to animation via attack

Code:
void changeaniondamage(int anim, int Damage, int Flag){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
	void ohealth = getentityproperty(target,"health");
     if(ohealth < Damage && Flag == 1){
	  changeentityproperty(target, "animation", anim);
}

So as players attack connects to enemy it sends enemy to any animation desired, I have the theory but trouble executing the code some help would be appreciated.

Hi danno! It seems you made everything right, except for the "anim" part. You forgot  to add the "openborconstant", like this:
Code:
changeentityproperty(target, "animation", openborconstant(anim));
 
Code:
void changeaniondamage(int anim, int Damage, int Flag){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
	void ohealth = getentityproperty(target,"health");
     if(ohealth < Damage && Flag == 1){
	  changeentityproperty(target, "animation", anim);
}

Kratus,

The way danno is doing this is actually correct. Scripts will run faster if you send them constants instead of strings. This allows OpenBOR to pre-process the openborconstant() function on load.

danno, I think this may have more to do with when the function is run than anything wrong within it. My guess is you are running it in a takkedamage event, right? But the engine applies the animation AFTER takedamage script runs, immediately overriding you. How exactly do you have it set up?

DC
 
Damon Caskey said:
Code:
void changeaniondamage(int anim, int Damage, int Flag){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
	void ohealth = getentityproperty(target,"health");
     if(ohealth < Damage && Flag == 1){
	  changeentityproperty(target, "animation", anim);
}

Kratus,

The way danno is doing this is actually correct. Scripts will run faster if you send them constants instead of strings. This allows OpenBOR to pre-process the openborconstant() function on load.

danno, I think this may have more to do with when the function is run than anything wrong within it. My guess is you are running it in a takkedamage event, right? But the engine applies the animation AFTER takedamage script runs, immediately overriding you. How exactly do you have it set up?

DC
Nice, it's good to know that. But maybe if he uses as an animation script and doesn't write the word "openborconstant", it will crash the engine?
 
Kratus said:
...But maybe if he uses as an animation script and doesn't write the word "openborconstant", it will crash the engine?

Well sure, you have to use the correct syntax for openborconstant() correctly same as anything else, or the engine will exit (not crash).

DC
 
Damon Caskey 
I have it set in animation script

Code:
void sendenemyto(int anim, int Damage, int Flag){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
	void ohealth = getentityproperty(target,"health");
     if(ohealth < Damage && Flag == 1){
     changeentityproperty(target, "animation", openborconstant(anim));
     }
   }
}

doesn't exit the engine anymore, thanks Kratus but still can't seem to get it to work, tried calling it a whole bunch of different ways too

Code:
anim attack
loop      0
delay     7
offset    66 117
bbox      56 54 26 64
@cmd sendenemyto ("ANI_PAIN2")
frame     data/chars/venom/a1.png
attack  79 54 39 23 2 
frame     data/chars/venom/a2.png
attack    0
frame     data/chars/venom/a1.png

tried @cmd sendenemyto openborconstant("ANI_PAIN2") but nada
 
danno
You need to make the script runs after the attack box, not before. Otherwise the engine will not return the opponent
Code:
anim attack
loop      0
delay     7
offset    66 117
bbox      56 54 26 64
frame     data/chars/venom/a1.png
attack  79 54 39 23 2 
frame     data/chars/venom/a2.png
@cmd sendenemyto ("ANI_PAIN2")
attack    0
frame     data/chars/venom/a1.png

Another thing that DC can confirm better than me. The animation is a string and need to be called by using "void", but you are calling it with a "int".
I don't know if the engine will distinguish "void" from "int", but between "float" and "int" I can confirm that has some differences.
void sendenemyto(void anim, int Damage, int Flag){
 
I made those changes and tried calling after attack box, still doesn't work. I can't figure it out, I know it's some small detail I'm missing
 
danno said:
I made those changes and tried calling after attack box, still doesn't work. I can't figure it out, I know it's some small detail I'm missing
I will copy and make some tests with your script in SOR2X to see what's happening. As soon I have any result, will post here

danno
EDIT: Tested your script directly in SOR2X and worked, but maybe I understood what you are trying to do.
You are trying to get the last "hit" damage, but animation scripts will not return the damage taken. To get the damage you need to use other events like "didhitscript" or "takedamagescript".

The "damage" value used in the "@cmd sendenemyto" script will work like a "limit" check. In other words, as soon you hit the opponent, the script will check if the "ohealth" is smaller than the defined "Limit", not the "Damage" dealt in the last hit
 
danno said:
I know it's some small detail I'm missing

Well, you created function which has 3 parameters yet you only filled one of them
...
@cmd sendenemyto ("ANI_PAIN2")
attack    0
frame    data/chars/venom/a1.png

Try filling the remaining 2 parameters to see if it works. Something like this:
...
@cmd sendenemyto "ANI_PAIN2" 10 1
attack    0
frame    data/chars/venom/a1.png
 
Kratus  Bloodbane

Thanks guys, after a little revision I finally got it to work

FYz8800.jpg


attack1    pain2

LK7abk9.jpg


attack2    pain4

B91wLIn.jpg


attack3    fall3

https://www.youtube.com/watch?v=QxRkdTitC24

Code:
void sendenemyto(void anim, int Damage){
{ // change opponent animation on damage
	void self = getlocalvar("self");
	void target = getentityproperty(self, "opponent");
     if(target > Damage == 1){
     changeentityproperty(target, "animation", openborconstant(anim));
     }
   }
}

example

Code:
anim attack
loop      0
delay     7
offset    66 117
bbox      56 54 26 64
frame     data/chars/venom/a1.png
attack  79 54 39 23 2
frame     data/chars/venom/a2.png
@cmd sendenemyto "ANI_PAIN2" 1
frame     data/chars/venom/a1.png
 
Danno, I got curious for what you need this script and after seeing it in action, I got even more confused: why you didn't simply set the desired attack type for each attack box?
 
I want to use it to hit enemies into animations like attack, get, follow, grabs, respawn, when I do specific magic moves, I know the examples I gave are hard coded already but didn't wanna give too much away on what I'm working on
 
Thanks guys, after a little revision I finally got it to work
Great! I'm glad it worked.
Bloodbane is right, I completely forgot to mention that your script only worked in my game after all 3 parameters are filled
 
@danno
Could this work with anim grab too?
try this on haggar but enemy not change to pain4

Code:
anim    grab
    loop    0
    delay    6
    offset    75 177
    bbox    63 98 41 79
    hitfx    data/sounds/silencio.wav
    cancel    0 33 0 S freespecial
    delay    6
    @cmd    sendenemyto "ANI_PAIN4" 1
    frame    data/chars/haggar/grab.gif
    offset    75 177
    frame    data/chars/haggar/gwk5.gif
 
I edit and added attack still the same, maybe it's not work with grab anim 🤔
Once you are trying to change the target animation with no attack box, you could try to change the "opponent" property to "grabbing", this way you will get the current grabbed opponent. In addition, you need to remove the "damage" confirmation from the script once you are not damaging him.

C:
void sendenemyto(void anim){
{ // change opponent animation on damage
    void self = getlocalvar("self");
    void target = getentityproperty(self, "grabbing");
    
    changeentityproperty(target, "animation", openborconstant(anim));
}
 
Once you are trying to change the target animation with no attack box, you could try to change the "opponent" property to "grabbing", this way you will get the current grabbed opponent. In addition, you need to remove the "damage" confirmation from the script once you are not damaging him.

C:
void sendenemyto(void anim){
{ // change opponent animation on damage
    void self = getlocalvar("self");
    void target = getentityproperty(self, "grabbing");
 
    changeentityproperty(target, "animation", openborconstant(anim));
}
The enemy anim still not changing

sf89 - 0016.png

Edit: Thank you @Kratus it works

Haggar:
Code:
anim    grab
    loop    0
    delay    60
    offset    75 177
    bbox    63 98 41 79
    hitfx    data/sounds/silencio.wav
    cancel    0 33 0 S freespecial
    frame    data/chars/haggar/grab.gif
    @cmd    sendenemyto "ANI_PAIN4"
    delay    60
    offset    75 177
    frame    data/chars/haggar/gwk5.gif


Enemy:
Code:
anim    grabbed
    loop    0
    delay    60
    offset    89 174
    bbox    70 96 40 78 10
    frame    data/chars/bred/wk6.gif

Code:
anim    pain4
    loop    0
    delay    10
    offset    80 190
    frame    data/chars/bred/pain01.gif

sf89 - 0050.png
 
Last edited:
Back
Top Bottom