fix top-down clicks and orbit yaw
This commit is contained in:
1 parent
0b2c8ae88c
commit
036466aa88
1 file changed
+47
-5
@@ -6,10 +6,12 @@ $RPGClient::Version = 2;
|
|||||||
$RPGClient::Active = 0;
|
$RPGClient::Active = 0;
|
||||||
$RPGClient::Yaw = 0;
|
$RPGClient::Yaw = 0;
|
||||||
$RPGClient::Dist = 14;
|
$RPGClient::Dist = 14;
|
||||||
|
$RPGClient::TopDownPitch = 0.95;
|
||||||
$RPGClient::HelloPending = 0;
|
$RPGClient::HelloPending = 0;
|
||||||
$RPGClient::HelloLast = "";
|
$RPGClient::HelloLast = "";
|
||||||
$RPGClient::TopDownWatchSched = 0;
|
$RPGClient::TopDownWatchSched = 0;
|
||||||
$RPGClient::CamSched = 0;
|
$RPGClient::CamSched = 0;
|
||||||
|
$RPGClient::LastClickTime = 0;
|
||||||
|
|
||||||
function RPGClient_NormPos(%ctrl, %pos)
|
function RPGClient_NormPos(%ctrl, %pos)
|
||||||
{
|
{
|
||||||
@@ -67,6 +69,12 @@ function RPGClient_SendClick(%button, %pos)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
%now = getSimTime();
|
||||||
|
if (%now - $RPGClient::LastClickTime < 80)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$RPGClient::LastClickTime = %now;
|
||||||
%norm = RPGClient_NormPos(RPGClient_Mouse, %pos);
|
%norm = RPGClient_NormPos(RPGClient_Mouse, %pos);
|
||||||
commandToServer('RPG_Click', %button, getWord(%norm, 0), getWord(%norm, 1), RPGClient_Aspect());
|
commandToServer('RPG_Click', %button, getWord(%norm, 0), getWord(%norm, 1), RPGClient_Aspect());
|
||||||
schedule(1, 0, RPGClient_ApplyCamera);
|
schedule(1, 0, RPGClient_ApplyCamera);
|
||||||
@@ -99,8 +107,32 @@ function RPGClient_Mouse::onWake(%this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_BlockMouse(%val)
|
function RPGClient_OrbitTransform(%body, %yaw, %dist)
|
||||||
{
|
{
|
||||||
|
%p = %body.getPosition();
|
||||||
|
%cx = getWord(%p, 0);
|
||||||
|
%cy = getWord(%p, 1);
|
||||||
|
%cz = getWord(%p, 2) + 1.5;
|
||||||
|
%pitch = $RPGClient::TopDownPitch;
|
||||||
|
%bx = -mCos(%yaw) * mCos(%pitch) * %dist;
|
||||||
|
%by = -mSin(%yaw) * mCos(%pitch) * %dist;
|
||||||
|
%bz = mSin(%pitch) * %dist;
|
||||||
|
%ex = %cx + %bx;
|
||||||
|
%ey = %cy + %by;
|
||||||
|
%ez = %cz + %bz;
|
||||||
|
%eye = %ex @ " " @ %ey @ " " @ %ez;
|
||||||
|
%euler = %pitch @ " 0 " @ (%yaw + $pi);
|
||||||
|
%rot = eulerRadToMatrix(%euler);
|
||||||
|
return %eye @ " " @ %rot;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RPGClient_SendClickFromCursor(%button)
|
||||||
|
{
|
||||||
|
if (!$RPGClient::Active || !isObject(Canvas))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RPGClient_SendClick(%button, Canvas.getCursorPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_EnableOverlay()
|
function RPGClient_EnableOverlay()
|
||||||
@@ -121,7 +153,7 @@ function RPGClient_EnableOverlay()
|
|||||||
enabled = "1";
|
enabled = "1";
|
||||||
};
|
};
|
||||||
PlayGui.add(RPGClient_Mouse);
|
PlayGui.add(RPGClient_Mouse);
|
||||||
PlayGui.pushToBack(RPGClient_Mouse);
|
PlayGui.bringToFront(RPGClient_Mouse);
|
||||||
if (isObject(RPGClient_KeyMap))
|
if (isObject(RPGClient_KeyMap))
|
||||||
{
|
{
|
||||||
RPGClient_KeyMap.delete();
|
RPGClient_KeyMap.delete();
|
||||||
@@ -135,9 +167,9 @@ function RPGClient_EnableOverlay()
|
|||||||
RPGClient_KeyMap.bind(keyboard0, "pagedown", RPGClient_ZoomOut);
|
RPGClient_KeyMap.bind(keyboard0, "pagedown", RPGClient_ZoomOut);
|
||||||
RPGClient_KeyMap.bind(keyboard0, equals, RPGClient_ZoomIn);
|
RPGClient_KeyMap.bind(keyboard0, equals, RPGClient_ZoomIn);
|
||||||
RPGClient_KeyMap.bind(keyboard0, minus, RPGClient_ZoomOut);
|
RPGClient_KeyMap.bind(keyboard0, minus, RPGClient_ZoomOut);
|
||||||
|
RPGClient_KeyMap.bind(keyboard0, w, RPGClient_ZoomIn);
|
||||||
|
RPGClient_KeyMap.bind(keyboard0, s, RPGClient_ZoomOut);
|
||||||
RPGClient_KeyMap.bind(keyboard0, m, RPGClient_ToggleCursor);
|
RPGClient_KeyMap.bind(keyboard0, m, RPGClient_ToggleCursor);
|
||||||
RPGClient_KeyMap.bind(mouse0, button0, RPGClient_BlockMouse);
|
|
||||||
RPGClient_KeyMap.bind(mouse0, button1, RPGClient_BlockMouse);
|
|
||||||
RPGClient_KeyMap.push();
|
RPGClient_KeyMap.push();
|
||||||
$mvFreeLook = 0;
|
$mvFreeLook = 0;
|
||||||
$firstPerson = 0;
|
$firstPerson = 0;
|
||||||
@@ -208,8 +240,10 @@ function RPGClient_ApplyCamera()
|
|||||||
$mvFreeLook = 0;
|
$mvFreeLook = 0;
|
||||||
$firstPerson = 0;
|
$firstPerson = 0;
|
||||||
%cam.unmountImage(0);
|
%cam.unmountImage(0);
|
||||||
|
%xfm = RPGClient_OrbitTransform(%body, $RPGClient::Yaw, $RPGClient::Dist);
|
||||||
|
%cam.setTransform(%xfm);
|
||||||
%cam.setMode("Corpse", %body);
|
%cam.setMode("Corpse", %body);
|
||||||
%cam.setOrbitMode(%body, %cam.getTransform(), 0, 32, $RPGClient::Dist);
|
%cam.setOrbitMode(%body, %xfm, 0, 32, $RPGClient::Dist);
|
||||||
%cam.mode = "Corpse";
|
%cam.mode = "Corpse";
|
||||||
%cam.thirdPersonOnly = 1;
|
%cam.thirdPersonOnly = 1;
|
||||||
commandToServer('RPG_CamSync', $RPGClient::Yaw, $RPGClient::Dist);
|
commandToServer('RPG_CamSync', $RPGClient::Yaw, $RPGClient::Dist);
|
||||||
@@ -494,6 +528,10 @@ package RPGClient_BlockMouseFire
|
|||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if ($RPGClient::Active)
|
||||||
{
|
{
|
||||||
|
if (%val)
|
||||||
|
{
|
||||||
|
RPGClient_SendClickFromCursor(0);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Parent::mouseFire(%val);
|
Parent::mouseFire(%val);
|
||||||
@@ -503,6 +541,10 @@ package RPGClient_BlockMouseFire
|
|||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if ($RPGClient::Active)
|
||||||
{
|
{
|
||||||
|
if (%val)
|
||||||
|
{
|
||||||
|
RPGClient_SendClickFromCursor(1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Parent::altTrigger(%val);
|
Parent::altTrigger(%val);
|
||||||
|
|||||||
Reference in new issue
Block a user