ScummVM API documentation
GameEnemy_Worm.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_WORM_H
29 #define GAME_GAME_ENEMY_WORM_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_Worm;
39 
40 // BASE STATE
42 public:
43  iGameEnemyState_Worm_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_Worm *mpEnemyWorm;
58 };
59 
60 //-----------------------------------------
61 
62 // IDLE STATE
64 public:
65  cGameEnemyState_Worm_Idle(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Worm_Base(alId, apInit, apEnemy) {}
66 
67  void OnEnterState(iGameEnemyState *apPrevState);
68  void OnLeaveState(iGameEnemyState *apNextState);
69 
70  void OnUpdate(float afTimeStep);
71 
72  // void OnSeePlayer(const cVector3f &avPosition, float afChance){}
73 
74 private:
75  bool mbStopped;
76  float mfNextWalkTime;
77 };
78 
79 //-----------------------------------------
80 
81 // HUNT STATE
83 public:
84  cGameEnemyState_Worm_Hunt(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Worm_Base(alId, apInit, apEnemy) {}
85 
86  void OnEnterState(iGameEnemyState *apPrevState);
87  void OnLeaveState(iGameEnemyState *apNextState);
88 
89  void OnUpdate(float afTimeStep);
90 
91  void OnSeePlayer(const cVector3f &avPosition, float afChance);
92  bool OnHearNoise(const cVector3f &avPosition, float afVolume);
93 
94  void OnDraw();
95  void OnPostSceneDraw();
96 
97 private:
98  float mfUpdatePathCount;
99  float mfUpdateFreq;
100  bool mbFreePlayerPath;
101  bool mbLostPlayer;
102  float mfLostPlayerCount;
103  float mfMaxLostPlayerCount;
104  float mfAttackSoundCount;
105 
106  float mfAttackCount;
107 
108  float mfSoundCount;
109 };
110 
111 //-----------------------------------------
112 
113 // DEAD STATE
115 public:
116  cGameEnemyState_Worm_Dead(int alId, cInit *apInit, iGameEnemy *apEnemy) : iGameEnemyState_Worm_Base(alId, apInit, apEnemy) {}
117 
118  void OnEnterState(iGameEnemyState *apPrevState);
119  void OnLeaveState(iGameEnemyState *apNextState);
120 
121  void OnUpdate(float afTimeStep) {}
122 
123  void OnSeePlayer(const cVector3f &avPosition, float afChance) {}
124  bool OnHearNoise(const cVector3f &avPosition, float afVolume) { return false; }
125 
126 private:
127 };
128 
129 //-----------------------------------------
130 
132 public:
133  cWormTailSegment() {
134  mpBone = NULL;
135  mpChildSegment = NULL;
136  }
137 
138  Common::List<cVector3f> mlstPositions;
139  cVector3f mvPosition;
140 
141  cVector3f mvGoalForward;
142 
143  cVector3f mvForward;
144  cVector3f mvUp;
145  cVector3f mvRight;
146 
147  float mfDistToFront;
148 
149  iPhysicsBody *mpBody;
150 
151  cBoneState *mpBone;
152 
153  cMatrixf m_mtxBaseRot;
154 
155  cWormTailSegment *mpChildSegment;
156 };
157 
158 //-----------------------------------------
159 
161 public:
163 
164  void AfterAnimationUpdate(cMeshEntity *apMeshEntity, float afTimeStep);
165 
166 private:
167  cGameEnemy_Worm *mpWorm;
168 };
169 
170 //-----------------------------------------
171 
173 public:
175 
176  void Add(const cVector3f &avVec);
177  cVector3f GetAverage();
178 
179  void SetMax(int alMax) { mlMaxVecs = alMax; }
180 
181 private:
182  int mlMaxVecs;
183  Common::List<cVector3f> mlstVecs;
184 };
185 
186 //-----------------------------------------
187 
188 class cGameEnemy_Worm : public iGameEnemy {
189  friend class cGameEnemy_Worm_MeshCallback;
190 
191 public:
192  cGameEnemy_Worm(cInit *apInit, const tString &asName, TiXmlElement *apGameElem);
193  ~cGameEnemy_Worm();
194 
195  void OnLoad();
196 
197  void OnUpdate(float afTimeStep);
198 
199  void ExtraPostSceneDraw();
200 
201  void ShowPlayer(const cVector3f &avPlayerFeetPos);
202 
203  bool MoveToPos(const cVector3f &avFeetPos);
204 
205  bool IsFighting();
206 
207  iCollideShape *GetAttackShape() { return mpAttackShape; }
208 
209  // Worm specific
210  void SetupTail();
211 
212  cSoundEntity *mpMoveSound;
213 
214  // State properties
215  tString msMoveSound;
216 
217  float mfIdleFOV;
218  tString msIdleFoundPlayerSound;
219  float mfIdleMinSeeChance;
220  float mfIdleMinHearVolume;
221  float mfIdleMinWaitLength;
222  float mfIdleMaxWaitLength;
223 
224  float mfHuntFOV;
225  float mfHuntSpeed;
226  float mfHuntForLostPlayerTime;
227  float mfHuntMinSeeChance;
228  float mfHuntMinHearVolume;
229 
230  tString msHuntSound;
231  float mfHuntSoundMinInteraval;
232  float mfHuntSoundMaxInteraval;
233 
234  float mfAttackDamage;
235  float mfAttackInterval;
236  tString msAttackHitSound;
237  float mfAttackHitSoundInterval;
238  float mfAttackMinMass;
239  float mfAttackMaxMass;
240  float mfAttackMinImpulse;
241  float mfAttackMaxImpulse;
242  int mlAttackStrength;
243 
244  cVector3f mvAttackDamageSize;
245 
246 private:
247  iCollideShape *mpAttackShape;
248 
249  cBoneState *mpRootBone;
250  Common::List<cVector3f> mlstRootPositions;
251  cVector3Smoother mRootForwards;
252  cVector3f mvRootPosition;
253  cVector3f mvRootGoalForward;
254  cVector3f mvRootForward;
255  cVector3f mvRootRight;
256  cVector3f mvRootUp;
257 
258  cVector3f mvRootBaseForward;
259 
260  cVector3f mvLastForward;
261 
262  int mlMaxSegmentPositions;
263  float mfTurnSpeed;
264 
265  bool mbFirstUpdate;
266  cVector3f mvFirstUpdatePos;
267 
268  cGameEnemy_Worm_MeshCallback *mpMeshCallback;
269 
270  cWormTailSegment *mpRootSegment;
271  Common::Array<cWormTailSegment *> mvTailSegments;
272 };
273 
274 //-----------------------------------------
275 
276 #endif // GAME_GAME_ENEMY_WORM_H
Definition: AI.h:36
Definition: GameEnemy_Worm.h:41
Definition: str.h:59
Definition: array.h:52
Definition: GameEnemy_Worm.h:160
Definition: GameEnemy_Worm.h:172
Definition: CollideShape.h:50
Definition: PhysicsBody.h:117
Definition: GameEnemy_Worm.h:114
Definition: MeshEntity.h:71
Definition: GameEnemy_Worm.h:82
Definition: BoneState.h:37
Definition: tinyxml.h:864
Definition: GameEnemy.h:152
Definition: MeshEntity.h:96
Definition: SoundEntity.h:86
Definition: GameEnemy_Worm.h:188
Definition: GameEnemy.h:189
Definition: GameEnemy_Worm.h:63
Definition: Init.h:70
Definition: GameEnemy_Worm.h:131