- added portal support to A_ThrustImpale, P_PushUp and P_PushDown.

This commit is contained in:
Christoph Oelckers 2016-03-07 00:17:52 +01:00
parent 5175d56129
commit 7d7112f427
3 changed files with 35 additions and 26 deletions

View File

@ -813,12 +813,6 @@ public:
return bloodcls;
}
bool intersects(AActor *other) const
{
fixed_t blockdist = radius + other->radius;
return ( abs(X() - other->X()) < blockdist && abs(Y() - other->Y()) < blockdist);
}
fixed_t AproxDistance(fixed_t otherx, fixed_t othery)
{
return P_AproxDistance(X() - otherx, Y() - othery);

View File

@ -153,24 +153,32 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale)
{
PARAM_ACTION_PROLOGUE;
AActor *thing;
// This doesn't need to iterate through portals.
FBlockThingsIterator it(FBoundingBox(self->X(), self->Y(), self->radius));
while ((thing = it.Next()))
FPortalGroupArray check;
FMultiBlockThingsIterator it(check, self);
FMultiBlockThingsIterator::CheckResult cres;
while (it.Next(&cres))
{
if (!thing->intersects(self))
{
fixed_t blockdist = self->radius + cres.thing->radius;
if (abs(self->X() - cres.position.x) >= blockdist || abs(self->Y() - cres.position.y) >= blockdist)
continue;
// Q: Make this z-aware for everything? It never was before.
if (cres.thing->Top() < self->Z() || cres.thing->Z() > self->Top())
{
if (self->Sector->PortalGroup != cres.thing->Sector->PortalGroup)
continue;
}
if (!(thing->flags & MF_SHOOTABLE) )
if (!(cres.thing->flags & MF_SHOOTABLE) )
continue;
if (thing == self)
if (cres.thing == self)
continue; // don't clip against self
int newdam = P_DamageMobj (thing, self, self, 10001, NAME_Crush);
P_TraceBleed (newdam > 0 ? newdam : 10001, thing);
int newdam = P_DamageMobj (cres.thing, self, self, 10001, NAME_Crush);
P_TraceBleed (newdam > 0 ? newdam : 10001, cres.thing);
self->args[1] = 1; // Mark thrust thing as bloody
}
return 0;

View File

@ -5513,14 +5513,16 @@ void P_FindAboveIntersectors(AActor *actor)
if (!(actor->flags & MF_SOLID))
return;
AActor *thing;
FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius));
while ((thing = it.Next()))
FPortalGroupArray check;
FMultiBlockThingsIterator it(check, actor);
FMultiBlockThingsIterator::CheckResult cres;
while (it.Next(&cres))
{
if (!thing->intersects(actor))
{
AActor *thing = cres.thing;
fixed_t blockdist = actor->radius + thing->radius;
if (abs(actor->X() - cres.position.x) >= blockdist || abs(actor->Y() - cres.position.y) >= blockdist)
continue;
}
if (!(thing->flags & MF_SOLID))
{ // Can't hit thing
continue;
@ -5568,13 +5570,16 @@ void P_FindBelowIntersectors(AActor *actor)
return;
AActor *thing;
FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius));
while ((thing = it.Next()))
FPortalGroupArray check;
FMultiBlockThingsIterator it(check, actor);
FMultiBlockThingsIterator::CheckResult cres;
while (it.Next(&cres))
{
if (!thing->intersects(actor))
{
AActor *thing = cres.thing;
fixed_t blockdist = actor->radius + thing->radius;
if (abs(actor->X() - cres.position.x) >= blockdist || abs(actor->Y() - cres.position.y) >= blockdist)
continue;
}
if (!(thing->flags & MF_SOLID))
{ // Can't hit thing
continue;
@ -5718,6 +5723,7 @@ int P_PushUp(AActor *thing, FChangePosition *cpos)
return 2;
}
}
thing->CheckPortalTransition(true);
return 0;
}
@ -5765,6 +5771,7 @@ int P_PushDown(AActor *thing, FChangePosition *cpos)
}
}
}
thing->CheckPortalTransition(true);
return 0;
}