DayZ 1.24
Loading...
Searching...
No Matches
DeveloperTeleport Class Reference
Collaboration diagram for DeveloperTeleport:
[legend]

Static Protected Member Functions

static void TeleportAtCursor ()
 
static void TeleportAtCursorEx ()
 
static void SetPlayerPosition (PlayerBase player, vector position, bool breakSync=false)
 
static void SetPlayerDirection (PlayerBase player, vector direction)
 
static void OnRPC (PlayerBase player, int rpc_type, ParamsReadContext ctx)
 
void OnRPCSetPlayerPosition (PlayerBase player, ParamsReadContext ctx)
 
void OnRPCSetPlayerDirection (PlayerBase player, ParamsReadContext ctx)
 

Static Protected Attributes

static const float TELEPORT_DISTANCE_MAX = 1000
 
static const float TELEPORT_DISTANCE_MAX_EX = 500
 

Detailed Description

Definition at line 1 of file DeveloperTeleport.c.

Member Function Documentation

◆ OnRPC()

static void DeveloperTeleport::OnRPC ( PlayerBase player,
int rpc_type,
ParamsReadContext ctx )
inlinestaticprotected

Definition at line 134 of file DeveloperTeleport.c.

135 {
136#ifdef DIAG_DEVELOPER
137 if (rpc_type == ERPCs.DEV_RPC_TELEPORT)
139 else if (rpc_type == ERPCs.DEV_RPC_SET_PLAYER_DIRECTION)
141#endif
142 }
ERPCs
Definition ERPCs.c:2
void OnRPCSetPlayerPosition(PlayerBase player, ParamsReadContext ctx)
void OnRPCSetPlayerDirection(PlayerBase player, ParamsReadContext ctx)

References OnRPCSetPlayerDirection(), and OnRPCSetPlayerPosition().

Referenced by PluginBase::OnRPC().

◆ OnRPCSetPlayerDirection()

void DeveloperTeleport::OnRPCSetPlayerDirection ( PlayerBase player,
ParamsReadContext ctx )
inlinestaticprotected

Definition at line 157 of file DeveloperTeleport.c.

158 {
160 if (ctx.Read(p))
161 {
162 vector v = "0 0 0";
163 v[0] = p.param1;
164 v[1] = p.param2;
165 v[2] = p.param3;
167 }
168 }
static void SetPlayerDirection(PlayerBase player, vector direction)

References SetPlayerDirection().

Referenced by OnRPC().

◆ OnRPCSetPlayerPosition()

void DeveloperTeleport::OnRPCSetPlayerPosition ( PlayerBase player,
ParamsReadContext ctx )
inlinestaticprotected

Definition at line 144 of file DeveloperTeleport.c.

145 {
147 if (ctx.Read(p))
148 {
149 vector v = "0 0 0";
150 v[0] = p.param1;
151 v[1] = p.param2;
152 v[2] = p.param3;
153 SetPlayerPosition(player, v, p.param4);
154 }
155 }
static void SetPlayerPosition(PlayerBase player, vector position, bool breakSync=false)

References SetPlayerPosition().

Referenced by OnRPC().

◆ SetPlayerDirection()

static void DeveloperTeleport::SetPlayerDirection ( PlayerBase player,
vector direction )
inlinestaticprotected

Definition at line 113 of file DeveloperTeleport.c.

114 {
115 if (GetGame().IsServer())
116 {
117 HumanCommandVehicle vehCmd = player.GetCommand_Vehicle();
118 if (vehCmd)
119 {
120 Transport transport = vehCmd.GetTransport();
121 if (transport)
122 transport.SetDirection(direction);
123 }
124 else
125 player.SetDirection(direction);
126 }
127 else
128 {
130 player.RPCSingleParam(ERPCs.DEV_RPC_SET_PLAYER_DIRECTION, params, true);
131 }
132 }
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
proto native CGame GetGame()

References GetGame().

Referenced by OnRPCSetPlayerDirection(), and TeleportAtCursorEx().

◆ SetPlayerPosition()

static void DeveloperTeleport::SetPlayerPosition ( PlayerBase player,
vector position,
bool breakSync = false )
inlinestaticprotected

Definition at line 78 of file DeveloperTeleport.c.

79 {
80 Object object = player;
81
82 HumanCommandVehicle vehCmd = player.GetCommand_Vehicle();
83 if (vehCmd)
84 object = vehCmd.GetTransport();
85
86#ifdef DIAG_DEVELOPER
87 if (GetGame().IsMultiplayer() && breakSync)
88 {
89 vector v;
90 v[0] = Math.RandomFloat(-Math.PI, Math.PI);
91 v[1] = Math.RandomFloat(-Math.PI, Math.PI);
92 v[2] = Math.RandomFloat(-Math.PI, Math.PI);
94 SetVelocity(object, vector.Zero);
95
96 v[0] = Math.RandomFloat(-Math.PI, Math.PI);
97 v[1] = Math.RandomFloat(-Math.PI, Math.PI);
98 v[2] = Math.RandomFloat(-Math.PI, Math.PI);
99 object.SetOrientation(v * Math.RAD2DEG);
100 }
101#endif
102
103 if (GetGame().IsServer())
104 object.SetPosition(position);
105 else
106 {
108 player.RPCSingleParam(ERPCs.DEV_RPC_TELEPORT, params, true);
109 }
110 }
Definition EnMath.c:7
static const vector Zero
Definition EnConvert.c:110
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static const float RAD2DEG
Definition EnMath.c:16
static const float PI
Definition EnMath.c:12
proto native void SetVelocity(notnull IEntity ent, vector vel)
Sets linear velocity (for Rigid bodies)
proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel)
Changed an angular velocity.

References dBodySetAngularVelocity(), GetGame(), Math::PI, Math::RAD2DEG, Math::RandomFloat(), SetVelocity(), and vector::Zero.

Referenced by OnRPCSetPlayerPosition(), PluginBase::Teleport(), TeleportAtCursor(), and TeleportAtCursorEx().

◆ TeleportAtCursor()

static void DeveloperTeleport::TeleportAtCursor ( )
inlinestaticprotected

Definition at line 5 of file DeveloperTeleport.c.

6 {
8 {
10 vector pos_player = player.GetPosition();
11
12 Object ignore;
13 if (!Class.CastTo(ignore, player.GetParent()))
14 ignore = player;
15
16 vector rayStart = GetGame().GetCurrentCameraPosition();
17 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * 1000;
22
24
26 {
27 bool breakSync = false;
28
29#ifdef DIAG_DEVELOPER
30 breakSync = DiagMenu.GetBool(DiagMenuIDs.MISC_TELEPORT_BREAKS_SYNC);
31#endif
32
34 }
35 else
36 Debug.LogWarning("Distance for teleportation is too far!");
37 }
38 }
DiagMenuIDs
Definition EDiagMenuIDs.c:2
PlayerBase GetPlayer()
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
Definition Debug.c:14
static void LogWarning(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as warning message.
Definition Debug.c:321
static bool IsFreeCameraEnabled()
static const float TELEPORT_DISTANCE_MAX
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), vector::Distance(), DiagMenu::GetBool(), GetGame(), GetPlayer(), DeveloperFreeCamera::IsFreeCameraEnabled(), Debug::LogWarning(), DayZPhysics::RaycastRV(), SetPlayerPosition(), and TELEPORT_DISTANCE_MAX.

◆ TeleportAtCursorEx()

static void DeveloperTeleport::TeleportAtCursorEx ( )
inlinestaticprotected

Definition at line 41 of file DeveloperTeleport.c.

42 {
44 vector rayStart = GetGame().GetCurrentCameraPosition();
45 vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * TELEPORT_DISTANCE_MAX_EX;
48 float hitFraction;
50
51 Object ignore;
52 if (!Class.CastTo(ignore, player.GetParent()))
53 ignore = player;
54
55 int layers = 0;
58 layers |= PhxInteractionLayers.ITEM_LARGE;
59 layers |= PhxInteractionLayers.BUILDING;
63 {
64 bool breakSync = false;
65
66#ifdef DIAG_DEVELOPER
67 breakSync = DiagMenu.GetBool(DiagMenuIDs.MISC_TELEPORT_BREAKS_SYNC);
68#endif
69
71
73 DeveloperTeleport.SetPlayerDirection(player, FreeDebugCamera.GetInstance().GetDirection());
74 }
75 }
PhxInteractionLayers
Definition DayZPhysics.c:2
static proto bool SphereCastBullet(vector begPos, vector endPos, float radius, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
static const float TELEPORT_DISTANCE_MAX_EX

References Class::CastTo(), DiagMenu::GetBool(), GetGame(), GetPlayer(), DeveloperFreeCamera::IsFreeCameraEnabled(), SetPlayerDirection(), SetPlayerPosition(), DayZPhysics::SphereCastBullet(), and TELEPORT_DISTANCE_MAX_EX.

Referenced by DeveloperFreeCamera::DisableFreeCamera(), and PluginBase::TeleportAtCursor().

Member Data Documentation

◆ TELEPORT_DISTANCE_MAX

const float DeveloperTeleport::TELEPORT_DISTANCE_MAX = 1000
staticprotected

Definition at line 3 of file DeveloperTeleport.c.

Referenced by TeleportAtCursor().

◆ TELEPORT_DISTANCE_MAX_EX

const float DeveloperTeleport::TELEPORT_DISTANCE_MAX_EX = 500
staticprotected

Definition at line 40 of file DeveloperTeleport.c.

Referenced by TeleportAtCursorEx().


The documentation for this class was generated from the following file: