Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzanimal.c
Go to the documentation of this file.
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 
24 class 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);
33  proto native int GetCurrentAnimationInstanceUUID();
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 true;
63  }
64 
65  override bool IsIgnoredByConstruction()
66  {
67  return IsRuined();
68  }
69 
70  override bool IsManagingArrows()
71  {
72  return true;
73  }
74 
75  override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
76  {
77  CachedObjectsArrays.ARRAY_STRING.Clear();
78  GetActionComponentNameList(componentIndex, CachedObjectsArrays.ARRAY_STRING, "fire");
79 
80  int pivot = -1;
81 
82 
83  for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count() && pivot == -1; i++)
84  {
85  pivot = GetBoneIndexByName(CachedObjectsArrays.ARRAY_STRING.Get(i));
86  }
87 
88  vector parentTransMat[4];
89  vector arrowTransMat[4];
90 
91  if (pivot == -1)
92  {
93  GetTransform(parentTransMat);
94  }
95  else
96  {
97  vector rotMatrix[3];
98  Math3D.YawPitchRollMatrix(closeBoneRotWS * Math.RAD2DEG,rotMatrix);
99 
100  parentTransMat[0] = rotMatrix[0];
101  parentTransMat[1] = rotMatrix[1];
102  parentTransMat[2] = rotMatrix[2];
103  parentTransMat[3] = closeBonePosWS;
104  }
105 
106  arrow.GetTransform(arrowTransMat);
107  Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
108  // orthogonalize matrix - parent might be skewed
109  Math3D.MatrixOrthogonalize4(arrowTransMat);
110  arrow.SetTransform(arrowTransMat);
111 
112  AddChild(arrow, pivot);
113  }
114 
116  {
117  return true;
118  }
119 
120  //-------------------------------------------------------------
124  // these functions are for modded overide in script command mods
125 
126  bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
127  {
128  return false;
129  }
130 
131  bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
132  {
133  return false;
134  }
135 
136  bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
137  {
138  return false;
139  }
140 }
141 
143 {
144  proto native AIAgent GetAIAgent();
145 
146  proto native bool IsSoundInsideBuilding();
147 #ifdef DIAG_DEVELOPER
148  proto native void DebugDisableAIControl();
149  proto native void DebugRestoreAIControl();
150 #endif
151  proto native void AddDamageSphere(string bone_name, string ammo_name, float radius, float duration, bool invertTeams);
152 
153  proto native DayZCreatureAIType GetCreatureAIType();
158  proto native void InitAIAgent(AIGroup group);
159  proto native void DestroyAIAgent();
160 
161  int m_EffectTriggerCount;//how many effect triggers is this AI inside of(overlapping triggers)
162 
163  protected DayZPlayer m_CinematicPlayer;
164 
165 
166  void DayZCreatureAI()
167  {
168  RegisterAnimEvents();
169  SetFlags(EntityFlags.TOUCHTRIGGERS, false);
170  }
171 
172 
173  void IncreaseEffectTriggerCount()
174  {
175  m_EffectTriggerCount++;
176  }
177 
178  void DecreaseEffectTriggerCount()
179  {
180  m_EffectTriggerCount--;
181  }
182 
183  void AddDamageSphere(AnimDamageParams damage_params)
184  {
185  AddDamageSphere(damage_params.m_sBoneName, damage_params.m_sAmmoName, damage_params.m_fRadius, damage_params.m_fDuration, damage_params.m_bInvertTeams);
186  }
187 
188  override void EEKilled(Object killer)
189  {
190  super.EEKilled(killer);
191  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
192  }
193 
194  AnimBootsType GetBootsType()
195  {
196  return AnimBootsType.None;
197  }
198 
200  {
201  if(so == NULL)
202  {
203  return NULL;
204  }
205 
206  so.SetPosition(GetPosition());
207  AbstractWave wave = GetGame().GetSoundScene().Play3D(so, sob);
208  return wave;
209  }
210 
211  void OnSoundEvent(int event_id, string event_user_string)
212  {
213  AnimSoundEvent sound_event = GetCreatureAIType().GetSoundEvent(event_id);
214  if(sound_event != NULL)
215  {
216  ProcessSoundEvent(sound_event);
217  }
218  }
219 
220  void OnSoundVoiceEvent(int event_id, string event_user_string)
221  {
222  AnimSoundVoiceEvent voice_event = GetCreatureAIType().GetSoundVoiceEvent(event_id);
223  if(voice_event != NULL)
224  {
225  ProcessSoundVoiceEvent(voice_event);
226  }
227  }
228 
229  void OnStepEvent(int event_id, string event_user_string)
230  {
231  AnimStepEvent step_event = GetCreatureAIType().GetStepEvent(event_id);
232  if(step_event != NULL)
233  {
234  ProcessStepEvent(step_event);
235  }
236  }
237 
238  void OnDamageEvent(int event_id, string event_user_string)
239  {
240  AnimDamageEvent damage_event = GetCreatureAIType().GetDamageEvent(event_id);
241  if(damage_event != NULL)
242  {
243  ProcessDamageEvent(damage_event);
244  }
245  }
246 
247  protected void RegisterAnimEvents()
248  {
249  if(!RegisterAnimationEvent("Sound", "OnSoundEvent"))
250  {
251  Print("Error registering anim. event (Sound)");
252  }
253 
254  if(!RegisterAnimationEvent("SoundVoice", "OnSoundVoiceEvent"))
255  {
256  Print("Error registering anim. event (SoundVoice)");
257  }
258 
259  if(!GetGame().IsDedicatedServer())
260  {
261  if(!RegisterAnimationEvent("Step", "OnStepEvent"))
262  {
263  Print("Error registering anim. event (Step)");
264  }
265  }
266 
267  if(!RegisterAnimationEvent("Damage", "OnDamageEvent"))
268  {
269  Print("Error registering anim. event (Damage)");
270  }
271  }
272 
273  private void ProcessSoundEvent(AnimSoundEvent sound_event)
274  {
275  if(!GetGame().IsDedicatedServer())
276  {
277  SoundObjectBuilder objectBuilder = sound_event.GetSoundBuilder();
278  if(NULL != objectBuilder)
279  {
280  objectBuilder.AddEnvSoundVariables(GetPosition());
281  SoundObject soundObject = objectBuilder.BuildSoundObject();
282  PlaySound(soundObject, objectBuilder);
283  }
284  }
285 
286  if(GetGame().IsServer())
287  {
288  if(sound_event.m_NoiseParams != NULL)
289  GetGame().GetNoiseSystem().AddNoise(this, sound_event.m_NoiseParams);
290  }
291  }
292 
293  private void ProcessSoundVoiceEvent(AnimSoundVoiceEvent sound_event)
294  {
295  if(!GetGame().IsDedicatedServer())
296  {
297  SoundObjectBuilder objectBuilder = sound_event.GetSoundBuilder();
298  if(NULL != objectBuilder)
299  {
300  objectBuilder.AddEnvSoundVariables(GetPosition());
301  SoundObject soundObject = objectBuilder.BuildSoundObject();
302  AttenuateSoundIfNecessary(soundObject);
303  PlaySound(soundObject, objectBuilder);
304  }
305  }
306 
307  if(GetGame().IsServer())
308  {
309  if(sound_event.m_NoiseParams != NULL)
310  GetGame().GetNoiseSystem().AddNoise(this, sound_event.m_NoiseParams);
311  }
312  }
313 
314  private void ProcessStepEvent(AnimStepEvent step_event)
315  {
316  SoundObjectBuilder soundBuilder = step_event.GetSoundBuilder(GetSurfaceType().Hash());
317  if(soundBuilder == NULL)
318  return;
319 
320  soundBuilder.AddEnvSoundVariables(GetPosition());
321  SoundObject soundObject = soundBuilder.BuildSoundObject();
322  AttenuateSoundIfNecessary(soundObject);
323  PlaySound(soundObject, soundBuilder);
324 
325  //TODO effects
326  }
327 
328  private void ProcessDamageEvent(AnimDamageEvent damage_event)
329  {
330  AddDamageSphere(damage_event.m_DamageParams);
331  }
332 
333  protected void AttenuateSoundIfNecessary(SoundObject soundObject)
334  {
335  if (GetGame().GetPlayer() != NULL && (IsSoundInsideBuilding() != GetGame().GetPlayer().IsSoundInsideBuilding() || GetGame().GetPlayer().IsCameraInsideVehicle()))
336  {
337  soundObject.SetKind(WaveKind.WAVEATTALWAYS);
338  }
339  else
340  {
341  soundObject.SetKind(WaveKind.WAVEEFFECTEX);
342  }
343  }
344 
346  {
347  return false;
348  }
349 
350  // ================
351  // EASTER EGG
352  // ================
353 
354  //Used for easter egg sound selection
355  bool IsDanger()
356  {
357  return false;
358  }
359 
360  string CaptureSound()
361  {
362  return "";
363  }
364 
365  string ReleaseSound()
366  {
367  return "";
368  }
369 
370  // ================
371  // CINEMATIC CONTROLLER
372  // ================
373 
374  void CinematicTakeControl(DayZPlayer player)
375  {
376  m_CinematicPlayer = player;
377  }
378 
379  bool CinematicCanJump()
380  {
381  return true;
382  }
383 
384  override bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
385  {
386  if (!m_CinematicPlayer)
387  {
388  return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
389  }
390 
391  UAInterface input = m_CinematicPlayer.GetInputInterface();
392 
394  GetGame().GameScript.CallFunction(this, "GetInputController", controller, 0);
395 
396  if (!input || !controller)
397  {
398  return super.ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished);
399  }
400 
401  float movementX = input.SyncedValue_ID(UAAimRight) - input.SyncedValue_ID(UAAimLeft);
402 
403  float maxTurnSpeed = 100.0;
404  movementX = Math.Clamp(movementX * maxTurnSpeed * pDt, -180, 180);
405 
406  if (input.SyncedValue_ID(UALookAround) > 0)
407  {
408  movementX = 0;
409  }
410 
411  bool isJump = input.SyncedValue_ID(UAGetOver) > 0;
412  bool isMove = input.SyncedValue_ID(UAMoveForward) > 0;
413 
414  bool isRest = input.SyncedValue_ID(UAMoveBack) > 0;
415  bool isSleep = input.SyncedValue_ID(UAReloadMagazine) > 0;
416 
417  float heading = GetOrientation()[0] + movementX;
418 
419  int iAlert = 0;
420  float fAlert = 0;
421  int iSpeed = 0;
422  float fSpeed = 0;
423 
424  if (isMove)
425  {
426  iAlert = 1;
427  fAlert = 0.2;
428 
429  bool isSprint = input.SyncedValue_ID(UATurbo) > 0;
430  bool isJog = input.SyncedValue_ID(UAWalkRunTemp) > 0;
431  bool isWalk = !isSprint && !isJog;
432  if (isSprint)
433  {
435  iSpeed = 3;
436  }
437  else if (isJog)
438  {
440  iSpeed = 2;
441  }
442  else if (isWalk)
443  {
445  iSpeed = 1;
446  }
447  }
448 
449  DayZAnimalInputController animalController;
450  if (Class.CastTo(animalController, controller))
451  {
452  animalController.OverrideBehaviourSlot(true, DayZAnimalBehaviourSlot.NON_SPECIFIC_THREAT);
453  animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.TRAVELING_INPUT);
454 
455  if (!isMove)
456  {
457  if (isRest)
458  {
459  iSpeed = 0;
460  animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.IDLE1_INPUT);
461  }
462 
463  if (isSleep)
464  {
465  iSpeed = 0;
466  animalController.OverrideBehaviourAction(true, DayZAnimalBehaviourAction.WALKING_INPUT);
467  }
468  }
469  }
470 
471  bool lowVel = GetVelocity(this).Length() < 0.5;
472  if (iSpeed > 0 && lowVel)
473  {
474  iAlert = 4;
475  fAlert = 1.0;
476 
477  iSpeed = 3;
478  }
479 
480  if (animalController)
481  {
482  switch (iSpeed)
483  {
484  case 0:
485  fSpeed = 0;
486  break;
487  case 1:
488  fSpeed = 2;
489  break;
490  case 2:
491  fSpeed = 3;
492  break;
493  case 3:
494  fSpeed = 5;
495  break;
496  }
497  }
498 
499  controller.OverrideTurnSpeed(true, Math.PI2 / pDt);
500  controller.OverrideMovementSpeed(true, fSpeed);
501  controller.OverrideHeading(true, heading * Math.DEG2RAD);
502  controller.OverrideAlertLevel(true, true, iAlert, fAlert);
503 
504  if (CinematicCanJump() && isJump)
505  {
506  controller.OverrideJump(true, 101, 2.0);
507  }
508 
509  return true;
510  }
511 }
512 
513 enum DayZAnimalConstants
514 {
521 };
522 
524 {
525 
526 }
527 
528 class DayZAnimalCommandAttack extends AnimCommandBase
529 {
530 
531 }
532 
533 class DayZAnimalCommandJump extends AnimCommandBase
534 {
535 
536 }
537 
538 class DayZAnimalCommandLookAt extends AnimCommandBase
539 {
540 
541 }
542 
543 class DayZAnimalCommandBehaviourModifier extends AnimCommandBase
544 {
545 
546 }
547 
548 class DayZAnimalCommandHit extends AnimCommandBase
549 {
550 
551 }
552 
553 class DayZAnimalCommandDeath extends AnimCommandBase
554 {
555 
556 }
557 
558 class DayZAnimalCommandAnimCallback extends AnimCommandBase
559 {
560 
561 }
562 
570 class DayZAnimalCommandScript extends AnimCommandBase
571 {
573  //void DayZAnimalCommandScript(DayZAnimal pAnimal)
574 
575  //---------------------------------------------------------------
576  // usable everywhere
577 
579  proto native void SetFlagFinished(bool pFinished);
580 
581  //---------------------------------------------------------------
582  // PrePhys Update
583 
585  proto native bool PrePhys_GetTranslation(out vector pOutTransl); // vec3 in local space !
586  proto native bool PrePhys_GetRotation(out float pOutRot[4]); // quaternion in local space !
587  proto native void PrePhys_SetTranslation(vector pInTransl); // vec3 in local space !
588  proto native void PrePhys_SetRotation(float pInRot[4]); // quaternion in local space !
589 
590  //---------------------------------------------------------------
591  // PostPhys Update
592 
596  bool PostPhysUpdate(float pDt);
597 
599  proto native void PostPhys_GetPosition(out vector pOutTransl);
600  proto native void PostPhys_GetRotation(out float pOutRot[4]);
601  proto native void PostPhys_SetPosition(vector pInTransl);
602  proto native void PostPhys_SetRotation(float pInRot[4]);
603  proto native void PostPhys_LockRotation();
604 }
605 
607 {
608 
611  protected string m_DefaultHitComponent;
612  protected string m_DefaultHitPositionComponent;
613  protected vector m_DefaultHitPosition;
614 
616 
617  proto native void StartCommand_Death(int pType, int pDirection);
618  proto native void StartCommand_Move();
619  proto native void StartCommand_Jump();
620  proto native void StartCommand_Attack();
621  proto native void StartCommand_Hit(int pType, int pDirection);
622 
624  proto native DayZAnimalCommandScript StartCommand_Script(DayZAnimalCommandScript pInfectedCommand);
625  proto native DayZAnimalCommandScript StartCommand_ScriptInst(typename pCallbackClass);
626  proto native DayZAnimalCommandScript GetCommand_Script();
627 
628  proto native void SignalAIAttackStarted();
629  proto native void SignalAIAttackEnded();
630 
631  void DayZAnimal()
632  {
633  // testing: animals have no inventory by default
634  //GetInventory().LockInventory(LOCK_FROM_SCRIPT); // Hides animals from vicinity in inventory. Remove this if wanted otherwise.
635 
637 
639 
641  m_DefaultHitPosition = SetDefaultHitPosition(GetDefaultHitPositionComponent());
642  }
643 
644  override bool IsHealthVisible()
645  {
646  return false;
647  }
648 
649  override bool IsAnimal()
650  {
651  return true;
652  }
653 
654  override bool IsInventoryVisible()
655  {
656  return false;
657  }
658 
659  override int GetHideIconMask()
660  {
661  return EInventoryIconVisibility.HIDE_VICINITY;
662  /*
663  if (IsAlive())
664  {
665  return EInventoryIconVisibility.HIDE_VICINITY;
666  }
667  return super.GetHideIconMask();
668  */
669  }
670 
671  void CommandHandler(float dt, int currentCommandID, bool currentCommandFinished)
672  {
673  DayZAnimalInputController inputController = GetInputController();
674 
676  if( ModCommandHandlerBefore(dt, currentCommandID, currentCommandFinished) )
677  {
678  return;
679  }
680 
681  if (HandleDeath(currentCommandID, inputController))
682  {
683  return;
684  }
685 
686  if (currentCommandFinished)
687  {
688  if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
689  {
690  SignalAIAttackEnded();
691  }
692 
694 
695  return;
696  }
697 
699  if( ModCommandHandlerInside(dt, currentCommandID, currentCommandFinished) )
700  {
701  return;
702  }
703 
704  if (HandleDamageHit(currentCommandID))
705  {
706  if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
707  {
708  SignalAIAttackEnded();
709  }
710  return;
711  }
712 
713  if (currentCommandID == DayZAnimalConstants.COMMANDID_MOVE)
714  {
715  if (inputController.IsJump())
716  {
717  StartCommand_Jump();
718  return;
719  }
720 
721  if (inputController.IsAttack())
722  {
723  StartCommand_Attack();
724  SignalAIAttackStarted();
725  return;
726  }
727  }
728 
730  if( ModCommandHandlerAfter(dt, currentCommandID, currentCommandFinished) )
731  {
732  return;
733  }
734  }
735 
736  bool m_DamageHitToProcess = false;
737  int m_DamageHitType = 0;
738  int m_DamageHitDirection = 0;
739 
740  bool HandleDeath(int currentCommandID, DayZAnimalInputController inputController)
741  {
742  if (inputController.IsDead())
743  {
744  if (currentCommandID == DayZAnimalConstants.COMMANDID_DEATH)
745  {
746  return true;
747  }
748 
749  if (m_DamageHitToProcess)
750  {
751  m_DamageHitToProcess = false;
752 
753  StartCommand_Death(m_DamageHitType, m_DamageHitDirection);
754  }
755  else
756  {
757  StartCommand_Death(0, 0);
758  }
759 
760  return true;
761  }
762 
763  return false;
764  }
765 
766  bool HandleDamageHit(int currentCommandID)
767  {
768  if (m_DamageHitToProcess)
769  {
770  m_DamageHitToProcess = false;
771 
772  if (currentCommandID != DayZAnimalConstants.COMMANDID_HIT)
773  {
774  StartCommand_Hit(m_DamageHitType, m_DamageHitDirection);
775  }
776  return true;
777  }
778  return false;
779  }
780 
781  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
782  {
783  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
784  m_TransportHitRegistered = false;
785 
786  int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
787  if (transferShockToDamageCoef == 1)
788  {
789  //Print("DayZAnimal | EEHitBy | nonlethal hit");
790  AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
791  }
792  else
793  {
794  ComponentAnimalBleeding animal_bleeding = ComponentAnimalBleeding.Cast( GetComponent( COMP_TYPE_ANIMAL_BLEEDING ) );
795  animal_bleeding.CreateWound( damageResult, dmgZone, ammo );
796  }
797 
798  int type = 0;
799  int direction = 0;
800  if (ComputeDamageHitParams(source, dmgZone, ammo, type, direction) == true)
801  {
802  QueueDamageHit(type, direction);
803  }
804 
805  }
806 
807  void QueueDamageHit(int type, int direction)
808  {
809  m_DamageHitToProcess = true;
810  m_DamageHitType = type;
811  m_DamageHitDirection = direction;
812  }
813 
814  bool ComputeDamageHitParams(EntityAI source, string dmgZone, string ammo, out int type, out int direction)
815  {
816  type = 0; // not used right now
817 
818  float angleDeg = ComputeHitDirectionAngleDeg(source);
819  direction = TranslateHitAngleDegToDirectionIndex(angleDeg);
820 
821  direction += FindComponentDirectionOffset(dmgZone);
822 
823  return true;
824  }
825 
826  float ComputeHitDirectionAngleDeg(EntityAI source)
827  {
828  vector targetDirection = GetDirection();
829  vector toSourceDirection = (source.GetPosition() - GetPosition());
830 
831  targetDirection[1] = 0;
832  toSourceDirection[1] = 0;
833 
834  targetDirection.Normalize();
835  toSourceDirection.Normalize();
836 
837  float cosFi = vector.Dot(targetDirection, toSourceDirection);
838  vector cross = targetDirection * toSourceDirection;
839 
840  float dirAngleDeg = Math.Acos(cosFi) * Math.RAD2DEG;
841  if ( cross[1] < 0 )
842  dirAngleDeg = -dirAngleDeg;
843 
844  return dirAngleDeg;
845  }
846 
847  int TranslateHitAngleDegToDirectionIndex(float angleDeg)
848  {
849  if (angleDeg >= -20 && angleDeg <= 20) // front
850  {
851  return 1;
852  }
853  else if (angleDeg < 0) // left
854  {
855  return 2;
856  }
857 
858  return 3; // right
859  }
860 
861  int FindComponentDirectionOffset(string component)
862  {
863  const int directionCount = 4;
864 
865  int offset = 0;
866  if (component.Length() == 0)
867  {
868  offset = 0;
869  }
870  else if (component == "Zone_Head")
871  {
872  offset = directionCount;
873  }
874  else if (component == "Zone_Chest" || component == "Zone_Legs_Front" || component == "Zone_Spine_Front" || component == "Zone_Neck")
875  {
876  offset = 2 * directionCount;
877  }
878  else
879  {
880  offset = 3 * directionCount;
881  }
882 
883  return offset;
884  }
885 
886  //-------------------------------------------------------------
890 
891  override protected void EOnContact(IEntity other, Contact extra)
892  {
893  if( !IsAlive() )
894  return;
895 
896  Transport transport = Transport.Cast(other);
897  if( transport )
898  {
899  if ( GetGame().IsServer() )
900  {
901  RegisterTransportHit(transport);
902  }
903  }
904  }
905 
908  {
910  m_DefaultHitComponent = "Zone_Chest";
913 
915  DayZAIHitComponentHelpers.RegisterHitComponent(m_HitComponentsForAI, "Zone_Chest", 50);
916  }
917 
918  override string GetHitComponentForAI()
919  {
920  string hitComp;
921 
922  if (DayZAIHitComponentHelpers.SelectMostProbableHitComponent(m_HitComponentsForAI, hitComp))
923  {
924  return hitComp;
925  }
926 
927  return GetDefaultHitComponent();
928  }
929 
930  override string GetDefaultHitComponent()
931  {
932  return m_DefaultHitComponent;
933  }
934 
935  override string GetDefaultHitPositionComponent()
936  {
938  }
939 
940  override vector GetDefaultHitPosition()
941  {
942  return m_DefaultHitPosition;
943  }
944 
945  protected vector SetDefaultHitPosition(string pSelection)
946  {
947  return GetSelectionPositionMS(pSelection);
948  }
949 
950  override protected float ConvertNonlethalDamage(float damage, DamageType damageType)
951  {
952  switch (damageType)
953  {
954  case DamageType.CLOSE_COMBAT:
955  return damage * GameConstants.NL_DAMAGE_CLOSECOMBAT_CONVERSION_ANIMALS;
956  case DamageType.FIRE_ARM:
957  return damage * GameConstants.NL_DAMAGE_FIREARM_CONVERSION_ANIMALS;
958  }
959 
960  return super.ConvertNonlethalDamage(damage, damageType);
961  }
962 }
TAnimGraphCommand
class HumanInputController TAnimGraphCommand
GetGame
proto native CGame GetGame()
ResetDeathCooldown
proto native void ResetDeathCooldown()
GetHideIconMask
override int GetHideIconMask()
Definition: basebuildingbase.c:87
m_HitComponentsForAI
protected ref array< ref DayZAIHitComponent > m_HitComponentsForAI
Melee hit components (AI targeting)
Definition: dayzplayer.c:587
PrePhys_SetRotation
proto native void PrePhys_SetRotation(float pInRot[4])
COMP_TYPE_ANIMAL_BLEEDING
const int COMP_TYPE_ANIMAL_BLEEDING
Definition: component.c:11
SetAnimationInstanceByName
proto native void SetAnimationInstanceByName(string animation_instance_name, int instance_uuid, float duration)
IsManagingArrows
override bool IsManagingArrows()
Definition: dayzanimal.c:70
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
GetBoneIndexByName
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
GetCurrentAnimationInstanceUUID
proto native int GetCurrentAnimationInstanceUUID()
PostPhys_LockRotation
proto native void PostPhys_LockRotation()
quaternion in world space
StartCommand_Script
proto native HumanCommandScript StartCommand_Script(HumanCommandScript pHumanCommand)
— SCRIPTED COMMANDS
ModCommandHandlerAfter
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:136
PrePhys_GetRotation
proto native bool PrePhys_GetRotation(out float pOutRot[4])
COMMANDID_JUMP
class DayZCreatureAI extends DayZCreature COMMANDID_JUMP
DayZAnimalBehaviourAction
DayZAnimalBehaviourAction
defined in C++
Definition: dayzanimalinputcontroller.c:26
IsInventoryVisible
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
Definition: advancedcommunication.c:135
Print
proto void Print(void var)
Prints content of variable to console/log.
SoundObject
class SoundObjectBuilder SoundObject(SoundParams soundParams)
PostPhys_GetRotation
proto native void PostPhys_GetRotation(out float pOutRot[4])
vec3 in world space
CommandHandler
void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
-------------— command handling ----------------------—
PostPhysUpdate
bool PostPhysUpdate(float pDt)
ResetDeath
proto native void ResetDeath()
DayZCreatureAI
do not process rotations !
Definition: dayzanimal.c:606
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
IsDeathProcessed
proto native bool IsDeathProcessed()
CanBeSkinned
override bool CanBeSkinned()
Definition: dayzanimal.c:60
COMMANDID_HIT
class DayZCreatureAI extends DayZCreature COMMANDID_HIT
Param3
Definition: entityai.c:95
AnimBootsType
AnimBootsType
Definition: dayzanimevents.c:97
AIAgent
Definition: aiagent.c:1
DayZPlayer
Definition: dayzplayerimplement.c:72
IEntity
Definition: enentity.c:164
DayZAnimalBehaviourSlot
DayZAnimalBehaviourSlot
defined in C++
Definition: dayzanimalinputcontroller.c:2
COMMANDID_SCRIPT
class DayZCreatureAI extends DayZCreature COMMANDID_SCRIPT
StartDeath
proto native void StartDeath()
EOnContact
override void EOnContact(IEntity other, Contact extra)
Definition: easteregg.c:112
ModCommandHandlerInside
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:131
AnimCommandBase
base class of all commands exposed to script to provide common functionality over animations
Definition: animcommand.c:2
ReleaseSound
override string ReleaseSound()
Definition: animalbase.c:40
ComponentAnimalBleeding
Definition: componentanimalbleeding.c:8
COMMANDID_MOVE
class DayZCreatureAI extends DayZCreature COMMANDID_MOVE
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
SetFlagFinished
class DayZAnimalCommandMove extends AnimCommandBase SetFlagFinished(bool pFinished)
DayZAnimalCommandScript fully scriptable command.
DayZCreatureAnimInterface
Definition: dayzanimal.c:1
vector
Definition: enconvert.c:105
RegisterHitComponentsForAI
class Entity extends ObjectTyped RegisterHitComponentsForAI
Definition: animalbase.c:49
PostPhys_GetPosition
proto native void PostPhys_GetPosition(out vector pOutTransl)
script function usable in PostPhysUpdate
TotalDamageResult
Definition: damagesystem.c:1
RegisterAnimationEvent
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
DayZAnimalInputController
Definition: dayzanimalinputcontroller.c:49
GetHitComponentForAI
string GetHitComponentForAI()
Definition: dayzplayer.c:485
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
GetInputController
proto native HumanInputController GetInputController()
returns human input controller
Object
Definition: objecttyped.c:1
EEKilled
override void EEKilled(Object killer)
Definition: remotedetonator.c:242
COMMANDID_DEATH
class DayZCreatureAI extends DayZCreature COMMANDID_DEATH
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
WaveKind
WaveKind
Definition: sound.c:1
IsDanger
override bool IsDanger()
Definition: animalbase.c:61
PrePhys_SetTranslation
proto native void PrePhys_SetTranslation(vector pInTransl)
Contact
Definition: enphysics.c:300
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: broom.c:43
m_DefaultHitComponent
protected string m_DefaultHitComponent
Definition: dayzplayer.c:588
DayZCreature
Definition: dayzanimal.c:142
SetFlags
proto native void SetFlags(ShapeFlags flags)
AddArrow
override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
Definition: dayzanimal.c:75
AIGroup
Definition: aigroup.c:1
array< ref DayZAIHitComponent >
GetDefaultHitPosition
override vector GetDefaultHitPosition()
Definition: carscript.c:2592
GetCommand_Script
proto native HumanCommandScript GetCommand_Script()
is human is in command action - returns its callback, if current command is action
StartCommand_ScriptInst
proto native HumanCommandScript StartCommand_ScriptInst(typename pCallbackClass)
DayZAnimalCommandMove
Definition: dayzanimalimplement.c:1
CaptureSound
override string CaptureSound()
Definition: animalbase.c:35
PostPhys_SetPosition
proto native void PostPhys_SetPosition(vector pInTransl)
quaternion in world space
IsDayZCreature
override bool IsDayZCreature()
Definition: dayzanimal.c:55
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
StartCommand_Move
proto native HumanCommandMove StartCommand_Move()
--— MOVE --—
GameConstants
Definition: constants.c:612
StartCommand_Death
proto native HumanCommandDeathCallback StartCommand_Death(int pType, float pDirection, typename pCallbackClass, bool pKeepInLocalSpaceAfterLeave=false)
--— Death --—
ResistContaminatedEffect
override bool ResistContaminatedEffect()
Definition: animalbase.c:136
DayZCreatureAIInputController
Definition: dayzcreatureaiinputcontroller.c:1
ModCommandHandlerBefore
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:126
DayZAIHitComponentHelpers
Definition: dayzaihitcomponents.c:8
PrePhys_GetTranslation
proto native bool PrePhys_GetTranslation(out vector pOutTransl)
script function usable in PrePhysUpdate
SoundObjectBuilder
Definition: sound.c:45
AddChild
proto native void AddChild(Widget child, bool immedUpdate=true)
PlaySound
void PlaySound()
Definition: hungersoundhandler.c:38
GetDefaultHitComponent
string GetDefaultHitComponent()
Definition: dayzplayer.c:497
m_DefaultHitPositionComponent
protected string m_DefaultHitPositionComponent
Definition: dayzplayer.c:589
DayZCreatureAIType
Definition: dayzanimaltype.c:1
COMMANDID_ATTACK
class DayZCreatureAI extends DayZCreature COMMANDID_ATTACK
GetDefaultHitPositionComponent
string GetDefaultHitPositionComponent()
Definition: dayzplayer.c:502
Math
Definition: enmath.c:6
CFG_AMMO
const string CFG_AMMO
Definition: constants.c:212
GetVelocity
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
AbstractWave
Definition: sound.c:118
UAInterface
Definition: uainput.c:95
COMP_TYPE_BODY_STAGING
const int COMP_TYPE_BODY_STAGING
Definition: component.c:10
EntityAI
Definition: building.c:5
HasFixedActionTargetCursorPosition
override bool HasFixedActionTargetCursorPosition()
Definition: dayzanimal.c:115
PostPhys_SetRotation
proto native void PostPhys_SetRotation(float pInRot[4])
vec3 in world space
IsDeathConditionMet
proto native bool IsDeathConditionMet()
Math3D
Definition: enmath3d.c:27
IsIgnoredByConstruction
override bool IsIgnoredByConstruction()
Definition: dayzanimal.c:65
UpdateSimulationPrecision
proto native void UpdateSimulationPrecision(int simLOD)
CachedObjectsArrays
Definition: utilityclasses.c:40
GetAnimInterface
proto native DayZCreatureAnimInterface GetAnimInterface()
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306
DayZAnimal
Definition: animalbase.c:1