DayZ 1.24
Loading...
Searching...
No Matches
ActionDismantlePart.c
Go to the documentation of this file.
2{
8
10 {
11 /*switch( item.Type() )
12 {
13 case Pickaxe:
14 case Shovel:
15 case FieldShovel:
16 return UATimeSpent.BASEBUILDING_DECONSTRUCT_MEDIUM;
17 case FirefighterAxe:
18 return UATimeSpent.BASEBUILDING_DECONSTRUCT_FAST;
19 default:
20 return UATimeSpent.BASEBUILDING_DECONSTRUCT_SLOW;
21 }*/
23 }
24};
25
27{
29 {
31 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
32 m_FullBody = true;
33 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
34
36 m_Text = "#dismantle";
37 }
38
40 {
42 m_ConditionTarget = new CCTNone;//CCTNonRuined( UAMaxDistances.BASEBUILDING );
43 }
44
46 {
47 ConstructionActionData construction_action_data = player.GetConstructionActionData();
48 m_Text = "#dismantle " + construction_action_data.GetTargetPart().GetName();
49 }
50
51 override string GetText()
52 {
54 if (player)
55 {
56 ConstructionActionData construction_action_data = player.GetConstructionActionData();
58
60 return "#dismantle" + " " + constrution_part.GetName();
61 }
62
63 return "";
64 }
65
66 override bool CanBeUsedLeaning()
67 {
68 return false;
69 }
70
71 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
72 {
73 if (player.IsPlacingLocal())
74 return false;
75
76 //Action not allowed if player has broken legs
77 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
78 return false;
79
80 return DismantleCondition(player, target, item, true) && player.m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE;
81 }
82
84 {
85 return DismantleCondition(action_data.m_Player, action_data.m_Target, action_data.m_MainItem, false) && action_data.m_Player.m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE;
86 }
87
89 {
91 Construction construction = base_building.GetConstruction();
92 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
94
95 if (construction.CanDismantlePart(construction_part.GetPartName(), action_data.m_MainItem))
96 {
97 //build
98 construction.DismantlePartServer(action_data.m_Player, construction_part.GetPartName(), AT_DISMANTLE_PART);
99
100 //add damage to tool
101 action_data.m_MainItem.DecreaseHealth(UADamageApplied.DISMANTLE, false);
102 }
103
104 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
105 }
106
107 //setup
109 {
110 if (super.SetupAction(player, target, item, action_data, extra_data))
111 {
113
114 return true;
115 }
116
117 return false;
118 }
119
121 {
122 switch (item.Type())
123 {
124 case Pickaxe:
125 case Shovel:
126 case FarmingHoe:
127 case FieldShovel:
128 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
129 break;
130 case Pliers:
131 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
132 break;
133 default:
134 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
135 break;
136 }
137 }
138
140 {
141 if (player && !player.IsPlacingLocal() && !player.IsPlacingServer())
142 {
143 Object target_object = target.GetObject();
145 if (target_object && target_object.CanUseConstruction())
146 {
147 //invalid if is gate and is locked
148 if (Class.CastTo(target_entity, target_object) && (target_entity.FindAttachmentBySlotName("Att_CombinationLock") || target_entity.FindAttachmentBySlotName("Material_FPole_Flag")))
149 return false;
150
151 string part_name = target_object.GetActionComponentName(target.GetComponentIndex());
152
154 Construction construction = base_building.GetConstruction();
155 ConstructionPart construction_part = construction.GetConstructionPartToDismantle(part_name, item);
156
158 {
159 /*Print("DismantleCondition");
160 Print(part_name);
161 Print("construction_part.GetPartName: " + construction_part.GetPartName());
162 Print("construction_part.GetMainPartName: " + construction_part.GetMainPartName());
163 Print("-----");*/
164
165 //invalid on gate if the gate is opened
166 if (construction_part.IsGate() && base_building.IsOpened())
167 return false;
168
169 //camera and position checks
170 bool checked = false;
171
172 if (construction_part.IsBase())
173 checked = true;
174
175 if (!checked && base_building.IsPlayerInside(player, part_name) && !player.GetInputController().CameraIsFreeLook())
176 {
177 //Camera check (client-only)
178 if (camera_check)
179 {
180 if (GetGame() && (!GetGame().IsDedicatedServer()))
181 {
182 if (base_building.IsFacingCamera(part_name))
183 return false;
184 }
185 }
186
187 checked = true;
188 }
189
190 if (checked)
191 {
192 ConstructionActionData construction_action_data = player.GetConstructionActionData();
194
195 return true;
196 }
197 }
198 }
199 }
200
201 return false;
202 }
203
205 {
206 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
208
209 string message = string.Format("Dismantled %1 from %2 with %3", construction_part.GetName(), action_data.m_Target.GetObject().GetDisplayName(), action_data.m_MainItem.GetDisplayName());
210 return message;
211 }
212}
const int AT_DISMANTLE_PART
Definition _constants.c:7
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
void Construction(BaseBuildingBase parent)
eBrokenLegs
Definition EBrokenLegs.c:2
PlayerBase GetPlayer()
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
ItemBase m_MainItem
Definition ActionBase.c:28
float SetCallbackDuration(ItemBase item)
override void CreateActionComponent()
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
bool DismantleCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
void SetBuildingAnimation(ItemBase item)
override bool CanBeUsedLeaning()
override void OnFinishProgressServer(ActionData action_data)
override void CreateConditionComponents()
override string GetAdminLogMessage(ActionData action_data)
override bool ActionConditionContinue(ActionData action_data)
override string GetText()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
const float DISMANTLE
const float BASEBUILDING_DECONSTRUCT_SLOW
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.