29 #include "../idlib/precompiled.h"
95 savefile->
ReadObject( reinterpret_cast<idClass *&>(
self ) );
98 savefile->
ReadObject( reinterpret_cast<idClass *&>( animowner ) );
152 func =
self->scriptObject.GetFunction( statename );
235 if ( animDoneTime < 0 ) {
262 memset( &flags, 0,
sizeof( flags ) );
364 const idEventDef EV_SetDamageGroupScale(
"setDamageGroupScale",
"sf" );
365 const idEventDef EV_SetDamageGroupScaleAll(
"setDamageGroupScaleAll",
"f" );
366 const idEventDef EV_GetDamageGroupScale(
"getDamageGroupScale",
"s",
'f' );
367 const idEventDef EV_SetDamageCap(
"setDamageCap",
"f" );
368 const idEventDef EV_SetWaitState(
"setWaitState" ,
"s" );
415 EVENT( EV_SetDamageGroupScale, idActor::Event_SetDamageGroupScale )
416 EVENT( EV_SetDamageGroupScaleAll,
idActor::Event_SetDamageGroupScaleAll )
417 EVENT( EV_GetDamageGroupScale,
idActor::Event_GetDamageGroupScale )
559 args.
Set(
"no_touch",
"1" );
562 args.
Set(
"dropToFloor",
"0" );
654 const char *scriptObjectName;
659 gameLocal.
Error(
"Script object '%s' not found on entity '%s'.", scriptObjectName,
name.c_str() );
676 const char *headModel;
687 if ( headModel[ 0 ] ) {
719 headEnt->
SetBody(
this, headModel, damageJoint );
736 attach.
ent = headEnt;
923 for ( i = 0; i <
num; i++ ) {
924 savefile->
ReadObject( reinterpret_cast<idClass *&>( ent ) );
943 for( i = 0; i <
num; i++ ) {
949 for( i = 0; i <
num; i++ ) {
958 for( i = 0; i <
num; i++ ) {
994 for ( i = 0; i <
num; i++ ) {
1005 if ( statename.
Length() > 0 ) {
1010 if ( statename.
Length() > 0 ) {
1037 if ( ent->
IsType( idLight::Type ) ) {
1038 static_cast<idLight *
>( ent )->Off();
1062 if ( ent->
IsType( idLight::Type ) ) {
1065 static_cast<idLight *
>( ent )->On();
1118 return af.
Load(
this, fileName );
1127 const char *jointname;
1310 if ( !constructor ) {
1386 for( i = 0; i < 20; i++ ) {
1487 delta -= gravityDir * ( gravityDir * delta );
1492 return ( dot >=
fovDot );
1509 if ( ent->
IsType( idActor::Type ) ) {
1510 toPos = ( (
idActor * )ent )->GetEyePosition();
1515 if ( useFov && !
CheckFOV( toPos ) ) {
1543 return ( results.
fraction >= 1.0f );
1652 float slomoStart, slomoEnd;
1653 float jointFrictionDent, jointFrictionDentStart, jointFrictionDentEnd;
1654 float contactFrictionDent, contactFrictionDentStart, contactFrictionDentEnd;
1685 contactFrictionDent =
spawnArgs.
GetFloat(
"ragdoll_contactFrictionDent",
"0.1" );
1782 idMat3 newAxis = rotate * axis;
1850 float bestDistSquared;
1862 if ( distSquared < bestDistSquared ) {
1864 bestDistSquared = distSquared;
2085 anim = animatorPtr->
GetAnim( temp );
2091 anim = animatorPtr->
GetAnim( animname );
2110 blendTime =
FRAME2MS( blendFrames );
2204 const char *damageDefName,
const float damageScale,
const int location ) {
2217 SetTimeState ts( timeGroup );
2226 (!
idStr::Icmp( damageDefName,
"damage_maledict_asteroid" ) || !
idStr::Icmp( damageDefName,
"damage_maledict_asteroid_splash" ) ) ) {
2250 if(damageCap >= 0 &&
health < damageCap) {
2259 Killed( inflictor, attacker, damage, dir, location );
2261 Gib( dir, damageDefName );
2264 Pain( inflictor, attacker, damage, dir, location );
2310 }
else if (
health > 50 ) {
2312 }
else if (
health > 25 ) {
2332 if ( damageGroup.
Length() && ( damageGroup !=
"legs" ) ) {
2348 }
else if ( damageGroup.
Length() && ( damageGroup !=
"legs" ) ) {
2399 groupname = arg->
GetKey();
2400 groupname.
Strip(
"damage_zone " );
2402 for( i = 0; i < jointList.
Num(); i++ ) {
2403 jointnum = jointList[
i ];
2420 groupname = arg->
GetKey();
2421 groupname.
Strip(
"damage_scale " );
2441 return (
int)ceil( damage *
damageScale[ location ] );
2470 const char *sound =
NULL;
2479 if ( material !=
NULL ) {
2482 if ( *sound ==
'\0' ) {
2485 if ( *sound !=
'\0' ) {
2645 anim =
GetAnim( channel, animname );
2724 anim =
GetAnim( channel, animname );
2797 anim =
GetAnim( channel, animname );
3137 if (
GetAnim( channel, animname ) ) {
3150 if ( !
GetAnim( channel, animname ) ) {
3167 anim =
GetAnim( channel, animname );
3191 anim =
GetAnim( channel, animname );
3215 anim =
GetAnim( channel, animname );
3251 if ( !ent || ( ent ==
this ) ) {
3254 if ( !ent->
IsType( idActor::Type ) ) {
3258 actor =
static_cast<idActor *
>( ent );
3293 headEnt->
StopSound( channel, ( netSync != 0 ) );
3352 void idActor::Event_SetDamageGroupScale(
const char* groupName,
float scale) {
3366 void idActor::Event_SetDamageGroupScaleAll(
float scale ) {
3373 void idActor::Event_GetDamageGroupScale(
const char* groupName ) {
3385 void idActor::Event_SetDamageCap(
float _damageCap ) {
3386 damageCap = _damageCap;
3389 void idActor::Event_SetWaitState(
const char* waitState) {
3393 void idActor::Event_GetWaitState() {
virtual const idVec3 & GetOrigin(int id=0) const =0
const idEventDef AI_DisableEyeFocus("disableEyeFocus")
void Event_PlayCycle(int channel, const char *name)
const idEventDef AI_SetSyncedAnimWeight("setSyncedAnimWeight","ddf")
const idEventDef AI_PlayCycle("playCycle","ds", 'd')
renderEntity_t renderEntity
bool TracePoint(trace_t &results, const idVec3 &start, const idVec3 &end, int contentMask, const idEntity *passEntity)
void Restore(idRestoreGame *savefile)
int GetChannelForJoint(jointHandle_t joint) const
float GetFloat(const char *key, const char *defaultString="0") const
static const float INFINITY
const function_t * idealState
bool GetJointTransform(jointHandle_t jointHandle, int currenttime, idVec3 &offset, idMat3 &axis)
virtual void GetAASLocation(idAAS *aas, idVec3 &pos, int &areaNum) const
virtual bool LoadAF(void)
virtual bool Init(idEntity *self, const char *anim, const idVec3 &modelOffset)
void WriteString(const char *string)
void SetCycleCount(int count)
bool PointVisible(const idVec3 &point) const
int GetInt(const char *key, const char *defaultString="0") const
void Event_SetNextState(const char *name)
idList< idAttachInfo > attachments
assert(prefInfo.fullscreenBtn)
void StopAnim(int frames)
virtual void Evaluate(void)
virtual const idSoundShader * FindSound(const char *name, bool makeDefault=true)=0
const idDict * FindEntityDefDict(const char *name, bool makeDefault=true) const
void SyncAnimChannels(int channelNum, int fromChannelNum, int currenttime, int blendTime)
virtual const idVec3 & GetGravityNormal(void) const =0
void Restore(idRestoreGame *savefile)
virtual idThread * ConstructScriptObject(void)
void Event_HasAnim(int channel, const char *name)
void Event_StopSound(int channel, int netsync)
void SetContactFrictionDent(const float dent, const float start, const float end)
virtual void UnlinkCombat(void)
idLinkList< idActor > enemyNode
virtual idAnimator * GetAnimator(void)
void CallFunction(const function_t *func, bool clearStack)
void WriteObject(const idClass *obj)
idVec3 GetCenter(void) const
idLinkList * ListHead(void) const
const idEventDef AI_AnimState("animState","dsd")
virtual void DeconstructScriptObject(void)
bool GetFloorPos(float max_dist, idVec3 &floorpos) const
void Event_DisableEyeFocus(void)
void Printf(const char *fmt,...) const id_attribute((format(printf
void Event_EnableWalkIK(void)
int GetDamageForLocation(int damage, int location)
const idEventDef AI_EnableEyeFocus("enableEyeFocus")
struct idEntity::entityFlags_s fl
void Attach(idEntity *ent)
void BindToJoint(idEntity *master, const char *jointname, bool orientated)
type * GetEntity(void) const
bool SetType(const char *typeName)
void Event_Footstep(void)
const idEventDef AI_DisablePain("disablePain")
const char * GetTypeName(void) const
idEntityPtr< idEntity > ent
const idStr & GetKey(void) const
void SetOwner(type *object)
void SetNum(int newnum, bool resize=true)
bool SetSyncedAnimWeight(int num, float weight)
const idEventDef AI_GetBlendFrames("getBlendFrames","d", 'd')
idEntity * GetBindMaster(void) const
GLenum GLenum GLenum GLenum GLenum scale
idMat3 Transpose(void) const
void SetAxis(const idMat3 &axis)
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
const int ANIMCHANNEL_ALL
void Restore(idRestoreGame *savefile)
int NumJoints(void) const
idScriptObject scriptObject
idAngles GetAngles(const char *key, const char *defaultString=NULL) const
bool IsType(const idTypeInfo &c) const
void SetCombatModel(void)
virtual bool GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis)
bool HasObject(void) const
void Event_NextEnemy(idEntity *ent)
idClipModel * GetCombatModel(void) const
idLinkList< idActor > enemyList
const int ANIMCHANNEL_EYELIDS
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
static void DropItems(idAnimatedEntity *ent, const char *type, idList< idEntity * > *list)
virtual void DamageFeedback(idEntity *victim, idEntity *inflictor, int &damage)
void PlayAnim(int channelNum, int animnum, int currenttime, int blendTime)
void SetGranularity(int newgranularity)
idList< float > damageScale
const idEventDef EV_EnableLegIK("EnableLegIK","d")
void SetCombatModel(void)
jointHandle_t GetJointHandle(const char *name) const
void SetEyeHeight(float height)
const idEventDef AI_SetNextState("setNextState","s")
const idEventDef AI_AnimLength("animLength","ds", 'f')
void Event_GetPainAnim(void)
void ReadJoint(jointHandle_t &value)
void ReadBool(bool &value)
const idEventDef AI_AnimDistance("animDistance","ds", 'f')
void PlayFootStepSound(void)
void Event_IdleAnim(int channel, const char *name)
void Event_EnableLegIK(int num)
idPhysics_AF * GetPhysics(void)
void Event_GetBlendFrames(int channel)
virtual int GetDefaultSurfaceType(void) const
virtual void Gib(const idVec3 &dir, const char *damageDefName)
virtual void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)=0
virtual void ProjectOverlay(const idVec3 &origin, const idVec3 &dir, float size, const char *material)
void SetJointPos(jointHandle_t jointnum, jointModTransform_t transform_type, const idVec3 &pos)
virtual int PointReachableAreaNum(const idVec3 &origin, const idBounds &bounds, const int areaFlags) const =0
virtual void LinkCombat(void)
const char * GetClassname(void) const
const int ANIMCHANNEL_HEAD
void Set(const char *key, const char *value)
void CopyJointsFromBodyToHead(void)
const idEventDef AI_NextEnemy("nextEnemy","E", 'e')
int ReadTokenOnLine(idToken *token)
virtual void SpawnGibs(const idVec3 &dir, const char *damageDefName)
idBounds boundingBoxes[MAX_AAS_BOUNDING_BOXES]
void SetStartTime(int startTime)
const idVec3 & TotalMovementDelta(int animnum) const
const char * Name(void) const
virtual void UnlinkCombat(void)
void SetAnimator(idAnimator *a)
void WriteVec3(const idVec3 &vec)
void Event_PlayAnim(int channel, const char *name)
void SetDeltaViewAngles(const idAngles &delta)
void SetThreadName(const char *name)
void SetAnimState(int channel, const char *name, int blendFrames)
const idEventDef EV_EnableWalkIK("EnableWalkIK")
int Icmp(const char *text) const
void SetName(const char *name)
void Event_AnimDone(int channel, int blendFrames)
#define EVENT(event, function)
const idEventDef AI_EnablePain("enablePain")
bool Load(idEntity *ent, const char *fileName)
idClipModel * combatModel
const idEventDef EV_StopSound("stopSound","dd")
void Event_DisableWalkIK(void)
void SetJointAxis(jointHandle_t jointnum, jointModTransform_t transform_type, const idMat3 &mat)
void WriteJoint(const jointHandle_t value)
void WriteBool(const bool value)
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
void Event_PreventPain(float duration)
const idEventDef AI_InAnimState("inAnimState","ds", 'd')
virtual renderView_t * GetRenderView()
bool IsHidden(void) const
bool HasEnemies(void) const
idEntity * SpawnEntityType(const idTypeInfo &classdef, const idDict *args=NULL, bool bIsClientReadSnapshot=false)
bool AnimDone(int blendFrames) const
void void void Warning(const char *fmt,...) const id_attribute((format(printf
const idEventDef EV_DisableWalkIK("DisableWalkIK")
bool CanSee(idEntity *ent, bool useFOV) const
virtual const idBounds & GetBounds(int id=-1) const =0
const char * AnimName(void) const
virtual bool OnLadder(void) const
bool StartSoundShader(const idSoundShader *shader, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
void GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis) const
void KillBox(idEntity *ent, bool catch_teleport=false)
const char * AnimFullName(void) const
void ClearAllJoints(void)
const idEventDef AI_SetBlendFrames("setBlendFrames","dd")
idVec3 GetEyePosition(void) const
void DisableDebugInfo(void)
void ShutdownThreads(void)
const idEventDef AI_IdleAnim("idleAnim","ds", 'd')
virtual const contactInfo_t & GetContact(int num) const =0
const idEventDef EV_FootstepLeft("leftFoot")
void SetTimeScaleRamp(const float start, const float end)
idEntityPtr< idAFAttachment > head
int GetAnim(int channel, const char *name)
idPhysics * GetPhysics(void) const
const char * GetString(const char *key, const char *defaultString="") const
bool SpawnEntityDef(const idDict &args, idEntity **ent=NULL, bool setDefaults=true)
void ReadFloat(float &value)
const idEventDef AI_OverrideAnim("overrideAnim","d")
const idEventDef AI_GetAnimState("getAnimState","d", 's')
void Event_ClosestEnemyToPoint(const idVec3 &pos)
void Event_OverrideAnim(int channel)
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
const idEventDef AI_GetHead("getHead", NULL, 'e')
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
const idAngles & GetDeltaViewAngles(void) const
const idEventDef AI_HasEnemies("hasEnemies", NULL, 'd')
idCVar g_debugDamage("g_debugDamage","0", CVAR_GAME|CVAR_BOOL,"")
void DoneProcessing(void)
virtual bool GetPhysicsToSoundTransform(idVec3 &origin, idMat3 &axis)
const idEventDef AI_PreventPain("preventPain","f")
void WriteFloat(const float value)
void Event_EnablePain(void)
const idEventDef AI_EnableAnim("enableAnim","dd")
static const char * sufaceTypeNames[MAX_SURFACE_TYPES]
void ClearAllAnims(int currentTime, int cleartime)
void Event_StopAnim(int channel, int frames)
bool GetBool(const char *key, const char *defaultString="0") const
void Event_DisableLegIK(int num)
idAnimBlend * CurrentAnim(int channelNum)
void void DPrintf(const char *fmt,...) const id_attribute((format(printf
static void DropAFs(idEntity *ent, const char *type, idList< idEntity * > *list)
int GetInteger(void) const
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
bool GetJointLocalTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
void Save(idSaveGame *savefile) const
const char * GetDamageGroup(int location)
idEntity * GetNextTeamEntity(void) const
virtual void SetOrigin(const idVec3 &newOrigin, int id=-1)=0
const idAnim * GetAnim(int index) const
const idEventDef AI_PlayAnim("playAnim","ds", 'd')
void CycleAnim(int channelNum, int animnum, int currenttime, int blendtime)
static void ReturnFloat(float value)
const idEventDef AI_SetAnimPrefix("setAnimPrefix","s")
const idEventDef EV_DisableLegIK("DisableLegIK","d")
void GetJointList(const char *jointnames, idList< jointHandle_t > &jointList) const
virtual void Teleport(const idVec3 &origin, const idAngles &angles, idEntity *destination)
const char * WaitState(void) const
idActor * ClosestEnemyToPoint(const idVec3 &pos)
const idStr & GetValue(void) const
void Event_InAnimState(int channel, const char *name)
virtual const idMat3 & GetAxis(int id=0) const =0
virtual idAnimator * GetAnimator(void)
bool IsInitialized(void) const
const function_t * GetConstructor(void) const
animFlags_t GetAnimFlags(void) const
void SetBool(const char *key, bool val)
float LengthSqr(void) const
void Restore(idRestoreGame *savefile)
const animFlags_t GetAnimFlags(int animnum) const
const idEventDef EV_Footstep("footstep")
int GetCycleCount(void) const
bool InAnimState(int channel, const char *name) const
void SetJointFrictionDent(const float dent, const float start, const float end)
void Init(idActor *owner, idAnimator *_animator, int animchannel)
void SetState(const char *name, int blendFrames)
const surfTypes_t GetSurfaceType(void) const
virtual void DisableClip(void)=0
void Enable(int blendFrames)
GLenum GLsizei GLsizei height
const char * ToString(int precision=2) const
void WriteInt(const int value)
idActor * EnemyWithMostHealth()
void SetupDamageGroups(void)
float EyeHeight(void) const
void RemoveAttachments(void)
const idEventDef AI_HasAnim("hasAnim","ds", 'f')
idDeclManager * declManager
void WriteMat3(const idMat3 &mat)
idCVar ai_debugScript("ai_debugScript","-1", CVAR_GAME|CVAR_INTEGER,"displays script calls for the specified monster entity number")
void ReadMat3(idMat3 &mat)
bool IsLoaded(void) const
void Save(idSaveGame *savefile) const
const idEventDef AI_GetPainAnim("getPainAnim", NULL, 's')
int ExpectTokenString(const char *string)
void AddToEnd(idLinkList &node)
idEntity * GetTraceEntity(const trace_t &trace) const
int AnimLength(int animnum) const
const idEventDef AI_FinishAction("finishAction","s")
int Append(const type &obj)
bool HasAnim(const char *name) const
void PlayIdleAnim(int blendTime)
void Event_AnimState(int channel, const char *name, int blendFrames)
void Event_GetState(void)
void Event_EnableEyeFocus(void)
void StartFromCurrentPose(int inheritVelocityTime)
static void ReturnString(const char *text)
void UpdateAnimState(void)
void WriteAngles(const idAngles &angles)
void SyncAnimChannels(int channel, int syncToChannel, int blendFrames)
const char * AnimFullName(int animnum) const
void SetWaitState(const char *_waitstate)
jointHandle_t leftEyeJoint
bool LoadModel(const char *name)
const idEventDef EV_FootstepRight("rightFoot")
virtual void SpawnGibs(const idVec3 &dir, const char *damageDefName)
#define AREA_REACHABLE_WALK
idMat3 ToMat3(void) const
virtual bool Pain(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
virtual const idAASSettings * GetSettings(void) const =0
void Event_SetState(const char *name)
const function_t * GetFunction(const char *name) const
void Event_FinishAction(const char *name)
virtual void GetAIAimTargets(const idVec3 &lastSightPos, idVec3 &headPos, idVec3 &chestPos)
virtual bool ShouldConstructScriptObjectAtSpawn(void) const
bool GetJointWorldTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
virtual bool UpdateAnimationControllers(void)
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
virtual void LinkCombat(void)
void Event_EnableAnim(int channel, int blendFrames)
idList< copyJoints_t > copyJoints
const function_t * GetScriptFunction(const char *funcname)
const idEventDef AI_ChooseAnim("chooseAnim","ds", 's')
void Save(idSaveGame *savefile) const
void ReadVec3(idVec3 &vec)
void Event_GetAnimState(int channel)
static void ReturnEntity(idEntity *ent)
void SetBody(idEntity *bodyEnt, const char *headModel, jointHandle_t attachJoint)
const char * c_str(void) const
void Error(const char *fmt,...) const id_attribute((format(printf
void EnableDebugInfo(void)
void Clear(int channelNum, int currentTime, int cleartime)
bool Disabled(void) const
void ReadAngles(idAngles &angles)
ID_INLINE int FRAME2MS(int framenum)
const char * GetJointName(jointHandle_t handle) const
void BecomeActive(int flags)
virtual void GetViewPos(idVec3 &origin, idMat3 &axis) const
const int ANIMCHANNEL_TORSO
virtual renderView_t * GetRenderView()
const idEventDef EV_Remove("<immediateremove>", NULL)
void Event_HasEnemies(void)
int GetEndTime(void) const
void SetFrame(int channelNum, int animnum, int frame, int currenttime, int blendtime)
virtual const idDeclSkin * FindSkin(const char *name, bool makeDefault=true)=0
idVec3 EyeOffset(void) const
bool CheckFOV(const idVec3 &pos) const
const idEventDef AI_SetState("setState","s")
const int ANIMCHANNEL_LEGS
bool prevent_idle_override
int GetStartTime(void) const
virtual void PushPointIntoAreaNum(int areaNum, idVec3 &origin) const =0
float dot(float a[], float b[])
void Event_SetAnimPrefix(const char *name)
virtual void Restart(void)
const char * GetEntityDefName(void) const
const idEventDef AI_CheckAnim("checkAnim","ds")
const idEventDef AI_GetState("getState", NULL, 's')
char * va(const char *fmt,...)
void Event_AnimDistance(int channel, const char *animname)
void Event_AnimLength(int channel, const char *animname)
void SetOrigin(const idVec3 &org)
bool PostEventMS(const idEventDef *ev, int time)
const idEventDef AI_StopAnim("stopAnim","dd")
idEntity * GetEntity(void) const
void Event_SetSyncedAnimWeight(int channel, int anim, float weight)
void Event_DisablePain(void)
virtual void ProjectOverlay(const idVec3 &origin, const idVec3 &dir, float size, const char *material)
bool IsActive(void) const
void ReadString(idStr &string)
static void ReturnInt(int value)
int sprintf(idStr &string, const char *fmt,...)
virtual bool UpdateAnimationControllers(void)
void Event_ChooseAnim(int channel, const char *animname)
jointHandle_t rightEyeJoint
const idEventDef AI_AnimDone("animDone","dd", 'd')
void StopSound(const s_channelType channel, bool broadcast)
virtual void Gib(const idVec3 &dir, const char *damageDefName)
void SetState(const function_t *newState)
bool StripLeadingOnce(const char *string)
const idEventDef AI_ClosestEnemyToPoint("closestEnemyToPoint","v", 'e')
void Event_SetBlendFrames(int channel, int blendFrames)
void ReadObject(idClass *&obj)
void void Warning(const char *fmt,...) const id_attribute((format(printf
void Event_CheckAnim(int channel, const char *animname)
const char * GetAnimState(int channel) const
void Save(idSaveGame *savefile) const