|
Note This action was removed in 2.2.0
|
|
To do Add a diagram displaying movement angle ranges?
|
A_ArrowCheck is an action that switches to one of the actor's Object type anchor states according to the vertical direction the actor is moving in. The actor's RaiseState
is used for when the actor is facing upwards, the XDeathState
for when it is facing downwards, and the SpawnState
for when it is facing directly forwards or up/down within a range of 20°. In SRB2, this action is used to align the sprites of the arrow shot by the Robo-Hood with its movement.
Object property |
Use |
Range of angle
|
SpawnState |
Switched to when moving straight ahead |
340°–20°
|
RaiseState |
Switched to when moving upwards |
21°–180°
|
XDeathState |
Switched to when moving downwards |
181°–339°
|
Code – A_ArrowCheck
|
|
// Function: A_ArrowCheck
//
// Description: Checks arrow direction and adjusts sprite accordingly
//
// var1 = unused
// var2 = unused
//
void A_ArrowCheck(mobj_t *actor)
{
fixed_t x,y,z;
angle_t angle;
fixed_t dist;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ArrowCheck", actor))
return;
#endif
// Movement vector
x = actor->momx;
y = actor->momy;
z = actor->momz;
// Calculate the angle of movement.
/*
Z
/ |
/ |
/ |
0------dist(X,Y)
*/
dist = P_AproxDistance(x, y);
angle = R_PointToAngle2(0, 0, dist, z);
if (angle > ANG20 && angle <= ANGLE_180)
P_SetMobjStateNF(actor, actor->info->raisestate);
else if (angle < ANG340 && angle > ANGLE_180)
P_SetMobjStateNF(actor, actor->info->xdeathstate);
else
P_SetMobjStateNF(actor, actor->info->spawnstate);
}
|
|