DayZ 1.24
Loading...
Searching...
No Matches
DeveloperTeleport.c
Go to the documentation of this file.
2{
3 protected static const float TELEPORT_DISTANCE_MAX = 1000;
4
5 static void TeleportAtCursor()
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 }
39
40 protected static const float TELEPORT_DISTANCE_MAX_EX = 500;
41 static void TeleportAtCursorEx()
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 }
76
77 // Set Player Position (MP support)
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 }
111
112 // Set Player Direction (MP support)
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 }
133
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 }
143
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 }
156
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 }
169}
PhxInteractionLayers
Definition DayZPhysics.c:2
DiagMenuIDs
Definition EDiagMenuIDs.c:2
ERPCs
Definition ERPCs.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.
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)
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_EX
static void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
static const float TELEPORT_DISTANCE_MAX
static void TeleportAtCursor()
static void TeleportAtCursorEx()
void OnRPCSetPlayerPosition(PlayerBase player, ParamsReadContext ctx)
static void SetPlayerDirection(PlayerBase player, vector direction)
void OnRPCSetPlayerDirection(PlayerBase player, ParamsReadContext ctx)
static void SetPlayerPosition(PlayerBase player, vector position, bool breakSync=false)
Definition EnMath.c:7
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
static const vector Zero
Definition EnConvert.c:110
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
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.
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.