DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionDigInStash.c
См. документацию.
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;
19 m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
20 m_Text = "#bury";
21 }
22
28
29 override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
30 {
31 if (!super.Can(player, target, item, condition_mask))
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 {
39 ItemBase targetIB;
40 if (Class.CastTo(targetIB, target.GetObject()) && targetIB.CanBeDigged())
41 {
42 if (player.IsPlacingLocal())
43 {
44 return false;
45 }
46
47 if (targetIB.IsRuined() || targetIB.GetInventory().IsAttachment())
48 {
49 return false;
50 }
51
52 if (targetIB.GetInventory().IsAttachment())
53 {
54 return false;
55 }
56
57 if (targetIB.IsInherited(UndergroundStash))
58 {
59 return false;
60 }
61
63 EntityAI entityToCheck = targetIB;
64 if (targetIB.GetInventory().IsInCargo())
65 entityToCheck = player;
66
67 // here we check if a stash is nearby and block digging a new one in close proximity
68 array<Object> excludedObjects = new array<Object>();
69 excludedObjects.Insert(targetIB);
70 array<Object> nearbyObjects = new array<Object>();
71 // For now we exclude an area of 2 X 2 X 2 meters
72 if (GetGame().IsBoxColliding(entityToCheck.GetPosition(), entityToCheck.GetOrientation(), "2 2 2", excludedObjects, nearbyObjects))
73 {
74 foreach (Object nearbyObject : nearbyObjects)
75 {
76 if (nearbyObject.IsInherited(UndergroundStash))
77 return false;
78 }
79 }
80
81 // Check surface
82 int liquidType;
83 string surfaceType;
84 GetGame().SurfaceUnderObject(entityToCheck, surfaceType, liquidType);
85 if (!GetGame().IsSurfaceDigable(surfaceType))
86 {
87 return false;
88 }
89 else
90 {
92 vector position = entityToCheck.GetPosition();
93
94 array<vector> positions = new array<vector>;
95 positions.Insert(position + "0.5 0 0.5");
96 positions.Insert(position + "-0.5 0 0.5");
97 positions.Insert(position + "0.5 0 -0.5");
98 positions.Insert(position + "-0.5 0 -0.5");
99
100 float difference = GetGame().GetHighestSurfaceYDifference(positions);
101
102 return difference < m_DigStashSlopeTolerance;
103 }
104 }
105
106 return false;
107 }
108
109 override void OnExecuteClient(ActionData action_data)
110 {
111 super.OnExecuteClient(action_data);
112
113 SpawnParticleShovelRaise(action_data);
114 }
115
116 override void OnExecuteServer(ActionData action_data)
117 {
118 super.OnExecuteServer(action_data);
119
120 if (!GetGame().IsMultiplayer())
121 {
122 SpawnParticleShovelRaise(action_data);
123 }
124 }
125
127 {
128 ParticleManager.GetInstance().PlayOnObject(ParticleList.DIGGING_STASH, action_data.m_Player);
129 }
130
131 override void OnFinishProgressServer(ActionData action_data)
132 {
133 EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
134 if (!targetEntity)
135 {
136 ErrorEx("Cannot get entity=" + targetEntity);
137 return;
138 }
139
140 InventoryLocation targetIL = new InventoryLocation();
141 if (!targetEntity.GetInventory().GetCurrentInventoryLocation(targetIL))
142 {
143 ErrorEx("Cannot get inventory location of entity=" + targetEntity);
144 return;
145 }
146
147 EntityAI entityToCheck = targetEntity;
148 if (targetEntity.GetInventory().IsInCargo())
149 entityToCheck = action_data.m_Player;
150
151 int liquidType;
152 string surfaceType;
153 GetGame().SurfaceUnderObject(entityToCheck, surfaceType, liquidType);
154 string undergroundStashType;
155
156 GetGame().GetSurfaceDigPile(surfaceType, undergroundStashType);
157
158 if (undergroundStashType == "")
159 undergroundStashType = "UndergroundStash";
160
161 UndergroundStash stash = UndergroundStash.Cast(GetGame().CreateObjectEx(undergroundStashType, targetEntity.GetPosition(), ECE_PLACE_ON_SURFACE));
162 if (stash)
163 {
164 ClearActionJuncture(action_data);
165 stash.PlaceOnGround();
167 stash.GetInventory().GetCurrentInventoryLocation(ilj);
168
170 {
171 GetGame().AddInventoryJunctureEx(action_data.m_Player, targetEntity, ilj, true, 10000);
172 GetGame().ClearJunctureEx(action_data.m_Player, targetEntity);
173
174 if (!GetGame().IsMultiplayer())
175 {
176 ClearInventoryReservationEx(action_data);
177 action_data.m_Player.LocalTakeEntityToTargetCargo(stash, targetEntity);
178 }
179 else
180 action_data.m_Player.ServerTakeEntityToTargetCargo(stash, targetEntity);
181 }
182 else
183 {
184 Debug.Log(string.Format("Cannot remove entity=%1 obj from current location=%2", targetEntity, InventoryLocation.DumpToStringNullSafe(targetIL)));
185 }
186 }
187 else
188 {
189 ErrorEx("Stash not spawned!");
190 }
191
192 //Apply tool damage
193 MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 10);
194 }
195
196 override string GetAdminLogMessage(ActionData action_data)
197 {
198 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());
199 }
200}
ActionBase ActionData
Определения ActionBase.c:30
class ActionTargets ActionTarget
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
float m_SpecialtyWeight
Определения ActionBase.c:77
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1083
int m_StanceMask
Определения ActionBase.c:62
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1025
bool m_FullBody
Определения ActionBase.c:61
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
ActionData m_ActionData
Определения AnimatedActionBase.c:3
void ActionContinuousBase()
Определения ActionContinuousBase.c:124
override void OnExecuteServer(ActionData action_data)
Определения ActionDigInStash.c:116
void SpawnParticleShovelRaise(ActionData action_data)
Определения ActionDigInStash.c:126
override void CreateConditionComponents()
Определения ActionDigInStash.c:23
void ActionDigInStash()
Определения ActionDigInStash.c:13
override void OnFinishProgressServer(ActionData action_data)
Определения ActionDigInStash.c:131
override void OnExecuteClient(ActionData action_data)
Определения ActionDigInStash.c:109
static float m_DigStashSlopeTolerance
Определения ActionDigInStash.c:11
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionDigInStash.c:37
override string GetAdminLogMessage(ActionData action_data)
Определения ActionDigInStash.c:196
override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Определения ActionDigInStash.c:29
override void CreateActionComponent()
Определения ActionDigInStash.c:3
int m_CommandUID
Определения AnimatedActionBase.c:143
Определения CCINonRuined.c:2
Определения CCTObject.c:2
float GetHighestSurfaceYDifference(array< vector > positions)
Returns the largest height difference between the given positions.
Определения Game.c:1119
bool ClearJunctureEx(Man player, notnull EntityAI item)
Определения Game.c:762
bool AddInventoryJunctureEx(Man player, notnull EntityAI item, InventoryLocation dst, bool test_dst_occupancy, int timeout_ms)
Определения Game.c:741
bool GetSurfaceDigPile(string surface, out string result)
Определения Game.c:1161
proto void SurfaceUnderObject(notnull Object object, out string type, out int liquidType)
Super root of all classes in Enforce script.
Определения EnScript.c:11
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.
Определения Debug.c:122
Определения Debug.c:2
Определения Building.c:6
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/....
script counterpart to engine's class Inventory
Определения Inventory.c:79
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения ObjectTyped.c:2
static const int DIGGING_STASH
Определения ParticleList.c:96
Определения ParticleList.c:12
Определения PlayerBaseClient.c:2
const float DEFAULT
Определения ActionConstants.c:112
const float DIG_STASH
Определения ActionConstants.c:78
Определения ActionConstants.c:28
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Forward
Определения EnConvert.c:109
Определения EnConvert.c:106
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
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.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.