DayZ 1.24
Loading...
Searching...
No Matches
ActionDigInStash Class Reference
Inheritance diagram for ActionDigInStash:
[legend]
Collaboration diagram for ActionDigInStash:
[legend]

Private Member Functions

void ActionDigInStash ()
 
override void CreateConditionComponents ()
 
override bool Can (PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override void OnExecuteClient (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 
void SpawnParticleShovelRaise (ActionData action_data)
 
override void OnFinishProgressServer (ActionData action_data)
 
override string GetAdminLogMessage (ActionData action_data)
 
- Private Member Functions inherited from ActionContinuousBase
void OnStartAnimationLoopServer (ActionData action_data)
 
void OnStartAnimationLoopClient (ActionData action_data)
 
void OnEndAnimationLoopServer (ActionData action_data)
 
void OnEndAnimationLoopClient (ActionData action_data)
 
void OnFinishProgressServer (ActionData action_data)
 
void OnFinishProgressClient (ActionData action_data)
 

Static Private Attributes

static float m_DigStashSlopeTolerance = 0.6
 

Detailed Description

Definition at line 9 of file ActionDigInStash.c.

Constructor & Destructor Documentation

◆ ActionDigInStash()

void ActionDigInStash::ActionDigInStash ( )
inlineprivate

Member Function Documentation

◆ ActionCondition()

override bool ActionDigInStash::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

was initialized from inventory?

Check slope angle

Definition at line 37 of file ActionDigInStash.c.

38 {
40 if (Class.CastTo(targetIB, target.GetObject()) && targetIB.CanBeDigged())
41 {
42 if (player.IsPlacingLocal())
43 return false;
44
45 if (targetIB.IsRuined() || targetIB.GetInventory().IsAttachment())
46 return false;
47
48 if (targetIB.GetInventory().IsAttachment())
49 return false;
50
51 if (targetIB.IsInherited(UndergroundStash))
52 return false;
53
56 if (targetIB.GetInventory().IsInCargo())
58
59 // here we check if a stash is nearby and block digging a new one in close proximity
63 // For now we exclude an area of 2 X 2 X 2 meters
64 if (GetGame().IsBoxColliding(entityToCheck.GetPosition(), entityToCheck.GetOrientation(), "2 2 2", excludedObjects, nearbyObjects))
65 {
66 for (int i = 0; i < nearbyObjects.Count(); i++)
67 {
68 if (nearbyObjects[i].IsInherited(UndergroundStash))
69 return false;
70 }
71 }
72
73 // Check surface
74 int liquidType;
75 string surfaceType;
76 GetGame().SurfaceUnderObject(entityToCheck, surfaceType, liquidType);
77 if (!GetGame().IsSurfaceDigable(surfaceType))
78 return false;
79 else
80 {
82 vector position = entityToCheck.GetPosition();
83
85 positions.Insert(position + "0.5 0 0.5");
86 positions.Insert(position + "-0.5 0 0.5");
87 positions.Insert(position + "0.5 0 -0.5");
88 positions.Insert(position + "-0.5 0 -0.5");
89
90 float difference = GetGame().GetHighestSurfaceYDifference(positions);
91
93 }
94 }
95
96 return false;
97 }
static float m_DigStashSlopeTolerance
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), GetGame(), and m_DigStashSlopeTolerance.

◆ Can()

override bool ActionDigInStash::Can ( PlayerBase player,
ActionTarget target,
ItemBase item,
int condition_mask )
inlineprivate

Definition at line 29 of file ActionDigInStash.c.

30 {
32 return false;
33
34 return player.CheckFreeSpace(vector.Forward, 1.0, false);
35 }
static const vector Forward
Definition EnConvert.c:109

References vector::Forward.

◆ CreateConditionComponents()

override void ActionDigInStash::CreateConditionComponents ( )
inlineprivate

Definition at line 23 of file ActionDigInStash.c.

24 {
27 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
const float DEFAULT

References UAMaxDistances::DEFAULT, m_ConditionItem, and m_ConditionTarget.

◆ GetAdminLogMessage()

override string ActionDigInStash::GetAdminLogMessage ( ActionData action_data)
inlineprivate

Definition at line 152 of file ActionDigInStash.c.

153 {
154 return string.Format("Player %1 Dug in %2 at position %3", action_data.m_Player, action_data.m_Target.GetObject(), action_data.m_Target.GetObject().GetPosition());
155 }

◆ OnExecuteClient()

override void ActionDigInStash::OnExecuteClient ( ActionData action_data)
inlineprivate

Definition at line 99 of file ActionDigInStash.c.

100 {
101 super.OnExecuteClient(action_data);
102
104 }
void SpawnParticleShovelRaise(ActionData action_data)

References SpawnParticleShovelRaise().

◆ OnExecuteServer()

override void ActionDigInStash::OnExecuteServer ( ActionData action_data)
inlineprivate

Definition at line 106 of file ActionDigInStash.c.

107 {
108 super.OnExecuteServer(action_data);
109
110 if (!GetGame().IsMultiplayer())
112 }

References GetGame(), and SpawnParticleShovelRaise().

◆ OnFinishProgressServer()

override void ActionDigInStash::OnFinishProgressServer ( ActionData action_data)
inlineprivate

Definition at line 119 of file ActionDigInStash.c.

120 {
121 EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
122 if (!targetEntity)
123 {
124 ErrorEx("Cannot get entity=" + targetEntity);
125 return;
126 }
127
129 if (!targetEntity.GetInventory().GetCurrentInventoryLocation(targetIL))
130 {
131 ErrorEx("Cannot get inventory location of entity=" + targetEntity);
132 return;
133 }
134
135 UndergroundStash stash = UndergroundStash.Cast(GetGame().CreateObjectEx("UndergroundStash", targetEntity.GetPosition(), ECE_PLACE_ON_SURFACE));
136 if (stash)
137 {
138 stash.PlaceOnGround();
140 action_data.m_Player.ServerTakeEntityToTargetCargo(stash, targetEntity);
141 else
142 Debug.Log(string.Format("Cannot remove entity=%1 obj from current location=%2", targetEntity, InventoryLocation.DumpToStringNullSafe(targetIL)));
143 }
144 else
145 ErrorEx("Stash not spawned!");
146
147 //Apply tool damage
148 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 10);
149 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
150 }
const int ECE_PLACE_ON_SURFACE
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/....
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
enum ShapeType ErrorEx

References InventoryLocation::DumpToStringNullSafe(), ECE_PLACE_ON_SURFACE, ErrorEx, GetGame(), GameInventory::LocationCanRemoveEntity(), Debug::Log(), and m_SpecialtyWeight.

◆ SpawnParticleShovelRaise()

void ActionDigInStash::SpawnParticleShovelRaise ( ActionData action_data)
inlineprivate

Definition at line 114 of file ActionDigInStash.c.

115 {
116 ParticleManager.GetInstance().PlayOnObject(ParticleList.DIGGING_STASH, action_data.m_Player);
117 }
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
static const int DIGGING_STASH

References ParticleList::DIGGING_STASH, and ParticleManager().

Referenced by OnExecuteClient(), and OnExecuteServer().

Member Data Documentation

◆ m_DigStashSlopeTolerance

float ActionDigInStash::m_DigStashSlopeTolerance = 0.6
staticprivate

Definition at line 11 of file ActionDigInStash.c.

Referenced by ActionCondition().


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