Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionworldliquidactionswitch.c
Go to the documentation of this file.
1 //can be eventually extended to allow switching for multiple action types?
3 {
4  bool m_switch_to;
6  {
7  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE;
8  }
9 
10  override void CreateConditionComponents()
11  {
14  }
15 
16  /*override string GetText()
17  {
18  //return "#switch_to" + " " + m_switch_to;
19  if (!m_switch_to)
20  return "#switch_to_liquid_drain";
21  return "#switch_to_liquid_pour";
22  }*/
23 
24  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
25  {
26  ItemBase target_item = ItemBase.Cast(target.GetObject());
27  if (Barrel_ColorBase.Cast(target_item) && !target_item.IsOpen())
28  return false;
29 
30  if ( target_item && item && Liquid.CanFillContainer( item, target_item.GetLiquidType(),true ) && Liquid.CanFillContainer( target_item, item.GetLiquidType(), true ) && !GetGame().IsInventoryOpen() ) //TODO find better condition than IsKindOf
31  {
32  if ( target_item.GetQuantity() > target_item.GetQuantityMin() && item.GetQuantity() < item.GetQuantityMax() && !player.GetLiquidTendencyDrain() && Liquid.CanFillContainer( item, target_item.GetLiquidType() ) )
33  {
34  if ( Liquid.CanFillContainer( target_item, item.GetLiquidType() ) )
35  {
36  m_switch_to = 0;//"#liquid_drain";
37  return true;
38  }
39  else
40  {
41  player.SetLiquidTendencyDrain(true);
42  return false;
43  }
44  }
45  if ( item.GetQuantity() > item.GetQuantityMin() && target_item.GetQuantity() < target_item.GetQuantityMax() && player.GetLiquidTendencyDrain() && Liquid.CanFillContainer( target_item, item.GetLiquidType() ) )
46  {
47  if ( Liquid.CanFillContainer( item, target_item.GetLiquidType() ) )
48  {
49  m_switch_to = 1;//"#liquid_pour";
50  return true;
51  }
52  else
53  {
54  player.SetLiquidTendencyDrain(false);
55  return false;
56  }
57  }
58  }
59  return false;
60  }
61 
62  override void Start( ActionData action_data ) //Setup on start of action
63  {
64  super.Start( action_data );
65  bool state;
66  state = action_data.m_Player.GetLiquidTendencyDrain();
67  action_data.m_Player.SetLiquidTendencyDrain(!state);
68 
69  //Print(action_data.m_Player.GetLiquidTendencyDrain());
70  }
71 
72  override bool IsLocal()
73  {
74  return true;
75  }
76 
77  override bool IsInstant()
78  {
79  return true;
80  }
81 
82  override bool RemoveForceTargetAfterUse()
83  {
84  return false;
85  }
86 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionWorldLiquidActionSwitch
Definition: actionworldliquidactionswitch.c:2
UAMaxDistances
Definition: actionconstants.c:104
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
ActionSingleUseBase
Definition: actionsingleusebase.c:41
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
Barrel_ColorBase
Definition: barrel_colorbase.c:1
Liquid
Definition: liquid.c:1
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53