Decouple Flicky Thing logic from spawnpoint variables; use mobj variables

This commit is contained in:
mazmazz 2018-08-12 00:51:01 -04:00
parent 07c882139b
commit f4a813891f
2 changed files with 61 additions and 44 deletions

View file

@ -10779,11 +10779,11 @@ void A_FlickySpawn(mobj_t *actor)
void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo)
{
UINT8 flickycolors[] = {
SKINCOLOR_RED,
SKINCOLOR_CYAN,
SKINCOLOR_BLUE,
SKINCOLOR_VAPOR,
SKINCOLOR_PURPLE,
SKINCOLOR_RED,
SKINCOLOR_CYAN,
SKINCOLOR_BLUE,
SKINCOLOR_VAPOR,
SKINCOLOR_PURPLE,
SKINCOLOR_BUBBLEGUM,
SKINCOLOR_NEON,
SKINCOLOR_BLACK,
@ -10809,10 +10809,14 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo)
// var1 = if 0, spawns random flicky based on level header. Else, spawns the designated thing type.
// var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius.
//
// If MTF_EXTRA is flagged, Flickies move independently of a target. Else, move around the target.
// If MTF_OBJECTSPECIAL and NOT MTF_EXTRA are flagged, Angle sign determines direction of circular movement.
// If MTF_AMBUSH is flagged, Flickies hop in-place.
// If MTF_AMBUSH and MTF_OBJECTSPECIAL is flagged, Flickies stand in-place without gravity.
// If MTF_EXTRA (MF_SLIDEME) is flagged, Flickies move independently of a target. Else, move around the target.
// If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) and NOT MTF_EXTRA (MF_SLIDEME) are flagged, Angle sign determines direction of circular movement.
// If MTF_AMBUSH (MF_NOCLIPTHING) is flagged, Flickies hop in-place.
// If MTF_AMBUSH (MF_NOCLIPTHING) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) is flagged, Flickies stand in-place without gravity.
//
// actor->friction = X origin
// actor->movefactor = Y origin
// actor->radius = Z origin
//
void A_FlickyCenter(mobj_t *actor)
{
@ -10825,13 +10829,28 @@ void A_FlickyCenter(mobj_t *actor)
if (!actor->tracer)
{
if (actor->spawnpoint && (actor->spawnpoint->options & MTF_EXTRA))
if (actor->spawnpoint)
{
actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING);
actor->flags |= (
((actor->spawnpoint->options & MTF_EXTRA) ? MF_SLIDEME : 0)
| ((actor->spawnpoint->options & MTF_OBJECTSPECIAL) ? MF_GRENADEBOUNCE : 0)
| ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0)
);
actor->extravalue1 = actor->spawnpoint->angle;
actor->extravalue2 = actor->spawnpoint->extrainfo;
actor->friction = actor->spawnpoint->x*FRACUNIT;
actor->movefactor = actor->spawnpoint->y*FRACUNIT;
actor->watertop = actor->spawnpoint->z*FRACUNIT;
}
if (actor->flags & MF_SLIDEME)
{
actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false);
P_SetTarget(&actor->tracer->target, actor);
actor->tracer->fuse = 0; // < 2*TICRATE means move aimlessly.
if (!(actor->spawnpoint->options & MTF_AMBUSH))
if (!(actor->flags & MF_NOCLIPTHING))
actor->tracer->angle = P_RandomKey(180)*ANG2;
}
else
@ -10840,36 +10859,38 @@ void A_FlickyCenter(mobj_t *actor)
P_SetTarget(&actor->tracer->target, actor);
actor->tracer->fuse = FRACUNIT;
if (actor->spawnpoint
&& (actor->spawnpoint->options & MTF_OBJECTSPECIAL)
&& !(actor->spawnpoint->options & MTF_EXTRA))
actor->tracer->movedir = actor->spawnpoint->angle >= 0 ? 1 : -1;
if ((actor->flags & MF_GRENADEBOUNCE) && !(actor->flags & MF_SLIDEME))
actor->tracer->movedir = actor->extravalue1 >= 0 ? 1 : -1;
}
if (locvar1 == MT_FLICKY_08 && actor->spawnpoint)
P_InternalFlickySetColor(actor->tracer, actor->spawnpoint->extrainfo);
if (locvar1 == MT_FLICKY_08)
P_InternalFlickySetColor(actor->tracer, actor->extravalue2);
actor->extravalue1 = 0;
actor->extravalue2 = 0;
}
if (actor->spawnpoint && !(actor->spawnpoint->options & MTF_EXTRA) && !(actor->spawnpoint->options & MTF_AMBUSH))
if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_NOCLIPTHING))
{
fixed_t originx = actor->friction;
fixed_t originy = actor->movefactor;
fixed_t originz = actor->watertop;
actor->tracer->fuse = FRACUNIT;
if (actor->spawnpoint->angle)
locvar2 = abs(actor->spawnpoint->angle)*FRACUNIT;
if (actor->extravalue1)
locvar2 = abs(actor->extravalue1)*FRACUNIT;
P_LookForPlayers(actor, true, false, locvar2);
if (actor->target && P_AproxDistance(actor->target->x - actor->spawnpoint->x*FRACUNIT, actor->target->y - actor->spawnpoint->y*FRACUNIT) < locvar2)
if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < locvar2)
{
actor->extravalue1 = 1;
actor->extravalue2 = 1;
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
}
else if(actor->extravalue1)
else if(actor->extravalue2)
{
actor->extravalue1 = 0;
P_TeleportMove(actor, actor->spawnpoint->x*FRACUNIT, actor->spawnpoint->y*FRACUNIT, actor->spawnpoint->z*FRACUNIT);
actor->extravalue2 = 0;
P_TeleportMove(actor, originx, originy, originz);
}
}
}
@ -10984,11 +11005,10 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi
if (actor->target && abs(chasez - actor->z) > targetdist)
targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& actor->target->spawnpoint
&& (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL)
&& (actor->target->spawnpoint->options & MTF_EXTRA))
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& (actor->target->flags & MF_GRENADEBOUNCE)
&& (actor->target->flags & MF_SLIDEME))
vertangle = 0;
else
vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK;
@ -11148,12 +11168,11 @@ void A_FlickyCheck(mobj_t *actor)
if (LUA_CallAction("A_FlickyCheck", actor))
return;
#endif
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& actor->target->spawnpoint
&& (actor->target->spawnpoint->options & MTF_AMBUSH))
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& (actor->target->flags & MF_NOCLIPTHING))
{
if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL)
if (actor->target->flags & MF_GRENADEBOUNCE)
{
actor->momz = 0;
actor->flags |= MF_NOGRAVITY;
@ -11186,12 +11205,11 @@ void A_FlickyHeightCheck(mobj_t *actor)
if (LUA_CallAction("A_FlickyHeightCheck", actor))
return;
#endif
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& actor->target->spawnpoint
&& (actor->target->spawnpoint->options & MTF_AMBUSH))
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& (actor->target->flags & MF_NOCLIPTHING))
{
if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL)
if (actor->target->flags & MF_GRENADEBOUNCE)
{
actor->momz = 0;
actor->flags |= MF_NOGRAVITY;

View file

@ -7114,9 +7114,8 @@ void P_MobjThinker(mobj_t *mobj)
case MT_SECRETFLICKY_01_CENTER:
case MT_SECRETFLICKY_02_CENTER:
if (mobj->tracer
&& mobj->spawnpoint
&& (mobj->spawnpoint->options & MTF_AMBUSH)
&& !(mobj->spawnpoint->options & MTF_OBJECTSPECIAL))
&& (mobj->flags & MF_NOCLIPTHING)
&& !(mobj->flags & MF_GRENADEBOUNCE))
{
if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz)
mobj->tracer->momz = 7*FRACUNIT;