2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __GAME_ACTOR_H__
30 #define __GAME_ACTOR_H__
33 ===============================================================================
37 ===============================================================================
40 extern const idEventDef AI_EnableEyeFocus;
41 extern const idEventDef AI_DisableEyeFocus;
42 extern const idEventDef EV_Footstep;
43 extern const idEventDef EV_FootstepLeft;
44 extern const idEventDef EV_FootstepRight;
45 extern const idEventDef EV_EnableWalkIK;
46 extern const idEventDef EV_DisableWalkIK;
47 extern const idEventDef EV_EnableLegIK;
48 extern const idEventDef EV_DisableLegIK;
49 extern const idEventDef AI_SetAnimPrefix;
50 extern const idEventDef AI_PlayAnim;
51 extern const idEventDef AI_PlayCycle;
52 extern const idEventDef AI_AnimDone;
53 extern const idEventDef AI_SetBlendFrames;
54 extern const idEventDef AI_GetBlendFrames;
57 extern const idEventDef AI_SetState;
67 int lastAnimBlendFrames; // allows override anims to blend based on the last transition time
73 void Save( idSaveGame *savefile ) const;
74 void Restore( idRestoreGame *savefile );
76 void Init( idActor *owner, idAnimator *_animator, int animchannel );
77 void Shutdown( void );
78 void SetState( const char *name, int blendFrames );
79 void StopAnim( int frames );
80 void PlayAnim( int anim );
81 void CycleAnim( int anim );
82 void BecomeIdle( void );
83 bool UpdateState( void );
84 bool Disabled( void ) const;
85 void Enable( int blendFrames );
87 bool AnimDone( int blendFrames ) const;
88 bool IsIdle( void ) const;
89 animFlags_t GetAnimFlags( void ) const;
93 idAnimator * animator;
101 idEntityPtr<idEntity> ent;
106 jointModTransform_t mod;
111 class idActor : public idAFEntity_Gibbable {
113 CLASS_PROTOTYPE( idActor );
116 int rank; // monsters don't fight back if the attacker's rank is higher
117 idMat3 viewAxis; // view axis of the actor
119 idLinkList<idActor> enemyNode; // node linked into an entity's enemy list for quick lookups of who is attacking him
120 idLinkList<idActor> enemyList; // list of characters that have targeted the player as their enemy
124 virtual ~idActor( void );
127 virtual void Restart( void );
129 void Save( idSaveGame *savefile ) const;
130 void Restore( idRestoreGame *savefile );
132 virtual void Hide( void );
133 virtual void Show( void );
134 virtual int GetDefaultSurfaceType( void ) const;
135 virtual void ProjectOverlay( const idVec3 &origin, const idVec3 &dir, float size, const char *material );
137 virtual bool LoadAF( void );
138 void SetupBody( void );
140 void CheckBlink( void );
142 virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
143 virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
145 // script state management
146 void ShutdownThreads( void );
147 virtual bool ShouldConstructScriptObjectAtSpawn( void ) const;
148 virtual idThread * ConstructScriptObject( void );
149 void UpdateScript( void );
150 const function_t *GetScriptFunction( const char *funcname );
151 void SetState( const function_t *newState );
152 void SetState( const char *statename );
155 void SetEyeHeight( float height );
156 float EyeHeight( void ) const;
157 idVec3 EyeOffset( void ) const;
158 idVec3 GetEyePosition( void ) const;
159 virtual void GetViewPos( idVec3 &origin, idMat3 &axis ) const;
160 void SetFOV( float fov );
161 bool CheckFOV( const idVec3 &pos ) const;
162 bool CanSee( idEntity *ent, bool useFOV ) const;
163 bool PointVisible( const idVec3 &point ) const;
164 virtual void GetAIAimTargets( const idVec3 &lastSightPos, idVec3 &headPos, idVec3 &chestPos );
167 void SetupDamageGroups( void );
168 virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
169 int GetDamageForLocation( int damage, int location );
170 const char * GetDamageGroup( int location );
171 void ClearPain( void );
172 virtual bool Pain( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
174 // model/combat model/ragdoll
175 void SetCombatModel( void );
176 idClipModel * GetCombatModel( void ) const;
177 virtual void LinkCombat( void );
178 virtual void UnlinkCombat( void );
179 bool StartRagdoll( void );
180 void StopRagdoll( void );
181 virtual bool UpdateAnimationControllers( void );
183 // delta view angles to allow movers to rotate the view of the actor
184 const idAngles & GetDeltaViewAngles( void ) const;
185 void SetDeltaViewAngles( const idAngles &delta );
187 bool HasEnemies( void ) const;
188 idActor * ClosestEnemyToPoint( const idVec3 &pos );
189 idActor * EnemyWithMostHealth();
191 virtual bool OnLadder( void ) const;
193 virtual void GetAASLocation( idAAS *aas, idVec3 &pos, int &areaNum ) const;
195 void Attach( idEntity *ent );
197 virtual void Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
199 virtual renderView_t * GetRenderView();
201 // animation state control
202 int GetAnim( int channel, const char *name );
203 void UpdateAnimState( void );
204 void SetAnimState( int channel, const char *name, int blendFrames );
205 const char * GetAnimState( int channel ) const;
206 bool InAnimState( int channel, const char *name ) const;
207 const char * WaitState( void ) const;
208 void SetWaitState( const char *_waitstate );
209 bool AnimDone( int channel, int blendFrames ) const;
210 virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName );
213 idEntity* GetHeadEntity() { return head.GetEntity(); };
217 friend class idAnimState;
219 float fovDot; // cos( fovDegrees )
220 idVec3 eyeOffset; // offset of eye relative to physics origin
221 idVec3 modelOffset; // offset of visual model relative to the physics origin
223 idAngles deltaViewAngles; // delta angles relative to view input angles
225 int pain_debounce_time; // next time the actor can show pain
226 int pain_delay; // time between playing pain sound
227 int pain_threshold; // how much damage monster can take at any one time before playing pain animation
229 idStrList damageGroups; // body damage groups
230 idList<float> damageScale; // damage scale per damage gruop
232 bool use_combat_bbox; // whether to use the bounding box for combat collision
233 idEntityPtr<idAFAttachment> head;
234 idList<copyJoints_t> copyJoints; // copied from the body animation to the head model
237 const function_t *state;
238 const function_t *idealState;
241 jointHandle_t leftEyeJoint;
242 jointHandle_t rightEyeJoint;
243 jointHandle_t soundJoint;
257 idThread * scriptThread;
259 idAnimState headAnim;
260 idAnimState torsoAnim;
261 idAnimState legsAnim;
269 idList<idAttachInfo> attachments;
275 virtual void Gib( const idVec3 &dir, const char *damageDefName );
277 // removes attachments with "remove" set for when character dies
278 void RemoveAttachments( void );
280 // copies animation from body to head joints
281 void CopyJointsFromBodyToHead( void );
284 void SyncAnimChannels( int channel, int syncToChannel, int blendFrames );
285 void FinishSetup( void );
286 void SetupHead( void );
287 void PlayFootStepSound( void );
289 void Event_EnableEyeFocus( void );
290 void Event_DisableEyeFocus( void );
291 void Event_Footstep( void );
292 void Event_EnableWalkIK( void );
293 void Event_DisableWalkIK( void );
294 void Event_EnableLegIK( int num );
295 void Event_DisableLegIK( int num );
296 void Event_SetAnimPrefix( const char *name );
297 void Event_LookAtEntity( idEntity *ent, float duration );
298 void Event_PreventPain( float duration );
299 void Event_DisablePain( void );
300 void Event_EnablePain( void );
301 void Event_GetPainAnim( void );
302 void Event_StopAnim( int channel, int frames );
303 void Event_PlayAnim( int channel, const char *name );
304 void Event_PlayCycle( int channel, const char *name );
305 void Event_IdleAnim( int channel, const char *name );
306 void Event_SetSyncedAnimWeight( int channel, int anim, float weight );
307 void Event_OverrideAnim( int channel );
308 void Event_EnableAnim( int channel, int blendFrames );
309 void Event_SetBlendFrames( int channel, int blendFrames );
310 void Event_GetBlendFrames( int channel );
311 void Event_AnimState( int channel, const char *name, int blendFrames );
312 void Event_GetAnimState( int channel );
313 void Event_InAnimState( int channel, const char *name );
314 void Event_FinishAction( const char *name );
315 void Event_AnimDone( int channel, int blendFrames );
316 void Event_HasAnim( int channel, const char *name );
317 void Event_CheckAnim( int channel, const char *animname );
318 void Event_ChooseAnim( int channel, const char *animname );
319 void Event_AnimLength( int channel, const char *animname );
320 void Event_AnimDistance( int channel, const char *animname );
321 void Event_HasEnemies( void );
322 void Event_NextEnemy( idEntity *ent );
323 void Event_ClosestEnemyToPoint( const idVec3 &pos );
324 void Event_StopSound( int channel, int netsync );
325 void Event_SetNextState( const char *name );
326 void Event_SetState( const char *name );
327 void Event_GetState( void );
328 void Event_GetHead( void );
330 void Event_SetDamageGroupScale( const char* groupName, float scale);
331 void Event_SetDamageGroupScaleAll( float scale );
332 void Event_GetDamageGroupScale( const char* groupName );
333 void Event_SetDamageCap( float _damageCap );
334 void Event_SetWaitState( const char* waitState);
335 void Event_GetWaitState();
340 #endif /* !__GAME_ACTOR_H__ */