If you want to know why I am doing this, it's simply because enemies and allies in my mod keeps firing continuously if their target is close enough to their melee range, plus there is the problem that the engine doesn't calculate the 3D distance to their target so, sometimes NPC's may keep firing at one another indefinitely if the player's ally target is on another ground level...so I had to create a custom A_Chase function with Distance3D to correct this...although I didn't expect it would crash.
The only thing I know it's that it always crashes with the +FRIENDLY flag, so I can be certain that it must be some sort of engine bug.
Here is my custom A_Chase function
Code: Select all
class Allies : Actor
{
Default
{
// INFO
Species "Allies";
// FLAGS
MONSTER;
+FRIENDLY;
+DONTFOLLOWPLAYERS;
-COUNTKILL;
+DONTTHRUST;
+DONTGIB;
+FIXMAPTHINGPOS;
+FLOORCLIP;
+NOINFIGHTSPECIES;
}
Void A_ExtChase()
{
if(target.health <= 0) //Otherwise the game will crash..since he still targets dead enemies
{
A_TakeInventory("ForgetTarget", 20);
A_ClearTarget();
SetStateLabel("Idle");
}
else if(target.health > 0 && Distance3D(target) < Radius + MeleeRange && CheckSight(target))
{
SetStateLabel("PointBlank");
}
else
{
A_Chase(null, null);
}
}
[...]
Code: Select all
class UNLARegular_Bunker : Allies
{
Default
{
// INFO
Tag "U.N.L.A. Regular G.I.";
Obituary "%o made the Regulars angry.";
// PROPERTY
Scale 1.0;
Mass 175;//100;
Health 100;
Radius 16;
Height 54;
Speed 4;
PainChance 256;
MaxStepHeight 24;
MaxTargetRange 1024;
MeleeRange 128; //MaxTargetRange/8
// MISC
BloodType "WolfRedBloodSplash";
DamageFactor "LCaliber", 1.0;
DamageFactor "MCaliber", 1.0;
DamageFactor "EnergyCaliber", 1.0;
DamageFactor "MiniExplosive", 1.0;
DamageFactor "Explosive", 1.0;
// SOUNDS
SeeSound "A_Infantry/Sight";
ActiveSound " ";
PainSound "A_Infantry/Pain";
DeathSound "A_Infantry/Death";
// FLAGS
+NOTELEPORT;
}
States
{
// SPAWN AND IDLE
Spawn:
UFA1 N 1 NoDelay;
Idle:
//Wander
TNT1 A 0 A_LookEx(0, radius, 1536, 1024, 180);
UFA1 AAAAA 1 A_Wander();
UFA1 A 1;
TNT1 A 0 A_StartSound("Walk/L_Step", 4, CHANF_OVERLAP, 1.0, 1.0);
//Wander
UFA1 BBBB 1 A_Wander();
//Wander
TNT1 A 0 A_LookEx(0, radius, 1536, 1024, 180);
UFA1 CCCCC 1 A_Wander();
UFA1 CC 1;
TNT1 A 0 A_StartSound("Walk/L_Step", 4, CHANF_OVERLAP, 1.0, 1.0);
//Wander
UFA1 DDDD 1 A_Wander();
TNT1 A 0 A_Jump(32, "Stand"); //25%
Loop;
// CHASE
See:
//Chase
UFA1 AAAAA 1 A_ExtChase();
UFA1 A 1;
TNT1 A 0 A_StartSound("Walk/L_Step", 4, CHANF_OVERLAP, 1.0, 1.0);
//Chase
UFA1 BBBB 1 A_ExtChase();
//Chase
UFA1 CCCCC 1 A_ExtChase();
UFA1 CC 1;
TNT1 A 0 A_StartSound("Walk/L_Step", 4, CHANF_OVERLAP, 1.0, 1.0);
//Chase
UFA1 DDDD 1 A_ExtChase();
TNT1 A 0 A_GiveInventory("ForgetTarget", 1);
TNT1 A 0 A_JumpIfInventory("ForgetTarget", 20, "Forget");
TNT1 A 0 A_Jump(64, "CheckConditions"); //25%
Loop;
[...]

Can someone help me? it's for a project of mine that I've been working since april and it's nearing it's final beta stages.
Thanks in advance.
PS.: If you want anymore details, I will be happy to show it
