Crimsondeath
Active member
Hi, I'm stuck x.x .
I need an enemy do an specifict animation just before getting shot by a bullet to dodge it.
I tried with animationscripts:
Spawnbinding an invisible entity that detect the bullets and forced him to do the animation:
The Spawnbinded entity code, Kogacounter.txt:
The Spawnbinded entity animationscript, Kogacounter.c:
The problem: The script throws me "There's an exception while executing script 'Kogacounter' data/chars/koga/kogacounter.txt"
I attached the log.
I also tried with takedamagescript, but It didn't detect the attacktype I guess.
Is there an effective way to do it?
I need an enemy do an specifict animation just before getting shot by a bullet to dodge it.
I tried with animationscripts:
Spawnbinding an invisible entity that detect the bullets and forced him to do the animation:
Code:
name Koga
health 400
mp 90
type enemy
...
load Kogacounter
animationscript data/scripts/fscript.c
...
anim follow4 #The boss Spawns with this animation
loop 0
delay 1
offset 53 206
@cmd spawnbind "Kogacounter" 0 0 0 # The spawnbinded entity
frame data/chars/koga/spawn1.gif
frame data/chars/koga/spawn4.gif
frame data/chars/koga/spawn2.gif
frame data/chars/koga/spawn3.gif
delay 3
offset 53 150
frame data/chars/koga/attack1c.gif
frame data/chars/misc/empty.gif
frame data/chars/koga/attack1c.gif
frame data/chars/misc/empty.gif
frame data/chars/koga/attack1c.gif
frame data/chars/misc/empty.gif
frame data/chars/koga/attack1c.gif
frame data/chars/misc/empty.gif
frame data/chars/koga/attack1c.gif
delay 109
frame data/chars/koga/attack1c.gif
The Spawnbinded entity code, Kogacounter.txt:
Code:
name Kogacounter
type npc
shadow 0
stealth 100 100
nomove 1 1
animationscript data/chars/koga/Kogacounter.c
anim follow1
loop 0
delay 1
offset 0 0
@script
if(frame == 0){
void self = getlocalvar("self");
void vEntity;
int iEntity;
char iName;
int iMax = openborvariant("count_entities");
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity);
iName = getentityproperty(vEntity, "name");
if(iName == "Koga"){ // This force the boss to dodge the bullet
executeanimation(openborconstant("ANI_FOLLOW2"), 1);
}
}
}
@end_script
frame data/chars/misc/empty.gif
delay 100
frame data/chars/misc/empty.gif
anim idle
loop 1
delay 1
offset 0 0
@cmd dodgebullet -100 100 -100 100 -10 10 "ANI_FOLLOW1"
frame data/chars/misc/empty.gif
@cmd dodgebullet -100 100 -100 100 -10 10 "ANI_FOLLOW1"
frame data/chars/misc/empty.gif
anim spawn
loop 0
delay 1
offset 0 0
frame data/chars/misc/empty.gif
The Spawnbinded entity animationscript, Kogacounter.c:
Code:
void dodgebullet(int RxMin, int RxMax, int RyMin, int RyMax, int RzMin, int RzMax, void Ani)
{
void self = getlocalvar("self");
void target;
void vEntity;
int iEntity;
char iName;
int iMax = openborvariant("count_entities");
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float z = getentityproperty(self, "z");
int dir = getentityproperty(self, "direction");
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity);
iName = getentityproperty(vEntity, "name");
if(iName == "Bala"){
target = vEntity;
}
}
if(target!=NULL()){
float Tx = getentityproperty(target, "x");
float Ty = getentityproperty(target, "a");
float Tz = getentityproperty(target, "z");
float Disx = Tx - x;
float Disy = Ty - y;
float Disz = Tz - z;
if(
Disx >= RxMin &&
Disx <= RxMax &&
Disy >= RyMin &&
Disy <= RyMax &&
Disz >= RzMin &&
Disz <= RzMax && dir == 1) // Target within range on right facing?
{
performattack(self, openborconstant(Ani)); //Change the animation
} else if(
Disx >= -RxMax &&
Disx <= -RxMin &&
Disy >= RyMin &&
Disy <= RyMax &&
Disz >= RzMax &&
Disz <= RzMin && dir == 0) // Target within range on left facing?
{
performattack(self, openborconstant(Ani)); //Change the animation
}
}
}
The problem: The script throws me "There's an exception while executing script 'Kogacounter' data/chars/koga/kogacounter.txt"
I attached the log.
I also tried with takedamagescript, but It didn't detect the attacktype I guess.
Code:
void main()
{
void self = getlocalvar("self");
void attacker = getlocalvar("attacker");
int iTyp7 = openborconstant("ATK_NORMAL7");
int iTyp8 = openborconstant("ATK_NORMAL8");
int attacktype = getentityproperty(attacker, "attackid");
if(attacktype == iTyp7 || attacktype == iTyp8) {
executeanimation(self, openborconstant("ANI_FOLLOW5"), 1);
}
}
Is there an effective way to do it?