diff --git a/src/shared/NSMonster.h b/src/shared/NSMonster.h index 149cb9c9..ccb7c221 100644 --- a/src/shared/NSMonster.h +++ b/src/shared/NSMonster.h @@ -311,6 +311,14 @@ public: virtual bool IsAlive(void); /** Returns whether they are allied with the type in question */ virtual bool IsFriend(int); + /** Overridable: Called once, when the monster has died. */ + virtual void HasBeenKilled(void); + /** Overridable: Called every time the monster is hurt, while still alive. */ + virtual void HasBeenHit(void); + /* Overridable: Called when the monster was gibbed. */ + virtual void HasBeenGibbed(void); + /* Overridable: Called when the monster has been alerted to threat. */ + virtual void HasBeenAlerted(void); /* see/hear subsystem */ /** Internal use only. Called every frame to simulate vision. */ @@ -396,13 +404,22 @@ public: #endif #ifdef CLIENT - nonvirtual void _RenderDebugViewCone(); /** overrides */ virtual void customphysics(void); virtual float predraw(void); virtual void ReceiveEntity(float,float); #endif + +private: + +#ifdef CLIENT + nonvirtual void _RenderDebugViewCone(); +#endif + +#ifdef SERVER + virtual void _Alerted(void); +#endif }; #ifdef CLIENT diff --git a/src/shared/NSMonster.qc b/src/shared/NSMonster.qc index 67c3882f..72aa04de 100644 --- a/src/shared/NSMonster.qc +++ b/src/shared/NSMonster.qc @@ -28,9 +28,9 @@ NSMonster::NSMonster(void) oldnet_velocity = g_vec_null; m_flPitch = 1.0f; m_iFlags = 0i; - base_mins = g_vec_null; - base_maxs = g_vec_null; - base_health = 100; + //base_mins = g_vec_null; + //base_maxs = g_vec_null; + //base_health = 100; m_strRouteEnded = __NULL__; m_iSequenceRemove = 0i; m_iSequenceState = 0i; @@ -227,9 +227,10 @@ NSMonster::Sound(string msg) void NSMonster::Gib(void) { + vector vecDir = vectoangles(GetOrigin() - g_dmg_vecLocation); SetState(MONSTER_DEAD); SetTakedamage(DAMAGE_NO); - FX_GibHuman(origin, vectoangles(origin - g_dmg_eAttacker.origin), g_dmg_iDamage * 2.0f); + FX_GibHuman(origin, vecDir, g_dmg_iDamage * 2.5f); Disappear(); } @@ -301,6 +302,7 @@ NSMonster::AlertNearby(void) continue; f.m_eEnemy = m_eEnemy; + f._Alerted(); } } @@ -409,6 +411,7 @@ NSMonster::SeeThink(void) if (m_eEnemy != w) { m_eEnemy = w; m_flTrackingTime = time; + _Alerted(); AlertNearby(); } return; @@ -765,6 +768,7 @@ NSMonster::InSequence(void) void NSMonster::RunAI(void) { + IdleNoise(); SeeThink(); AttackThink(); } @@ -858,6 +862,12 @@ NSMonster::Touch(entity eToucher) } } +void +NSMonster::HasBeenHit(void) +{ + /* to be filled in by the sub-class */ +} + void NSMonster::Pain(void) { @@ -885,6 +895,31 @@ NSMonster::Pain(void) /* alert all nearby friendlies */ AlertNearby(); + HasBeenHit(); +} + +void +NSMonster::HasBeenKilled(void) +{ + /* to be filled in by the sub-class */ +} + +void +NSMonster::HasBeenGibbed(void) +{ + /* to be filled in by the sub-class */ +} + +void +NSMonster::HasBeenAlerted(void) +{ + /* to be filled in by the sub-class */ +} + +void +NSMonster::_Alerted(void) +{ + HasBeenAlerted(); } void @@ -892,6 +927,7 @@ NSMonster::Death(void) { /* we were already dead before, so gib */ if (GetState() == MONSTER_DEAD) { + HasBeenGibbed(); Gib(); return; } @@ -900,11 +936,13 @@ NSMonster::Death(void) /* if we make more than 50 damage, gib immediately */ if (GetHealth() < -50) { + HasBeenGibbed(); Gib(); return; } /* make sure we're not causing any more obituaries */ + HasBeenKilled(); RemoveFlags(FL_MONSTER); /* set the monster up for getting gibbed */ diff --git a/src/shared/NSTalkMonster.h b/src/shared/NSTalkMonster.h index 14852811..0d42eabe 100644 --- a/src/shared/NSTalkMonster.h +++ b/src/shared/NSTalkMonster.h @@ -36,57 +36,6 @@ They also can communicate with other NSTalkMonster based entities. */ class NSTalkMonster:NSMonster { -private: -#ifdef SERVER - /* our NPCs can have a unique pitch to their voice */ - float m_flPitch; - float m_flNextSentence; - int m_iFlags; - - entity m_eFollowing; - entity m_eFollowingChain; - vector m_vecLastUserPos; - float m_flChangePath; - float m_flTraceTime; - float m_flFollowSpeedChanged; - float m_flFollowSpeed; - - - /* sentences identifiers */ - string m_talkAnswer; /* random answer to whenever a question is asked */ - string m_talkAsk; /* asks a random generic question */ - string m_talkAllyShot; /* asks to not shoot an ally further */ - string m_talkGreet; /* greet other NPCs */ - string m_talkIdle; /* idle chatter */ - string m_talkPanic; /* panic screams */ - string m_talkHearing; /* what did we just hear? */ - string m_talkSmelling; /* is something smelling bad? */ - string m_talkStare; /* when NPC is being stared at */ - string m_talkSurvived; /* we're near death */ - string m_talkWounded; /* we've sustained light wounds */ - - /* things that NPCs will only say to the player */ - string m_talkPlayerAsk; /* ask player some question */ - string m_talkPlayerGreet; /* say hello to the player */ - string m_talkPlayerIdle; /* idle chatter with the player */ - string m_talkPlayerWounded1; /* slightly wounded player comment */ - string m_talkPlayerWounded2; /* a bit worse */ - string m_talkPlayerWounded3; /* yup, got thus far */ - string m_talkUnfollow; /* when the player asks us to stop following */ - string m_talkFollow; /* whenever player asks the NPC to follow */ - string m_talkStopFollow; /* we have to stop following */ -#endif - -#ifdef CLIENT - /* sentence system */ - float m_flSentenceTime; - sound_t *m_pSentenceQue; - int m_iSentenceCount; - int m_iSentencePos; - float m_sndVoiceOffs; - bool m_bWasPaused; -#endif - public: void NSTalkMonster(void); @@ -163,6 +112,60 @@ public: /* model events */ virtual void HandleAnimEvent(float,int,string); + +private: +#ifdef SERVER + /* our NPCs can have a unique pitch to their voice */ + float m_flPitch; + float m_flNextSentence; + int m_iFlags; + + entity m_eFollowing; + entity m_eFollowingChain; + vector m_vecLastUserPos; + float m_flChangePath; + float m_flTraceTime; + float m_flFollowSpeedChanged; + float m_flFollowSpeed; + + + /* sentences identifiers */ + string m_talkAnswer; /* random answer to whenever a question is asked */ + string m_talkAsk; /* asks a random generic question */ + string m_talkAllyShot; /* asks to not shoot an ally further */ + string m_talkGreet; /* greet other NPCs */ + string m_talkIdle; /* idle chatter */ + string m_talkPanic; /* panic screams */ + string m_talkHearing; /* what did we just hear? */ + string m_talkSmelling; /* is something smelling bad? */ + string m_talkStare; /* when NPC is being stared at */ + string m_talkSurvived; /* we're near death */ + string m_talkWounded; /* we've sustained light wounds */ + string m_talkAlert; /* we've been alerted to a threat */ + + /* things that NPCs will only say to the player */ + string m_talkPlayerAsk; /* ask player some question */ + string m_talkPlayerGreet; /* say hello to the player */ + string m_talkPlayerIdle; /* idle chatter with the player */ + string m_talkPlayerWounded1; /* slightly wounded player comment */ + string m_talkPlayerWounded2; /* a bit worse */ + string m_talkPlayerWounded3; /* yup, got thus far */ + string m_talkUnfollow; /* when the player asks us to stop following */ + string m_talkFollow; /* whenever player asks the NPC to follow */ + string m_talkStopFollow; /* we have to stop following */ + + virtual void _Alerted(void); +#endif + +#ifdef CLIENT + /* sentence system */ + float m_flSentenceTime; + sound_t *m_pSentenceQue; + int m_iSentenceCount; + int m_iSentencePos; + float m_sndVoiceOffs; + bool m_bWasPaused; +#endif }; #ifdef CLIENT diff --git a/src/shared/NSTalkMonster.qc b/src/shared/NSTalkMonster.qc index e25b6c61..7dbdf6c5 100644 --- a/src/shared/NSTalkMonster.qc +++ b/src/shared/NSTalkMonster.qc @@ -23,7 +23,7 @@ NSTalkMonster::NSTalkMonster(void) m_flNextSentence = 0.0f; m_iFlags = 0i; m_eFollowingChain = __NULL__; - m_vecLastUserPos = [0,0,0]; + m_vecLastUserPos = g_vec_null; m_flChangePath = 0.0f; m_flTraceTime = 0.0f; m_flFollowSpeedChanged = 0.0f; @@ -39,6 +39,7 @@ NSTalkMonster::NSTalkMonster(void) m_talkStare = __NULL__; m_talkSurvived = __NULL__; m_talkWounded = __NULL__; + m_talkAlert = __NULL__; m_talkPlayerAsk = __NULL__; m_talkPlayerGreet = __NULL__; m_talkPlayerIdle = __NULL__; @@ -74,6 +75,15 @@ NSTalkMonster::HandleAnimEvent(float flTimeStamp, int iCode, string strData) } #ifdef SERVER +void +NSTalkMonster::_Alerted(void) +{ + super::_Alerted(); + + if (m_talkAlert) + Sentence(m_talkAlert); +} + void NSTalkMonster::Save(float handle) { @@ -101,6 +111,7 @@ NSTalkMonster::Save(float handle) SaveString(handle, "m_talkStare", m_talkStare); SaveString(handle, "m_talkSurvived", m_talkSurvived); SaveString(handle, "m_talkWounded", m_talkWounded); + SaveString(handle, "m_talkAlert", m_talkAlert); SaveString(handle, "m_talkPlayerAsk", m_talkPlayerAsk); SaveString(handle, "m_talkPlayerGreet", m_talkPlayerGreet); SaveString(handle, "m_talkPlayerIdle", m_talkPlayerIdle); @@ -179,6 +190,9 @@ NSTalkMonster::Restore(string strKey, string strValue) case "m_talkWounded": m_talkWounded = ReadString(strValue); break; + case "m_talkAlert": + m_talkAlert = ReadString(strValue); + break; case "m_talkPlayerAsk": m_talkPlayerAsk = ReadString(strValue); break; diff --git a/src/shared/pmove_custom.qc b/src/shared/pmove_custom.qc index cc5ccb84..88f4dd05 100644 --- a/src/shared/pmove_custom.qc +++ b/src/shared/pmove_custom.qc @@ -256,12 +256,6 @@ PMoveCustom_AccelFriction(float move_time, float premove, vector wish_dir, float float flFriction; vector vecTemp; - /* friction does not apply to monsters right now */ - if (self.flags & FL_MONSTER) { - self.velocity = wish_dir * wish_speed; - return; - } - flApplyFriction = serverkeyfloat("phy_friction"); /* per frame basis friction modifier */ @@ -412,6 +406,11 @@ PMoveCustom_DoTouch(entity tother) self.touch(); } self = oself; + + if (self.touch) { + other = tother; + self.touch(); + } } /* bounce us back off a place normal */