-
Notifications
You must be signed in to change notification settings - Fork 595
/
talkmonster.h
183 lines (152 loc) · 5.91 KB
/
talkmonster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/***
*
* Copyright (c) 1996-2001, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef TALKMONSTER_H
#define TALKMONSTER_H
#ifndef MONSTERS_H
#include "monsters.h"
#endif
//=========================================================
// Talking monster base class
// Used for scientists and barneys
//=========================================================
#define TALKRANGE_MIN 500.0 // don't talk to anyone farther away than this
#define TLK_STARE_DIST 128 // anyone closer than this and looking at me is probably staring at me.
#define bit_saidDamageLight (1<<0) // bits so we don't repeat key sentences
#define bit_saidDamageMedium (1<<1)
#define bit_saidDamageHeavy (1<<2)
#define bit_saidHelloPlayer (1<<3)
#define bit_saidWoundLight (1<<4)
#define bit_saidWoundHeavy (1<<5)
#define bit_saidHeard (1<<6)
#define bit_saidSmelled (1<<7)
#define TLK_CFRIENDS 3
typedef enum
{
TLK_ANSWER = 0,
TLK_QUESTION,
TLK_IDLE,
TLK_STARE,
TLK_USE,
TLK_UNUSE,
TLK_STOP,
TLK_NOSHOOT,
TLK_HELLO,
TLK_PHELLO,
TLK_PIDLE,
TLK_PQUESTION,
TLK_PLHURT1,
TLK_PLHURT2,
TLK_PLHURT3,
TLK_SMELL,
TLK_WOUND,
TLK_MORTAL,
TLK_CGROUPS, // MUST be last entry
} TALKGROUPNAMES;
enum
{
SCHED_CANT_FOLLOW = LAST_COMMON_SCHEDULE + 1,
SCHED_MOVE_AWAY, // Try to get out of the player's way
SCHED_MOVE_AWAY_FOLLOW, // same, but follow afterward
SCHED_MOVE_AWAY_FAIL, // Turn back toward player
LAST_TALKMONSTER_SCHEDULE, // MUST be last
};
enum
{
TASK_CANT_FOLLOW = LAST_COMMON_TASK + 1,
TASK_MOVE_AWAY_PATH,
TASK_WALK_PATH_FOR_UNITS,
TASK_TLK_RESPOND, // say my response
TASK_TLK_SPEAK, // question or remark
TASK_TLK_HELLO, // Try to say hello to player
TASK_TLK_HEADRESET, // reset head position
TASK_TLK_STOPSHOOTING, // tell player to stop shooting friend
TASK_TLK_STARE, // let the player know I know he's staring at me.
TASK_TLK_LOOK_AT_CLIENT,// faces player if not moving and not talking and in idle.
TASK_TLK_CLIENT_STARE, // same as look at client, but says something if the player stares.
TASK_TLK_EYECONTACT, // maintain eyecontact with person who I'm talking to
TASK_TLK_IDEALYAW, // set ideal yaw to face who I'm talking to
TASK_FACE_PLAYER, // Face the player
LAST_TALKMONSTER_TASK, // MUST be last
};
class CTalkMonster : public CBaseMonster
{
public:
void TalkInit( void );
CBaseEntity *FindNearestFriend(BOOL fPlayer);
float TargetDistance( void );
void StopTalking( void ) { SentenceStop(); }
// Base Monster functions
void Precache( void );
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
void Touch( CBaseEntity *pOther );
void Killed( entvars_t *pevAttacker, int iGib );
int IRelationship ( CBaseEntity *pTarget );
virtual int CanPlaySentence( BOOL fDisregardState );
virtual void PlaySentence( const char *pszSentence, float duration, float volume, float attenuation );
void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener );
void KeyValue( KeyValueData *pkvd );
// AI functions
void SetActivity ( Activity newActivity );
Schedule_t *GetScheduleOfType ( int Type );
void StartTask( Task_t *pTask );
void RunTask( Task_t *pTask );
void HandleAnimEvent( MonsterEvent_t *pEvent );
void PrescheduleThink( void );
// Conversations / communication
int GetVoicePitch( void );
void IdleRespond( void );
int FIdleSpeak( void );
int FIdleStare( void );
int FIdleHello( void );
void IdleHeadTurn( Vector &vecFriend );
int FOkToSpeak( void );
void TrySmellTalk( void );
CBaseEntity *EnumFriends( CBaseEntity *pentPrevious, int listNumber, BOOL bTrace );
void AlertFriends( void );
void ShutUpFriends( void );
BOOL IsTalking( void );
void Talk( float flDuration );
// For following
BOOL CanFollow( void );
BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && m_hTargetEnt->IsPlayer(); }
void StopFollowing( BOOL clearSchedule );
void StartFollowing( CBaseEntity *pLeader );
virtual void DeclineFollowing( void ) {}
void LimitFollowers( CBaseEntity *pPlayer, int maxFollowers );
void EXPORT FollowerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual void SetAnswerQuestion( CTalkMonster *pSpeaker );
virtual int FriendNumber( int arrayNumber ) { return arrayNumber; }
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
static char *m_szFriends[TLK_CFRIENDS]; // array of friend names
static float g_talkWaitTime;
int m_bitsSaid; // set bits for sentences we don't want repeated
int m_nSpeak; // number of times initiated talking
int m_voicePitch; // pitch of voice for this head
const char *m_szGrp[TLK_CGROUPS]; // sentence group names
float m_useTime; // Don't allow +USE until this time
int m_iszUse; // Custom +USE sentence group (follow)
int m_iszUnUse; // Custom +USE sentence group (stop following)
float m_flLastSaidSmelled;// last time we talked about something that stinks
float m_flStopTalkTime;// when in the future that I'll be done saying this sentence.
EHANDLE m_hTalkTarget; // who to look at while talking
CUSTOM_SCHEDULES;
};
// Clients can push talkmonsters out of their way
#define bits_COND_CLIENT_PUSH ( bits_COND_SPECIAL1 )
// Don't see a client right now.
#define bits_COND_CLIENT_UNSEEN ( bits_COND_SPECIAL2 )
#endif //TALKMONSTER_H