ScummVM API documentation
GameEnemy_Dog.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_GAME_ENEMY_DOG_H
29 #define GAME_GAME_ENEMY_DOG_H
30 
31 #include "hpl1/engine/engine.h"
32 #include "hpl1/penumbra-overture/GameEnemy.h"
33 
34 using namespace hpl;
35 
36 //-----------------------------------------
37 
38 class cGameEnemy_Dog;
39 
40 // BASE STATE
42 public:
43  iGameEnemyState_Dog_Base(int alId, cInit *apInit, iGameEnemy *apEnemy);
44 
45  virtual void OnSeePlayer(const cVector3f &avPosition, float afChance);
46  virtual bool OnHearNoise(const cVector3f &avPosition, float afVolume);
47  virtual void OnTakeHit(float afDamage);
48  virtual void OnDeath(float afDamage);
49  virtual void OnFlashlight(const cVector3f &avPosition);
50 
51  virtual void OnAnimationOver(const tString &asAnimName) {}
52 
53  virtual void OnDraw() {}
54  virtual void OnPostSceneDraw() {}
55 
56 protected:
57  cGameEnemy_Dog *mpEnemyDog;
58 };
59 
60 //-----------------------------------------
61 
62 // IDLE STATE
64 public:
65  cGameEnemyState_Dog_Idle(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
66 
67  void OnEnterState(iGameEnemyState *apPrevState);
68  void OnLeaveState(iGameEnemyState *apNextState);
69 
70  void OnUpdate(float afTimeStep);
71 };
72 
73 //-----------------------------------------
74 
75 // ATTENTION STATE
77 public:
78  cGameEnemyState_Dog_Attention(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
79 
80  void OnEnterState(iGameEnemyState *apPrevState);
81  void OnLeaveState(iGameEnemyState *apNextState);
82 
83  void OnUpdate(float afTimeStep);
84 
85  void OnSeePlayer(const cVector3f &avPosition, float afChance);
86  bool OnHearNoise(const cVector3f &avPosition, float afVolume);
87  void OnFlashlight(const cVector3f &avPosition);
88 
89  void OnDraw();
90 
91 private:
92  float mfTime;
93 };
94 
95 //-----------------------------------------
96 
97 // HUNT STATE
99 public:
100  cGameEnemyState_Dog_Hunt(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {
101  mbBreakingDoor = false;
102  }
103 
104  void OnEnterState(iGameEnemyState *apPrevState);
105  void OnLeaveState(iGameEnemyState *apNextState);
106 
107  void OnUpdate(float afTimeStep);
108 
109  void OnSeePlayer(const cVector3f &avPosition, float afChance);
110  bool OnHearNoise(const cVector3f &avPosition, float afVolume);
111  void OnFlashlight(const cVector3f &avPosition) {}
112 
113  void OnDraw();
114 
115 private:
116  float mfUpdatePathCount;
117  float mfUpdateFreq;
118  bool mbFreePlayerPath;
119  bool mbLostPlayer;
120  float mfLostPlayerCount;
121  float mfMaxLostPlayerCount;
122  bool mbFoundNoPath;
123 
124  int mlStuckAtMaxCount;
125 
126  int mlBreakDoorCount;
127  bool mbBreakingDoor;
128 };
129 
130 //-----------------------------------------
131 
132 // ATTACK STATE
134 public:
135  cGameEnemyState_Dog_Attack(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
136 
137  void OnEnterState(iGameEnemyState *apPrevState);
138  void OnLeaveState(iGameEnemyState *apNextState);
139 
140  void OnUpdate(float afTimeStep);
141 
142  void OnAnimationOver(const tString &asName);
143 
144  void OnPostSceneDraw();
145 
146  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
147  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
148  void OnFlashlight(const cVector3f &avPosition) {}
149 
150 private:
151  float mfDamageTimer;
152  float mfJumpTimer;
153  bool mbAttacked;
154 };
155 
156 //-----------------------------------------
157 
158 // BREAK DOOR STATE
160 public:
161  cGameEnemyState_Dog_BreakDoor(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
162 
163  void OnEnterState(iGameEnemyState *apPrevState);
164  void OnLeaveState(iGameEnemyState *apNextState);
165 
166  void OnUpdate(float afTimeStep);
167 
168  void OnAnimationOver(const tString &asName);
169 
170  void OnPostSceneDraw();
171 
172  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
173  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
174  void OnFlashlight(const cVector3f &avPosition) {}
175 
176 private:
177  float mfDamageTimer;
178  float mfStopMoveTimer;
179  bool mbAttacked;
180  bool mbStopped;
181  int mlCount;
182 };
183 
184 //-----------------------------------------
185 
186 // FLEE STATE
188 public:
189  cGameEnemyState_Dog_Flee(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
190 
191  void OnEnterState(iGameEnemyState *apPrevState);
192  void OnLeaveState(iGameEnemyState *apNextState);
193 
194  void OnUpdate(float afTimeStep);
195 
196  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
197  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
198  void OnFlashlight(const cVector3f &avPosition) {}
199 
200 private:
201  float mfTimer;
202  float mfBackAngle;
203  bool mbBackwards;
204  float mfCheckBehindTime;
205  bool mbBackingFromBreakDoor;
206 };
207 
208 //-----------------------------------------
209 
210 // CALL BACKUP STATE
212 public:
213  cGameEnemyState_Dog_CallBackup(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
214 
215  void OnEnterState(iGameEnemyState *apPrevState);
216  void OnLeaveState(iGameEnemyState *apNextState);
217 
218  void OnUpdate(float afTimeStep);
219 
220  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
221  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
222  // void OnTakeHit(float afDamage){}
223  void OnFlashlight(const cVector3f &avPosition) {}
224 
225  void OnAnimationOver(const tString &asName);
226 
227 private:
228  // bool mbCheckAnim;
229 };
230 
231 //-----------------------------------------
232 
233 // KNOCKDOWN STATE
235 public:
236  cGameEnemyState_Dog_KnockDown(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
237 
238  void OnEnterState(iGameEnemyState *apPrevState);
239  void OnLeaveState(iGameEnemyState *apNextState);
240 
241  void OnUpdate(float afTimeStep);
242 
243  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
244  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
245  void OnTakeHit(float afDamage) {}
246  void OnFlashlight(const cVector3f &avPosition) {}
247 
248  void OnAnimationOver(const tString &asName);
249 
250 private:
251  float mfTimer;
252  bool mbCheckAnim;
253  int mlPrevToughness;
254 
255  // int mlStuckAtMaxCount;
256 };
257 
258 //-----------------------------------------
259 
260 // DEAD STATE
262 public:
263  cGameEnemyState_Dog_Dead(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
264 
265  void OnEnterState(iGameEnemyState *apPrevState);
266  void OnLeaveState(iGameEnemyState *apNextState);
267 
268  void OnUpdate(float afTimeStep);
269 
270  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
271  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
272  void OnTakeHit(float afDamage) {}
273  void OnFlashlight(const cVector3f &avPosition) {}
274 };
275 
276 //-----------------------------------------
277 
278 // PATROL STATE
280 public:
281  cGameEnemyState_Dog_Patrol(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
282 
283  void OnEnterState(iGameEnemyState *apPrevState);
284  void OnLeaveState(iGameEnemyState *apNextState);
285 
286  void OnUpdate(float afTimeStep);
287 
288  void OnAnimationOver(const tString &asName);
289 
290 private:
291  bool mbWaiting;
292  bool mbAnimation;
293 
294  float mfIdleSoundTime;
295 
296  int mlStuckAtMaxCount;
297 };
298 
299 //-----------------------------------------
300 
301 // INVESTIGATE STATE
303 public:
304  cGameEnemyState_Dog_Investigate(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {
305  mlKnockCount = 0;
306  }
307 
308  void OnEnterState(iGameEnemyState *apPrevState);
309  void OnLeaveState(iGameEnemyState *apNextState);
310 
311  void OnUpdate(float afTimeStep);
312 
313  bool OnHearNoise(const cVector3f &avPosition, float afVolume);
314 
315  float mfIdleSoundTime;
316  float mfHearSoundCount;
317  float mfHighestVolume;
318 
319  int mlKnockCount;
320 };
321 
322 //-----------------------------------------
323 
324 // MOVETO STATE
326 public:
327  cGameEnemyState_Dog_MoveTo(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
328 
329  void OnEnterState(iGameEnemyState *apPrevState);
330  void OnLeaveState(iGameEnemyState *apNextState);
331 
332  void OnUpdate(float afTimeStep);
333 
334  float mfIdleSoundTime;
335  int mlBreakCount;
336 };
337 
338 //-----------------------------------------
339 
340 // EAT STATE
342 public:
343  cGameEnemyState_Dog_Eat(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Dog_Base(alId, apInit, apEnemy) {}
344 
345  void OnEnterState(iGameEnemyState *apPrevState);
346  void OnLeaveState(iGameEnemyState *apNextState);
347 
348  void OnUpdate(float afTimeStep);
349 
350  bool OnHearNoise(const cVector3f &avPosition, float afVolume);
351  void OnSeePlayer(const cVector3f &avPosition, float afChance);
352 
353  float mfTime;
354 };
355 
356 //-----------------------------------------
357 
358 class cGameEnemy_Dog : public iGameEnemy {
359 public:
360  cGameEnemy_Dog(cInit *apInit, const tString &asName, TiXmlElement *apGameElem);
361  ~cGameEnemy_Dog();
362 
363  void OnLoad();
364 
365  void OnUpdate(float afTimeStep);
366 
367  void ShowPlayer(const cVector3f &avPlayerFeetPos);
368 
369  bool MoveToPos(const cVector3f &avFeetPos);
370 
371  bool IsFighting();
372 
373  iCollideShape *GetAttackShape() { return mpAttackShape; }
374  iCollideShape *GetBreakDoorShape() { return mpBreakDoorShape; }
375 
376  float mfMinKnockDamage;
377  float mfCertainKnockDamage;
378 
379  float mfLengthBodyToAss;
380 
381  // State properties
382  float mfIdleFOV;
383  tString msIdleFoundPlayerSound;
384  float mfIdleMinSeeChance;
385  float mfIdleMinHearVolume;
386  tString msIdleSound;
387  float mfIdleSoundMinInteraval;
388  float mfIdleSoundMaxInteraval;
389  float mfIdleCallBackupChance;
390 
391  tString msInvestigateSound;
392 
393  tString msAttentionSound;
394  float mfAttentionTime;
395  float mfAttentionMinDist;
396 
397  float mfHuntFOV;
398  float mfHuntSpeed;
399  float mfHuntForLostPlayerTime;
400  float mfHuntMinSeeChance;
401  float mfHuntMinHearVolume;
402 
403  float mfAttackDistance;
404  float mfAttackSpeed;
405  float mfAttackJumpTime;
406  float mfAttackDamageTime;
407  cVector3f mvAttackDamageSize;
408  float mfAttackDamageRange;
409  float mfAttackMinDamage;
410  float mfAttackMaxDamage;
411  tString msAttackStartSound;
412  tString msAttackHitSound;
413  float mfAttackMinMass;
414  float mfAttackMaxMass;
415  float mfAttackMinImpulse;
416  float mfAttackMaxImpulse;
417  int mlAttackStrength;
418 
419  tString msBreakDoorAnimation;
420  float mfBreakDoorSpeed;
421  float mfBreakDoorDamageTime;
422  cVector3f mvBreakDoorDamageSize;
423  float mfBreakDoorDamageRange;
424  float mfBreakDoorMinDamage;
425  float mfBreakDoorMaxDamage;
426  tString msBreakDoorStartSound;
427  tString msBreakDoorHitSound;
428  float mfBreakDoorMinMass;
429  float mfBreakDoorMaxMass;
430  float mfBreakDoorMinImpulse;
431  float mfBreakDoorMaxImpulse;
432  int mlBreakDoorStrength;
433  bool mbBreakDoorRiseAtEnd;
434 
435  tString msKnockDownSound;
436 
437  tString msDeathSound;
438 
439  float mfFleePositionChance;
440  float mfFleePositionMaxTime;
441  float mfFleePositionMinDistance;
442  float mfFleePositionMaxDistance;
443  float mfFleeBackChance;
444  float mfFleeBackTime;
445  float mfFleeBackSpeed;
446 
447  tString msCallBackupAnimation;
448  tString msCallBackupSound;
449  float mfCallBackupRange;
450 
451  float mfEatFOV;
452  float mfEatMinSeeChance;
453  float mfEatMinHearVolume;
454 
455 private:
456  iCollideShape *mpAttackShape;
457  iCollideShape *mpBreakDoorShape;
458 };
459 
460 //-----------------------------------------
461 
462 #endif // GAME_GAME_ENEMY_DOG_H
Definition: AI.h:36
Definition: GameEnemy_Dog.h:234
Definition: str.h:59
Definition: GameEnemy_Dog.h:261
Definition: GameEnemy_Dog.h:211
Definition: GameEnemy_Dog.h:302
Definition: GameEnemy_Dog.h:279
Definition: GameEnemy_Dog.h:133
Definition: GameEnemy_Dog.h:159
Definition: CollideShape.h:50
Definition: GameEnemy_Dog.h:63
Definition: GameEnemy_Dog.h:41
Definition: tinyxml.h:864
Definition: GameEnemy.h:152
Definition: GameEnemy_Dog.h:325
Definition: GameEnemy_Dog.h:358
Definition: GameEnemy_Dog.h:187
Definition: GameEnemy.h:189
Definition: GameEnemy_Dog.h:76
Definition: GameEnemy_Dog.h:98
Definition: GameEnemy_Dog.h:341
Definition: Init.h:70