DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 if (hitPosition == vector.Zero)
26 hitPosition = player.GetPosition();
27
28 string surfaceType;
29 float waterLevel = player.GetCurrentWaterLevel();
30 g_Game.SurfaceGetType3D(hitPosition[0], hitPosition[1] + waterLevel, hitPosition[2], surfaceType);
31
32 if (waterLevel > 0.0)
33 return Surface.AllowedWaterSurface(hitPosition[1] + waterLevel, surfaceType, m_AllowedSurfaceList);
34
35 float surfaceHeight = g_Game.SurfaceY(hitPosition[0], hitPosition[2]);
37 if (!surfaceType)
38 {
39 surfaceHeight = hitPosition[1];
40 }
41
42 float heightDiff = Math.AbsFloat(hitPosition[1] - surfaceHeight);
43 if (surfaceType != "" && heightDiff > HEIGHT_DIFF_LIMIT_METERS)
44 return false;
45
46 float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
47 if (distSq > m_MaximalActionDistanceSq)
48 return false;
49
50 return Surface.AllowedWaterSurface(hitPosition[1], surfaceType, m_AllowedSurfaceList);
51 }
52
53 override bool CanContinue(PlayerBase player, ActionTarget target)
54 {
55 return true;
56 }
57}
class ActionTargets ActionTarget
DayZGame g_Game
Definition DayZGame.c:3654
protected float m_MaximalActionDistanceSq
override bool CanContinue(PlayerBase player, ActionTarget target)
void CCTWaterSurface(float maximal_target_distance=UAMaxDistances.DEFAULT, string surfaceType="")
protected string m_SurfaceType
override bool Can(PlayerBase player, ActionTarget target)
protected const int HEIGHT_DIFF_LIMIT_METERS
protected ref array< string > m_AllowedSurfaceList
DEPRECATED.
Definition EnMath.c:7
static bool AllowedWaterSurface(float pHeight, string pSurface, array< string > pAllowedSurfaceList)
Definition Surface.c:8
const float DEFAULT
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Definition EnConvert.c:110
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static proto float AbsFloat(float f)
Returns absolute value.