Detect different opponents and broadcast different attack animations

xyz555

Member
I wrote a script to attack enemy with different name, hoping to play different animations,

But he doesn’t seem to work,

anim grabattack
@script
if (frame==0){
void self = getlocalvar("self");
void target = getentityproperty(self, "opponent");
void Tname = getentityproperty(target, "defaultname");
void iType = getentityproperty(target, "type");


if(Tname == "yong" || Tname == "yong" || Tname == "yong" || Tname == "yong"
|| iType == openborconstant("TYPE_ENEMY")
|| iType ==openborconstant("TYPE_ENEMY"))
{
performattack(self, openborconstant("ANI_freespecial"));




}else if(Tname == "abak" || Tname == "abak" || Tname == "abak" || Tname == "abak"
|| iType == openborconstant("TYPE_ENEMY")
|| iType ==openborconstant("TYPE_ENEMY"))
{
performattack(self, openborconstant("ANI_freespecial2"));





}
} @end_script
Delay 10
hitflash free
OffSet 164 171
BBox 157 101 35 77
Frame data/chars/guanyu/head001.gif
Attack11 182 102 41 37 5 0 0 0 10
BBox 163 108 31 67
@cmd spawn01 "flash" 30 68 1
Frame data/chars/guanyu/head002.gif
Delay 2
OffSet 164 171
BBox 157 101 35 77
Frame data/chars/guanyu/head001.gif





希望得到幫助,謝謝
 
Well, if you see this part:
Code:
    if(Tname == "yong" || Tname == "yong" || Tname == "yong" || Tname == "yong" || iType == openborconstant("TYPE_ENEMY") || iType ==openborconstant("TYPE_ENEMY")){

there are plenty of || operator there but my main point is as long one statement is true, the function in if will be run.
In other words, as long the grabbed entity is an enemy, Guan Yu will perform FREESPECIAL , regardless of enemy's name/alias.

This could happen with the second if too but since the quoted one is the first one, it will be prioritized.

Simply put, you need to replace || with && and remove double statements.
 
Well, if you see this part:
Code:
    if(Tname == "yong" || Tname == "yong" || Tname == "yong" || Tname == "yong" || iType == openborconstant("TYPE_ENEMY") || iType ==openborconstant("TYPE_ENEMY")){

there are plenty of || operator there but my main point is as long one statement is true, the function in if will be run.
In other words, as long the grabbed entity is an enemy, Guan Yu will perform FREESPECIAL , regardless of enemy's name/alias.

if too but since the quoted one is the first one, it will be prioritized.

Simply put, you need to replace || with && and remove double statements.
I sincerely thank Bloodbane.
Because every time I have a problem, I still get Bloodbane's help.
I changed the code to this and now it can run normally
I am very grateful for Bloodbane’s generosity
very thank you!!!


anim grabattack
@script
if (frame==0){
void self = getlocalvar("self");
void target = getentityproperty(self, "opponent");
void Tname = getentityproperty(target, "defaultname");
void iType = getentityproperty(target, "type");


if(Tname == "yong" && iType == openborconstant("TYPE_ENEMY"))
{
performattack(self, openborconstant("ANI_freespecial"));




}else if(Tname == "abak" && iType == openborconstant("TYPE_ENEMY"))
{
performattack(self, openborconstant("ANI_freespecial2"));




}
} @end_script
Delay 10
hitflash free
OffSet 164 171
BBox 157 101 35 77
Frame data/chars/guanyu/head001.gif
Attack11 182 102 41 37 5 0 0 0 10
BBox 163 108 31 67
@cmd spawn01 "flash" 30 68 1
Frame data/chars/guanyu/head002.gif
Delay 2
OffSet 164 171
BBox 157 101 35 77
Frame data/chars/guanyu/head001.gif


I sincerely wish you a happy life.
 
Back
Top Bottom