DayZ 1.24
Loading...
Searching...
No Matches
DayZCreatureAI Class Reference

do not process rotations ! More...

Collaboration diagram for DayZCreatureAI:
[legend]

Protected Member Functions

proto native DayZAnimalInputController GetInputController ()
 
proto native void StartCommand_Death (int pType, int pDirection)
 
proto native void StartCommand_Move ()
 
proto native void StartCommand_Jump ()
 
proto native void StartCommand_Attack ()
 
proto native void StartCommand_Hit (int pType, int pDirection)
 
proto native DayZAnimalCommandScript StartCommand_Script (DayZAnimalCommandScript pInfectedCommand)
 scripted commands
 
proto native DayZAnimalCommandScript StartCommand_ScriptInst (typename pCallbackClass)
 
proto native DayZAnimalCommandScript GetCommand_Script ()
 
proto native void SignalAIAttackStarted ()
 
proto native void SignalAIAttackEnded ()
 
void DayZAnimal ()
 
override bool IsHealthVisible ()
 
override bool IsAnimal ()
 
override bool IsInventoryVisible ()
 
override int GetHideIconMask ()
 
void CommandHandler (float dt, int currentCommandID, bool currentCommandFinished)
 
bool HandleDeath (int currentCommandID, DayZAnimalInputController inputController)
 
bool HandleDamageHit (int currentCommandID)
 
override void EEHitBy (TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
 
void QueueDamageHit (int type, int direction)
 
bool ComputeDamageHitParams (EntityAI source, string dmgZone, string ammo, out int type, out int direction)
 
float ComputeHitDirectionAngleDeg (EntityAI source)
 
int TranslateHitAngleDegToDirectionIndex (float angleDeg)
 
int FindComponentDirectionOffset (string component)
 
void EOnContact (IEntity other, Contact extra)
 
void RegisterHitComponentsForAI ()
 register hit components for AI melee (used by attacking AI)
 
override string GetHitComponentForAI ()
 
override string GetDefaultHitComponent ()
 
override string GetDefaultHitPositionComponent ()
 
override vector GetDefaultHitPosition ()
 
vector SetDefaultHitPosition (string pSelection)
 
float ConvertNonlethalDamage (float damage, DamageType damageType)
 

Protected Attributes

ref array< ref DayZAIHitComponentm_HitComponentsForAI
 Melee hit components (AI targeting)
 
string m_DefaultHitComponent
 
string m_DefaultHitPositionComponent
 
vector m_DefaultHitPosition
 
bool m_DamageHitToProcess = false
 
int m_DamageHitType = 0
 
int m_DamageHitDirection = 0
 

Detailed Description

do not process rotations !

Definition at line 572 of file DayZAnimal.c.

Member Function Documentation

◆ CommandHandler()

void DayZCreatureAI::CommandHandler ( float dt,
int currentCommandID,
bool currentCommandFinished )
inlineprotected

for mods

for mods

Definition at line 637 of file DayZAnimal.c.

638 {
640
643 return;
644
646 return;
647
649 {
650 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
652
654
655 return;
656 }
657
660 return;
661
663 {
664 if (currentCommandID == DayZAnimalConstants.COMMANDID_ATTACK)
666 return;
667 }
668
669 if (currentCommandID == DayZAnimalConstants.COMMANDID_MOVE)
670 {
671 if (inputController.IsJump())
672 {
674 return;
675 }
676
677 if (inputController.IsAttack())
678 {
681 return;
682 }
683 }
684
687 return;
688 }
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:127
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:122
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:132
proto native void SignalAIAttackEnded()
bool HandleDeath(int currentCommandID, DayZAnimalInputController inputController)
Definition DayZAnimal.c:694
proto native void StartCommand_Jump()
bool HandleDamageHit(int currentCommandID)
Definition DayZAnimal.c:716
proto native void StartCommand_Attack()
proto native DayZAnimalInputController GetInputController()
proto native void StartCommand_Move()
proto native void SignalAIAttackStarted()

References GetInputController(), ModCommandHandlerAfter(), ModCommandHandlerBefore(), ModCommandHandlerInside(), and StartCommand_Move().

◆ ComputeDamageHitParams()

bool DayZCreatureAI::ComputeDamageHitParams ( EntityAI source,
string dmgZone,
string ammo,
out int type,
out int direction )
inlineprotected

Definition at line 760 of file DayZAnimal.c.

761 {
762 type = 0; // not used right now
763
766
768
769 return true;
770 }
int FindComponentDirectionOffset(string component)
Definition DayZAnimal.c:803
float ComputeHitDirectionAngleDeg(EntityAI source)
Definition DayZAnimal.c:772
int TranslateHitAngleDegToDirectionIndex(float angleDeg)
Definition DayZAnimal.c:793

◆ ComputeHitDirectionAngleDeg()

float DayZCreatureAI::ComputeHitDirectionAngleDeg ( EntityAI source)
inlineprotected

Definition at line 772 of file DayZAnimal.c.

773 {
774 vector targetDirection = GetDirection();
775 vector toSourceDirection = (source.GetPosition() - GetPosition());
776
777 targetDirection[1] = 0;
778 toSourceDirection[1] = 0;
779
780 targetDirection.Normalize();
781 toSourceDirection.Normalize();
782
785
787 if (cross[1] < 0)
789
790 return dirAngleDeg;
791 }
class JsonUndergroundAreaTriggerData GetPosition
Definition EnMath.c:7
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static proto float Acos(float c)
Returns angle in radians from cosinus.
static const float RAD2DEG
Definition EnMath.c:16

References Math::Acos(), vector::Dot(), GetPosition, and Math::RAD2DEG.

◆ ConvertNonlethalDamage()

float DayZCreatureAI::ConvertNonlethalDamage ( float damage,
DamageType damageType )
inlineprotected

Definition at line 880 of file DayZAnimal.c.

881 {
882 switch (damageType)
883 {
884 case DamageType.CLOSE_COMBAT:
886 case DamageType.FIRE_ARM:
888 }
889
890 return super.ConvertNonlethalDamage(damage, damageType);
891 }
DamageType
exposed from C++ (do not change)
const float NL_DAMAGE_FIREARM_CONVERSION_ANIMALS
Definition constants.c:859
const float NL_DAMAGE_CLOSECOMBAT_CONVERSION_ANIMALS
Definition constants.c:863

References GameConstants::NL_DAMAGE_CLOSECOMBAT_CONVERSION_ANIMALS, and GameConstants::NL_DAMAGE_FIREARM_CONVERSION_ANIMALS.

◆ DayZAnimal()

void DayZCreatureAI::DayZAnimal ( )
inlineprotected

sets default hit position and cache it here (mainly for impact particles)

Definition at line 597 of file DayZAnimal.c.

598 {
599 // testing: animals have no inventory by default
600 //GetInventory().LockInventory(LOCK_FROM_SCRIPT); // Hides animals from vicinity in inventory. Remove this if wanted otherwise.
601
603
605
608 }
vector SetDefaultHitPosition(string pSelection)
Definition DayZAnimal.c:875
void RegisterHitComponentsForAI()
register hit components for AI melee (used by attacking AI)
Definition DayZAnimal.c:839
override string GetDefaultHitPositionComponent()
Definition DayZAnimal.c:865
ref array< ref DayZAIHitComponent > m_HitComponentsForAI
Melee hit components (AI targeting)
Definition DayZAnimal.c:576
vector m_DefaultHitPosition
Definition DayZAnimal.c:579

References GetDefaultHitPositionComponent(), m_HitComponentsForAI, and RegisterHitComponentsForAI().

◆ EEHitBy()

override void DayZCreatureAI::EEHitBy ( TotalDamageResult damageResult,
int damageType,
EntityAI source,
int component,
string dmgZone,
string ammo,
vector modelPos,
float speedCoef )
inlineprotected

Definition at line 729 of file DayZAnimal.c.

730 {
732 m_TransportHitRegistered = false;
733
734 int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
736 {
737 //Print("DayZAnimal | EEHitBy | nonlethal hit");
738 AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
739 }
740 else
741 {
744 }
745
746 int type = 0;
747 int direction = 0;
748 if (ComputeDamageHitParams(source, dmgZone, ammo, type, direction) == true)
750
751 }
DayZGame g_Game
Definition DayZGame.c:3528
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool ComputeDamageHitParams(EntityAI source, string dmgZone, string ammo, out int type, out int direction)
Definition DayZAnimal.c:760
float ConvertNonlethalDamage(float damage, DamageType damageType)
Definition DayZAnimal.c:880
void QueueDamageHit(int type, int direction)
Definition DayZAnimal.c:753
const int COMP_TYPE_ANIMAL_BLEEDING
Definition Component.c:11
const string CFG_AMMO
Definition constants.c:212

References CFG_AMMO, COMP_TYPE_ANIMAL_BLEEDING, component, and g_Game.

◆ EOnContact()

void DayZCreatureAI::EOnContact ( IEntity other,
Contact extra )
inlineprotected

Phx contact event

Definition at line 825 of file DayZAnimal.c.

826 {
827 if (!IsAlive())
828 return;
829
831 if (transport)
832 {
833 if (GetGame().IsServer())
834 RegisterTransportHit(transport);
835 }
836 }
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
proto native CGame GetGame()

References GetGame().

◆ FindComponentDirectionOffset()

int DayZCreatureAI::FindComponentDirectionOffset ( string component)
inlineprotected

Definition at line 803 of file DayZAnimal.c.

804 {
805 const int directionCount = 4;
806
807 int offset = 0;
808 if (component.Length() == 0)
809 offset = 0;
810 else if (component == "Zone_Head")
812 else if (component == "Zone_Chest" || component == "Zone_Legs_Front" || component == "Zone_Spine_Front" || component == "Zone_Neck")
814 else
816
817 return offset;
818 }

References component.

◆ GetCommand_Script()

proto native DayZAnimalCommandScript DayZCreatureAI::GetCommand_Script ( )
protected

◆ GetDefaultHitComponent()

override string DayZCreatureAI::GetDefaultHitComponent ( )
inlineprotected

Definition at line 860 of file DayZAnimal.c.

861 {
863 }
string m_DefaultHitComponent
Definition DayZAnimal.c:577

References m_DefaultHitComponent.

◆ GetDefaultHitPosition()

override vector DayZCreatureAI::GetDefaultHitPosition ( )
inlineprotected

Definition at line 870 of file DayZAnimal.c.

871 {
873 }

◆ GetDefaultHitPositionComponent()

override string DayZCreatureAI::GetDefaultHitPositionComponent ( )
inlineprotected

Definition at line 865 of file DayZAnimal.c.

866 {
868 }
string m_DefaultHitPositionComponent
Definition DayZAnimal.c:578

References m_DefaultHitPositionComponent.

◆ GetHideIconMask()

override int DayZCreatureAI::GetHideIconMask ( )
inlineprotected

Definition at line 625 of file DayZAnimal.c.

626 {
627 return EInventoryIconVisibility.HIDE_VICINITY;
628 /*
629 if (IsAlive())
630 {
631 return EInventoryIconVisibility.HIDE_VICINITY;
632 }
633 return super.GetHideIconMask();
634 */
635 }

◆ GetHitComponentForAI()

override string DayZCreatureAI::GetHitComponentForAI ( )
inlineprotected

Definition at line 850 of file DayZAnimal.c.

851 {
852 string hitComp;
853
855 return hitComp;
856
857 return GetDefaultHitComponent();
858 }
static bool SelectMostProbableHitComponent(array< ref DayZAIHitComponent > pHitComponents, out string pHitComponent)
override string GetDefaultHitComponent()
Definition DayZAnimal.c:860

References GetDefaultHitComponent(), m_HitComponentsForAI, and DayZAIHitComponentHelpers::SelectMostProbableHitComponent().

◆ GetInputController()

proto native DayZAnimalInputController DayZCreatureAI::GetInputController ( )
protected

◆ HandleDamageHit()

bool DayZCreatureAI::HandleDamageHit ( int currentCommandID)
inlineprotected

Definition at line 716 of file DayZAnimal.c.

717 {
719 {
720 m_DamageHitToProcess = false;
721
722 if (currentCommandID != DayZAnimalConstants.COMMANDID_HIT)
724 return true;
725 }
726 return false;
727 }
bool m_DamageHitToProcess
Definition DayZAnimal.c:690
proto native void StartCommand_Hit(int pType, int pDirection)
int m_DamageHitDirection
Definition DayZAnimal.c:692

◆ HandleDeath()

bool DayZCreatureAI::HandleDeath ( int currentCommandID,
DayZAnimalInputController inputController )
inlineprotected

Definition at line 694 of file DayZAnimal.c.

695 {
696 if (inputController.IsDead())
697 {
698 if (currentCommandID == DayZAnimalConstants.COMMANDID_DEATH)
699 return true;
700
702 {
703 m_DamageHitToProcess = false;
704
706 }
707 else
708 StartCommand_Death(0, 0);
709
710 return true;
711 }
712
713 return false;
714 }
proto native void StartCommand_Death(int pType, int pDirection)

References StartCommand_Death().

◆ IsAnimal()

override bool DayZCreatureAI::IsAnimal ( )
inlineprotected

Definition at line 615 of file DayZAnimal.c.

616 {
617 return true;
618 }

◆ IsHealthVisible()

override bool DayZCreatureAI::IsHealthVisible ( )
inlineprotected

Definition at line 610 of file DayZAnimal.c.

611 {
612 return false;
613 }

◆ IsInventoryVisible()

override bool DayZCreatureAI::IsInventoryVisible ( )
inlineprotected

Definition at line 620 of file DayZAnimal.c.

621 {
622 return false;
623 }

◆ QueueDamageHit()

void DayZCreatureAI::QueueDamageHit ( int type,
int direction )
inlineprotected

Definition at line 753 of file DayZAnimal.c.

754 {
756 m_DamageHitType = type;
758 }

◆ RegisterHitComponentsForAI()

void DayZCreatureAI::RegisterHitComponentsForAI ( )
inlineprotected

register hit components for AI melee (used by attacking AI)

registers default hit compoent for the entity

registers default hit position component for entity

register hit components that are selected by probability

Definition at line 839 of file DayZAnimal.c.

840 {
842 m_DefaultHitComponent = "Zone_Chest";
845
848 }
static void RegisterHitComponent(array< ref DayZAIHitComponent > pHitComponents, string pName, float pWeight)
Register Hit Component for AI targeting.

References m_DefaultHitComponent, m_DefaultHitPositionComponent, m_HitComponentsForAI, and DayZAIHitComponentHelpers::RegisterHitComponent().

◆ SetDefaultHitPosition()

vector DayZCreatureAI::SetDefaultHitPosition ( string pSelection)
inlineprotected

Definition at line 875 of file DayZAnimal.c.

876 {
877 return GetSelectionPositionMS(pSelection);
878 }

◆ SignalAIAttackEnded()

proto native void DayZCreatureAI::SignalAIAttackEnded ( )
protected

◆ SignalAIAttackStarted()

proto native void DayZCreatureAI::SignalAIAttackStarted ( )
protected

◆ StartCommand_Attack()

proto native void DayZCreatureAI::StartCommand_Attack ( )
protected

◆ StartCommand_Death()

proto native void DayZCreatureAI::StartCommand_Death ( int pType,
int pDirection )
protected

◆ StartCommand_Hit()

proto native void DayZCreatureAI::StartCommand_Hit ( int pType,
int pDirection )
protected

◆ StartCommand_Jump()

proto native void DayZCreatureAI::StartCommand_Jump ( )
protected

◆ StartCommand_Move()

proto native void DayZCreatureAI::StartCommand_Move ( )
protected

◆ StartCommand_Script()

proto native DayZAnimalCommandScript DayZCreatureAI::StartCommand_Script ( DayZAnimalCommandScript pInfectedCommand)
protected

scripted commands

◆ StartCommand_ScriptInst()

proto native DayZAnimalCommandScript DayZCreatureAI::StartCommand_ScriptInst ( typename pCallbackClass )
protected

◆ TranslateHitAngleDegToDirectionIndex()

int DayZCreatureAI::TranslateHitAngleDegToDirectionIndex ( float angleDeg)
inlineprotected

Definition at line 793 of file DayZAnimal.c.

794 {
795 if (angleDeg >= -20 && angleDeg <= 20) // front
796 return 1;
797 else if (angleDeg < 0) // left
798 return 2;
799
800 return 3; // right
801 }

Member Data Documentation

◆ m_DamageHitDirection

int DayZCreatureAI::m_DamageHitDirection = 0
protected

Definition at line 692 of file DayZAnimal.c.

◆ m_DamageHitToProcess

bool DayZCreatureAI::m_DamageHitToProcess = false
protected

Definition at line 690 of file DayZAnimal.c.

◆ m_DamageHitType

int DayZCreatureAI::m_DamageHitType = 0
protected

Definition at line 691 of file DayZAnimal.c.

◆ m_DefaultHitComponent

string DayZCreatureAI::m_DefaultHitComponent
protected

Definition at line 577 of file DayZAnimal.c.

◆ m_DefaultHitPosition

vector DayZCreatureAI::m_DefaultHitPosition
protected

Definition at line 579 of file DayZAnimal.c.

◆ m_DefaultHitPositionComponent

string DayZCreatureAI::m_DefaultHitPositionComponent
protected

Definition at line 578 of file DayZAnimal.c.

◆ m_HitComponentsForAI

ref array<ref DayZAIHitComponent> DayZCreatureAI::m_HitComponentsForAI
protected

Melee hit components (AI targeting)

Definition at line 576 of file DayZAnimal.c.


The documentation for this class was generated from the following file: