Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actioncraftboltsfeather.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  protected bool m_IsFeatherInHands;
14  protected Ammunition_Base m_ResultEntity;
15 
17  {
18  m_CallbackClass = ActionCraftBoltsFeatherCB;
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 
28  override void CreateConditionComponents()
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 
55  override void OnStartServer(ActionData action_data)
56  {
57  m_IsFeatherInHands = IsFeatherType(action_data.m_MainItem.ClassName());
58  m_ResultEntity = null;
59  }
60 
61  override void OnFinishProgressServer(ActionData action_data)
62  {
63  ItemBase feather;
64  Ammunition_Base bolt;
65 
66  bool added = false;
67 
68  if (m_IsFeatherInHands)
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 
89  if (m_ResultEntity)
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 };
ItemBase
Definition: inventoryitem.c:730
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
ActionCraftBoltsFeather
Definition: actioncraftboltsfeather.c:11
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
ActionCraftBoltsFeatherCB
Definition: actioncraftboltsfeather.c:1
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