forked from FrictionalGames/PenumbraOverture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameEnemy_Dog.h
477 lines (360 loc) · 12.3 KB
/
GameEnemy_Dog.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
/*
* Copyright (C) 2006-2010 - Frictional Games
*
* This file is part of Penumbra Overture.
*
* Penumbra Overture is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Penumbra Overture is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Penumbra Overture. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAME_GAME_ENEMY_DOG_H
#define GAME_GAME_ENEMY_DOG_H
#include "StdAfx.h"
#include "GameEnemy.h"
using namespace hpl;
//-----------------------------------------
class cGameEnemy_Dog;
// BASE STATE
class iGameEnemyState_Dog_Base : public iGameEnemyState
{
public:
iGameEnemyState_Dog_Base(int alId, cInit *apInit, iGameEnemy *apEnemy);
virtual void OnSeePlayer(const cVector3f &avPosition, float afChance);
virtual bool OnHearNoise(const cVector3f &avPosition, float afVolume);
virtual void OnTakeHit(float afDamage);
virtual void OnDeath(float afDamage);
virtual void OnFlashlight(const cVector3f &avPosition);
virtual void OnAnimationOver(const tString& asAnimName){}
virtual void OnDraw(){}
virtual void OnPostSceneDraw(){}
protected:
cGameEnemy_Dog *mpEnemyDog;
};
//-----------------------------------------
// IDLE STATE
class cGameEnemyState_Dog_Idle : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Idle(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
};
//-----------------------------------------
// ATTENTION STATE
class cGameEnemyState_Dog_Attention : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Attention(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnSeePlayer(const cVector3f &avPosition, float afChance);
bool OnHearNoise(const cVector3f &avPosition, float afVolume);
void OnFlashlight(const cVector3f &avPosition);
void OnDraw();
private:
float mfTime;
};
//-----------------------------------------
// HUNT STATE
class cGameEnemyState_Dog_Hunt : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Hunt(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){
mbBreakingDoor = false;
}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnSeePlayer(const cVector3f &avPosition, float afChance);
bool OnHearNoise(const cVector3f &avPosition, float afVolume);
void OnFlashlight(const cVector3f &avPosition){}
void OnDraw();
private:
float mfUpdatePathCount;
float mfUpdateFreq;
bool mbFreePlayerPath;
bool mbLostPlayer;
float mfLostPlayerCount;
float mfMaxLostPlayerCount;
bool mbFoundNoPath;
int mlStuckAtMaxCount;
int mlBreakDoorCount;
bool mbBreakingDoor;
};
//-----------------------------------------
// ATTACK STATE
class cGameEnemyState_Dog_Attack : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Attack(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnAnimationOver(const tString &asName);
void OnPostSceneDraw();
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
void OnFlashlight(const cVector3f &avPosition){}
private:
float mfDamageTimer;
float mfJumpTimer;
bool mbAttacked;
};
//-----------------------------------------
// BREAK DOOR STATE
class cGameEnemyState_Dog_BreakDoor : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_BreakDoor(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnAnimationOver(const tString &asName);
void OnPostSceneDraw();
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
void OnFlashlight(const cVector3f &avPosition){}
private:
float mfDamageTimer;
float mfStopMoveTimer;
bool mbAttacked;
bool mbStopped;
int mlCount;
};
//-----------------------------------------
// FLEE STATE
class cGameEnemyState_Dog_Flee : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Flee(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
void OnFlashlight(const cVector3f &avPosition){}
private:
float mfTimer;
float mfBackAngle;
bool mbBackwards;
float mfCheckBehindTime;
bool mbBackingFromBreakDoor;
};
//-----------------------------------------
// CALL BACKUP STATE
class cGameEnemyState_Dog_CallBackup : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_CallBackup(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
//void OnTakeHit(float afDamage){}
void OnFlashlight(const cVector3f &avPosition){}
void OnAnimationOver(const tString &asName);
private:
bool mbCheckAnim;
};
//-----------------------------------------
// KNOCKDOWN STATE
class cGameEnemyState_Dog_KnockDown : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_KnockDown(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
void OnTakeHit(float afDamage){}
void OnFlashlight(const cVector3f &avPosition){}
void OnAnimationOver(const tString &asName);
private:
float mfTimer;
bool mbCheckAnim;
int mlPrevToughness;
int mlStuckAtMaxCount;
};
//-----------------------------------------
// DEAD STATE
class cGameEnemyState_Dog_Dead : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Dead(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnSeePlayer(const cVector3f &avPosition, float afChance){}
bool OnHearNoise(const cVector3f &avPosition, float afVolume){return false;}
void OnTakeHit(float afDamage){}
void OnFlashlight(const cVector3f &avPosition){}
};
//-----------------------------------------
// PATROL STATE
class cGameEnemyState_Dog_Patrol : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Patrol(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
void OnAnimationOver(const tString &asName);
private:
bool mbWaiting;
bool mbAnimation;
float mfIdleSoundTime;
int mlStuckAtMaxCount;
};
//-----------------------------------------
// INVESTIGATE STATE
class cGameEnemyState_Dog_Investigate : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Investigate(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){
mlKnockCount =0;
}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
bool OnHearNoise(const cVector3f &avPosition, float afVolume);
float mfIdleSoundTime;
float mfHearSoundCount;
float mfHighestVolume;
int mlKnockCount;
};
//-----------------------------------------
// MOVETO STATE
class cGameEnemyState_Dog_MoveTo : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_MoveTo(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
float mfIdleSoundTime;
int mlBreakCount;
};
//-----------------------------------------
// EAT STATE
class cGameEnemyState_Dog_Eat : public iGameEnemyState_Dog_Base
{
public:
cGameEnemyState_Dog_Eat(int alId, cInit *apInit, iGameEnemy *apEnemy) :
iGameEnemyState_Dog_Base(alId, apInit,apEnemy){}
void OnEnterState(iGameEnemyState *apPrevState);
void OnLeaveState(iGameEnemyState *apNextState);
void OnUpdate(float afTimeStep);
bool OnHearNoise(const cVector3f &avPosition, float afVolume);
void OnSeePlayer(const cVector3f &avPosition, float afChance);
float mfTime;
};
//-----------------------------------------
class cGameEnemy_Dog : public iGameEnemy
{
public:
cGameEnemy_Dog(cInit *apInit,const tString& asName,TiXmlElement *apGameElem);
~cGameEnemy_Dog();
void OnLoad();
void OnUpdate(float afTimeStep);
void ShowPlayer(const cVector3f& avPlayerFeetPos);
bool MoveToPos(const cVector3f& avFeetPos);
bool IsFighting();
iCollideShape *GetAttackShape(){ return mpAttackShape;}
iCollideShape *GetBreakDoorShape(){ return mpBreakDoorShape;}
float mfMinKnockDamage;
float mfCertainKnockDamage;
float mfLengthBodyToAss;
//State properties
float mfIdleFOV;
tString msIdleFoundPlayerSound;
float mfIdleMinSeeChance;
float mfIdleMinHearVolume;
tString msIdleSound;
float mfIdleSoundMinInteraval;
float mfIdleSoundMaxInteraval;
float mfIdleCallBackupChance;
tString msInvestigateSound;
tString msAttentionSound;
float mfAttentionTime;
float mfAttentionMinDist;
float mfHuntFOV;
float mfHuntSpeed;
float mfHuntForLostPlayerTime;
float mfHuntMinSeeChance;
float mfHuntMinHearVolume;
float mfAttackDistance;
float mfAttackSpeed;
float mfAttackJumpTime;
float mfAttackDamageTime;
cVector3f mvAttackDamageSize;
float mfAttackDamageRange;
float mfAttackMinDamage;
float mfAttackMaxDamage;
tString msAttackStartSound;
tString msAttackHitSound;
float mfAttackMinMass;
float mfAttackMaxMass;
float mfAttackMinImpulse;
float mfAttackMaxImpulse;
int mlAttackStrength;
tString msBreakDoorAnimation;
float mfBreakDoorSpeed;
float mfBreakDoorDamageTime;
cVector3f mvBreakDoorDamageSize;
float mfBreakDoorDamageRange;
float mfBreakDoorMinDamage;
float mfBreakDoorMaxDamage;
tString msBreakDoorStartSound;
tString msBreakDoorHitSound;
float mfBreakDoorMinMass;
float mfBreakDoorMaxMass;
float mfBreakDoorMinImpulse;
float mfBreakDoorMaxImpulse;
int mlBreakDoorStrength;
bool mbBreakDoorRiseAtEnd;
tString msKnockDownSound;
tString msDeathSound;
float mfFleePositionChance;
float mfFleePositionMaxTime;
float mfFleePositionMinDistance;
float mfFleePositionMaxDistance;
float mfFleeBackChance;
float mfFleeBackTime;
float mfFleeBackSpeed;
tString msCallBackupAnimation;
tString msCallBackupSound;
float mfCallBackupRange;
float mfEatFOV;
float mfEatMinSeeChance;
float mfEatMinHearVolume;
private:
iCollideShape *mpAttackShape;
iCollideShape *mpBreakDoorShape;
};
//-----------------------------------------
#endif // GAME_GAME_ENEMY_DOG_H