A_1upThinker is an action that changes the actor's sprite to the 1-up icon of the player's skin. The actor will spawn an overlay displaying the 1-up monitor icon sprite set (LIFE
) for the skin of the nearest player to the actor. In SRB2, this action is used by the Extra Life Monitor.
Code – A_1upThinker
|
|
// Function: A_1upThinker
//
// Description: Used by the 1up box to show the player's face.
//
// var1 = unused
// var2 = unused
//
void A_1upThinker(mobj_t *actor)
{
INT32 i;
fixed_t dist = INT32_MAX;
fixed_t temp;
INT32 closestplayer = -1;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_1upThinker", actor))
return;
#endif
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].bot || players[i].spectator)
continue;
if (!players[i].mo)
continue;
if ((netgame || multiplayer) && players[i].playerstate != PST_LIVE)
continue;
temp = P_AproxDistance(players[i].mo->x-actor->x, players[i].mo->y-actor->y);
if (temp < dist)
{
closestplayer = i;
dist = temp;
}
}
if (closestplayer == -1 || skins[players[closestplayer].skin].sprites[SPR2_LIFE].numframes == 0)
{ // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite.
if (actor->tracer)
{
mobj_t *tracer = actor->tracer;
P_SetTarget(&actor->tracer, NULL);
P_RemoveMobj(tracer);
}
return;
}
// We're using the overlay, so use the overlay 1up box (no text)
actor->sprite = SPR_TV1P;
if (!actor->tracer)
{
P_SetTarget(&actor->tracer, P_SpawnMobj(actor->x, actor->y, actor->z, MT_OVERLAY));
P_SetTarget(&actor->tracer->target, actor);
actor->tracer->skin = &skins[players[closestplayer].skin]; // required here to prevent spr2 default showing stand for a single frame
P_SetMobjState(actor->tracer, actor->info->seestate);
// The overlay is going to be one tic early turning off and on
// because it's going to get its thinker run the frame we spawned it.
// So make it take one tic longer if it just spawned.
++actor->tracer->tics;
}
actor->tracer->color = players[closestplayer].mo->color;
actor->tracer->skin = &skins[players[closestplayer].skin];
}
|
|