DayZ 1.24
Loading...
Searching...
No Matches
ActionCraftBoltsFeather.c
Go to the documentation of this file.
10
12{
13 protected bool m_IsFeatherInHands;
15
17 {
19 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
20 m_FullBody = true;
21 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
23
24 m_Text = "#STR_CraftBolt1";
25
26 }
27
29 {
32 }
33
34 protected bool IsFeatherType(string itemInHandsType)
35 {
36 return itemInHandsType == "ChickenFeather";
37 }
38
39 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
40 {
41 if (IsFeatherType(item.ClassName()))
42 {
43 //feather in hands
44 if (target.GetObject())
45 return (target.GetObject().ClassName() == "Ammo_ImprovisedBolt_1");
46 }
47 else if (target.GetObject())
48 {
49 // bolt in hands
50 return IsFeatherType(target.GetObject().ClassName());
51 }
52 return false;
53 }
54
56 {
57 m_IsFeatherInHands = IsFeatherType(action_data.m_MainItem.ClassName());
59 }
60
62 {
65
66 bool added = false;
67
69 {
70 //feather in hands
71 feather = action_data.m_MainItem;
72 bolt = Ammunition_Base.Cast(action_data.m_Target.GetObject());
73 }
74 else
75 {
76 // bolt in hands
77 bolt = Ammunition_Base.Cast(action_data.m_MainItem);
78 feather = ItemBase.Cast(action_data.m_Target.GetObject());
79 }
80
81 if (!bolt || !feather)
82 return;
83
84 float dmg;
85 string type;
86
87 bolt.ServerAcquireCartridge(dmg, type);
88
90 {
91 type = m_ResultEntity.ConfigGetString("Ammo");
92 if (m_ResultEntity.GetAmmoCount() < m_ResultEntity.GetAmmoMax())
93 {
94 m_ResultEntity.ServerStoreCartridge(dmg, type);
95 added = true;
96 }
97 }
98
99 if (!added)
100 {
101 m_ResultEntity = Ammunition_Base.Cast(action_data.m_Player.SpawnEntityOnGroundPos("Ammo_ImprovisedBolt_2", action_data.m_Player.GetPosition()));
102 type = m_ResultEntity.ConfigGetString("Ammo");
103 m_ResultEntity.ServerSetAmmoCount(0);
104 m_ResultEntity.ServerStoreCartridge(dmg, type);
105 m_ResultEntity.SetHealth01("", "", bolt.GetHealth01("", ""));
106 }
107
108 feather.AddQuantity(-1);
109 }
110};
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
bool IsFeatherType(string itemInHandsType)
override void OnStartServer(ActionData action_data)
override void CreateConditionComponents()
override void OnFinishProgressServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
ref CABase m_ActionComponent
Definition ActionBase.c:30
ammo pile base
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597