Nuclide
Software Development Kit for id Technology
NSTalkMonster.h
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
78{
79public:
80 void NSTalkMonster(void);
81
83 virtual void Sentence(string);
84
85#ifdef SERVER
87 virtual void Speak(string);
89 virtual void WarnAllies(void);
91 virtual void StartleAllies(void);
94 virtual void FollowPlayer(void);
97 virtual void FollowChain(void);
98 virtual void RunAI(void);
100 virtual void PanicFrame(void);
101
102 virtual void OnPlayerUse(void);
103 //virtual void Hide(void);
104 virtual void Respawn(void);
105 virtual void SpawnKey(string,string);
106 virtual float SendEntity(entity,float);
107 virtual void Save(float);
108 virtual void Restore(string,string);
109 virtual void Touch(entity);
110
111 /*virtual void(void) TalkAnswer;
112 virtual void(void) TalkAsk;
113 virtual void(void) TalkAllyShot;
114 virtual void(void) TalkGreet;
115 virtual void(void) TalkIdle;
116 virtual void(void) TalkHearing;
117 virtual void(void) TalkSmelling;
118 virtual void(void) TalkStare;
119 virtual void(void) TalkSurvived;
120 virtual void(void) TalkWounded;*/
121
123 virtual void TalkPanic(void);
125 virtual void TalkPlayerAsk(void);
127 virtual void SeenPlayer(NSActor);
129 virtual void SeenFriend(NSActor);
131 virtual void TalkPlayerWounded1(void);
133 virtual void TalkPlayerWounded2(void);
135 virtual void TalkPlayerWounded3(void);
137 virtual void TalkUnfollow(void);
139 virtual void TalkFollow(void);
141 virtual void TalkStopFollow(void);
143 virtual void TalkDenyFollow(void);
144#endif
145
146#ifdef CLIENT
147 virtual float predraw(void);
148 virtual void ReceiveEntity(float,float);
149
151 virtual void SentenceSample(string);
153 virtual void ProcessWordQue(void);
154#endif
155
156 /* model events */
157 virtual void HandleAnimEvent(float,int,string);
158
159private:
160#ifdef SERVER
161 /* our NPCs can have a unique pitch to their voice */
162 float m_flPitch;
163 float m_flNextSentence;
164 int m_iFlags;
165
166 entity m_eFollowingChain;
167 vector m_vecLastUserPos;
168 float m_flChangePath;
169 float m_flTraceTime;
170 float m_flFollowSpeedChanged;
171 float m_flFollowSpeed;
172 bool m_bFollowOnUse;
173
174 float m_flFollowDistance;
175 float m_flMaxFollowDistance;
176 bool m_bFollowGrouping;
177
178 /* sentences identifiers */
179 string m_talkAnswer; /* random answer to whenever a question is asked */
180 string m_talkAsk; /* asks a random generic question */
181 string m_talkAllyShot; /* asks to not shoot an ally further */
182 string m_talkGreet; /* greet other NPCs */
183 string m_talkIdle; /* idle chatter */
184 string m_talkPanic; /* panic screams */
185 string m_talkHearing; /* what did we just hear? */
186 string m_talkSmelling; /* is something smelling bad? */
187 string m_talkStare; /* when NPC is being stared at */
188 string m_talkSurvived; /* we're near death */
189 string m_talkWounded; /* we've sustained light wounds */
190 string m_talkAlert; /* we've been alerted to a threat */
191
192 /* things that NPCs will only say to the player */
193 string m_talkPlayerAsk; /* ask player some question */
194 string m_talkPlayerGreet; /* say hello to the player */
195 string m_talkPlayerIdle; /* idle chatter with the player */
196 string m_talkPlayerWounded1; /* slightly wounded player comment */
197 string m_talkPlayerWounded2; /* a bit worse */
198 string m_talkPlayerWounded3; /* yup, got thus far */
199 string m_talkUnfollow; /* when the player asks us to stop following */
200 string m_talkFollow; /* whenever player asks the NPC to follow */
201 string m_talkStopFollow; /* we have to stop following */
202 string m_talkDenyFollow; /* deny the follow request. */
203
204 virtual void _Alerted(void);
205#endif
206
207#ifdef CLIENT
208 /* sentence system */
209 float m_flSentenceTime;
210 sound_t *m_pSentenceQue;
211 int m_iSentenceCount;
212 int m_iSentencePos;
213 float m_sndVoiceOffs;
214 bool m_bWasPaused;
215#endif
216};
217
218#ifdef CLIENT
219void NSTalkMonster_ParseSentence(void);
220void NSTalkMonster_ReadEntity(bool);
221#endif
This entity class represents an object with choreographed/free-form movement.
Definition: NSNavAI.h:50
NSSquadMonster based NPCs are able to communicate strategies together.
Definition: NSSquadMonster.h:24
This class represents NSMonsters that talk.
Definition: NSTalkMonster.h:78
virtual void RunAI(void)
Internal use only.
Definition: NSTalkMonster.qc:716
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:785
virtual void OnPlayerUse(void)
Definition: NSTalkMonster.qc:757
void NSTalkMonster(void)
Definition: NSTalkMonster.qc:18
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:384
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:879
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSTalkMonster.qc:544
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:414
virtual void SeenPlayer(NSActor)
Called when they are greeting the player.
Definition: NSTalkMonster.qc:317
virtual void ProcessWordQue(void)
Called once per frame to process the word queue.
virtual void FollowPlayer(void)
Internal use only.
Definition: NSTalkMonster.qc:564
virtual void TalkStopFollow(void)
Called when they tell the player that they'll stop following.
Definition: NSTalkMonster.qc:516
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
virtual void Restore(string, string)
Similar to NSIO::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:530
virtual void TalkUnfollow(void)
Called when they tell the player that they'll give up following.
Definition: NSTalkMonster.qc:488
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:701
virtual void TalkFollow(void)
Called when they tell the player that they'll start following.
Definition: NSTalkMonster.qc:502
virtual void TalkPanic(void)
Called when they're in a state of panic.
Definition: NSTalkMonster.qc:473
virtual void SeenFriend(NSActor)
Called when they are chit-chatting with the player.
Definition: NSTalkMonster.qc:339
virtual void PanicFrame(void)
Run every frame if we're in a state of panic.
Definition: NSTalkMonster.qc:662
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:742
virtual void TalkPlayerWounded3(void)
Called when they tell the player that they're near death.
Definition: NSTalkMonster.qc:445
virtual void TalkPlayerAsk(void)
Called when they want to ask the player a question.
Definition: NSTalkMonster.qc:356
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
A sound sample of a sentences.txt word sequence.
Definition: sound.h:185