DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionDigOutStash.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
6 }
7}
8
10{
12 {
13 m_CallbackClass = ActionDigOutStashCB;
14 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGUPCACHE;
15 m_FullBody = true;
16 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
18 m_Text = "#dig_stash";
19 }
20
22 {
25 }
26
27 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
28 {
29 ItemBase target_IB;
30 if (Class.CastTo(target_IB, target.GetObject()))
31 {
32 if (target_IB.CanBeDigged())
33 {
34 return target_IB.IsInherited(UndergroundStash);
35 }
36 }
37
38 return false;
39 }
40
41 override void OnExecuteClient(ActionData action_data)
42 {
43 super.OnExecuteClient(action_data);
44
45 SpawnParticleShovelRaise(action_data);
46 }
47
48 override void OnExecuteServer(ActionData action_data)
49 {
50 super.OnExecuteServer(action_data);
51
52 if (!GetGame().IsMultiplayer())
53 {
54 SpawnParticleShovelRaise(action_data);
55 }
56 }
57
59 {
60 ParticleManager.GetInstance().PlayOnObject(ParticleList.DIGGING_STASH, action_data.m_Player);
61 }
62
63 override void OnFinishProgressServer( ActionData action_data )
64 {
65 EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
66 if (!targetEntity)
67 {
68 ErrorEx("Cannot get entity=" + targetEntity);
69 return;
70 }
71
72 InventoryLocation target_IL = new InventoryLocation();
73 if (!targetEntity.GetInventory().GetCurrentInventoryLocation(target_IL))
74 {
75 ErrorEx("Cannot get inventory location of entity=" + targetEntity);
76 return;
77 }
78
79 // Dig out of stash
80 UndergroundStash stash;
81 if (Class.CastTo(stash, targetEntity))
82 {
83 ItemBase stashedItem = stash.GetStashedItem();
84 if (stashedItem)
85 {
86 DigOutStashLambda lambda(stash, "", action_data.m_Player);
87 action_data.m_Player.ServerReplaceItemWithNew(lambda);
88 }
89 else
90 g_Game.ObjectDelete(stash);
91 }
92
93 //Apply tool damage
94 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 10);
95 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
96 }
97
98 override string GetAdminLogMessage(ActionData action_data)
99 {
100 return string.Format("Player %1 Dug out %2 at position %3", action_data.m_Player, action_data.m_Target.GetObject(), action_data.m_Target.GetObject().GetPosition());
101 }
102}
103
105{
106 void DigOutStashLambda(EntityAI old_item, string new_item_type, PlayerBase player) {}
107
108 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
109 {
110 super.CopyOldPropertiesToNew(old_item, new_item);
111 }
112}
void CreateConditionComponents()
Definition ActionBase.c:218
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
string GetAdminLogMessage(ActionData action_data)
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
ActionDigOutStashCB ActionContinuousBaseCB ActionDigOutStash()
void SpawnParticleShovelRaise(ActionData action_data)
class ActionTargets ActionTarget
DayZGame g_Game
Definition DayZGame.c:3654
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
protected ActionData m_ActionData
protected void OnFinishProgressServer(ActionData action_data)
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
override void CreateActionComponent()
protected void OnExecuteServer(ActionData action_data)
protected void OnExecuteClient(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
void DigOutStashLambda(EntityAI old_item, string new_item_type, PlayerBase player)
this one is a bit special: it drops all items and destroys the ex-root of the hierarchy
InventoryLocation.
ItemBase GetStashedItem()
static const int DIGGING_STASH
const float DEFAULT
const float DIG_STASH
DayZPlayerConstants
defined in C++
Definition 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.