mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 13:21:10 +00:00
Rewrote A_SetTargetsTarget to be more sensible and efficient
This commit is contained in:
parent
ac5c8f10e9
commit
b449bd826a
1 changed files with 21 additions and 34 deletions
|
@ -7592,48 +7592,35 @@ void A_SetTargetsTarget(mobj_t *actor)
|
||||||
{
|
{
|
||||||
INT32 locvar1 = var1;
|
INT32 locvar1 = var1;
|
||||||
INT32 locvar2 = var2;
|
INT32 locvar2 = var2;
|
||||||
mobj_t *targetedmobj = NULL;
|
mobj_t *oldtarg = NULL, *newtarg = NULL;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *mo2;
|
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
if (LUA_CallAction("A_SetTargetsTarget", actor))
|
if (LUA_CallAction("A_SetTargetsTarget", actor))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((!locvar1 && (!actor->target)) || (locvar1 && (!actor->tracer)))
|
// actor's target
|
||||||
|
if (locvar1) // or tracer
|
||||||
|
oldtarg = actor->tracer;
|
||||||
|
else
|
||||||
|
oldtarg = actor->target;
|
||||||
|
|
||||||
|
if (P_MobjWasRemoved(oldtarg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((!locvar1 && !locvar2 && (!actor->target->target))
|
// actor's target's target!
|
||||||
|| (!locvar1 && locvar2 && (!actor->target->tracer))
|
if (locvar2) // or tracer
|
||||||
|| (locvar1 && !locvar2 && (!actor->tracer->target))
|
newtarg = oldtarg->tracer;
|
||||||
|| (locvar1 && locvar2 && (!actor->tracer->tracer)))
|
|
||||||
return; // Don't search for nothing.
|
|
||||||
|
|
||||||
// scan the thinkers
|
|
||||||
for (th = thinkercap.next; th != &thinkercap; th = th->next)
|
|
||||||
{
|
|
||||||
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)th;
|
|
||||||
|
|
||||||
if ((!locvar1 && !locvar2 && (mo2 == actor->target->target))
|
|
||||||
|| (!locvar1 && locvar2 && (mo2 == actor->target->tracer))
|
|
||||||
|| (locvar1 && !locvar2 && (mo2 == actor->tracer->target))
|
|
||||||
|| (locvar1 && locvar2 && (mo2 == actor->tracer->tracer)))
|
|
||||||
{
|
|
||||||
targetedmobj = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!targetedmobj)
|
|
||||||
return; // Oops, nothing found..
|
|
||||||
|
|
||||||
if (!locvar1)
|
|
||||||
P_SetTarget(&actor->target, targetedmobj);
|
|
||||||
else
|
else
|
||||||
P_SetTarget(&actor->tracer, targetedmobj);
|
newtarg = oldtarg->target;
|
||||||
|
|
||||||
|
if (P_MobjWasRemoved(newtarg))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// set actor's new target
|
||||||
|
if (locvar1) // or tracer
|
||||||
|
P_SetTarget(&actor->tracer, newtarg);
|
||||||
|
else
|
||||||
|
P_SetTarget(&actor->target, newtarg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function: A_SetObjectFlags
|
// Function: A_SetObjectFlags
|
||||||
|
|
Loading…
Reference in a new issue