A_SetObjectTypeState is an action that changes the state of Objects of a specified type to the one specified by Var1 – refer to list of states for reference. Var2's lower 16 bits specify the Object type; the upper 16 bits determine the horizontal range to apply the action's effect within (scaled with the actor's own scale), measured in fracunits; only Objects of the specified type whose horizontal distance from the actor is within this range will have their state changed. If the range is set to 0, this action can change the state of Objects of the specified type anywhere across the whole map, regardless of distance. Note that this action will not affect any Objects of the specified type that do not have any health points.
This action originates from the v2.0 modification SRB2Morphed and was added to SRB2 itself in v2.1.
Code – A_SetObjectTypeState
// Function: A_SetObjectTypeState
// Description: Changes the state of all active objects of a certain type in a certain range of the actor.
// var1 = state number
// lower 16 bits = type
// upper 16 bits = range (if == 0, across whole map)
void A_SetObjectTypeState(mobj_t *actor)
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const UINT16 loc2lw = (UINT16)(locvar2 & 65535);
const UINT16 loc2up = (UINT16)(locvar2 >> 16);
fixed_t dist = 0;
if (LUA_CallAction("A_SetObjectTypeState", actor))
for (th = thinkercap.next; th != &thinkercap; th = th->next)
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
mo2 = (mobj_t *)th;
if (mo2->type == (mobjtype_t)loc2lw)
dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y);
if (mo2->health > 0)
if (loc2up == 0)
if (dist <= FixedMul(loc2up*FRACUNIT, actor->scale))