A_ItemPop, is an action exclusive to SRB2Kart that is used by the Random Item. It removes the actor's solidity then spawns remains determined by the actor's damage value at the actor's position. The mass of the remains determines what object is spawned after the actor is destroyed. The player who destroys the actor gets the item roulette. The actor will respawn after some time using this action.
Code – A_ItemPop
|
|
void A_ItemPop(mobj_t *actor)
{
mobj_t *remains;
mobjtype_t explode;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ItemPop", actor))
return;
#endif
if (!(actor->target && actor->target->player))
{
if (cv_debug && !(actor->target && actor->target->player))
CONS_Printf("ERROR: Powerup has no target!\n");
return;
}
// de-solidify
P_UnsetThingPosition(actor);
actor->flags &= ~MF_SOLID;
actor->flags |= MF_NOCLIP;
P_SetThingPosition(actor);
// item explosion
explode = mobjinfo[actor->info->damage].mass;
remains = P_SpawnMobj(actor->x, actor->y,
((actor->eflags & MFE_VERTICALFLIP) ? (actor->z + 3*(actor->height/4) - FixedMul(mobjinfo[explode].height, actor->scale)) : (actor->z + actor->height/4)), explode);
if (actor->eflags & MFE_VERTICALFLIP)
{
remains->eflags |= MFE_VERTICALFLIP;
remains->flags2 |= MF2_OBJECTFLIP;
}
remains->destscale = actor->destscale;
P_SetScale(remains, actor->scale);
remains = P_SpawnMobj(actor->x, actor->y, actor->z, actor->info->damage);
remains->type = actor->type; // Transfer type information
P_UnsetThingPosition(remains);
if (sector_list)
{
P_DelSeclist(sector_list);
sector_list = NULL;
}
P_SetThingPosition(remains);
remains->destscale = actor->destscale;
P_SetScale(remains, actor->scale);
remains->flags = actor->flags; // Transfer flags
remains->flags2 = actor->flags2; // Transfer flags2
remains->fuse = actor->fuse; // Transfer respawn timer
remains->threshold = (actor->threshold == 69 ? 69 : 68);
remains->skin = NULL;
remains->spawnpoint = actor->spawnpoint;
P_SetTarget(&tmthing, remains);
if (actor->info->deathsound)
S_StartSound(remains, actor->info->deathsound);
if (!(G_BattleGametype() && actor->target->player->kartstuff[k_bumper] <= 0))
actor->target->player->kartstuff[k_itemroulette] = 1;
remains->flags2 &= ~MF2_AMBUSH;
if (G_BattleGametype() && actor->threshold != 69)
numgotboxes++;
P_RemoveMobj(actor);
}
|
|