// A_ReaperThinker
// Mementos's Reaper's thinker. A huge pain in the Derek Bum to translate from Lua to this shite if you ask me.
void A_ReaperThinker(mobj_t *actor)
{
mobj_t *particle; // particles to spawn
int i = 0; // for loops
angle_t an = ANGLE_22h; // Reminder that angle constants suck.
//Waypoint stuff:
mobj_t *mo2;
thinker_t *th;
//Player targetting stuff:
UINT32 maxscore = 0; // we target the player with the highest score so yeah there you go.
player_t *player; // used as a shortcut in a loop.
mobj_t *targetplayermo = NULL; // the player mo we can eventually target, or whatever.
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ReaperThinker", (actor)))
return;
#endif
// We don't have custom variables or whatever so we'll do with whatever the fuck we have left.
if (actor->health == 1000) // if health is 1000, set it to a small scale and have it start growing with destscale. Then set the health to uh, not 1000.
{
actor->scale = 1;
actor->destscale = 2<<FRACBITS;
actor->scalespeed = FRACUNIT/24; // Should take a bit less than 2 seconds to fully grow.
S_StartSound(NULL, sfx_chain);
actor->health--; // now we have 999 health, so that above won't happen again. Awesome.
}
if (actor->scale < 2<<FRACBITS) // we haven't finished growing YET.
{
// Spawn particles as we grow out of the floor, ゴ ゴ ゴ ゴ
for (; i<16; i++)
{
particle = P_SpawnMobj(actor->x + (P_RandomRange(-60, 60)<<FRACBITS), actor->y + (P_RandomRange(-60, 60)<<FRACBITS), actor->z, MT_THOK);
particle->momz = 20<<FRACBITS;
particle->color = ((i%2 !=0) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
particle->frame = 0;
P_SetScale(particle, FRACUNIT/2);
}
// Spawn particles in some edgy circle or w/e.
if (leveltime%5 != 0) // spawn the thing under that every tic.
return;
i=0;
for (; i<15; i++) // spawn in a circle formation or w/e.
{
particle = P_SpawnMobj(actor->x, actor->y, actor->z, MT_THOK);
particle->momz = 20<<FRACBITS;
particle->color = ((i%2 !=0) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
particle->frame = 0;
P_SetScale(particle, FRACUNIT/2);
P_InstaThrust(particle, an*i, 30<<FRACBITS);
}
return; // don't continue, what lies beyond that is the movement code.
}
// We finished growing and can now be a dangerous piece o' garbage scaring the living heck outta players!
actor->flags = MF_NOGRAVITY|MF_PAIN|MF_SPECIAL|MF_NOCLIP|MF_NOCLIPHEIGHT; // set our flags to be a damaging thing.
// Handle animation:
if (!(leveltime%5))
actor->extravalue2 = (actor->extravalue2 < 9) ? (actor->extravalue2+1) : (0); // Ghetto animation, but hey it works for what it's worth
// Chain sfx
if (!S_SoundPlaying(actor, sfx_chain))
S_StartSound(actor, sfx_chain);
actor->frame = actor->extravalue2; // yes i'm that bad at maths don't @ me.
if (!actor->target)
{
if (actor->hnext)
{
P_SetTarget(&actor->target, actor->hnext); // Default back to last waypoint.
return;
}
// We have no target and oughta find one, so let's scan through thinkers for a waypoint of angle 0, or something.
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_REAPERWAYPOINT)
continue;
if (mo2->spawnpoint->angle != 0)
continue;
P_SetTarget(&actor->target, mo2); // The main target we're pursing.
P_SetTarget(&actor->hnext, mo2); // The last waypoint we hit. We will default back to that if a player goes out of our range!
actor->extravalue1 = 0; // This will store the angle of the last waypoint we touched. This will essentially be useful later on.
if (!actor->tracer) // If we already have a tracer (Waypoint #0), don't do anything.
{
P_SetTarget(&actor->tracer, mo2); // Because our target might be a player OR a waypoint, we need some sort of fallback option. This will always be waypoint 0.
break;
}
}
}
else // Awesome, we now have a target.
{
// Follow target:
P_InstaThrust(actor, R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y), 20<<FRACBITS);
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
// The player we should target if it's near us:
for (i=0; i<MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
player = &players[i];
if (player && player->mo && player->kartstuff[k_bumper] && player->score >= maxscore)
{
targetplayermo = player->mo;
maxscore = player->score;
}
}
// Try to target that player:
if (targetplayermo)
{
if (P_LookForPlayers(actor, false, false, 1024<<FRACBITS)) // got target
{
if (!(actor->target == targetplayermo && actor->target && !actor->target->player->powers[pw_flashing]
&& !actor->target->player->kartstuff[k_invincibilitytimer]
&& !actor->target->player->kartstuff[k_growshrinktimer]
&& !actor->target->player->kartstuff[k_spinouttimer]))
P_SetTarget(&actor->target, actor->hnext);
// if the above isn't correct, then we should go back to targetting waypoints or something.
}
}
// Waypoint behavior.
if (actor->target->type == MT_REAPERWAYPOINT)
{
if (R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y) < 22<<FRACBITS)
{
P_SetTarget(&actor->target, NULL); // remove target so we can default back to first waypoint if things go ham.
// If we reach close to a waypoint, then we should go to the NEXT one.
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_REAPERWAYPOINT)
continue;
if (mo2->spawnpoint->angle != actor->extravalue1+1)
continue;
P_SetTarget(&actor->target, mo2); // The main target we're pursing.
P_SetTarget(&actor->hnext, mo2); // The last waypoint we hit. We will default back to that if a player goes out of our range!
actor->extravalue1++; // This will store the angle of the last waypoint we touched. This will essentially be useful later on.
break;
}
}
if (!actor->target) // If we have no target, revert back to waypoint 0.
{
actor->extravalue1 = 0;
P_SetTarget(&actor->target, actor->tracer);
}
}
else // if our target ISN'T a waypoint, then it can only be a player.
{
if (!P_CheckSight(actor, actor->target) || R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y) > 1024<<FRACBITS)
P_SetTarget(&actor->target, actor->hnext);
}
}
}