A_Look is an action that looks for a player and sets them as the new target. The upper 16 bits of Var1 can be used to specify a distance limit in fracunits. Only players within that limit can be targeted. If the lower 16 bits are set to 0, the actor only looks in front of itself, otherwise it looks all around. Once a target is found, the actor switches into its SeeState
and A_PlaySeeSound
is called to play its SeeSound
. If Var2 is set to 1, it will only switch to its SeeState
; if Var2 is set to 2, it will only play its SeeSound
.
Object property |
Use
|
SeeState |
Goes to this state when a target is found (Unless Var2 = 2)
|
SeeSound |
Plays this sound when a target is found (Unless Var2 = 1)
|
Attributes |
Use
|
Var1 |
Upper 16 bits: Distance limit
Lower 16 bits: 0 – looks only in front; 1 – looks all around
|
Var2 |
0 – Plays SeeSound and goes to SeeState 1 – Goes to SeeState 2 – Plays SeeSound
|
Code – A_Look
|
|
// Function: A_Look
//
// Description: Look for a player and set your target to them.
//
// var1:
// lower 16 bits = look all around
// upper 16 bits = distance limit
// var2 = If 1, only change to seestate. If 2, only play seesound. If 0, do both.
//
void A_Look(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_Look", actor))
return;
#endif
if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale)))
return;
// go into chase state
if (!locvar2)
{
P_SetMobjState(actor, actor->info->seestate);
A_PlaySeeSound(actor);
}
else if (locvar2 == 1) // Only go into seestate
P_SetMobjState(actor, actor->info->seestate);
else if (locvar2 == 2) // Only play seesound
A_PlaySeeSound(actor);
}
|
|