A_SpawnFreshCopy is an action that spawns a new Object that has the same position, Object type, angle, color, scale, target and tracer as the actor. If the actor has the MF2_AMBUSH
flag, the newly spawned Object will also be given it. All other Object properties are not carried over. If the Object type has a SeeSound
, the newly spawned Object will play it. In SRB2, this action is used by Brak Eggman's electric barrier, while invisible after being doused in water, to appear to re-spawn by creating a fresh copy of itself.
Code – A_SpawnFreshCopy
|
|
// Function: A_SpawnFreshCopy
//
// Description: Spawns a copy of the mobj. x, y, z, angle, scale, target and tracer carry over; everything else starts anew.
// Mostly writing this because I want to do multiple actions to pass these along in a single frame instead of several.
//
// var1 = unused
// var2 = unused
//
void A_SpawnFreshCopy(mobj_t *actor)
{
mobj_t *newObject;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_SpawnFreshCopy", actor))
return;
#endif
newObject = P_SpawnMobjFromMobj(actor, 0, 0, 0, actor->type);
newObject->flags2 = actor->flags2 & MF2_AMBUSH;
newObject->angle = actor->angle;
newObject->color = actor->color;
P_SetTarget(&newObject->target, actor->target);
P_SetTarget(&newObject->tracer, actor->tracer);
if (newObject->info->seesound)
S_StartSound(newObject, newObject->info->seesound);
}
|
|