Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
dayzanimal.c
Go to the documentation of this file.
1class DayZCreatureAnimInterface
2{
3 private void DayZCreatureAnimInterface() {}
4 private void ~DayZCreatureAnimInterface() {}
5
6 //-----------------------------------------------------
7 // Binds, returns -1 when error, otherwise if ok
8
10 proto native TAnimGraphCommand BindCommand(string pCommandName);
11
13 proto native TAnimGraphVariable BindVariableFloat(string pVariable);
14 proto native TAnimGraphVariable BindVariableInt(string pVariable);
15 proto native TAnimGraphVariable BindVariableBool(string pVariable);
16
18 proto native TAnimGraphTag BindTag(string pTagName);
19
21 proto native TAnimGraphEvent BindEvent(string pEventName);
22}
23
24class DayZCreature extends EntityAI
25{
26 #ifdef _DAYZ_CREATURE_DEBUG_SHADOW
27 proto native void DebugSetShadow(DayZCreature creature);
28 #endif
29
30 proto native bool RegisterAnimationEvent(string event_name, string function_name);
31
32 proto native void SetAnimationInstanceByName(string animation_instance_name, int instance_uuid, float duration);
34
36
37
38 proto native void UpdateSimulationPrecision(int simLOD);
39
40 //---------------------------------------------------------
41 // helper functions for disabling simulation upon death
42 proto native void StartDeath();
43 proto native void ResetDeath();
44
45 proto native void ResetDeathCooldown();
46 proto native bool IsDeathProcessed();
47 proto native bool IsDeathConditionMet();
48
49 //---------------------------------------------------------
50 // bone transforms
51
53 proto native int GetBoneIndexByName(string pBoneName);
54
55 override bool IsDayZCreature()
56 {
57 return true;
58 }
59
60 override bool CanBeSkinned()
61 {
62 return !GetIsFrozen();
63 }
64
66 {
67 return IsRuined();
68 }
69
70 override bool IsManagingArrows()
71 {
72 return true;
73 }
74
75 override bool DisableVicinityIcon()
76 {
77 return true;
78 }
79
80 override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
81 {
82 CachedObjectsArrays.ARRAY_STRING.Clear();
83 GetActionComponentNameList(componentIndex, CachedObjectsArrays.ARRAY_STRING, "fire");
84
85 int pivot = -1;
86
87
88 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count() && pivot == -1; i++)
89 {
90 pivot = GetBoneIndexByName(CachedObjectsArrays.ARRAY_STRING.Get(i));
91 }
92
93 vector parentTransMat[4];
94 vector arrowTransMat[4];
95
96 if (pivot == -1)
97 {
98 GetTransform(parentTransMat);
99 }
100 else
101 {
102 vector rotMatrix[3];
103 Math3D.YawPitchRollMatrix(closeBoneRotWS * Math.RAD2DEG,rotMatrix);
104
105 parentTransMat[0] = rotMatrix[0];
106 parentTransMat[1] = rotMatrix[1];
107 parentTransMat[2] = rotMatrix[2];
108 parentTransMat[3] = closeBonePosWS;
109 }
110
111 arrow.GetTransform(arrowTransMat);
112 Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
113 // orthogonalize matrix - parent might be skewed
114 Math3D.MatrixOrthogonalize4(arrowTransMat);
115 arrow.SetTransform(arrowTransMat);
116
117 AddChild(arrow, pivot);
118 }
119
121 {
122 return true;
123 }
124
125 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
126 {
127 super.GetDebugActions(outputList);
128
129 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
130 if (Gizmo_IsSupported())
131 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
132 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
133 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
134 }
135
136 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
137 {
138 if (super.OnAction(action_id, player, ctx))
139 return true;
140
141 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
142 {
143 switch (action_id)
144 {
145 case EActions.GIZMO_OBJECT:
146 if (GetGizmoApi())
147 GetGizmoApi().SelectObject(this);
148 return true;
149 case EActions.GIZMO_PHYSICS:
150 if (GetGizmoApi())
151 GetGizmoApi().SelectPhysics(GetPhysics());
152 return true;
153 }
154 }
155
156 if (g_Game.IsServer())
157 {
158 switch (action_id)
159 {
160 case EActions.DELETE:
161 Delete();
162 return true;
163 }
164 }
165
166 return false;
167 }
168
169 //-------------------------------------------------------------
173 // these functions are for modded overide in script command mods
174
175 bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
176 {
177 return false;
178 }
179
180 bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
181 {
182 return false;
183 }
184
185 bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
186 {
187 return false;
188 }
189}
190
192{
193 proto native AIAgent GetAIAgent();
194
195 proto native bool IsSoundInsideBuilding();
196#ifdef DIAG_DEVELOPER
197 proto native void DebugDisableAIControl();
198 proto native void DebugRestoreAIControl();
199#endif
200 proto native void AddDamageSphere(string bone_name, string ammo_name, float radius, float duration, bool invertTeams);
201
202 proto native DayZCreatureAIType GetCreatureAIType();
207 proto native void InitAIAgent(AIGroup group);
208 proto native void DestroyAIAgent();
209
210 int m_EffectTriggerCount;//how many effect triggers is this AI inside of(overlapping triggers)
211
213
214
216 {
218 SetFlags(EntityFlags.TOUCHTRIGGERS, false);
219 }
220
221
223 {
224 m_EffectTriggerCount++;
225 }
226
228 {
229 m_EffectTriggerCount--;
230 }
231
232 void AddDamageSphere(AnimDamageParams damage_params)
233 {
234 AddDamageSphere(damage_params.m_sBoneName, damage_params.m_sAmmoName, damage_params.m_fRadius, damage_params.m_fDuration, damage_params.m_bInvertTeams);
235 }
236
237 override void EEKilled(Object killer)
238 {
239 super.EEKilled(killer);
240 CreateComponent(COMP_TYPE_BODY_STAGING); // TO DO: This is never called on clients in multiplayer! That's why skinning doesn't work properly in MP. DAYZ-28269
241 }
242
244 {
245 return AnimBootsType.None;
246 }
247
249 {
250 if(so == NULL)
251 {
252 return NULL;
253 }
254
255 so.SetPosition(GetPosition());
256 AbstractWave wave = g_Game.GetSoundScene().Play3D(so, sob);
257 return wave;
258 }
259
260 void OnSoundEvent(int event_id, string event_user_string)
261 {
262 AnimSoundEvent sound_event = GetCreatureAIType().GetSoundEvent(event_id);
263 if(sound_event != NULL)
264 {
265 ProcessSoundEvent(sound_event);
266 }
267 }
268
269 void OnSoundVoiceEvent(int event_id, string event_user_string)
270 {
271 AnimSoundVoiceEvent voice_event = GetCreatureAIType().GetSoundVoiceEvent(event_id);
272 if(voice_event != NULL)
273 {
274 ProcessSoundVoiceEvent(voice_event);
275 }
276 }
277
278 void OnStepEvent(int event_id, string event_user_string)
279 {
280 AnimStepEvent step_event = GetCreatureAIType().GetStepEvent(event_id);
281 if(step_event != NULL)
282 {
283 ProcessStepEvent(step_event);
284 }
285 }
286
287 void OnDamageEvent(int event_id, string event_user_string)
288 {
289 AnimDamageEvent damage_event = GetCreatureAIType().GetDamageEvent(event_id);
290 if(damage_event != NULL)
291 {
292 ProcessDamageEvent(damage_event);
293 }
294 }
295
296 protected void RegisterAnimEvents()
297 {
298 if(!RegisterAnimationEvent("Sound", "OnSoundEvent"))
299 {
300 Print("Error registering anim. event (Sound)");
301 }
302
303 if(!RegisterAnimationEvent("SoundVoice", "OnSoundVoiceEvent"))
304 {
305 Print("Error registering anim. event (SoundVoice)");
306 }
307
308 if(!g_Game.IsDedicatedServer())
309 {
310 if(!RegisterAnimationEvent("Step", "OnStepEvent"))
311 {
312 Print("Error registering anim. event (Step)");
313 }
314 }
315
316 if(!RegisterAnimationEvent("Damage", "OnDamageEvent"))
317 {
318 Print("Error registering anim. event (Damage)");
319 }
320 }
321
322 private void ProcessSoundEvent(AnimSoundEvent sound_event)
323 {
324 if(!g_Game.IsDedicatedServer())
325 {
326 SoundObjectBuilder objectBuilder = sound_event.GetSoundBuilder();
327 if(NULL != objectBuilder)
328 {
329 objectBuilder.AddEnvSoundVariables(GetPosition());
330 SoundObject soundObject = objectBuilder.BuildSoundObject();
331 PlaySound(soundObject, objectBuilder);
332 }
333 }
334
335 if(g_Game.IsServer())
336 {
337 if(sound_event.m_NoiseParams != NULL)
338 g_Game.GetNoiseSystem().AddNoise(this, sound_event.m_NoiseParams, g_Game.GetWeather().GetNoiseReductionByWeather());
339 }
340 }
341
342 private void ProcessSoundVoiceEvent(AnimSoundVoiceEvent sound_event)
343 {
344 if(!g_Game.IsDedicatedServer())
345 {
346 SoundObjectBuilder objectBuilder = sound_event.GetSoundBuilder();
347 if(NULL != objectBuilder)
348 {
349 objectBuilder.AddEnvSoundVariables(GetPosition());
350 SoundObject soundObject = objectBuilder.BuildSoundObject();
351 AttenuateSoundIfNecessary(soundObject);
352 PlaySound(soundObject, objectBuilder);
353 }
354 }
355
356 if(g_Game.IsServer())
357 {
358 if(sound_event.m_NoiseParams != NULL)
359 g_Game.GetNoiseSystem().AddNoise(this, sound_event.m_NoiseParams, g_Game.GetWeather().GetNoiseReductionByWeather());
360 }
361 }
362
363 private void ProcessStepEvent(AnimStepEvent step_event)
364 {
365 SoundObjectBuilder soundBuilder = step_event.GetSoundBuilder(GetSurfaceType().Hash());
366 if(soundBuilder == NULL)
367 return;
368
369 soundBuilder.AddEnvSoundVariables(GetPosition());
370 SoundObject soundObject = soundBuilder.BuildSoundObject();
371 AttenuateSoundIfNecessary(soundObject);
372 PlaySound(soundObject, soundBuilder);
373
374 //TODO effects
375 }
376
377 private void ProcessDamageEvent(AnimDamageEvent damage_event)
378 {
379 AddDamageSphere(damage_event.m_DamageParams);
380 }
381
382 protected void AttenuateSoundIfNecessary(SoundObject soundObject)
383 {
384 if (g_Game.GetPlayer() != NULL && (IsSoundInsideBuilding() != g_Game.GetPlayer().IsSoundInsideBuilding() || g_Game.GetPlayer().IsCameraInsideVehicle()))
385 {
386 soundObject.SetKind(WaveKind.WAVEATTALWAYS);
387 }
388 else
389 {
390 soundObject.SetKind(WaveKind.WAVEEFFECTEX);
391 }
392 }
393
395 {
396 return false;
397 }
398
399 // ================
400 // EASTER EGG
401 // ================
402
403 //Used for easter egg sound selection
404 bool IsDanger()
405 {
406 return false;
407 }
408
410 {
411 return "";
412 }
413
415 {
416 return "";
417 }
418
419 // ================
420 // CINEMATIC CONTROLLER
421 // ================
422
424 {
425 m_CinematicPlayer = player;
426 }
427
429 {
430 return true;
431 }
432
433 override bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
434 {
436 {
437 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
438 }
439
440 UAInterface input = m_CinematicPlayer.GetInputInterface();
441
443 g_Game.GameScript.CallFunction(this, "GetInputController", controller, 0);
444
445 if (!input || !controller)
446 {
447 return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
448 }
449
450 float movementX = input.SyncedValue_ID(UAAimRight) - input.SyncedValue_ID(UAAimLeft);
451
452 float maxTurnSpeed = 100.0;
453 movementX = Math.Clamp(movementX * maxTurnSpeed * pDt, -180, 180);
454
455 if (input.SyncedValue_ID(UALookAround) > 0)
456 {
457 movementX = 0;
458 }
459
460 bool isJump = input.SyncedValue_ID(UAGetOver) > 0;
461 bool isMove = input.SyncedValue_ID(UAMoveForward) > 0;
462
463 bool isRest = input.SyncedValue_ID(UAMoveBack) > 0;
464 bool isSleep = input.SyncedValue_ID(UAReloadMagazine) > 0;
465
466 float heading = GetOrientation()[0] + movementX;
467
468 int iAlert = 0;
469 float fAlert = 0;
470 int iSpeed = 0;
471 float fSpeed = 0;
472
473 if (isMove)
474 {
475 iAlert = 1;
476 fAlert = 0.2;
477
478 bool isSprint = input.SyncedValue_ID(UATurbo) > 0;
479 bool isJog = input.SyncedValue_ID(UAWalkRunTemp) > 0;
480 bool isWalk = !isSprint && !isJog;
481 if (isSprint)
482 {
484 iSpeed = 3;
485 }
486 else if (isJog)
487 {
489 iSpeed = 2;
490 }
491 else if (isWalk)
492 {
494 iSpeed = 1;
495 }
496 }
497
498 DayZAnimalInputController animalController;
499 if (Class.CastTo(animalController, controller))
500 {
501 animalController.OverrideBehaviourSlot(true, DayZAnimalBehaviourSlot.NON_SPECIFIC_THREAT);
502 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.TRAVELING_INPUT);
503
504 if (!isMove)
505 {
506 if (isRest)
507 {
508 iSpeed = 0;
509 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.IDLE1_INPUT);
510 }
511
512 if (isSleep)
513 {
514 iSpeed = 0;
515 animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.WALKING_INPUT);
516 }
517 }
518 }
519
520 bool lowVel = GetVelocity(this).Length() < 0.5;
521 if (iSpeed > 0 && lowVel)
522 {
523 iAlert = 4;
524 fAlert = 1.0;
525
526 iSpeed = 3;
527 }
528
529 if (animalController)
530 {
531 switch (iSpeed)
532 {
533 case 0:
534 fSpeed = 0;
535 break;
536 case 1:
537 fSpeed = 2;
538 break;
539 case 2:
540 fSpeed = 3;
541 break;
542 case 3:
543 fSpeed = 5;
544 break;
545 }
546 }
547
548 controller.OverrideTurnSpeed(true, Math.PI2 / pDt);
549 controller.OverrideMovementSpeed(true, fSpeed);
550 controller.OverrideHeading(true, heading * Math.DEG2RAD);
551 controller.OverrideAlertLevel(true, true, iAlert, fAlert);
552
553 if (CinematicCanJump() && isJump)
554 {
555 controller.OverrideJump(true, 101, 2.0);
556 }
557
558 return true;
559 }
560}
561
562enum DayZAnimalConstants
563{
570};
571
573{
574
575}
576
577class DayZAnimalCommandAttack extends AnimCommandBase
578{
579
580}
581
582class DayZAnimalCommandJump extends AnimCommandBase
583{
584
585}
586
587class DayZAnimalCommandLookAt extends AnimCommandBase
588{
589
590}
591
592class DayZAnimalCommandBehaviourModifier extends AnimCommandBase
593{
594
595}
596
597class DayZAnimalCommandHit extends AnimCommandBase
598{
599
600}
601
602class DayZAnimalCommandDeath extends AnimCommandBase
603{
604
605}
606
607class DayZAnimalCommandAnimCallback extends AnimCommandBase
608{
609
610}
611
619class DayZAnimalCommandScript extends AnimCommandBase
620{
622 //void DayZAnimalCommandScript(DayZAnimal pAnimal)
623
624 //---------------------------------------------------------------
625 // usable everywhere
626
628 proto native void SetFlagFinished(bool pFinished);
629
630 //---------------------------------------------------------------
631 // PrePhys Update
632
634 proto native bool PrePhys_GetTranslation(out vector pOutTransl); // vec3 in local space !
635 proto native bool PrePhys_GetRotation(out float pOutRot[4]); // quaternion in local space !
636 proto native void PrePhys_SetTranslation(vector pInTransl); // vec3 in local space !
637 proto native void PrePhys_SetRotation(float pInRot[4]); // quaternion in local space !
638
639 //---------------------------------------------------------------
640 // PostPhys Update
641
645 bool PostPhysUpdate(float pDt);
646
648 proto native void PostPhys_GetPosition(out vector pOutTransl);
649 proto native void PostPhys_GetRotation(out float pOutRot[4]);
650 proto native void PostPhys_SetPosition(vector pInTransl);
651 proto native void PostPhys_SetRotation(float pInRot[4]);
652 proto native void PostPhys_LockRotation();
653}
654
656{
657
660 protected string m_DefaultHitComponent;
663
665
666 proto native void StartCommand_Death(int pType, int pDirection);
667 proto native void StartCommand_Move();
668 proto native void StartCommand_Jump();
669 proto native void StartCommand_Attack();
670 proto native void StartCommand_Hit(int pType, int pDirection);
671
673 proto native DayZAnimalCommandScript StartCommand_Script(DayZAnimalCommandScript pInfectedCommand);
674 proto native DayZAnimalCommandScript StartCommand_ScriptInst(typename pCallbackClass);
675 proto native DayZAnimalCommandScript GetCommand_Script();
676
677 proto native void SignalAIAttackStarted();
678 proto native void SignalAIAttackEnded();
679
681 {
682 // testing: animals have no inventory by default
683 //GetInventory().LockInventory(LOCK_FROM_SCRIPT); // Hides animals from vicinity in inventory. Remove this if wanted otherwise.
684
686
688
691
692 SetEventMask(EntityEvent.CONTACT);
693 }
694
695 override bool IsHealthVisible()
696 {
697 return false;
698 }
699
700 override bool IsAnimal()
701 {
702 return true;
703 }
704
705 override bool IsInventoryVisible()
706 {
707 return false;
708 }
709
710 override int GetHideIconMask()
711 {
712 return EInventoryIconVisibility.HIDE_VICINITY;
713 /*
714 if (IsAlive())
715 {
716 return EInventoryIconVisibility.HIDE_VICINITY;
717 }
718 return super.GetHideIconMask();
719 */
720 }
721
722 void CommandHandler(float dt, int currentCommandID, bool currentCommandFinished)
723 {
725
727 if( ModCommandHandlerBefore(dt, currentCommandID, currentCommandFinished) )
728 {
729 return;
730 }
731
732 if (HandleDeath(currentCommandID, inputController))
733 {
734 return;
735 }
736
737 if (currentCommandFinished)
738 {
739 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
740 {
742 }
743
745
746 return;
747 }
748
750 if( ModCommandHandlerInside(dt, currentCommandID, currentCommandFinished) )
751 {
752 return;
753 }
754
755 if (HandleDamageHit(currentCommandID))
756 {
757 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
758 {
760 }
761 return;
762 }
763
764 if (currentCommandID == DayZAnimalConstants.COMMANDID_MOVE)
765 {
766 if (inputController.IsJump())
767 {
769 return;
770 }
771
772 if (inputController.IsAttack())
773 {
776 return;
777 }
778 }
779
781 if( ModCommandHandlerAfter(dt, currentCommandID, currentCommandFinished) )
782 {
783 return;
784 }
785 }
786
790
791 bool HandleDeath(int currentCommandID, DayZAnimalInputController inputController)
792 {
793 if (inputController.IsDead())
794 {
795 if (currentCommandID == DayZAnimalConstants.COMMANDID_DEATH)
796 {
797 return true;
798 }
799
801 {
802 m_DamageHitToProcess = false;
803
805 }
806 else
807 {
808 StartCommand_Death(0, 0);
809 }
810
811 return true;
812 }
813
814 return false;
815 }
816
817 bool HandleDamageHit(int currentCommandID)
818 {
820 {
821 m_DamageHitToProcess = false;
822
823 if (currentCommandID != DayZAnimalConstants.COMMANDID_HIT)
824 {
826 }
827 return true;
828 }
829 return false;
830 }
831
832 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
833 {
834 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
835 m_TransportHitRegistered = false;
836
837 int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
838 if (transferShockToDamageCoef == 1)
839 {
840 //Print("DayZAnimal | EEHitBy | nonlethal hit");
841 AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
842 }
843 else
844 {
845 ComponentAnimalBleeding animal_bleeding = ComponentAnimalBleeding.Cast( GetComponent( COMP_TYPE_ANIMAL_BLEEDING ) );
846 animal_bleeding.CreateWound( damageResult, dmgZone, ammo );
847 }
848
849 int type = 0;
850 int direction = 0;
851 if (ComputeDamageHitParams(source, dmgZone, ammo, type, direction) == true)
852 {
853 QueueDamageHit(type, direction);
854 }
855
856 }
857
858 void QueueDamageHit(int type, int direction)
859 {
861 m_DamageHitType = type;
862 m_DamageHitDirection = direction;
863 }
864
865 bool ComputeDamageHitParams(EntityAI source, string dmgZone, string ammo, out int type, out int direction)
866 {
867 type = 0; // not used right now
868
869 float angleDeg = ComputeHitDirectionAngleDeg(source);
870 direction = TranslateHitAngleDegToDirectionIndex(angleDeg);
871
872 direction += FindComponentDirectionOffset(dmgZone);
873
874 return true;
875 }
876
878 {
879 vector targetDirection = GetDirection();
880 vector toSourceDirection = (source.GetPosition() - GetPosition());
881
882 targetDirection[1] = 0;
883 toSourceDirection[1] = 0;
884
885 targetDirection.Normalize();
886 toSourceDirection.Normalize();
887
888 float cosFi = vector.Dot(targetDirection, toSourceDirection);
889 vector cross = targetDirection * toSourceDirection;
890
891 float dirAngleDeg = Math.Acos(cosFi) * Math.RAD2DEG;
892 if ( cross[1] < 0 )
893 dirAngleDeg = -dirAngleDeg;
894
895 return dirAngleDeg;
896 }
897
899 {
900 if (angleDeg >= -20 && angleDeg <= 20) // front
901 {
902 return 1;
903 }
904 else if (angleDeg < 0) // left
905 {
906 return 2;
907 }
908
909 return 3; // right
910 }
911
913 {
914 const int directionCount = 4;
915
916 int offset = 0;
917 if (component.Length() == 0)
918 {
919 offset = 0;
920 }
921 else if (component == "Zone_Head")
922 {
923 offset = directionCount;
924 }
925 else if (component == "Zone_Chest" || component == "Zone_Legs_Front" || component == "Zone_Spine_Front" || component == "Zone_Neck")
926 {
927 offset = 2 * directionCount;
928 }
929 else
930 {
931 offset = 3 * directionCount;
932 }
933
934 return offset;
935 }
936
937 //-------------------------------------------------------------
941
942 override protected void EOnContact(IEntity other, Contact extra)
943 {
944 if( !IsAlive() )
945 return;
946
947 Transport transport = Transport.Cast(other);
948 if( transport )
949 {
950 if ( g_Game.IsServer() )
951 {
952 RegisterTransportHit(transport);
953 }
954 }
955 }
956
959 {
961 m_DefaultHitComponent = "Zone_Chest";
964
966 DayZAIHitComponentHelpers.RegisterHitComponent(m_HitComponentsForAI, "Zone_Chest", 50);
967 }
968
969 override string GetHitComponentForAI()
970 {
971 string hitComp;
972
973 if (DayZAIHitComponentHelpers.SelectMostProbableHitComponent(m_HitComponentsForAI, hitComp))
974 {
975 return hitComp;
976 }
977
978 return GetDefaultHitComponent();
979 }
980
981 override string GetDefaultHitComponent()
982 {
984 }
985
987 {
989 }
990
992 {
994 }
995
996 protected vector SetDefaultHitPosition(string pSelection)
997 {
998 return GetSelectionPositionMS(pSelection);
999 }
1000
1001 override protected float ConvertNonlethalDamage(float damage, DamageType damageType)
1002 {
1003 switch (damageType)
1004 {
1005 case DamageType.CLOSE_COMBAT:
1006 return damage * GameConstants.NL_DAMAGE_CLOSECOMBAT_CONVERSION_ANIMALS;
1007 case DamageType.FIRE_ARM:
1008 return damage * GameConstants.NL_DAMAGE_FIREARM_CONVERSION_ANIMALS;
1009 }
1010
1011 return super.ConvertNonlethalDamage(damage, damageType);
1012 }
1013}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
class AnimalBase extends DayZAnimal RegisterHitComponentsForAI()
Definition animalbase.c:40
vector GetOrientation()
base class of all commands exposed to script to provide common functionality over animations
Definition animcommand.c:3
Super root of all classes in Enforce script.
Definition enscript.c:11
void CreateWound(TotalDamageResult damage_result, string zone_name, string ammo)
do not process rotations !
Definition dayzanimal.c:656
vector SetDefaultHitPosition(string pSelection)
Definition dayzanimal.c:996
proto native void SignalAIAttackEnded()
bool HandleDeath(int currentCommandID, DayZAnimalInputController inputController)
Definition dayzanimal.c:791
override bool IsAnimal()
Definition dayzanimal.c:700
bool m_DamageHitToProcess
Definition dayzanimal.c:787
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)
Definition dayzanimal.c:958
int FindComponentDirectionOffset(string component)
Definition dayzanimal.c:912
bool HandleDamageHit(int currentCommandID)
Definition dayzanimal.c:817
override string GetDefaultHitPositionComponent()
Definition dayzanimal.c:986
bool ComputeDamageHitParams(EntityAI source, string dmgZone, string ammo, out int type, out int direction)
Definition dayzanimal.c:865
void DayZAnimal()
Definition dayzanimal.c:680
override vector GetDefaultHitPosition()
Definition dayzanimal.c:991
proto native void StartCommand_Attack()
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition dayzanimal.c:832
override int GetHideIconMask()
Definition dayzanimal.c:710
override bool IsHealthVisible()
Definition dayzanimal.c:695
string m_DefaultHitComponent
Definition dayzanimal.c:660
proto native DayZAnimalInputController GetInputController()
override bool IsInventoryVisible()
Definition dayzanimal.c:705
override string GetHitComponentForAI()
Definition dayzanimal.c:969
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).
Definition dayzanimal.c:659
proto native DayZAnimalCommandScript StartCommand_ScriptInst(typename pCallbackClass)
void CommandHandler(float dt, int currentCommandID, bool currentCommandFinished)
Definition dayzanimal.c:722
void EOnContact(IEntity other, Contact extra)
Definition dayzanimal.c:942
int m_DamageHitDirection
Definition dayzanimal.c:789
proto native void StartCommand_Move()
override string GetDefaultHitComponent()
Definition dayzanimal.c:981
vector m_DefaultHitPosition
Definition dayzanimal.c:662
float ComputeHitDirectionAngleDeg(EntityAI source)
Definition dayzanimal.c:877
string m_DefaultHitPositionComponent
Definition dayzanimal.c:661
proto native void SignalAIAttackStarted()
void QueueDamageHit(int type, int direction)
Definition dayzanimal.c:858
int TranslateHitAngleDegToDirectionIndex(float angleDeg)
Definition dayzanimal.c:898
void AttenuateSoundIfNecessary(SoundObject soundObject)
Definition dayzanimal.c:382
DayZPlayer m_CinematicPlayer
Definition dayzanimal.c:212
void OnSoundVoiceEvent(int event_id, string event_user_string)
Definition dayzanimal.c:269
string CaptureSound()
Definition dayzanimal.c:409
bool CinematicCanJump()
Definition dayzanimal.c:428
void OnStepEvent(int event_id, string event_user_string)
Definition dayzanimal.c:278
bool ResistContaminatedEffect()
Definition dayzanimal.c:394
AbstractWave PlaySound(SoundObject so, SoundObjectBuilder sob)
Definition dayzanimal.c:248
bool IsDanger()
Definition dayzanimal.c:404
void DayZCreatureAI()
Definition dayzanimal.c:215
void RegisterAnimEvents()
Definition dayzanimal.c:296
override bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition dayzanimal.c:433
void AddDamageSphere(AnimDamageParams damage_params)
Definition dayzanimal.c:232
void OnDamageEvent(int event_id, string event_user_string)
Definition dayzanimal.c:287
void DecreaseEffectTriggerCount()
Definition dayzanimal.c:227
void CinematicTakeControl(DayZPlayer player)
Definition dayzanimal.c:423
override void EEKilled(Object killer)
Definition dayzanimal.c:237
void OnSoundEvent(int event_id, string event_user_string)
Definition dayzanimal.c:260
void IncreaseEffectTriggerCount()
Definition dayzanimal.c:222
AnimBootsType GetBootsType()
Definition dayzanimal.c:243
string ReleaseSound()
Definition dayzanimal.c:414
Definition enmath.c:7
Native class for boats - handles physics simulation.
Definition boat.c:32
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DamageType
exposed from C++ (do not change)
override bool DisableVicinityIcon()
Definition dayzanimal.c:75
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)
Definition dayzanimal.c:180
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()
Definition dayzanimal.c:120
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition dayzanimal.c:136
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
override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
Definition dayzanimal.c:80
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
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()
Definition dayzanimal.c:65
proto native void PrePhys_SetTranslation(vector pInTransl)
proto native void ResetDeath()
proto native void StartDeath()
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition dayzanimal.c:125
class DayZCreatureAI extends DayZCreature COMMANDID_JUMP
proto native void PostPhys_LockRotation()
quaternion in world space
override bool CanBeSkinned()
Definition dayzanimal.c:60
proto native void ResetDeathCooldown()
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition dayzanimal.c:175
override bool IsManagingArrows()
Definition dayzanimal.c:70
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition dayzanimal.c:185
override bool IsDayZCreature()
Definition dayzanimal.c:55
proto native void PostPhys_GetPosition(out vector pOutTransl)
script function usable in PostPhysUpdate
proto native bool IsDeathConditionMet()
DayZAnimalBehaviourSlot
defined in C++
DayZAnimalBehaviourAction
defined in C++
AnimBootsType
DayZGame g_Game
Definition dayzgame.c:3942
string GetDefaultHitComponent()
Definition dayzplayer.c:497
@ COMMANDID_MOVE
Definition dayzplayer.c:696
@ COMMANDID_SCRIPT
Definition dayzplayer.c:708
@ COMMANDID_DEATH
Definition dayzplayer.c:701
string GetDefaultHitPositionComponent()
Definition dayzplayer.c:502
EActions
Definition eactions.c:2
Serializer ParamsReadContext
Definition gameplay.c:15
proto GizmoApi GetGizmoApi()
const int COMP_TYPE_ANIMAL_BLEEDING
Definition component.c:11
const int COMP_TYPE_BODY_STAGING
Definition component.c:10
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.
Definition enentity.c:45
EntityFlags
Entity flags.
Definition enentity.c:115
const string CFG_AMMO
Definition constants.c:223
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
const int SAT_DEBUG_ACTION
Definition constants.c:457
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
void SoundObject(SoundParams soundParams)
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
void AbstractWave()
Definition sound.c:167
int TAnimGraphVariable
Definition human.c:277
int TAnimGraphTag
Definition human.c:278
class HumanInputController TAnimGraphCommand
int TAnimGraphEvent
Definition human.c:279
void PlaySound()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
WaveKind
Definition sound.c:2