mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- added DavidPH's A_FaceTarget patch but modified it so that if a turn angle is set the MF_SHADOW flag is ignored.
SVN r2316 (trunk)
This commit is contained in:
parent
68fa08ca52
commit
942108f7ea
3 changed files with 45 additions and 9 deletions
|
@ -2671,7 +2671,7 @@ void A_Chase(AActor *self)
|
|||
// A_FaceTarget
|
||||
//
|
||||
//=============================================================================
|
||||
void A_FaceTarget (AActor *self)
|
||||
void A_FaceTarget (AActor *self, angle_t max_turn)
|
||||
{
|
||||
if (!self->target)
|
||||
return;
|
||||
|
@ -2683,18 +2683,54 @@ void A_FaceTarget (AActor *self)
|
|||
}
|
||||
|
||||
self->flags &= ~MF_AMBUSH;
|
||||
self->angle = R_PointToAngle2 (self->x, self->y,
|
||||
self->target->x, self->target->y);
|
||||
|
||||
if (self->target->flags & MF_SHADOW)
|
||||
angle_t target_angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y);
|
||||
|
||||
// 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms.
|
||||
// It also means that there is no need to check for going past the target.
|
||||
if (max_turn && (max_turn < abs(self->angle - target_angle)))
|
||||
{
|
||||
if (self->angle > target_angle)
|
||||
{
|
||||
if (self->angle - target_angle < ANGLE_180)
|
||||
{
|
||||
self->angle -= max_turn;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->angle += max_turn;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target_angle - self->angle < ANGLE_180)
|
||||
{
|
||||
self->angle += max_turn;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->angle -= max_turn;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self->angle = target_angle;
|
||||
}
|
||||
|
||||
// This will never work well if the turn angle is limited.
|
||||
if (max_turn == 0 && (self->angle == target_angle) && self->target->flags & MF_SHADOW)
|
||||
{
|
||||
self->angle += pr_facetarget.Random2() << 21;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_FaceTarget)
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget)
|
||||
{
|
||||
A_FaceTarget(self);
|
||||
ACTION_PARAM_START(1);
|
||||
ACTION_PARAM_ANGLE(max_turn, 0);
|
||||
|
||||
A_FaceTarget(self, max_turn);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -69,7 +69,7 @@ DECLARE_ACTION(A_FreezeDeathChunks)
|
|||
DECLARE_ACTION(A_BossDeath)
|
||||
|
||||
void A_Chase(AActor *self);
|
||||
void A_FaceTarget (AActor *actor);
|
||||
void A_FaceTarget (AActor *actor, angle_t max_turn = 0);
|
||||
|
||||
bool A_RaiseMobj (AActor *, fixed_t speed);
|
||||
bool A_SinkMobj (AActor *, fixed_t speed);
|
||||
|
|
|
@ -61,7 +61,7 @@ ACTOR Actor native //: Thinker
|
|||
action native A_XScream();
|
||||
action native A_Look();
|
||||
action native A_Chase(state melee = "*", state missile = "none", int flags = 0);
|
||||
action native A_FaceTarget();
|
||||
action native A_FaceTarget(float max_turn = 0);
|
||||
action native A_PosAttack();
|
||||
action native A_Scream();
|
||||
action native A_SPosAttack();
|
||||
|
|
Loading…
Reference in a new issue