3 protected static const float TELEPORT_DISTANCE_MAX = 1000;
5 static void TeleportAtCursor()
10 vector pos_player = player.GetPosition();
13 if (!
Class.CastTo(ignore, player.GetParent()))
19 vector rayEnd = rayStart +
GetGame().GetCurrentCameraDirection() * 1000;
22 int hitComponentIndex;
23 DayZPhysics.RaycastRV(rayStart, rayEnd, hitPos, hitNormal, hitComponentIndex, NULL, NULL, ignore);
25 float distance =
vector.Distance( pos_player, hitPos );
27 if ( distance < TELEPORT_DISTANCE_MAX )
29 bool breakSync =
false;
35 SetPlayerPosition(player, hitPos, breakSync);
39 Debug.LogWarning(
"Distance for teleportation is too far!");
44 protected static const float TELEPORT_DISTANCE_MAX_EX = 500;
45 static void TeleportAtCursorEx()
49 vector rayEnd = rayStart +
GetGame().GetCurrentCameraDirection() * TELEPORT_DISTANCE_MAX_EX;
56 if (!
Class.CastTo(ignore, player.GetParent()))
68 if (
DayZPhysics.SphereCastBullet(rayStart, rayEnd, 0.01, layers, ignore, hitObj, hitPos, hitNormal, hitFraction))
70 bool breakSync =
false;
76 SetPlayerPosition(player, hitPos, breakSync);
80 DeveloperTeleport.SetPlayerDirection( player, FreeDebugCamera.GetInstance().GetDirection() );
86 static void SetPlayerPosition(
PlayerBase player,
vector position,
bool breakSync =
false)
93 object = vehCmd.GetTransport();
97 if (
GetGame().IsMultiplayer() && breakSync)
109 object.SetOrientation(v *
Math.RAD2DEG);
115 object.SetPosition(position);
119 Param4<float, float, float, bool> params =
new Param4<float, float, float, bool>(position[0], position[1], position[2], breakSync);
120 player.RPCSingleParam(
ERPCs.DEV_RPC_TELEPORT, params,
true);
132 Transport transport = vehCmd.GetTransport();
134 transport.SetDirection(direction);
137 player.SetDirection(direction);
142 player.RPCSingleParam(
ERPCs.DEV_RPC_SET_PLAYER_DIRECTION, params,
true);
148 #ifdef DIAG_DEVELOPER
149 if ( rpc_type ==
ERPCs.DEV_RPC_TELEPORT )
151 OnRPCSetPlayerPosition(player, ctx);
153 else if ( rpc_type ==
ERPCs.DEV_RPC_SET_PLAYER_DIRECTION )
155 OnRPCSetPlayerDirection(player, ctx);
162 Param4<float, float, float, bool> p =
new Param4<float, float, float, bool>(0, 0, 0,
false);
169 SetPlayerPosition(player, v, p.param4);
182 SetPlayerDirection(player, v);