DayZ 1.24
Loading...
Searching...
No Matches
ActionWorldLiquidActionSwitch.c
Go to the documentation of this file.
1//can be eventually extended to allow switching for multiple action types?
3{
6 {
7 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE;
8 }
9
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
83 {
84 return false;
85 }
86};
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
override void Start(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition Liquid.c:2
static bool CanFillContainer(ItemBase container, int liquid_type, bool ignore_fullness_check=false)
Definition Liquid.c:136
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()