DayZ 1.24
Loading...
Searching...
No Matches
ActionCraftBolts.c
Go to the documentation of this file.
10
12{
14
15 protected bool m_IsKnifeInHands;
17
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
43 {
45 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
46 m_FullBody = true;
47 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
49
50 m_Text = "#STR_CraftBolt0";
51
53 }
54
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 {
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
88
90 {
93
94 bool added = false;
95
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};
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
ActionData m_ActionData
override void CreateActionComponent()
const float TIME_TO_CRAFT
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
const ref set< string > CUTTING_TYPES
override void OnFinishProgressServer(ActionData action_data)
Ammunition_Base m_ResultEntity
override void CreateConditionComponents()
override void OnStartServer(ActionData action_data)
bool IsCuttingType(Object item)
ref CABase m_ActionComponent
Definition ActionBase.c:30
ammo pile base
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597