Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondestroypart.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousRepeat( UATimeSpent.DEFAULT_DESTROY/ActionDestroyPart.Cast(m_ActionData.m_Action).CYCLES );
6  }
7 };
8 
10 {
11  static int CYCLES = 4;
12 
13  void ActionDestroyPart()
14  {
15  m_CallbackClass = ActionDestroyPartCB;
16  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
17  m_FullBody = true;
18  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
19 
21  m_Text = "#destroy";
22  }
23 
24  override void CreateConditionComponents()
25  {
28  }
29 
30  override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
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 
50  override bool ActionConditionContinue( ActionData action_data )
51  {
52  return DestroyCondition( action_data.m_Player, action_data.m_Target, action_data.m_MainItem , false );
53  }
54 
55  override void OnFinishProgressServer( ActionData action_data )
56  {
57  BaseBuildingBase base_building = BaseBuildingBase.Cast( action_data.m_Target.GetObject() );
58  Construction construction = base_building.GetConstruction();
59  ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
60  ConstructionPart construction_part = construction_action_data.GetTargetPart();
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  {
77  construction.DestroyPartServer( action_data.m_Player, construction_part.GetPartName(), AT_DESTROY_PART );
78  }
79 
80  //add damage to tool
81  action_data.m_MainItem.DecreaseHealth( UADamageApplied.DESTROY, false );
82  }
83 
84  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
85  }
86 
87  protected bool DestroyCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check )
88  {
89  Object target_object = target.GetObject();
90  if ( target_object && target_object.CanUseConstruction() )
91  {
92  string part_name = target_object.GetActionComponentName( target.GetComponentIndex() );
93 
94  BaseBuildingBase base_building = BaseBuildingBase.Cast( target_object );
95  Construction construction = base_building.GetConstruction();
96  ConstructionPart construction_part = construction.GetConstructionPartToDestroy( part_name );
97 
98  if ( construction_part )
99  {
100  //camera and position checks
101  if ( !player.GetInputController().CameraIsFreeLook() && IsInReach(player, target, UAMaxDistances.DEFAULT) && !player.GetInputController().CameraIsFreeLook() )
102  {
103  //Camera check (client-only)
104  if ( camera_check )
105  {
106  if ( GetGame() && ( !GetGame().IsDedicatedServer() ) )
107  {
108  if ( !base_building.IsFacingCamera( part_name ) )
109  {
110  return false;
111  }
112  }
113  }
114 
115  ConstructionActionData construction_action_data = player.GetConstructionActionData();
116  construction_action_data.SetTargetPart( construction_part );
117 
118  return true;
119  }
120  }
121  }
122 
123  return false;
124  }
125 
126  override string GetAdminLogMessage(ActionData action_data)
127  {
128  return " destroyed " + action_data.m_Target.GetObject().GetDisplayName() + " with " + action_data.m_MainItem.GetDisplayName();
129  }
130 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ConstructionActionData
Definition: constructionactiondata.c:1
CAContinuousRepeat
Definition: cacontinuousrepeat.c:1
UADamageApplied
Definition: actionconstants.c:130
Construction
void Construction(BaseBuildingBase parent)
Definition: construction.c:26
UASoftSkillsWeight
Definition: actionconstants.c:118
CCTNone
Definition: cctnone.c:1
UAMaxDistances
Definition: actionconstants.c:104
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
BaseBuildingBase
Definition: fence.c:1
Object
Definition: objecttyped.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
ActionDestroyPart
Definition: actiondestroypart.c:9
IsInReach
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition: actionbase.c:928
AT_DESTROY_PART
const int AT_DESTROY_PART
Definition: _constants.c:8
m_Text
protected string m_Text
Definition: actionbase.c:49
ConstructionPart
Definition: constructionpart.c:1
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionDestroyPartCB
Definition: actiondestroypart.c:1
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53