WASD: force cam sync; host local fly mirror

This commit is contained in:
RallyBlock committed 2026-11-10 06:28:40 -05:00
1 parent c9c595e449
commit 836fb2ac3a
1 file changed
+46 -4
+46 -4
View File
@@ -166,7 +166,7 @@ function RPGClient_EyeRay(%nx, %ny)
{
return "";
}
%p = %body.getHackPosition();
%p = %body.getPosition();
%cx = getWord(%p, 0);
%cy = getWord(%p, 1);
%cz = getWord(%p, 2) + 1.0;
@@ -361,9 +361,24 @@ function RPGClient_RaiseMouseOverlay()
PlayGui.pushToFront(RPGClient_Mouse);
}
function RPGClient_LocalCamMirror()
{
if (!isObject(ServerConnection))
{
return 0;
}
%addr = ServerConnection.getAddress();
if (%addr $= "" || %addr $= "local")
{
return 1;
}
%host = getWord(%addr, 0);
return %host $= "127.0.0.1" || %host $= "0.0.0.0";
}
function RPGClient_NetCam()
{
return $RPGClient::Active && isObject(ServerConnection);
return $RPGClient::Active && isObject(ServerConnection) && !RPGClient_LocalCamMirror();
}
function RPGClient_CameraTick()
@@ -400,7 +415,7 @@ function RPGClient_CameraTick()
}
if (%changed || $RPGClient::MvF || $RPGClient::MvB || $RPGClient::MvL || $RPGClient::MvR)
{
RPGClient_ApplyCamera(0);
RPGClient_ApplyCamera(1);
}
$RPGClient::CamTickSched = schedule(50, 0, RPGClient_CameraTick);
}
@@ -709,6 +724,33 @@ function RPGClient_ApplyCamera(%forceSync)
$RPGClient::PanX = 0;
$RPGClient::PanY = 0;
commandToServer('RPG_CamSync', $RPGClient::Yaw, $RPGClient::Dist, 0, 0, $RPGClient::Pitch);
if (RPGClient_NetCam())
{
return;
}
%conn = ServerConnection;
%body = RPGClient_BodyForCamera(%conn);
if (!isObject(%body))
{
return;
}
%cam = %conn.Camera;
if (!isObject(%cam))
{
%cam = %conn.camera;
}
if (!isObject(%cam))
{
return;
}
%conn.setControlObject(%cam);
$mvFreeLook = 0;
$firstPerson = 0;
%xfm = RPGClient_ViewTransform(%body, $RPGClient::Yaw, $RPGClient::Dist, 0, 0);
%cam.unmountImage(0);
%cam.setMode("Fly", 0);
%cam.setTransform(%xfm);
%cam.mode = "Fly";
}
function RPGClient_ScheduleCamera()
@@ -1214,7 +1256,7 @@ package RPGClient_Input
{
%sens = $pref::Input::MouseSensitivity;
$RPGClient::Yaw = $RPGClient::Yaw + %val * %sens * 0.004;
RPGClient_ApplyCamera(0);
RPGClient_ApplyCamera(1);
return;
}
Parent::yaw(%val);