Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionfillbottlebase.c
Go to the documentation of this file.
2 {
3  private int m_liquid_type;
4  private float m_BaseFillQuantity;
5 
6  override void CreateActionComponent()
7  {
8  m_liquid_type = ActionFillBottleBase.Cast(m_ActionData.m_Action).GetLiquidType(m_ActionData.m_Player, m_ActionData.m_Target, m_ActionData.m_MainItem);
9 
10  if (m_ActionData.m_Target.GetObject() && m_ActionData.m_Target.GetObject().IsFuelStation())
11  {
12  m_BaseFillQuantity = UAQuantityConsumed.FUEL;
13  }
14  else
15  {
16  m_BaseFillQuantity = UAQuantityConsumed.FILL_LIQUID;
17  }
18  m_ActionData.m_ActionComponent = new CAContinuousFill(m_BaseFillQuantity, m_liquid_type);
19  }
20 };
21 
23 {
24  private const float WATER_DEPTH = 0.5;
25  private const string ALLOWED_WATER_SURFACES = string.Format("%1|%2", UAWaterType.FRESH, UAWaterType.STILL);
26 
28  {
29  m_CallbackClass = ActionFillBottleBaseCB;
30  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEPOND;
31  m_FullBody = true;
32  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
34  m_Text = "#fill";
35  }
36 
37  override void CreateConditionComponents()
38  {
41  }
42 
43  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
44  {
45  if (item.IsFullQuantity())
46  return false;
47 
48  Object targetObject = target.GetObject();
49  if (targetObject)
50  {
51  Land_FuelStation_Feed fuelstation = Land_FuelStation_Feed.Cast(targetObject);
52  if (fuelstation)
53  {
54  if (!fuelstation.HasFuelToGive())
55  return false;
56  }
57  if (vector.DistanceSq(player.GetPosition(), targetObject.GetPosition()) > UAMaxDistances.DEFAULT * UAMaxDistances.DEFAULT)
58  return false;
59 
60  if (targetObject.GetWaterSourceObjectType() != EWaterSourceObjectType.NONE || targetObject.GetWaterSourceObjectType() == EWaterSourceObjectType.THROUGH || targetObject.IsFuelStation())
61  {
62  return GetLiquidType(player, target, item) != -1;
63  }
64  }
65 
67  if (waterCheck.Can(player, target))
68  return GetLiquidType(player, target, item) != -1;
69 
70  return false;
71  }
72 
73  override bool ActionConditionContinue(ActionData action_data)
74  {
75  return action_data.m_MainItem.GetQuantity() < action_data.m_MainItem.GetQuantityMax();
76  }
77 
78  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
79  {
80  SetupStance(player);
81 
82  if (super.SetupAction(player, target, item, action_data, extra_data))
83  {
84  if (action_data.m_Target.GetObject())
85  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEWELL;
86 
87  return true;
88  }
89 
90  return false;
91  }
92 
93  int GetLiquidType(PlayerBase player, ActionTarget target, ItemBase item)
94  {
95  if (target.GetObject() && target.GetObject().IsFuelStation())
96  {
97  if (Liquid.CanFillContainer(item, LIQUID_GASOLINE))
98  return LIQUID_GASOLINE;
99  }
100  else if ((!target.GetObject() || target.GetObject().IsWell() || target.GetObject().GetWaterSourceObjectType() == EWaterSourceObjectType.WELL || target.GetObject().GetWaterSourceObjectType() == EWaterSourceObjectType.THROUGH) && Liquid.CanFillContainer(item, LIQUID_WATER))
101  {
102  return LIQUID_WATER;
103  }
104 
105  return -1;
106  }
107 
108  void SetupStance(PlayerBase player)
109  {
110  //returns in format (totalWaterDepth, characterDepht, 0)
111  vector water_info = HumanCommandSwim.WaterLevelCheck(player, player.GetPosition());
112  if (water_info[1] > WATER_DEPTH)
113  {
114  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
115  }
116  else
117  {
118  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
119  }
120  }
121 }
ItemBase
Definition: inventoryitem.c:730
CAContinuousFill
Definition: cacontinuousfill.c:1
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
EWaterSourceObjectType
EWaterSourceObjectType
Definition: ewatersourceobjecttype.c:1
CCTWaterSurface
Definition: cctwatersurface.c:1
UASoftSkillsWeight
Definition: actionconstants.c:118
ActionFillBottleBaseCB
Definition: actionfillbottlebase.c:1
UAQuantityConsumed
Definition: actionconstants.c:3
CCTNone
Definition: cctnone.c:1
LIQUID_WATER
const int LIQUID_WATER
Definition: constants.c:505
LIQUID_GASOLINE
const int LIQUID_GASOLINE
Definition: constants.c:509
UAWaterType
Definition: actionconstants.c:144
UAMaxDistances
Definition: actionconstants.c:104
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
HumanCommandSwim
class HumanCommandLadder HumanCommandSwim()
Definition: human.c:673
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
ActionFillBottleBase
Definition: actionfillbottlebase.c:22
WATER_DEPTH
const protected float WATER_DEPTH
Definition: emoteclasses.c:2
ALLOWED_WATER_SURFACES
const protected string ALLOWED_WATER_SURFACES
Definition: actiondrinkpondcontinuous.c:12
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
Liquid
Definition: liquid.c:1
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