Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
cctwatersurface.c
Go to the documentation of this file.
2{
3 protected const int HEIGHT_DIFF_LIMIT_METERS = 1.0;
4
5 protected float m_MaximalActionDistanceSq;
6 protected string m_SurfaceType;
8
9 void CCTWaterSurface(float maximal_target_distance = UAMaxDistances.DEFAULT, string surfaceType = "")
10 {
11 m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;
12 m_SurfaceType = surfaceType;
13
15 surfaceType.Split("|", m_AllowedSurfaceList);
16 }
17
18 override bool Can(PlayerBase player, ActionTarget target)
19 {
20 if (!target || (target && target.GetObject()))
21 return false;
22
24 vector hitPosition = target.GetCursorHitPos();
25
26 string surfaceType;
27 float waterLevel = player.GetCurrentWaterLevel();
28 g_Game.SurfaceGetType3D(hitPosition[0], hitPosition[1] + waterLevel, hitPosition[2], surfaceType);
29
30 if (waterLevel > 0.0)
31 return Surface.AllowedWaterSurface(hitPosition[1] + waterLevel, surfaceType, m_AllowedSurfaceList);
32
33 float surfaceHeight = g_Game.SurfaceY(hitPosition[0], hitPosition[2]);
35 if (!surfaceType)
36 {
37 surfaceHeight = hitPosition[1];
38 }
39
40 float heightDiff = Math.AbsFloat(hitPosition[1] - surfaceHeight);
41 if (surfaceType != "" && heightDiff > HEIGHT_DIFF_LIMIT_METERS)
42 return false;
43
44 float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
45 if (distSq > m_MaximalActionDistanceSq)
46 return false;
47
48 return Surface.AllowedWaterSurface(hitPosition[1], surfaceType, m_AllowedSurfaceList);
49 }
50
51 override bool CanContinue(PlayerBase player, ActionTarget target)
52 {
53 return true;
54 }
55}
56
58{
60 protected int m_AllowedLiquidSource;
61 protected int m_LiquidType = LIQUID_NONE;
62
63 void CCTWaterSurfaceEx(float maximal_target_distance, int allowedLiquidSource)
64 {
65 m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;
66 m_AllowedLiquidSource = allowedLiquidSource;
67 }
68
69 override bool Can(PlayerBase player, ActionTarget target)
70 {
71 if (!target)
72 return false;
73
74 vector hitPosition = target.GetCursorHitPos();
75 float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
76 if (distSq > m_MaximalActionDistanceSq)
77 return false;
78
79 int liquidType = GetSurfaceLiquidType(target);
80 string surfaceName = target.GetSurfaceName();
81 return CheckLiquidSource(hitPosition, surfaceName, liquidType, m_AllowedLiquidSource);
82 }
83
84 bool CheckLiquidSource(vector hitPos, string surfaceName, int liquidType, int allowedWaterSourceMask)
85 {
86 bool success = false;
87 if (surfaceName == "" && hitPos != vector.Zero)
88 {
90 bool isSea = g_Game.SurfaceIsSea(hitPos[0], hitPos[2]);
91 if (allowedWaterSourceMask & LIQUID_SALTWATER && isSea)
92 {
93 success = hitPos[1] <= (g_Game.SurfaceGetSeaLevel() + 0.25);
94 }
95 }
96 else
97 {
98 success = allowedWaterSourceMask & liquidType;
99 }
100
101 return success;
102 }
103
104 int GetSurfaceLiquidType(ActionTarget target)
105 {
107
109 if (target.GetSurfaceLiquidType() != LIQUID_NONE)
110 {
111 m_LiquidType = target.GetSurfaceLiquidType();
112 }
113
115 Object targetObject = target.GetObject();
116 if (m_LiquidType == LIQUID_NONE && targetObject)
117 {
118 m_LiquidType = targetObject.GetLiquidSourceType();
119 }
120
121 return m_LiquidType;
122 }
123
124 override bool CanContinue(PlayerBase player, ActionTarget target)
125 {
126 return true;
127 }
128
130 {
131 return m_LiquidType;
132 }
133}
override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
override bool CanContinue(ActionData action_data)
not checking target damage anymore, callback takes care of that
#define LIQUID_SALTWATER
int m_AllowedLiquidSource
void CCTWaterSurfaceEx(float maximal_target_distance, int allowedLiquidSource)
bool CheckLiquidSource(vector hitPos, string surfaceName, int liquidType, int allowedWaterSourceMask)
int GetLiquidType()
CCTWaterSurface m_MaximalActionDistanceSq
float m_MaximalActionDistanceSq
override bool CanContinue(PlayerBase player, ActionTarget target)
override bool Can(PlayerBase player, ActionTarget target)
void CCTWaterSurface(float maximal_target_distance=UAMaxDistances.DEFAULT, string surfaceType="")
const int HEIGHT_DIFF_LIMIT_METERS
ref array< string > m_AllowedSurfaceList
DEPRECATED.
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3868
int m_LiquidType
Definition environment.c:61
const int LIQUID_NONE
Definition constants.c:529