From 6ba0689b8dc29facdcca491232b4a1cfc964a600 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Jun 2011 10:30:30 +0000 Subject: [PATCH] - added DavidPH's A_AlertMonsters range submission. SVN r3233 (trunk) --- src/g_strife/a_strifeweapons.cpp | 10 +++++++--- src/p_enemy.cpp | 13 +++++++------ src/p_enemy.h | 5 +++-- src/p_local.h | 5 ----- src/p_pspr.cpp | 1 + wadsrc/static/actors/actor.txt | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index bf5cb124e..e7d24dc36 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -137,15 +137,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) // //============================================================================ -DEFINE_ACTION_FUNCTION(AActor, A_AlertMonsters) +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_AlertMonsters) { + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(maxdist, 0); + if (self->player != NULL) { - P_NoiseAlert(self, self); + P_NoiseAlert(self, self, false, maxdist); } else if (self->target != NULL && self->target->player != NULL) { - P_NoiseAlert (self->target, self); + P_NoiseAlert (self->target, self, false, maxdist); } } @@ -624,6 +627,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) drop->flags |= MF_DROPPED; } } + } //============================================================================ diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 19d32626b..55787c650 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -115,7 +115,7 @@ void P_RandomChaseDir (AActor *actor); // sound blocking lines cut off traversal. //---------------------------------------------------------------------------- -void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks) +void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter, fixed_t maxdist) { int i; line_t* check; @@ -136,7 +136,8 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // [RH] Set this in the actors in the sector instead of the sector itself. for (actor = sec->thinglist; actor != NULL; actor = actor->snext) { - if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT))) + if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT)) && + (!maxdist || (P_AproxDistance(actor->x - emitter->x, actor->y - emitter->y) <= maxdist))) { actor->LastHeard = soundtarget; } @@ -179,11 +180,11 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun if (check->flags & ML_SOUNDBLOCK) { if (!soundblocks) - P_RecursiveSound (other, soundtarget, splash, 1); + P_RecursiveSound (other, soundtarget, splash, 1, emitter, maxdist); } else { - P_RecursiveSound (other, soundtarget, splash, soundblocks); + P_RecursiveSound (other, soundtarget, splash, soundblocks, emitter, maxdist); } } } @@ -199,7 +200,7 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // //---------------------------------------------------------------------------- -void P_NoiseAlert (AActor *target, AActor *emitter, bool splash) +void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, fixed_t maxdist) { if (emitter == NULL) return; @@ -208,7 +209,7 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash) return; validcount++; - P_RecursiveSound (emitter->Sector, target, splash, 0); + P_RecursiveSound (emitter->Sector, target, splash, 0, emitter, maxdist); } diff --git a/src/p_enemy.h b/src/p_enemy.h index f996a0c52..343ba27e9 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -2,6 +2,7 @@ #define __P_ENEMY_H__ #include "thingdef/thingdef.h" +#include "tables.h" struct sector_t; class AActor; @@ -46,9 +47,9 @@ struct FLookExParams }; void P_DaggerAlert (AActor *target, AActor *emitter); -void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks); +void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter=NULL, fixed_t maxdist=0); bool P_HitFriend (AActor *self); -void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false); +void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false, fixed_t maxdist=0); bool P_CheckMeleeRange2 (AActor *actor); bool P_Move (AActor *actor); bool P_TryWalk (AActor *actor); diff --git a/src/p_local.h b/src/p_local.h index 7d3c3d14c..9e361168d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -144,11 +144,6 @@ void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool void P_RemoveThing(AActor * actor); bool P_Thing_Raise(AActor *thing); -// -// P_ENEMY -// -void P_NoiseAlert (AActor* target, AActor* emmiter, bool splash); - // // P_MAPUTL diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 8b8c5bcdc..31eb1ac7e 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -18,6 +18,7 @@ #include "d_event.h" #include "c_cvars.h" #include "m_random.h" +#include "p_enemy.h" #include "p_local.h" #include "s_sound.h" #include "doomstat.h" diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 720caa858..251be5e0d 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -171,7 +171,7 @@ ACTOR Actor native //: Thinker action native A_TurretLook(); action native A_KlaxonBlare(); action native A_Countdown(); - action native A_AlertMonsters(); + action native A_AlertMonsters(float maxdist = 0); action native A_ClearSoundTarget(); action native A_FireAssaultGun(); action native A_CheckTerrain();