DayZ 1.24
Loading...
Searching...
No Matches
ActionDestroyPart.c
Go to the documentation of this file.
8
10{
11 static int CYCLES = 4;
12
14 {
16 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
17 m_FullBody = true;
18 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
19
21 m_Text = "#destroy";
22 }
23
29
31 {
32 ConstructionActionData construction_action_data = player.GetConstructionActionData();
33 m_Text = "#destroy " + construction_action_data.GetTargetPart();
34 }
35
36 override bool CanBeUsedLeaning()
37 {
38 return false;
39 }
40
41 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
42 {
43 //Action not allowed if player has broken legs
44 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
45 return false;
46
47 return DestroyCondition(player, target, item, true);
48 }
49
51 {
52 return DestroyCondition(action_data.m_Player, action_data.m_Target, action_data.m_MainItem, false);
53 }
54
56 {
58 Construction construction = base_building.GetConstruction();
59 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
61
62 if (construction.CanDestroyPart(construction_part.GetPartName()))
63 {
64 //build
65 string part_name = construction_part.GetPartName();
66 string zone_name;
67 DamageSystem.GetDamageZoneFromComponentName(base_building, part_name, zone_name);
68
69 if (zone_name != "")
70 {
71 base_building.AddHealth(zone_name, "Health", -(base_building.GetMaxHealth(zone_name, "") / CYCLES));
72 if (base_building.GetHealth(zone_name, "Health") < 1)
73 construction.DestroyPartServer(action_data.m_Player, construction_part.GetPartName(), AT_DESTROY_PART);
74 }
75 else
76 construction.DestroyPartServer(action_data.m_Player, construction_part.GetPartName(), AT_DESTROY_PART);
77
78 //add damage to tool
79 action_data.m_MainItem.DecreaseHealth(UADamageApplied.DESTROY, false);
80 }
81
82 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
83 }
84
85 protected bool DestroyCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
86 {
87 Object target_object = target.GetObject();
88 if (target_object && target_object.CanUseConstruction())
89 {
90 string part_name = target_object.GetActionComponentName(target.GetComponentIndex());
91
93 Construction construction = base_building.GetConstruction();
94 ConstructionPart construction_part = construction.GetConstructionPartToDestroy(part_name);
95
97 {
98 //camera and position checks
99 if (!player.GetInputController().CameraIsFreeLook() && IsInReach(player, target, UAMaxDistances.DEFAULT) && !player.GetInputController().CameraIsFreeLook())
100 {
101 //Camera check (client-only)
102 if (camera_check)
103 {
104 if (GetGame() && (!GetGame().IsDedicatedServer()))
105 {
106 if (!base_building.IsFacingCamera(part_name))
107 return false;
108 }
109 }
110
111 ConstructionActionData construction_action_data = player.GetConstructionActionData();
113
114 return true;
115 }
116 }
117 }
118
119 return false;
120 }
121
123 {
124 return " destroyed " + action_data.m_Target.GetObject().GetDisplayName() + " with " + action_data.m_MainItem.GetDisplayName();
125 }
126}
const int AT_DESTROY_PART
Definition _constants.c:8
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition ActionBase.c:856
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
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionBase m_Action
Definition ActionBase.c:27
override void CreateActionComponent()
bool DestroyCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressServer(ActionData action_data)
override bool CanBeUsedLeaning()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
override bool ActionConditionContinue(ActionData action_data)
override string GetAdminLogMessage(ActionData action_data)
const float DESTROY
const float DEFAULT
const float DEFAULT_DESTROY
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()