Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actioncraftbolts.c
Go to the documentation of this file.
2 {
3  private const float TIME_TO_CRAFT = 3.0;
4 
5  override void CreateActionComponent()
6  {
7  m_ActionData.m_ActionComponent = new CAContinuousRepeat(TIME_TO_CRAFT);
8  }
9 };
10 
12 {
13  const ref set<string> CUTTING_TYPES = new set<string>();
14 
15  protected bool m_IsKnifeInHands;
16  protected Ammunition_Base m_ResultEntity;
17 
18  void InitCuttingTypes()
19  {
20  CUTTING_TYPES.Clear();
21  CUTTING_TYPES.Insert("Sickle");
22  CUTTING_TYPES.Insert("KukriKnife");
23  CUTTING_TYPES.Insert("FangeKnife");
24  CUTTING_TYPES.Insert("KitchenKnife");
25  CUTTING_TYPES.Insert("SteakKnife");
26  CUTTING_TYPES.Insert("StoneKnife");
27  CUTTING_TYPES.Insert("Cleaver");
28  CUTTING_TYPES.Insert("CombatKnife");
29  CUTTING_TYPES.Insert("HuntingKnife");
30  CUTTING_TYPES.Insert("Machete");
31  CUTTING_TYPES.Insert("CrudeMachete");
32  CUTTING_TYPES.Insert("OrientalMachete");
33  CUTTING_TYPES.Insert("WoodAxe");
34  CUTTING_TYPES.Insert("Hatchet");
35  CUTTING_TYPES.Insert("FirefighterAxe");
36  CUTTING_TYPES.Insert("AK_Bayonet");
37  CUTTING_TYPES.Insert("M9A1_Bayonet");
38  CUTTING_TYPES.Insert("SKS_Bayonet");
39  CUTTING_TYPES.Insert("BoneKnife");
40  }
41 
42  void ActionCraftBolts()
43  {
44  m_CallbackClass = ActionCraftBoltsCB;
45  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
46  m_FullBody = true;
47  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
49 
50  m_Text = "#STR_CraftBolt0";
51 
52  InitCuttingTypes();
53  }
54 
55  override void CreateConditionComponents()
56  {
59  }
60 
61  protected bool IsCuttingType(Object item)
62  {
63  return CUTTING_TYPES.Find(item.ClassName()) >= 0;
64  }
65 
66  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
67  {
68  if (IsCuttingType(item))
69  {
70  //knife in hands
71  if (target.GetObject())
72  return (target.GetObject().ClassName() == "WoodenStick");
73  }
74  else if (target.GetObject())
75  {
76  // material in hands
77  return IsCuttingType(target.GetObject());
78  }
79 
80  return false;
81  }
82 
83  override void OnStartServer(ActionData action_data)
84  {
85  m_IsKnifeInHands = IsCuttingType(action_data.m_MainItem);
86  m_ResultEntity = null;
87  }
88 
89  override void OnFinishProgressServer(ActionData action_data)
90  {
91  ItemBase knife;
92  ItemBase material;
93 
94  bool added = false;
95 
96  if (m_IsKnifeInHands)
97  {
98  //knife in hands
99  knife = action_data.m_MainItem;
100  material = ItemBase.Cast(action_data.m_Target.GetObject());
101  }
102  else
103  {
104  // material in hands
105  material = action_data.m_MainItem;
106  knife = ItemBase.Cast(action_data.m_Target.GetObject());
107  }
108 
109  if (!material || !knife)
110  return;
111 
112  if (m_ResultEntity)
113  {
114  if (m_ResultEntity.GetAmmoCount() < m_ResultEntity.GetAmmoMax())
115  {
116  m_ResultEntity.ServerAddAmmoCount(1);
117  added = true;
118  }
119  }
120 
121  if (!added)
122  {
123  m_ResultEntity = Ammunition_Base.Cast(action_data.m_Player.SpawnEntityOnGroundPos("Ammo_ImprovisedBolt_1", action_data.m_Player.GetPosition()));
124  m_ResultEntity.SetHealth("", "", material.GetHealth("", ""));
125  m_ResultEntity.ServerSetAmmoCount(1);
126  }
127 
128  material.AddQuantity(-1);
129  knife.AddHealth("","",-3);
130  }
131 };
ItemBase
Definition: inventoryitem.c:730
ActionCraftBoltsCB
Definition: actioncraftbolts.c:1
CAContinuousRepeat
Definition: cacontinuousrepeat.c:1
UASoftSkillsWeight
Definition: actionconstants.c:118
Ammunition_Base
ammo pile base
Definition: ammunitionpiles.c:2
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
CCTNonRuined
Definition: cctnonruined.c:1
Object
Definition: objecttyped.c:1
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
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
ActionCraftBolts
Definition: actioncraftbolts.c:11