|
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
|
A_SharpChase is an action which is used as the thinker for the Spincushion. The actor chases the target player, moving a distance of Speed
fracunits each time the action is used. If the actor's target doesn't exist or is dead, the actor will look for a new target player; if none can be found, it returns to its SpawnState
.
Each time this action is used, the actor's reaction time is reduced by 1. When the actor's reaction time reaches 0, the actor goes to MissileState
for the Sharp's spinning attack, and plays AttackSound
when doing so. PainChance
sets the actor's threshold value for when the actor goes to MissileState
, which A_SharpSpin
then uses as a timer before returning to SpawnState
again.
Object property
|
Use
|
SpawnState |
Goes back to this state if no players can be found
|
MissileState |
Goes to this state when reaction time = 0
|
AttackSound |
Spinning attack's charging sound; used when actor is going to MissileState
|
PainChance |
Sets the actor's threshold for when the actor goes to MissileState
|
Speed |
Distance to move, measured in fracunits
|
Code – A_SharpChase
|
|
// Function: A_SharpChase
//
// Description: Thinker/Chase routine for Spincushions
//
// var1 = unused
// var2 = unused
//
void A_SharpChase(mobj_t *actor)
{
#ifdef HAVE_BLUA
if (LUA_CallAction("A_SharpChase", actor))
return;
#endif
if (actor->reactiontime)
{
INT32 delta;
actor->reactiontime--;
// turn towards movement direction if not there yet
if (actor->movedir < NUMDIRS)
{
actor->angle &= (7<<29);
delta = actor->angle - (actor->movedir << 29);
if (delta > 0)
actor->angle -= ANGLE_45;
else if (delta < 0)
actor->angle += ANGLE_45;
}
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
P_SetMobjState(actor, actor->info->spawnstate);
return;
}
// chase towards player
if (--actor->movecount < 0 || !P_Move(actor, actor->info->speed))
P_NewChaseDir(actor);
}
else
{
actor->threshold = actor->info->painchance;
P_SetMobjState(actor, actor->info->missilestate);
S_StartSound(actor, actor->info->attacksound);
}
}
|
|