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;
63 int lastAnimBlendFrames; // allows override anims to blend based on the last transition time
69 void Save( idSaveGame *savefile ) const;
70 void Restore( idRestoreGame *savefile );
72 void Init( idActor *owner, idAnimator *_animator, int animchannel );
73 void Shutdown( void );
74 void SetState( const char *name, int blendFrames );
75 void StopAnim( int frames );
76 void PlayAnim( int anim );
77 void CycleAnim( int anim );
78 void BecomeIdle( void );
79 bool UpdateState( void );
80 bool Disabled( void ) const;
81 void Enable( int blendFrames );
83 bool AnimDone( int blendFrames ) const;
84 bool IsIdle( void ) const;
85 animFlags_t GetAnimFlags( void ) const;
89 idAnimator * animator;
97 idEntityPtr<idEntity> ent;
102 jointModTransform_t mod;
107 class idActor : public idAFEntity_Gibbable {
109 CLASS_PROTOTYPE( idActor );
112 int rank; // monsters don't fight back if the attacker's rank is higher
113 idMat3 viewAxis; // view axis of the actor
115 idLinkList<idActor> enemyNode; // node linked into an entity's enemy list for quick lookups of who is attacking him
116 idLinkList<idActor> enemyList; // list of characters that have targeted the player as their enemy
120 virtual ~idActor( void );
123 virtual void Restart( void );
125 void Save( idSaveGame *savefile ) const;
126 void Restore( idRestoreGame *savefile );
128 virtual void Hide( void );
129 virtual void Show( void );
130 virtual int GetDefaultSurfaceType( void ) const;
131 virtual void ProjectOverlay( const idVec3 &origin, const idVec3 &dir, float size, const char *material );
133 virtual bool LoadAF( void );
134 void SetupBody( void );
136 void CheckBlink( void );
138 virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
139 virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
141 // script state management
142 void ShutdownThreads( void );
143 virtual bool ShouldConstructScriptObjectAtSpawn( void ) const;
144 virtual idThread * ConstructScriptObject( void );
145 void UpdateScript( void );
146 const function_t *GetScriptFunction( const char *funcname );
147 void SetState( const function_t *newState );
148 void SetState( const char *statename );
151 void SetEyeHeight( float height );
152 float EyeHeight( void ) const;
153 idVec3 EyeOffset( void ) const;
154 idVec3 GetEyePosition( void ) const;
155 virtual void GetViewPos( idVec3 &origin, idMat3 &axis ) const;
156 void SetFOV( float fov );
157 bool CheckFOV( const idVec3 &pos ) const;
158 bool CanSee( idEntity *ent, bool useFOV ) const;
159 bool PointVisible( const idVec3 &point ) const;
160 virtual void GetAIAimTargets( const idVec3 &lastSightPos, idVec3 &headPos, idVec3 &chestPos );
163 void SetupDamageGroups( void );
164 virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
165 int GetDamageForLocation( int damage, int location );
166 const char * GetDamageGroup( int location );
167 void ClearPain( void );
168 virtual bool Pain( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
170 // model/combat model/ragdoll
171 void SetCombatModel( void );
172 idClipModel * GetCombatModel( void ) const;
173 virtual void LinkCombat( void );
174 virtual void UnlinkCombat( void );
175 bool StartRagdoll( void );
176 void StopRagdoll( void );
177 virtual bool UpdateAnimationControllers( void );
179 // delta view angles to allow movers to rotate the view of the actor
180 const idAngles & GetDeltaViewAngles( void ) const;
181 void SetDeltaViewAngles( const idAngles &delta );
183 bool HasEnemies( void ) const;
184 idActor * ClosestEnemyToPoint( const idVec3 &pos );
185 idActor * EnemyWithMostHealth();
187 virtual bool OnLadder( void ) const;
189 virtual void GetAASLocation( idAAS *aas, idVec3 &pos, int &areaNum ) const;
191 void Attach( idEntity *ent );
193 virtual void Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
195 virtual renderView_t * GetRenderView();
197 // animation state control
198 int GetAnim( int channel, const char *name );
199 void UpdateAnimState( void );
200 void SetAnimState( int channel, const char *name, int blendFrames );
201 const char * GetAnimState( int channel ) const;
202 bool InAnimState( int channel, const char *name ) const;
203 const char * WaitState( void ) const;
204 void SetWaitState( const char *_waitstate );
205 bool AnimDone( int channel, int blendFrames ) const;
206 virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName );
209 friend class idAnimState;
211 float fovDot; // cos( fovDegrees )
212 idVec3 eyeOffset; // offset of eye relative to physics origin
213 idVec3 modelOffset; // offset of visual model relative to the physics origin
215 idAngles deltaViewAngles; // delta angles relative to view input angles
217 int pain_debounce_time; // next time the actor can show pain
218 int pain_delay; // time between playing pain sound
219 int pain_threshold; // how much damage monster can take at any one time before playing pain animation
221 idStrList damageGroups; // body damage groups
222 idList<float> damageScale; // damage scale per damage gruop
224 bool use_combat_bbox; // whether to use the bounding box for combat collision
225 idEntityPtr<idAFAttachment> head;
226 idList<copyJoints_t> copyJoints; // copied from the body animation to the head model
229 const function_t *state;
230 const function_t *idealState;
233 jointHandle_t leftEyeJoint;
234 jointHandle_t rightEyeJoint;
235 jointHandle_t soundJoint;
249 idThread * scriptThread;
251 idAnimState headAnim;
252 idAnimState torsoAnim;
253 idAnimState legsAnim;
261 idList<idAttachInfo> attachments;
263 virtual void Gib( const idVec3 &dir, const char *damageDefName );
265 // removes attachments with "remove" set for when character dies
266 void RemoveAttachments( void );
268 // copies animation from body to head joints
269 void CopyJointsFromBodyToHead( void );
272 void SyncAnimChannels( int channel, int syncToChannel, int blendFrames );
273 void FinishSetup( void );
274 void SetupHead( void );
275 void PlayFootStepSound( void );
277 void Event_EnableEyeFocus( void );
278 void Event_DisableEyeFocus( void );
279 void Event_Footstep( void );
280 void Event_EnableWalkIK( void );
281 void Event_DisableWalkIK( void );
282 void Event_EnableLegIK( int num );
283 void Event_DisableLegIK( int num );
284 void Event_SetAnimPrefix( const char *name );
285 void Event_LookAtEntity( idEntity *ent, float duration );
286 void Event_PreventPain( float duration );
287 void Event_DisablePain( void );
288 void Event_EnablePain( void );
289 void Event_GetPainAnim( void );
290 void Event_StopAnim( int channel, int frames );
291 void Event_PlayAnim( int channel, const char *name );
292 void Event_PlayCycle( int channel, const char *name );
293 void Event_IdleAnim( int channel, const char *name );
294 void Event_SetSyncedAnimWeight( int channel, int anim, float weight );
295 void Event_OverrideAnim( int channel );
296 void Event_EnableAnim( int channel, int blendFrames );
297 void Event_SetBlendFrames( int channel, int blendFrames );
298 void Event_GetBlendFrames( int channel );
299 void Event_AnimState( int channel, const char *name, int blendFrames );
300 void Event_GetAnimState( int channel );
301 void Event_InAnimState( int channel, const char *name );
302 void Event_FinishAction( const char *name );
303 void Event_AnimDone( int channel, int blendFrames );
304 void Event_HasAnim( int channel, const char *name );
305 void Event_CheckAnim( int channel, const char *animname );
306 void Event_ChooseAnim( int channel, const char *animname );
307 void Event_AnimLength( int channel, const char *animname );
308 void Event_AnimDistance( int channel, const char *animname );
309 void Event_HasEnemies( void );
310 void Event_NextEnemy( idEntity *ent );
311 void Event_ClosestEnemyToPoint( const idVec3 &pos );
312 void Event_StopSound( int channel, int netsync );
313 void Event_SetNextState( const char *name );
314 void Event_SetState( const char *name );
315 void Event_GetState( void );
316 void Event_GetHead( void );
319 #endif /* !__GAME_ACTOR_H__ */