Fix crash on mapload when removing Dragonbomber with Lua

This commit is contained in:
Steel Titanium 2019-12-16 21:25:41 -05:00
parent 53c7df4818
commit 0e371774c8
1 changed files with 23 additions and 8 deletions

View File

@ -14712,20 +14712,35 @@ void A_DragonWing(mobj_t *actor)
void A_DragonSegment(mobj_t *actor)
{
mobj_t *target = actor->target;
fixed_t dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z);
fixed_t radius = actor->radius + target->radius;
angle_t hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y);
angle_t zangle = R_PointToAngle2(0, target->z, dist, actor->z);
fixed_t hdist = P_ReturnThrustX(target, zangle, radius);
fixed_t xdist = P_ReturnThrustX(target, hangle, hdist);
fixed_t ydist = P_ReturnThrustY(target, hangle, hdist);
fixed_t zdist = P_ReturnThrustY(target, zangle, radius);
fixed_t dist;
fixed_t radius;
angle_t hangle;
angle_t zangle;
fixed_t hdist;
fixed_t xdist;
fixed_t ydist;
fixed_t zdist;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_DragonSegment", actor))
return;
#endif
if (target == NULL || !target->health)
{
P_RemoveMobj(actor);
return;
}
dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z);
radius = actor->radius + target->radius;
hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y);
zangle = R_PointToAngle2(0, target->z, dist, actor->z);
hdist = P_ReturnThrustX(target, zangle, radius);
xdist = P_ReturnThrustX(target, hangle, hdist);
ydist = P_ReturnThrustY(target, hangle, hdist);
zdist = P_ReturnThrustY(target, zangle, radius);
actor->angle = hangle;
P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist);
}