Nuclide
Software Development Kit for id Tech
NSTalkMonster.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2022 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17/* NPCs are more advanced than regular monsters in that they express emotions
18 * and are able to interact more with the environment */
19
20#ifdef SERVER
21#define PLAYER_DETECT_RADIUS 512
22
24{
25 MONSTER_USED,
26 MONSTER_FEAR,
27 MONSTER_METPLAYER,
28 MONSTER_CANFOLLOW
29};
30#endif
31
76{
77public:
78 void NSTalkMonster(void);
79
81 virtual void Sentence(string);
82
83#ifdef SERVER
85 virtual void Speak(string);
87 virtual void WarnAllies(void);
89 virtual void StartleAllies(void);
92 virtual void FollowPlayer(void);
95 virtual void FollowChain(void);
96 virtual void RunAI(void);
98 virtual void PanicFrame(void);
99
100 virtual void OnPlayerUse(void);
101 //virtual void Hide(void);
102 virtual void Respawn(void);
103 virtual void SpawnKey(string,string);
104 virtual float SendEntity(entity,float);
105 virtual void Save(float);
106 virtual void Restore(string,string);
107 virtual void Touch(entity);
108
109 /*virtual void(void) TalkAnswer;
110 virtual void(void) TalkAsk;
111 virtual void(void) TalkAllyShot;
112 virtual void(void) TalkGreet;
113 virtual void(void) TalkIdle;
114 virtual void(void) TalkHearing;
115 virtual void(void) TalkSmelling;
116 virtual void(void) TalkStare;
117 virtual void(void) TalkSurvived;
118 virtual void(void) TalkWounded;*/
119
121 virtual void TalkPanic(void);
123 virtual void TalkPlayerAsk(void);
125 virtual void TalkPlayerGreet(void);
127 virtual void TalkPlayerIdle(void);
129 virtual void TalkPlayerWounded1(void);
131 virtual void TalkPlayerWounded2(void);
133 virtual void TalkPlayerWounded3(void);
135 virtual void TalkUnfollow(void);
137 virtual void TalkFollow(void);
139 virtual void TalkStopFollow(void);
141 virtual void TalkDenyFollow(void);
142#endif
143
144#ifdef CLIENT
145 virtual float predraw(void);
146 virtual void ReceiveEntity(float,float);
147
149 virtual void SentenceSample(string);
151 virtual void ProcessWordQue(void);
152#endif
153
154 /* model events */
155 virtual void HandleAnimEvent(float,int,string);
156
157private:
158#ifdef SERVER
159 /* our NPCs can have a unique pitch to their voice */
160 float m_flPitch;
161 float m_flNextSentence;
162 int m_iFlags;
163
164 entity m_eFollowingChain;
165 vector m_vecLastUserPos;
166 float m_flChangePath;
167 float m_flTraceTime;
168 float m_flFollowSpeedChanged;
169 float m_flFollowSpeed;
170 bool m_bFollowOnUse;
171
172 float m_flFollowDistance;
173 float m_flMaxFollowDistance;
174 bool m_bFollowGrouping;
175
176 /* sentences identifiers */
177 string m_talkAnswer; /* random answer to whenever a question is asked */
178 string m_talkAsk; /* asks a random generic question */
179 string m_talkAllyShot; /* asks to not shoot an ally further */
180 string m_talkGreet; /* greet other NPCs */
181 string m_talkIdle; /* idle chatter */
182 string m_talkPanic; /* panic screams */
183 string m_talkHearing; /* what did we just hear? */
184 string m_talkSmelling; /* is something smelling bad? */
185 string m_talkStare; /* when NPC is being stared at */
186 string m_talkSurvived; /* we're near death */
187 string m_talkWounded; /* we've sustained light wounds */
188 string m_talkAlert; /* we've been alerted to a threat */
189
190 /* things that NPCs will only say to the player */
191 string m_talkPlayerAsk; /* ask player some question */
192 string m_talkPlayerGreet; /* say hello to the player */
193 string m_talkPlayerIdle; /* idle chatter with the player */
194 string m_talkPlayerWounded1; /* slightly wounded player comment */
195 string m_talkPlayerWounded2; /* a bit worse */
196 string m_talkPlayerWounded3; /* yup, got thus far */
197 string m_talkUnfollow; /* when the player asks us to stop following */
198 string m_talkFollow; /* whenever player asks the NPC to follow */
199 string m_talkStopFollow; /* we have to stop following */
200 string m_talkDenyFollow; /* deny the follow request. */
201
202 virtual void _Alerted(void);
203#endif
204
205#ifdef CLIENT
206 /* sentence system */
207 float m_flSentenceTime;
208 sound_t *m_pSentenceQue;
209 int m_iSentenceCount;
210 int m_iSentencePos;
211 float m_sndVoiceOffs;
212 bool m_bWasPaused;
213#endif
214};
215
216#ifdef CLIENT
218void NSTalkMonster_ReadEntity(bool);
219#endif
void NSTalkMonster_ParseSentence(void)
void NSTalkMonster_ReadEntity(bool)
Definition: NSTalkMonster.qc:1232
enumflags
Definition: NSTalkMonster.h:24
NSSquadMonster based NPCs are able to communicate strategies together.
Definition: NSSquadMonster.h:22
This class represents NSMonsters that talk.
Definition: NSTalkMonster.h:76
virtual void RunAI(void)
Internal use only.
Definition: NSTalkMonster.qc:743
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSTalkMonster.qc:99
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSTalkMonster.qc:808
virtual void OnPlayerUse(void)
Definition: NSTalkMonster.qc:780
void NSTalkMonster(void)
Definition: NSTalkMonster.qc:18
virtual void TalkPlayerGreet(void)
Called when they are greeting the player.
Definition: NSTalkMonster.qc:317
virtual void Sentence(string)
When called, will play a Sentence over the network.
Definition: NSTalkMonster.qc:281
virtual float predraw(void)
virtual void TalkPlayerWounded1(void)
Called when they tell the player that they're wounded.
Definition: NSTalkMonster.qc:411
virtual void HandleAnimEvent(float, int, string)
Callback for any model event that gets triggered while playing a framegroup.
Definition: NSTalkMonster.qc:68
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSTalkMonster.qc:902
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSTalkMonster.qc:571
virtual void Speak(string)
When called, will play a single sample (.wav/.ogg) over the network.
Definition: NSTalkMonster.qc:302
virtual void SentenceSample(string)
Plays a single sample from a sentence.
virtual void StartleAllies(void)
When called, will startle all allies in a nearby area.
Definition: NSTalkMonster.qc:268
virtual void TalkPlayerWounded2(void)
Called when they tell the player that severely wounded.
Definition: NSTalkMonster.qc:441
virtual void ProcessWordQue(void)
Called once per frame to process the word queue.
virtual void FollowPlayer(void)
Internal use only.
Definition: NSTalkMonster.qc:591
virtual void TalkStopFollow(void)
Called when they tell the player that they'll stop following.
Definition: NSTalkMonster.qc:543
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
virtual void Restore(string, string)
Similar to ::SpawnKey but for save-game fields.
Definition: NSTalkMonster.qc:142
virtual void TalkDenyFollow(void)
Called when they tell the player they won't follow you.
Definition: NSTalkMonster.qc:557
virtual void TalkPlayerIdle(void)
Called when they are chit-chatting with the player.
Definition: NSTalkMonster.qc:349
virtual void TalkUnfollow(void)
Called when they tell the player that they'll give up following.
Definition: NSTalkMonster.qc:515
virtual void WarnAllies(void)
When called, will alert all allies in a nearby area.
Definition: NSTalkMonster.qc:256
virtual void FollowChain(void)
Internal use only.
Definition: NSTalkMonster.qc:728
virtual void TalkFollow(void)
Called when they tell the player that they'll start following.
Definition: NSTalkMonster.qc:529
virtual void TalkPanic(void)
Called when they're in a state of panic.
Definition: NSTalkMonster.qc:500
virtual void PanicFrame(void)
Run every frame if we're in a state of panic.
Definition: NSTalkMonster.qc:689
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: NSTalkMonster.qc:765
virtual void TalkPlayerWounded3(void)
Called when they tell the player that they're near death.
Definition: NSTalkMonster.qc:472
virtual void TalkPlayerAsk(void)
Called when they want to ask the player a question.
Definition: NSTalkMonster.qc:383
vector(vector) normalize
entity() spawn
A sound sample of a sentences.txt word sequence.
Definition: sound.h:100