diff --git a/src/p_map.cpp b/src/p_map.cpp index 59ec6a8e2..41c1951d3 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2926,7 +2926,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e pitch_friend=thingpitch; } } - else if (!(th->flags3&MF3_ISMONSTER) ) + else if (!(th->flags3&MF3_ISMONSTER) && th->player == NULL) { if (sv_smartaim < 3) { diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 873a01bfc..d9a14e425 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1781,24 +1781,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) } -//=========================================================================== -// -// A_JumpIfTargetInSight -// jumps if monster can see its target -// -//=========================================================================== -DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInSight) -{ - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); - - ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - if (self->target == NULL || !P_CheckSight(self, self->target,4)) return; - ACTION_JUMP(jump); - -} - - //=========================================================================== // // Inventory drop @@ -2211,6 +2193,62 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) ACTION_JUMP(jump); } + +//========================================================================== +// +// A_JumpIfInTargetLOS (state label, optional fixed fov, optional bool +// projectiletarget) +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) +{ + ACTION_PARAM_START(3); + ACTION_PARAM_STATE(jump, 0); + ACTION_PARAM_ANGLE(fov, 1); + ACTION_PARAM_BOOL(projtarg, 2); + + angle_t an; + AActor *target; + + ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! + + if (self->flags & MF_MISSILE && projtarg) + { + if (self->flags2 & MF2_SEEKERMISSILE) + target = self->tracer; + else + target = NULL; + } + else + { + target = self->target; + } + + if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case. + + if (!P_CheckSight (target, self, 1)) + return; + + if (fov && (fov < ANGLE_MAX)) + { + an = R_PointToAngle2 (self->x, + self->y, + target->x, + target->y) + - self->angle; + + if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) + { + return; // [KS] Outside of FOV - return + } + + } + + ACTION_JUMP(jump); +} + + //=========================================================================== // // A_DamageMaster (int amount) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 67518e6a1..e758214fe 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -221,6 +221,7 @@ ACTOR Actor native //: Thinker action native A_LookEx(int flags = 0, float minseedist = 0, float maxseedist = 0, float maxheardist = 0, float fov = 0, state label = ""); action native A_ClearTarget(); action native A_JumpIfTargetInLOS (state label, float fov = 0, bool projectiletarget = false); + action native A_JumpIfInTargetLOS (state label, float fov = 0, bool projectiletarget = false); action native A_DamageMaster(int amount, name damagetype = "none"); action native A_DamageChildren(int amount, name damagetype = "none"); action native A_DamageSiblings(int amount, name damagetype = "none"); @@ -236,8 +237,6 @@ ACTOR Actor native //: Thinker action native A_RemoveForcefield(); action native A_DropWeaponPieces(class p1, class p2, class p3); action native A_PigPain (); - - action native A_JumpIfTargetInSight(state label); action native A_MonsterRefire(int chance, state label); States