|
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.
|
|
This article or section is outdated and has not been fully updated to reflect the current version of SRB2.
Please help the Wiki by correcting or removing any misinformation, as well as adding any new information to the page.
|
|
To do Rewrite description for 2.2.0
|
A_HoodThink is an action that is used as the thinker for the Robo-Hood. Normally when the player is far enough away the actor will fire arrows at the player. When the player is close enough however, the actor instead jumps at the player. It uses MissileState
for shooting, PainState
for jumping, XDeathState
for falling up after jumping, and RaiseState
for falling down after jumping. If the actor doesn't have a target, it will return to its SpawnState
.
Each time this action is used, the actor's reaction time will be reduced by 1. When it reaches 0, it will shoot the player if it is at least 192 fracunits away, otherwise it will jump at the player. After shooting/jumping, the actor will reset its reaction time to the value of ReactionTime
. If the map Thing flag Ambush is given to the actor's spawnpoint, it prevents the actor from jumping regardless of distance; the actor will instead continue to shoot even when the player is within jumping range.
When the actor is in mid-air, its state will be changed depending on its vertical momentum – if > 0 the actor's state switches to XDeathState
, if <= 0 RaiseState
is used instead. Note that the actor will not reduce its reaction time value nor attack when in mid-air.
Object property |
Use
|
SpawnState |
Goes to this state if actor has no target
|
SeeState |
Aiming state
|
PainState |
Jumping state
|
MissileState |
Shooting state
|
XDeathState |
Falling up state
|
RaiseState |
Falling down state
|
ReactionTime |
Reaction time
|
Code – A_HoodThink
|
|
// Function: A_HoodThink
//
// Description: Thinker for Robo-Hood
//
// var1 = unused
// var2 = unused
//
void A_HoodThink(mobj_t *actor)
{
fixed_t dx, dy, dz, dm;
boolean checksight;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_HoodThink", actor))
return;
#endif
// Check target first.
if (!actor->target)
{
actor->reactiontime = actor->info->reactiontime;
P_SetMobjState(actor, actor->info->spawnstate);
return;
}
dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z);
dm = P_AproxDistance(dx, dy);
// Target dangerously close to robohood, retreat then.
if ((dm < 256<<FRACBITS) && (abs(dz) < 128<<FRACBITS))
{
S_StartSound(actor, actor->info->attacksound);
P_SetMobjState(actor, actor->info->raisestate);
return;
}
// If target on sight, look at it.
if ((checksight = P_CheckSight(actor, actor->target)))
{
angle_t dang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
if (actor->angle >= ANGLE_180)
{
actor->angle = InvAngle(actor->angle)>>1;
actor->angle = InvAngle(actor->angle);
}
else
actor->angle >>= 1;
if (dang >= ANGLE_180)
{
dang = InvAngle(dang)>>1;
dang = InvAngle(dang);
}
else
dang >>= 1;
actor->angle += dang;
}
// Check whether to do anything.
if ((--actor->reactiontime) <= 0)
{
actor->reactiontime = actor->info->reactiontime;
// If way too far, don't shoot.
if ((dm < (3072<<FRACBITS)) && checksight)
{
P_SetMobjState(actor, actor->info->missilestate);
return;
}
}
}
|
|