Crimsondeath
Active member
Hi everyone, I've more or less got this part working, the issue I'm having is that the mines (or the traps in general) I've created don't activate immediately. I have to walk through them several times before they attack. Here's how the mine is coded, for example:
I think that "attackZ" makes the trap target a particular entity and not the one that passes over it (sometimes there are like 4 or 5 entities on screen), for example attackZ targets an enemy but when the player walks over the mine, the mine does not explode, until that enemy that it targeted passes over the mine (that's why I added the "clearL" to see if it would help but it didn't xd).
Here's the code for "attackZ":
Code:
name Mine
type trap
shadow 0
noatflash 1
nolife 1
aggresion 9999
min_noatk_chance 0
max_noatk_chance 0
stealth 6 10
hostile player enemy npc
candamage enemy player npc obstacle
palette data/chars/traps/mine/idle.gif
animationscript data/scripts/entities/traps/mine.c
anim idle
loop 1
delay 8
offset 3 3
@cmd attackZ -20 20 0 20 -20 20 "ANI_ATTACK1"
frame data/chars/traps/mine/idle.gif
frame data/chars/traps/mine/idle.gif
@cmd clearL
frame data/chars/traps/mine/idle.gif
anim attack1
loop 0
delay 10
offset 4 3
@cmd spawnAni "QuakeCall" 0 0 0 "ANI_FOLLOW8" NULL() NULL() NULL()
frame data/chars/traps/mine/idle1.gif
delay 6
offset 2 2
@cmd spawnAni "Explosion1" 0 0 0 "ANI_FOLLOW2" NULL() NULL() NULL()
frame data/chars/misc/empty.gif
@cmd killentity getlocalvar("self")
frame data/chars/misc/empty.gif
I think that "attackZ" makes the trap target a particular entity and not the one that passes over it (sometimes there are like 4 or 5 entities on screen), for example attackZ targets an enemy but when the player walks over the mine, the mine does not explode, until that enemy that it targeted passes over the mine (that's why I added the "clearL" to see if it would help but it didn't xd).
Here's the code for "attackZ":
C++:
void attackZ(int RxMin, int RxMax, int RyMin, int RyMax, int RzMin, int RzMax, void Ani)
{// Attack interruption with range check
void self = getlocalvar("self");
void target = findtarget(self); // <----- Get nearest entity (?)
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float z = getentityproperty(self, "z");
int dir = getentityproperty(self, "direction");
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
}
}
}