Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
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_liquid_type == LIQUID_GASOLINE)
11 {
12 m_BaseFillQuantity = UAQuantityConsumed.FUEL;
13 }
14 else if (m_liquid_type == LIQUID_SNOW)
15 {
16 m_BaseFillQuantity = UAQuantityConsumed.FILL_SNOW;
17 }
18 else
19 {
20 m_BaseFillQuantity = UAQuantityConsumed.FILL_LIQUID;
21 }
22 m_ActionData.m_ActionComponent = new CAContinuousFill(m_BaseFillQuantity, m_liquid_type);
23 }
24};
25
26class ActionFillBottleBase: ActionContinuousBase
27{
28 private const float WATER_DEPTH = 0.5;
29 private const string ALLOWED_WATER_SURFACES = string.Format("%1|%2|%3", UAWaterType.FRESH, UAWaterType.STILL, UAWaterType.SNOW);
30 protected int m_AllowedLiquidMask;
31
33 {
35 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEPOND;
36 m_FullBody = true;
37 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
38 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
39 m_Text = "#fill";
40
43 }
44
46 {
49 }
50
51 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
52 {
53 Object targetObject = target.GetObject();
54 if (targetObject)
55 {
56 if (vector.DistanceSq(player.GetPosition(), targetObject.GetPosition()) > UAMaxDistances.DEFAULT * UAMaxDistances.DEFAULT)
57 return false;
58 }
59 else
60 {
62 if (!waterCheck.Can(player, target))
63 return false;
64 }
65
66 int liquidType = GetLiquidType(player, target, item);
67
68 if (item.GetQuantity() > item.GetQuantityMin())
69 liquidType = Liquid.TranslateLiquidType(liquidType);
70
71 return liquidType != LIQUID_NONE && Liquid.CanFillContainer(item,liquidType);
72 }
73
74 override bool ActionConditionContinue(ActionData action_data)
75 {
76 return action_data.m_MainItem.GetQuantity() < action_data.m_MainItem.GetQuantityMax();
77 }
78
79 override protected int GetStanceMask(PlayerBase player)
80 {
81 vector water_info = HumanCommandSwim.WaterLevelCheck(player, player.GetPosition());
82 if (water_info[1] > WATER_DEPTH)
83 {
84 return DayZPlayerConstants.STANCEMASK_ERECT;
85 }
86 else
87 {
88 return DayZPlayerConstants.STANCEMASK_CROUCH;
89 }
90 }
91
92 override protected int GetActionCommandEx(ActionData actionData)
93 {
94 int commandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEPOND;
95 if (actionData.m_Target.GetObject())
96 {
97 commandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEWELL;
98 }
99
100 return commandUID;
101 }
102
103 int GetLiquidType(PlayerBase player, ActionTarget target, ItemBase item)
104 {
105 int liquidType = LIQUID_NONE;
106 if ( target.GetObject() )
107 {
108 liquidType = target.GetObject().GetLiquidSourceType();
109 }
110 else
111 {
112 string surfaceType;
113 vector hit_pos = target.GetCursorHitPos();
114 g_Game.SurfaceGetType3D(hit_pos[0], hit_pos[1], hit_pos[2], surfaceType);
115 if (surfaceType == "")
116 {
117 if ( hit_pos[1] <= g_Game.SurfaceGetSeaLevel() + 0.001 )
118 {
119 liquidType = LIQUID_SALTWATER;
120 }
121 }
122 else
123 {
124 liquidType = SurfaceInfo.GetByName(surfaceType).GetLiquidType();
125 }
126 }
127
128 return liquidType & m_AllowedLiquidMask;
129 }
130
132 {
133 //returns in format (totalWaterDepth, characterDepht, 0)
134 vector water_info = HumanCommandSwim.WaterLevelCheck(player, player.GetPosition());
135 if (water_info[1] > WATER_DEPTH)
136 {
137 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
138 }
139 else
140 {
141 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
142 }
143 }
144
145 override bool IsLockTargetOnUse()
146 {
147 return false;
148 }
149
150 // deprecated
151 private const int ALLOWED_LIQUID;
152}
ActionBase ActionData
Definition actionbase.c:30
#define LIQUID_SNOW
#define LIQUID_GASOLINE
#define LIQUID_SALTWATER
void CCTWaterSurfaceEx(float maximal_target_distance, int allowedLiquidSource)
void CreateActionComponent()
ActionData m_ActionData
float m_SpecialtyWeight
Definition actionbase.c:83
int m_StanceMask
Definition actionbase.c:68
string m_Text
Definition actionbase.c:64
ref CCIBase m_ConditionItem
Definition actionbase.c:70
bool m_FullBody
Definition actionbase.c:67
ref CCTBase m_ConditionTarget
Definition actionbase.c:71
override bool ActionConditionContinue(ActionData action_data)
int GetLiquidType(PlayerBase player, ActionTarget target, ItemBase item)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
int GetActionCommandEx(ActionData actionData)
int GetStanceMask(PlayerBase player)
void SetupStance(PlayerBase player)
override bool IsLockTargetOnUse()
override void CreateConditionComponents()
proto int GetLiquidType()
See 'LiquidTypes' in 'constants.c'.
static proto SurfaceInfo GetByName(string name)
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
const int LIQUID_NONE
Definition constants.c:532
const int LIQUID_GROUP_DRINKWATER
Definition constants.c:559
override int GetLiquidType()
Definition itembase.c:8794