Nuclide
Software Development Kit for id Technology (BETA)
TalkMonster.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 ncTalkMonster(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 Input(entity,string,string);
106 virtual void SpawnKey(string,string);
107 virtual float SendEntity(entity,float);
108 virtual void Save(float);
109 virtual void Restore(string,string);
110 virtual void Touch(entity);
111
112 /*virtual void(void) TalkAnswer;
113 virtual void(void) TalkAsk;
114 virtual void(void) TalkAllyShot;
115 virtual void(void) TalkGreet;
116 virtual void(void) TalkIdle;
117 virtual void(void) TalkHearing;
118 virtual void(void) TalkSmelling;
119 virtual void(void) TalkStare;
120 virtual void(void) TalkSurvived;
121 virtual void(void) TalkWounded;*/
122
124 virtual void TalkPanic(void);
126 virtual void TalkPlayerAsk(void);
128 virtual void SeenPlayer(ncActor);
130 virtual void SeenFriend(ncActor);
132 virtual void TalkPlayerWounded1(void);
134 virtual void TalkPlayerWounded2(void);
136 virtual void TalkPlayerWounded3(void);
138 virtual void TalkUnfollow(void);
140 virtual void TalkFollow(void);
142 virtual void TalkStopFollow(void);
144 virtual void TalkDenyFollow(void);
145#endif
146
147#ifdef CLIENT
148 virtual float predraw(void);
149 virtual void ReceiveEntity(float,float);
150
152 virtual void SentenceSample(string);
154 virtual void ProcessWordQue(void);
155#endif
156
157 /* model events */
158 virtual void HandleAnimEvent(float,int,string);
159
160private:
161#ifdef SERVER
162 /* our NPCs can have a unique pitch to their voice */
163 float m_flPitch;
164 float m_flNextSentence;
165 int m_iFlags;
166
167 entity m_eFollowingChain;
168 vector m_vecLastUserPos;
169 float m_flChangePath;
170 float m_flTraceTime;
171 float m_flFollowSpeedChanged;
172 float m_flFollowSpeed;
173 bool m_bFollowOnUse;
174
175 float m_flFollowDistance;
176 float m_flMaxFollowDistance;
177 bool m_bFollowGrouping;
178
179 /* sentences identifiers */
180 string m_talkAnswer; /* random answer to whenever a question is asked */
181 string m_talkAsk; /* asks a random generic question */
182 string m_talkAllyShot; /* asks to not shoot an ally further */
183 string m_talkGreet; /* greet other NPCs */
184 string m_talkIdle; /* idle chatter */
185 string m_talkPanic; /* panic screams */
186 string m_talkHearing; /* what did we just hear? */
187 string m_talkSmelling; /* is something smelling bad? */
188 string m_talkStare; /* when NPC is being stared at */
189 string m_talkSurvived; /* we're near death */
190 string m_talkWounded; /* we've sustained light wounds */
191 string m_talkAlert; /* we've been alerted to a threat */
192
193 /* things that NPCs will only say to the player */
194 string m_talkPlayerAsk; /* ask player some question */
195 string m_talkPlayerGreet; /* say hello to the player */
196 string m_talkPlayerIdle; /* idle chatter with the player */
197 string m_talkPlayerWounded1; /* slightly wounded player comment */
198 string m_talkPlayerWounded2; /* a bit worse */
199 string m_talkPlayerWounded3; /* yup, got thus far */
200 string m_talkUnfollow; /* when the player asks us to stop following */
201 string m_talkFollow; /* whenever player asks the NPC to follow */
202 string m_talkStopFollow; /* we have to stop following */
203 string m_talkDenyFollow; /* deny the follow request. */
204
205 virtual void _Alerted(void);
206#endif
207
208#ifdef CLIENT
209 /* sentence system */
210 float m_flSentenceTime;
211 sound_t *m_pSentenceQue;
212 int m_iSentenceCount;
213 int m_iSentencePos;
214 float m_sndVoiceOffs;
215 bool m_bWasPaused;
216#endif
217};
218
219#ifdef CLIENT
220void ncTalkMonster_ParseSentence(void);
221void ncTalkMonster_ReadEntity(bool);
222#endif
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:72
ncSquadMonster based NPCs are able to communicate strategies together.
Definition: SquadMonster.h:24
This class represents ncMonsters that talk.
Definition: TalkMonster.h:78
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: TalkMonster.qc:892
virtual void TalkPlayerWounded3(void)
Called when they tell the player that they're near death.
Definition: TalkMonster.qc:457
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: TalkMonster.qc:556
virtual void TalkPanic(void)
Called when they're in a state of panic.
Definition: TalkMonster.qc:485
virtual void TalkStopFollow(void)
Called when they tell the player that they'll stop following.
Definition: TalkMonster.qc:528
virtual void PanicFrame(void)
Run every frame if we're in a state of panic.
Definition: TalkMonster.qc:674
virtual void HandleAnimEvent(float, int, string)
Callback for any model event that gets triggered while playing a framegroup.
Definition: TalkMonster.qc:68
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: TalkMonster.qc:99
virtual void TalkPlayerAsk(void)
Called when they want to ask the player a question.
Definition: TalkMonster.qc:368
virtual void SeenPlayer(ncActor)
Called when they are greeting the player.
Definition: TalkMonster.qc:329
virtual void OnPlayerUse(void)
Definition: TalkMonster.qc:770
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: TalkMonster.qc:755
void ncTalkMonster(void)
Definition: TalkMonster.qc:18
virtual void FollowPlayer(void)
Internal use only.
Definition: TalkMonster.qc:576
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
virtual void TalkDenyFollow(void)
Called when they tell the player they won't follow you.
Definition: TalkMonster.qc:542
virtual void ProcessWordQue(void)
Called once per frame to process the word queue.
virtual void SeenFriend(ncActor)
Called when they are chit-chatting with the player.
Definition: TalkMonster.qc:351
virtual void StartleAllies(void)
When called, will startle all allies in a nearby area.
Definition: TalkMonster.qc:268
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: TalkMonster.qc:317
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: TalkMonster.qc:798
virtual void Speak(string)
When called, will play a single sample (.wav/.ogg) over the network.
Definition: TalkMonster.qc:302
virtual void TalkPlayerWounded1(void)
Called when they tell the player that they're wounded.
Definition: TalkMonster.qc:396
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: TalkMonster.qc:142
virtual void WarnAllies(void)
When called, will alert all allies in a nearby area.
Definition: TalkMonster.qc:256
virtual void TalkFollow(void)
Called when they tell the player that they'll start following.
Definition: TalkMonster.qc:514
virtual void TalkPlayerWounded2(void)
Called when they tell the player that severely wounded.
Definition: TalkMonster.qc:426
virtual void RunAI(void)
Internal use only.
Definition: TalkMonster.qc:728
virtual void Sentence(string)
When called, will play a Sentence over the network.
Definition: TalkMonster.qc:281
virtual void FollowChain(void)
Internal use only.
Definition: TalkMonster.qc:713
virtual float predraw(void)
virtual void SentenceSample(string)
Plays a single sample from a sentence.
virtual void TalkUnfollow(void)
Called when they tell the player that they'll give up following.
Definition: TalkMonster.qc:500
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