3 const float TARGET_CONE_ANGLE_CHASE = 20;
4 const float TARGET_CONE_ANGLE_FIGHT = 30;
5 const float ORIENTATION_SYNC_THRESHOLD = 30;
7 const float SHOCK_TO_STUN_MULTIPLIER = 2.82;
54 RegisterNetSyncVariableInt(
"m_MindState", -1, 4);
55 RegisterNetSyncVariableInt(
"m_OrientationSynced", 0, 359);
56 RegisterNetSyncVariableFloat(
"m_MovementSpeed", -1, 3);
57 RegisterNetSyncVariableBool(
"m_IsCrawling");
63 if ( !
g_Game.IsDedicatedServer() )
82 DebugSound(
"[Infected @ " +
this +
"][OnVariablesSynchronized]");
157 return GetDayZInfectedType().GetHitComponentForAI();
163 return GetDayZInfectedType().GetDefaultHitComponent();
173 return GetSelectionPositionMS(pSelection);
179 return GetDayZInfectedType().GetSuitableFinisherHitComponents();
198 void CommandHandler(
float pDt,
int pCurrentCommandID,
bool pCurrentCommandFinished)
214 else if (!pCurrentCommandFinished)
225 if (pCurrentCommandFinished)
253 if ( inputController )
255 if (
HandleVault(pCurrentCommandID, inputController, pDt) )
265 if (
FightLogic(pCurrentCommandID, inputController, pDt) )
287 PluginDayZInfectedDebug infectedDebug = PluginDayZInfectedDebug.Cast(
GetPluginManager().GetPluginByType(PluginDayZInfectedDebug));
289 infectedDebug.CommandHandler(
this);
319 yaw =
Math.NormalizeAngle(yaw);
323 float angleTargetRad = yaw *
Math.DEG2RAD;
325 float angleDiffRad =
Math.Atan2(
Math.Sin(angleTargetRad - angleSourceRad),
Math.Cos(angleSourceRad - angleTargetRad));
326 angleDiffRad *=
Math.RAD2DEG;
327 angleDiffRad =
Math.Round(angleDiffRad);
373 bool doPhxImpulse =
g_Game.ConfigGetInt(
"cfgAmmo " + pAmmoType +
" doPhxImpulse") > 0;
376 pAnimType = doPhxImpulse;
384 vector impulse = 80 * m_TransportHitVelocity;
385 impulse[1] = 80 * 1.5;
405 else if ( height <= 1.1 )
407 else if ( height <= 1.6 )
417 DayZInfectedCommandVault vaultCmd = GetCommand_Vault();
418 if ( vaultCmd && vaultCmd.WasLand() )
427 StartCommand_Vault(-1);
433 if ( pInputController.IsVault() )
435 float vaultHeight = pInputController.GetVaultHeight();
438 StartCommand_Vault(vaultType);
460 if ( moveCommand && !moveCommand.IsTurning() )
461 moveCommand.SetIdleState(0);
465 if ( moveCommand && !moveCommand.IsTurning() )
466 moveCommand.SetIdleState(1);
471 moveCommand.SetIdleState(2);
531 if (!
g_Game.IsDedicatedServer())
534 if ( !soundParams.IsValid() )
541 soundObject = soundObjectBuilder.BuildSoundObject();
542 AttenuateSoundIfNecessary(soundObject);
544 return PlaySound(soundObject, soundObjectBuilder);
553 AnimSoundVoiceEvent voice_event = GetCreatureAIType().GetSoundVoiceEvent(event_id);
554 if (voice_event != null)
560 DebugSound(
"[Infected @ " +
this +
"][SoundEvent] InfectedSoundEventHandler - stop all");
566 DebugSound(
"[Infected @ " +
this +
"][AnimVoiceEvent] Stopping LastAW");
579 if (!
g_Game.IsDedicatedServer())
582 if (NULL != objectBuilder)
585 SoundObject soundObject = objectBuilder.BuildSoundObject();
586 AttenuateSoundIfNecessary(soundObject);
587 aw =
PlaySound(soundObject, objectBuilder);
593 if (sound_event.m_NoiseParams != NULL)
612 int mindState = pInputController.GetMindState();
624 DayZInfectedCommandAttack attackCommand = GetCommand_Attack();
625 if (attackCommand && attackCommand.WasHit())
632 bool playerInBlockStance =
false;
634 vector hitPosWS = targetPos;
640 playerInBlockStance = playerTarget.GetMeleeFightLogic() && playerTarget.GetMeleeFightLogic().IsInBlock();
646 if (playerInBlockStance && (
Math.RAD2DEG *
Math.AbsFloat(
Math3D.AngleFromPosition(targetPos, MiscGameplayFunctions.GetHeadingVector(playerTarget), zombiePos))) <=
GameConstants.AI_MAX_BLOCKABLE_ANGLE)
683 if ( pb && pb.GetCommand_Vehicle() )
692 if ( !CanAttackToPosition(targetPos) )
724 if (pb && pb.GetCommand_Vehicle())
740 if (!CanAttackToPosition(targetPos))
766 attackRefPos = target.GetDefaultHitPosition();
768 if ( attackRefPos !=
vector.Zero )
770 attackRefPos = target.ModelToWorld(attackRefPos);
774 attackRefPos = target.GetPosition();
781 float diff =
Math.AbsFloat(attackRefPos[1] - headPosY);
786 if ( headPosY > attackRefPos[1] )
817 if ( pComponent ==
"LeftLeg" && GetHealth(pComponent,
"Health") == 0 )
819 else if ( pComponent ==
"RightLeg" && GetHealth(pComponent,
"Health") == 0 )
822 if ( pAnimType != -1 )
824 vector targetDirection = GetDirection();
827 targetDirection[1] = 0;
828 toSourceDirection[1] = 0;
830 targetDirection.Normalize();
831 toSourceDirection.Normalize();
833 float cosFi =
vector.Dot(targetDirection, toSourceDirection);
838 return pAnimType != -1;
871 int randNum =
Math.RandomIntInclusive(0, 100);
882 m_HeavyHitOverride =
false;
892 int invertHitDir = 0;
895 pHeavyHit = ((
g_Game.ConfigGetInt(
"cfgAmmo " + pAmmoType +
" hitAnimation") > 0) || m_HeavyHitOverride);
896 invertHitDir =
g_Game.ConfigGetInt(
"cfgAmmo " + pAmmoType +
" invertHitDir");
903 if ( pComponent ==
"Torso" )
905 else if ( pComponent ==
"Head" )
919 vector targetDirection = GetDirection();
922 targetDirection[1] = 0;
923 toSourceDirection[1] = 0;
925 targetDirection.Normalize();
926 toSourceDirection.Normalize();
928 float cosFi =
vector.Dot(targetDirection, toSourceDirection);
929 vector cross = targetDirection * toSourceDirection;
931 float dirAngle =
Math.Acos(cosFi) *
Math.RAD2DEG;
933 dirAngle = -dirAngle;
940 vector targetDirection = GetDirection();
943 targetDirection[1] = 0;
944 toSourceDirection[1] = 0;
946 targetDirection.Normalize();
947 toSourceDirection.Normalize();
949 float cosFi =
vector.Dot(targetDirection, toSourceDirection);
950 vector cross = targetDirection * toSourceDirection;
952 float dirAngle =
Math.Acos(cosFi) *
Math.RAD2DEG;
955 if ( invertHitDir > 0 )
959 dirAngle = -dirAngle;
971 super.EEHitBy(damageResult, damageType, source,
component, dmgZone, ammo, modelPos, speedCoef);
973 m_TransportHitRegistered =
false;
977 ZombieHitData data =
new ZombieHitData;
979 data.m_DamageZone = dmgZone;
980 data.m_AmmoType = ammo;
985 int crawlTransitionType = -1;
1004 super.EEHitByRemote(damageType, source,
component, dmgZone, ammo, modelPos);
1028 RegisterTransportHit(transport);
1039 return super.CanReceiveAttachment(attachment, slotId);
1056 GetAIAgent().SetKeepInIdle(
true);
1059 switch (backstabType)
1062 m_DeathType = DayZInfectedDeathAnims.ANIM_DEATH_BACKSTAB;
1066 m_DeathType = DayZInfectedDeathAnims.ANIM_DEATH_NECKSTAB;
1070 m_DeathType = DayZInfectedDeathAnims.ANIM_DEATH_DEFAULT;
1087 GetAIAgent().SetKeepInIdle(
false);
1106 vector parentTransMat[4];
1111 GetTransformWS(parentTransMat);
1116 Math3D.YawPitchRollMatrix(closeBoneRotWS *
Math.RAD2DEG,rotMatrix);
1118 parentTransMat[0] = rotMatrix[0];
1119 parentTransMat[1] = rotMatrix[1];
1120 parentTransMat[2] = rotMatrix[2];
1121 parentTransMat[3] = closeBonePosWS;
1124 arrow.GetTransform(arrowTransMat);
1125 Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
1127 Math3D.MatrixOrthogonalize4(arrowTransMat);
1128 arrow.SetTransform(arrowTransMat);
1130 AddChild(arrow, pivot);
RepairTentActionReciveData m_DamageZone
void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
int m_StanceVariation
server / singleplayer properties
override void OnSoundVoiceEvent(int event_id, string event_user_string)
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
bool m_FinisherInProgress
ref ArrowManagerBase m_ArrowManager
bool FightLogic(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
const float HIT_INTERVAL_MIN
ref InfectedSoundEventHandler m_InfectedSoundEventHandler
void CommandHandlerDebug(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
override bool IsManagingArrows()
bool HandleVault(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
override array< string > GetSuitableFinisherHitComponents()
returns suitable hit components for finisher attacks; DEPRECATED
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
void ProcessSoundVoiceEvent(AnimSoundVoiceEvent sound_event, out AbstractWave aw)
int GetOrientationSynced()
returns rounded zombie yaw for sync purposes
bool IsCrawling()
returns true if crawling; 'DayZInfectedCommandCrawl' is only for the transition, after that it remain...
override bool IsSelfAdjustingTemperature()
float m_LastMovementSpeed
override void EOnInit(IEntity other, int extra)
override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
void OnRecoverFromDeath()
override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
ref array< Object > m_AllTargetObjects
DayZInfectedAttackType m_ActualAttackType
AbstractWave ProcessVoiceFX(string pSoundSetName)
void HandleOrientation(float pDt, int pCurrentCommandID)
override bool CanBeSkinned()
bool HandleDamageHit(int pCurrentCommandID)
bool EvaluateCrawlTransitionAnimation(EntityAI pSource, string pComponent, string pAmmoType, out int pAnimType)
vector SetDefaultHitPosition(string pSelection)
AbstractWave m_LastSoundVoiceAW
override AnimBootsType GetBootsType()
bool FightAttackLogic(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
bool HandleCrawlTransition(int pCurrentCommandID)
float m_DamageHitDirection
void HandleMove(int pCurrentCommandID)
void DebugSound(string s)
sound debug messages
float m_AttackCooldownTime
vector m_DefaultHitPosition
override bool IsHealthVisible()
bool EvaluateDeathAnimationEx(EntityAI pSource, ZombieHitData data, out int pAnimType, out float pAnimHitDir)
override bool IsRefresherSignalingViable()
bool EvaluateDamageHitAnimation(EntityAI pSource, string pComponent, string pAmmoType, out bool pHeavyHit, out int pAnimType, out float pAnimHitDir)
selects animation type and direction based on damage system data
override string GetDefaultHitComponent()
returns default hit component (fallback)
override bool IsBeingBackstabbed()
returns true if backstab is in progress; used for suspending of AI targeting and other useful things ...
void EOnContact(IEntity other, Contact extra)
override vector GetCenter()
bool m_DamageHitToProcess
bool HandleDeath(int pCurrentCommandID)
ref array< typename > m_TargetableObjects
override void OnVariablesSynchronized()
synced variable(s) handler
override string GetHitComponentForAI()
returns hit component for attacking AI
int GetAttackPitch(EntityAI target)
float ComputeHitDirectionAngleEx(EntityAI pSource, int invertHitDir=0)
override void SetBeingBackstabbed(int backstabType)
override bool IsZombieMilitary()
override bool CanBeBackstabbed()
int GetVaultType(float height)
override vector GetDefaultHitPosition()
bool EvaluateDeathAnimation(EntityAI pSource, string pComponent, string pAmmoType, out int pAnimType, out float pAnimHitDir)
bool HandleMindStateChange(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
float ComputeHitDirectionAngle(EntityAI pSource)
override ArrowManagerBase GetArrowManager()
bool ChaseAttackLogic(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
Native class for boats - handles physics simulation.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
DayZInfectedAttackGroupType
string GetDefaultHitPositionComponent()
EntityEvent
Entity events for event-mask, or throwing event from code.
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin).
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
vector GetPosition()
Get the world position of the Effect.
class SoundObject SoundParams(string name)
void InfectedSoundEventHandler(ZombieBase pInfected)
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
PluginManager GetPluginManager()
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
class ZombieBase extends DayZInfected m_Component
an extendable data container