Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionlightitemonfire.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime( UATimeSpent.FIREPLACE_IGNITE );
6  }
7 }
8 
10 {
12  {
13  m_CallbackClass = ActionLightItemOnFireCB;
14  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_STARTFIRE;
15  m_FullBody = true;
16  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
17 
19  m_Text = "#ignite";
20  }
21 
22  override void CreateConditionComponents()
23  {
26  }
27 
29  {
30  return true;
31  }
32 
33  // Removed as a fix for igniting Torch by Matchbox through drag&drop in inventory
34  /*override bool CanBePerformedFromInventory()
35  {
36  return true;
37  }*/
38 
39  // Check if ignite candidate is in cargo of something or not.
41  {
42  if ( item.GetInventory() )
43  {
45  item.GetInventory().GetCurrentInventoryLocation(loc);
46 
47  if ( loc.GetIdx() > -1 )
48  {
49  return true;
50  }
51  }
52 
53  return false;
54  }
55 
56  override bool ActionConditionContinue( ActionData action_data )
57  {
58  FireworksBase fireworks = FireworksBase.Cast( action_data.m_Target.GetObject() );
59 
60  if (fireworks)
61  {
62  return true;//something might begin occluding the item after the ignition began, we don't want that to cancel the ignition process, not the prettiest solution, but it works
63  }
64  else
65  {
66  return ActionCondition(action_data.m_Player, action_data.m_Target,action_data.m_MainItem);
67  }
68  }
69 
70  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
71  {
72  ItemBase targetItem = ItemBase.Cast(target.GetObject());
73 
74  if (targetItem && item)
75  {
76  // when igniting item on the ground with igniter in hands
77  if (!targetItem.IsIgnited() && !IsItemInCargoOfSomething(targetItem) && item.CanIgniteItem(targetItem) && targetItem.CanBeIgnitedBy(item))
78  {
79  // oven stage of standard fireplace
80  if (targetItem.IsKindOf("Fireplace"))
81  {
82  if (Fireplace.Cast(targetItem).IsOven())
83  return true;
84 
85  if (Fireplace.CanIgniteEntityAsFireplace(targetItem))
86  return true;
87 
88  return false;
89  }
90 
91  return true;
92  }
93  // when igniting item in hands from something on ground
94  else if (!item.IsIgnited() && !IsItemInCargoOfSomething(item) && targetItem.CanIgniteItem(item) && item.CanBeIgnitedBy(targetItem))
95  {
96  return true;
97  }
98  }
99 
100  return false;
101  }
102 
103  override void OnFinishProgressServer( ActionData action_data )
104  {
105  ItemBase target_item = ItemBase.Cast( action_data.m_Target.GetObject() );
106  ItemBase item = action_data.m_MainItem;
107 
108  bool is_ignition_successful;
109  ItemBase ignited_item; //item that was lit on fire
110  ItemBase fire_source_item; //item that was the source of fire
111 
112  if ( item.CanIgniteItem( target_item ) )
113  {
114  is_ignition_successful = target_item.IsThisIgnitionSuccessful( item );
115  ignited_item = target_item;
116  fire_source_item = item;
117  }
118  else if ( item.CanBeIgnitedBy( target_item ) )
119  {
120  is_ignition_successful = target_item.IsTargetIgnitionSuccessful( item );
121  ignited_item = item;
122  fire_source_item = target_item;
123  }
124 
125  if ( is_ignition_successful )
126  {
127  fire_source_item.OnIgnitedTarget( ignited_item );
128  ignited_item.OnIgnitedThis( fire_source_item );
129  }
130  else
131  {
132  fire_source_item.OnIgnitedTargetFailed( ignited_item );
133  ignited_item.OnIgnitedThisFailed( fire_source_item );
134  }
135  }
136 
137  //setup
138  override bool SetupAction( PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
139  {
140  if ( super.SetupAction( player, target, item, action_data, extra_data ) )
141  {
142  ItemBase target_item = ItemBase.Cast( target.GetObject() );
143  if ( target_item )
144  {
145  SetIgnitingAnimation( target_item );
146  }
147 
148  return true;
149  }
150 
151  return false;
152  }
153 
154  void SetIgnitingAnimation( ItemBase target_item )
155  {
156  if ( target_item.HasFlammableMaterial() )
157  {
158  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_STARTFIRE;
159  }
160  else
161  {
162  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
163  }
164  }
165 }
ItemBase
Definition: inventoryitem.c:730
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
CAContinuousTime
Definition: cacontinuoustime.c:1
IsItemInCargoOfSomething
bool IsItemInCargoOfSomething(ItemBase item)
Definition: actionlightitemonfire.c:40
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionlightitemonfire.c:70
CreateConditionComponents
override void CreateConditionComponents()
Definition: actionlightitemonfire.c:22
UASoftSkillsWeight
Definition: actionconstants.c:118
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ActionConditionContinue
override bool ActionConditionContinue(ActionData action_data)
Definition: actionlightitemonfire.c:56
OnFinishProgressServer
override void OnFinishProgressServer(ActionData action_data)
Definition: actionlightitemonfire.c:103
ActionLightItemOnFireCB
Definition: actionlightitemonfire.c:1
CanBePerformedFromQuickbar
override bool CanBePerformedFromQuickbar()
Definition: actionlightitemonfire.c:28
SetIgnitingAnimation
void SetIgnitingAnimation(ItemBase target_item)
Definition: actionlightitemonfire.c:154
UAMaxDistances
Definition: actionconstants.c:104
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
ActionLightItemOnFire
ActionLightItemOnFireCB ActionContinuousBaseCB ActionLightItemOnFire()
Definition: actionlightitemonfire.c:11
CCTNonRuined
Definition: cctnonruined.c:1
UATimeSpent
Definition: actionconstants.c:26
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
SetupAction
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition: actionlightitemonfire.c:138
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
FireworksBase
void FireworksBase()
Definition: fireworksbase.c:18
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53