DayZ 1.24
Loading...
Searching...
No Matches
ActionDigInStash.c
Go to the documentation of this file.
8
10{
11 static float m_DigStashSlopeTolerance = 0.6;
12
14 {
16 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
17 m_FullBody = true;
18 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
20 m_Text = "#bury";
21 }
22
28
29 override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
30 {
32 return false;
33
34 return player.CheckFreeSpace(vector.Forward, 1.0, false);
35 }
36
37 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
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 }
98
100 {
101 super.OnExecuteClient(action_data);
102
104 }
105
107 {
108 super.OnExecuteServer(action_data);
109
110 if (!GetGame().IsMultiplayer())
112 }
113
115 {
116 ParticleManager.GetInstance().PlayOnObject(ParticleList.DIGGING_STASH, action_data.m_Player);
117 }
118
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 }
151
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 }
156}
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
const int ECE_PLACE_ON_SURFACE
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override void OnExecuteServer(ActionData action_data)
void SpawnParticleShovelRaise(ActionData action_data)
override void CreateConditionComponents()
override void OnFinishProgressServer(ActionData action_data)
override void OnExecuteClient(ActionData action_data)
static float m_DigStashSlopeTolerance
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override string GetAdminLogMessage(ActionData action_data)
override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Super root of all classes in Enforce script.
Definition EnScript.c:11
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)
static const int DIGGING_STASH
const float DEFAULT
const float DIG_STASH
static const vector Forward
Definition EnConvert.c:109
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.