A_WhoCaresIfYourSonIsABee is an action that makes a child object, and is used as the spawning handler for Hive Elementals. The upper 16 bits of Var1 are used to set the object type of the child. The lower 16 bits of Var2 determine the vertical momentum of the child upon spawn, and upper and lower 16 bits of Var2 determine the forwards and vertical offset, respectively. The number of created children is stored in actor.extravalue1
. It is important to note that this action doesn't check the number of currently existing children - the state with this action should be called through A_ParentTriesToSleep to keep the child count in order.
Attributes |
Use
|
Var1 |
Lower 16 bits: Vertical Momentum Upper 16 bits: Object type of child
|
Var2 |
Lower 16 bits: Vertical Offset Upper 16 bits: Forwards Offset
|
Code – A_WhoCaresIfYourSonIsABee
|
|
// Function: A_WhoCaresIfYourSonIsABee
//
// Description: Makes a child object, storing the number of created children in the parent's extravalue1.
//
// var1 = mobjtype of child
// var2 >> 16 = mobjtype of child
// var2 & 65535 = vertical momentum
// var2:
// var2 >> 16 = forward offset
// var2 & 65535 = vertical offset
//
void A_WhoCaresIfYourSonIsABee(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
fixed_t foffsetx;
fixed_t foffsety;
mobj_t *son;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_WhoCaresIfYourSonIsABee", actor))
return;
#endif
A_FaceTarget(actor);
if (actor->extravalue1)
actor->extravalue1--;
if (actor->info->attacksound)
S_StartSound(actor, actor->info->attacksound);
foffsetx = P_ReturnThrustX(actor, actor->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale));
foffsety = P_ReturnThrustY(actor, actor->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale));
if (!(son = P_SpawnMobjFromMobj(actor, foffsetx, foffsety, (locvar2&65535)*FRACUNIT, (mobjtype_t)(locvar1 >> 16))))
return;
P_SetObjectMomZ(son, (locvar1 & 65535)<<FRACBITS, true);
P_SetTarget(&son->tracer, actor);
P_SetTarget(&son->target, actor->target);
}
|
|