26 #ifdef _DAYZ_CREATURE_DEBUG_SHADOW
62 return !GetIsFrozen();
98 GetTransform(parentTransMat);
103 Math3D.YawPitchRollMatrix(closeBoneRotWS *
Math.RAD2DEG,rotMatrix);
105 parentTransMat[0] = rotMatrix[0];
106 parentTransMat[1] = rotMatrix[1];
107 parentTransMat[2] = rotMatrix[2];
108 parentTransMat[3] = closeBonePosWS;
111 arrow.GetTransform(arrowTransMat);
112 Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
114 Math3D.MatrixOrthogonalize4(arrowTransMat);
115 arrow.SetTransform(arrowTransMat);
117 AddChild(arrow, pivot);
127 super.GetDebugActions(outputList);
130 if (Gizmo_IsSupported())
138 if (super.OnAction(action_id, player, ctx))
146 GetGame().GizmoSelectObject(
this);
149 GetGame().GizmoSelectPhysics(GetPhysics());
191 proto native
AIAgent GetAIAgent();
193 proto native
bool IsSoundInsideBuilding();
195 proto native
void DebugDisableAIControl();
196 proto native
void DebugRestoreAIControl();
198 proto native
void AddDamageSphere(
string bone_name,
string ammo_name,
float radius,
float duration,
bool invertTeams);
205 proto native
void InitAIAgent(
AIGroup group);
206 proto native
void DestroyAIAgent();
208 int m_EffectTriggerCount;
215 RegisterAnimEvents();
222 m_EffectTriggerCount++;
227 m_EffectTriggerCount--;
232 AddDamageSphere(damage_params.m_sBoneName, damage_params.m_sAmmoName, damage_params.m_fRadius, damage_params.m_fDuration, damage_params.m_bInvertTeams);
237 super.EEKilled(killer);
260 AnimSoundEvent sound_event = GetCreatureAIType().GetSoundEvent(event_id);
261 if(sound_event != NULL)
263 ProcessSoundEvent(sound_event);
269 AnimSoundVoiceEvent voice_event = GetCreatureAIType().GetSoundVoiceEvent(event_id);
270 if(voice_event != NULL)
272 ProcessSoundVoiceEvent(voice_event);
278 AnimStepEvent step_event = GetCreatureAIType().GetStepEvent(event_id);
279 if(step_event != NULL)
281 ProcessStepEvent(step_event);
287 AnimDamageEvent damage_event = GetCreatureAIType().GetDamageEvent(event_id);
288 if(damage_event != NULL)
290 ProcessDamageEvent(damage_event);
298 Print(
"Error registering anim. event (Sound)");
303 Print(
"Error registering anim. event (SoundVoice)");
306 if(!
GetGame().IsDedicatedServer())
310 Print(
"Error registering anim. event (Step)");
316 Print(
"Error registering anim. event (Damage)");
320 private void ProcessSoundEvent(AnimSoundEvent sound_event)
322 if(!
GetGame().IsDedicatedServer())
325 if(NULL != objectBuilder)
328 SoundObject soundObject = objectBuilder.BuildSoundObject();
335 if(sound_event.m_NoiseParams != NULL)
336 GetGame().GetNoiseSystem().AddNoise(
this, sound_event.m_NoiseParams,
GetGame().GetWeather().GetNoiseReductionByWeather());
340 private void ProcessSoundVoiceEvent(AnimSoundVoiceEvent sound_event)
342 if(!
GetGame().IsDedicatedServer())
345 if(NULL != objectBuilder)
348 SoundObject soundObject = objectBuilder.BuildSoundObject();
349 AttenuateSoundIfNecessary(soundObject);
356 if(sound_event.m_NoiseParams != NULL)
357 GetGame().GetNoiseSystem().AddNoise(
this, sound_event.m_NoiseParams,
GetGame().GetWeather().GetNoiseReductionByWeather());
361 private void ProcessStepEvent(AnimStepEvent step_event)
363 SoundObjectBuilder soundBuilder = step_event.GetSoundBuilder(GetSurfaceType().Hash());
364 if(soundBuilder == NULL)
368 SoundObject soundObject = soundBuilder.BuildSoundObject();
369 AttenuateSoundIfNecessary(soundObject);
375 private void ProcessDamageEvent(AnimDamageEvent damage_event)
377 AddDamageSphere(damage_event.m_DamageParams);
384 soundObject.SetKind(
WaveKind.WAVEATTALWAYS);
388 soundObject.SetKind(
WaveKind.WAVEEFFECTEX);
423 m_CinematicPlayer = player;
433 if (!m_CinematicPlayer)
435 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
438 UAInterface input = m_CinematicPlayer.GetInputInterface();
441 GetGame().GameScript.CallFunction(
this,
"GetInputController", controller, 0);
443 if (!input || !controller)
445 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
448 float movementX = input.SyncedValue_ID(UAAimRight) - input.SyncedValue_ID(UAAimLeft);
450 float maxTurnSpeed = 100.0;
451 movementX =
Math.Clamp(movementX * maxTurnSpeed * pDt, -180, 180);
453 if (input.SyncedValue_ID(UALookAround) > 0)
458 bool isJump = input.SyncedValue_ID(UAGetOver) > 0;
459 bool isMove = input.SyncedValue_ID(UAMoveForward) > 0;
461 bool isRest = input.SyncedValue_ID(UAMoveBack) > 0;
462 bool isSleep = input.SyncedValue_ID(UAReloadMagazine) > 0;
476 bool isSprint = input.SyncedValue_ID(UATurbo) > 0;
477 bool isJog = input.SyncedValue_ID(UAWalkRunTemp) > 0;
478 bool isWalk = !isSprint && !isJog;
497 if (
Class.CastTo(animalController, controller))
519 if (iSpeed > 0 && lowVel)
527 if (animalController)
546 controller.OverrideTurnSpeed(
true,
Math.PI2 / pDt);
547 controller.OverrideMovementSpeed(
true, fSpeed);
548 controller.OverrideHeading(
true, heading *
Math.DEG2RAD);
549 controller.OverrideAlertLevel(
true,
true, iAlert, fAlert);
551 if (CinematicCanJump() && isJump)
553 controller.OverrideJump(
true, 101, 2.0);
560enum DayZAnimalConstants
710 return EInventoryIconVisibility.HIDE_VICINITY;
730 if (HandleDeath(currentCommandID, inputController))
735 if (currentCommandFinished)
737 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
739 SignalAIAttackEnded();
753 if (HandleDamageHit(currentCommandID))
755 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
757 SignalAIAttackEnded();
762 if (currentCommandID == DayZAnimalConstants.COMMANDID_MOVE)
764 if (inputController.IsJump())
770 if (inputController.IsAttack())
772 StartCommand_Attack();
773 SignalAIAttackStarted();
785 bool m_DamageHitToProcess =
false;
786 int m_DamageHitType = 0;
787 int m_DamageHitDirection = 0;
791 if (inputController.IsDead())
793 if (currentCommandID == DayZAnimalConstants.COMMANDID_DEATH)
798 if (m_DamageHitToProcess)
800 m_DamageHitToProcess =
false;
802 StartCommand_Death(m_DamageHitType, m_DamageHitDirection);
806 StartCommand_Death(0, 0);
817 if (m_DamageHitToProcess)
819 m_DamageHitToProcess =
false;
821 if (currentCommandID != DayZAnimalConstants.COMMANDID_HIT)
823 StartCommand_Hit(m_DamageHitType, m_DamageHitDirection);
832 super.EEHitBy(damageResult, damageType, source,
component, dmgZone, ammo, modelPos, speedCoef);
833 m_TransportHitRegistered =
false;
835 int transferShockToDamageCoef =
g_Game.ConfigGetInt(
string.Format(
"%1 %2 DamageApplied transferShockToDamage",
CFG_AMMO, ammo));
836 if (transferShockToDamageCoef == 1)
839 AddHealth(
"",
"Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone,
"Shock"), damageType));
844 animal_bleeding.
CreateWound( damageResult, dmgZone, ammo );
849 if (ComputeDamageHitParams(source, dmgZone, ammo, type, direction) ==
true)
851 QueueDamageHit(type, direction);
858 m_DamageHitToProcess =
true;
859 m_DamageHitType = type;
860 m_DamageHitDirection = direction;
867 float angleDeg = ComputeHitDirectionAngleDeg(source);
868 direction = TranslateHitAngleDegToDirectionIndex(angleDeg);
870 direction += FindComponentDirectionOffset(dmgZone);
877 vector targetDirection = GetDirection();
880 targetDirection[1] = 0;
881 toSourceDirection[1] = 0;
883 targetDirection.Normalize();
884 toSourceDirection.Normalize();
886 float cosFi =
vector.Dot(targetDirection, toSourceDirection);
887 vector cross = targetDirection * toSourceDirection;
889 float dirAngleDeg =
Math.Acos(cosFi) *
Math.RAD2DEG;
891 dirAngleDeg = -dirAngleDeg;
898 if (angleDeg >= -20 && angleDeg <= 20)
902 else if (angleDeg < 0)
912 const int directionCount = 4;
921 offset = directionCount;
925 offset = 2 * directionCount;
929 offset = 3 * directionCount;
950 RegisterTransportHit(transport);
991 return m_DefaultHitPosition;
996 return GetSelectionPositionMS(pSelection);
1004 return damage *
GameConstants.NL_DAMAGE_CLOSECOMBAT_CONVERSION_ANIMALS;
1006 return damage *
GameConstants.NL_DAMAGE_FIREARM_CONVERSION_ANIMALS;
1009 return super.ConvertNonlethalDamage(damage, damageType);
Param4< int, int, string, int > TSelectableActionInfoWithColor
class AnimalBase extends DayZAnimal RegisterHitComponentsForAI()
base class of all commands exposed to script to provide common functionality over animations
Super root of all classes in Enforce script.
void CreateWound(TotalDamageResult damage_result, string zone_name, string ammo)
do not process rotations !
vector SetDefaultHitPosition(string pSelection)
proto native void SignalAIAttackEnded()
bool HandleDeath(int currentCommandID, DayZAnimalInputController inputController)
proto native DayZAnimalCommandScript StartCommand_Script(DayZAnimalCommandScript pInfectedCommand)
scripted commands
proto native void StartCommand_Hit(int pType, int pDirection)
proto native void StartCommand_Jump()
proto native DayZAnimalCommandScript GetCommand_Script()
void RegisterHitComponentsForAI()
register hit components for AI melee (used by attacking AI)
int FindComponentDirectionOffset(string component)
bool HandleDamageHit(int currentCommandID)
override string GetDefaultHitPositionComponent()
bool ComputeDamageHitParams(EntityAI source, string dmgZone, string ammo, out int type, out int direction)
override vector GetDefaultHitPosition()
proto native void StartCommand_Attack()
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
override int GetHideIconMask()
override bool IsHealthVisible()
string m_DefaultHitComponent
proto native DayZAnimalInputController GetInputController()
override bool IsInventoryVisible()
override string GetHitComponentForAI()
float ConvertNonlethalDamage(float damage, DamageType damageType)
proto native void StartCommand_Death(int pType, int pDirection)
ref array< ref DayZAIHitComponent > m_HitComponentsForAI
Melee hit components (AI targeting)
proto native DayZAnimalCommandScript StartCommand_ScriptInst(typename pCallbackClass)
void CommandHandler(float dt, int currentCommandID, bool currentCommandFinished)
void EOnContact(IEntity other, Contact extra)
proto native void StartCommand_Move()
override string GetDefaultHitComponent()
vector m_DefaultHitPosition
float ComputeHitDirectionAngleDeg(EntityAI source)
string m_DefaultHitPositionComponent
proto native void SignalAIAttackStarted()
void QueueDamageHit(int type, int direction)
int TranslateHitAngleDegToDirectionIndex(float angleDeg)
void AttenuateSoundIfNecessary(SoundObject soundObject)
DayZPlayer m_CinematicPlayer
void OnSoundVoiceEvent(int event_id, string event_user_string)
void OnStepEvent(int event_id, string event_user_string)
bool ResistContaminatedEffect()
AbstractWave PlaySound(SoundObject so, SoundObjectBuilder sob)
void RegisterAnimEvents()
override bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
void AddDamageSphere(AnimDamageParams damage_params)
void OnDamageEvent(int event_id, string event_user_string)
void DecreaseEffectTriggerCount()
void CinematicTakeControl(DayZPlayer player)
override void EEKilled(Object killer)
void OnSoundEvent(int event_id, string event_user_string)
void IncreaseEffectTriggerCount()
AnimBootsType GetBootsType()
Serialization general interface. Serializer API works with:
Native class for boats - handles physics simulation.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DamageType
exposed from C++ (do not change)
override bool DisableVicinityIcon()
proto native DayZCreatureAnimInterface GetAnimInterface()
proto native void PrePhys_SetRotation(float pInRot[4])
bool PostPhysUpdate(float pDt)
class DayZCreatureAI extends DayZCreature COMMANDID_ATTACK
proto native void SetAnimationInstanceByName(string animation_instance_name, int instance_uuid, float duration)
proto native void PostPhys_SetPosition(vector pInTransl)
quaternion in world space
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
class DayZCreatureAI extends DayZCreature COMMANDID_HIT
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
class DayZAnimalCommandMove extends AnimCommandBase SetFlagFinished(bool pFinished)
DayZAnimalCommandScript fully scriptable command.
override bool HasFixedActionTargetCursorPosition()
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
proto native void UpdateSimulationPrecision(int simLOD)
proto native bool PrePhys_GetRotation(out float pOutRot[4])
proto native int GetCurrentAnimationInstanceUUID()
proto native bool IsDeathProcessed()
proto native void PostPhys_GetRotation(out float pOutRot[4])
vec3 in world space
class DayZCreatureAI extends DayZCreature COMMANDID_MOVE
override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
class DayZCreatureAI extends DayZCreature COMMANDID_SCRIPT
proto native bool PrePhys_GetTranslation(out vector pOutTransl)
script function usable in PrePhysUpdate
proto native void PostPhys_SetRotation(float pInRot[4])
vec3 in world space
override bool IsIgnoredByConstruction()
proto native void PrePhys_SetTranslation(vector pInTransl)
proto native void ResetDeath()
proto native void StartDeath()
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
class DayZCreatureAI extends DayZCreature COMMANDID_JUMP
proto native void PostPhys_LockRotation()
quaternion in world space
override bool CanBeSkinned()
proto native void ResetDeathCooldown()
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
class DayZCreatureAI extends DayZCreature COMMANDID_DEATH
override bool IsManagingArrows()
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
override bool IsDayZCreature()
proto native void PostPhys_GetPosition(out vector pOutTransl)
script function usable in PostPhysUpdate
proto native bool IsDeathConditionMet()
ref array< ref DayZAIHitComponent > m_HitComponentsForAI
Melee hit components (AI targeting)
string GetDefaultHitComponent()
string m_DefaultHitComponent
string GetDefaultHitPositionComponent()
string m_DefaultHitPositionComponent
proto native CGame GetGame()
const int COMP_TYPE_ANIMAL_BLEEDING
const int COMP_TYPE_BODY_STAGING
proto void Print(void var)
Prints content of variable to console/log.
proto native void SetFlags(ShapeFlags flags)
EntityEvent
Entity events for event-mask, or throwing event from code.
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
const int SAT_DEBUG_ACTION
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
class JsonUndergroundAreaTriggerData GetPosition
class HumanInputController TAnimGraphCommand
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.