A_ConnectToGround is an action that is used to connect an Object to the ground, spawning as many Objects as necessary between the starting Object and the nearest floor, or ceiling if the object is flipped. In SRB2, this is used by palm trees, Deep Sea's animated kelp, Arid Canyon's segmented cacti and Haunted Heights' trees. Var1 specifies which Object will be spawned repeatedly to bridge the gap, while Var2 optionally specifies the final Object to be spawned on the floor/ceiling.
Code – A_ConnectToGround
|
|
// Function: A_ConnectToGround
// Description: Create a palm tree trunk/mine chain.
//
// var1 = Object type to connect to ground
// var2 = Object type to place on ground
//
void A_ConnectToGround(mobj_t *actor)
{
mobj_t *work;
fixed_t workz;
fixed_t workh;
angle_t ang;
INT32 locvar1 = var1;
INT32 locvar2 = var2;
if (LUA_CallAction(A_CONNECTTOGROUND, actor))
return;
if (actor->subsector->sector->ffloors)
P_AdjustMobjFloorZ_FFloors(actor, actor->subsector->sector, 2);
if (actor->flags2 & MF2_OBJECTFLIP)
workz = (actor->z + actor->height) - actor->ceilingz;
else
workz = actor->floorz - actor->z;
if (locvar2)
{
workh = FixedMul(mobjinfo[locvar2].height, actor->scale);
if (actor->flags2 & MF2_OBJECTFLIP)
workz += workh;
work = P_SpawnMobjFromMobj(actor, 0, 0, workz, locvar2);
workz += workh;
}
if (!locvar1)
return;
if (!(workh = FixedMul(mobjinfo[locvar1].height, actor->scale)))
return;
ang = actor->angle + ANGLE_45;
while (workz < 0)
{
work = P_SpawnMobjFromMobj(actor, 0, 0, workz, locvar1);
if (work)
work->angle = ang;
ang += ANGLE_90;
workz += workh;
}
if (workz != 0)
actor->z += P_MobjFlip(actor)*workz;
}
|
|