Skip to content

Commit

Permalink
add game speed option
Browse files Browse the repository at this point in the history
  • Loading branch information
Micrologist committed Nov 1, 2020
1 parent d177b6b commit d660f67
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 15 deletions.
24 changes: 13 additions & 11 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GhostrunnerTrainer"
mc:Ignorable="d"
Title="Ghostrunner Trainer" Height="260" Width="485" Icon="Ghostrunner_101.ico" ResizeMode="CanMinimize">
Title="Ghostrunner Trainer" Height="266" Width="485" Icon="Ghostrunner_101.ico" ResizeMode="CanMinimize">
<Grid Background="#FF292929">
<Button x:Name="ghostBtn" Content="[F1] Ghost" HorizontalAlignment="Left" Height="35" Margin="211,12,0,0" VerticalAlignment="Top" Width="200" FontSize="20" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="ghostBtn_Click"/>
<Label x:Name="ghostLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="416,11,0,0" VerticalAlignment="Top" Width="46" FontSize="20" FontWeight="Bold" Foreground="Red"/>
<Button x:Name="godBtn" Content="[F2] God" HorizontalAlignment="Left" Height="35" Margin="211,52,0,0" VerticalAlignment="Top" Width="200" FontSize="20" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="godBtn_Click"/>
<Button x:Name="noclipBtn" Content="[F3] NoClip" HorizontalAlignment="Left" Height="35" Margin="211,92,0,0" VerticalAlignment="Top" Width="200" FontSize="20" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="noclipBtn_Click"/>
<Button x:Name="saveBtn" Content="[F5] Save Position" HorizontalAlignment="Left" Height="35" Margin="211,136,-82,0" VerticalAlignment="Top" Width="250" FontSize="20" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="saveBtn_Click"/>
<Button x:Name="teleBtn" Content="[F6] Teleport" HorizontalAlignment="Left" Height="35" Margin="211,176,-82,0" VerticalAlignment="Top" Width="250" FontSize="20" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="teleBtn_Click"/>
<Label x:Name="godLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="416,51,0,0" VerticalAlignment="Top" Width="46" FontSize="20" FontWeight="Bold" Foreground="Red"/>
<Label x:Name="noclipLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="415,91,0,0" VerticalAlignment="Top" Width="46" FontSize="20" FontWeight="Bold" Foreground="Red"/>
<Label x:Name="speedLabel" Content="Speed" HorizontalAlignment="Left" Height="35" Margin="10,175,0,0" VerticalAlignment="Top" Width="68" FontSize="20" Foreground="White" FontWeight="Bold"/>
<TextBlock x:Name="speedBlock" HorizontalAlignment="Left" Text="10.99 m/s" VerticalAlignment="Top" Margin="86,180,0,0" Height="31" Width="108" FontSize="20" Foreground="White" TextAlignment="Right"/>
<Button x:Name="ghostBtn" Content="[F1] Ghost" HorizontalAlignment="Left" Height="27" Margin="218,12,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="ghostBtn_Click"/>
<Label x:Name="ghostLabel" Content="OFF" HorizontalAlignment="Left" Height="27" Margin="423,10,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red"/>
<Button x:Name="godBtn" Content="[F2] God" HorizontalAlignment="Left" Height="27" Margin="218,44,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="godBtn_Click"/>
<Button x:Name="noclipBtn" Content="[F3] NoClip" HorizontalAlignment="Left" Height="28" Margin="218,76,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="noclipBtn_Click"/>
<Button x:Name="saveBtn" Content="[F5] Save Position" HorizontalAlignment="Left" Height="27" Margin="218,150,0,0" VerticalAlignment="Top" Width="240" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="saveBtn_Click"/>
<Button x:Name="teleBtn" Content="[F6] Teleport" HorizontalAlignment="Left" Height="28" Margin="218,182,0,0" VerticalAlignment="Top" Width="240" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="teleBtn_Click"/>
<Label x:Name="godLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,42,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red"/>
<Label x:Name="noclipLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,75,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red" RenderTransformOrigin="0.478,0.543"/>
<Label x:Name="speedLabel" Content="Speed" HorizontalAlignment="Left" Height="35" Margin="10,177,0,0" VerticalAlignment="Top" Width="68" FontSize="20" Foreground="White" FontWeight="Bold"/>
<TextBlock x:Name="speedBlock" HorizontalAlignment="Left" Text="10.99 m/s" VerticalAlignment="Top" Margin="86,182,0,0" Height="31" Width="108" FontSize="20" Foreground="White" TextAlignment="Right"/>
<Label x:Name="positionLabel" Content="Position" HorizontalAlignment="Left" Height="35" Margin="10,3,0,0" VerticalAlignment="Top" Width="196" FontSize="20" Foreground="White" FontWeight="Bold"/>
<TextBlock x:Name="positionLabelBlock" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="17,41,0,0" Height="85" Width="61" FontSize="20" Foreground="White" TextAlignment="Left"><Run Text="x"/><LineBreak/><Run Text="y"/><LineBreak/><Run Text="z"/></TextBlock>
<TextBlock x:Name="positionBlock" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="78,41,0,0" Height="85" Width="116" FontSize="20" Foreground="White" TextAlignment="Right"/>
<Button x:Name="gameSpeedBtn" Content="[F4] Game Speed" HorizontalAlignment="Left" Height="28" Margin="218,109,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="gameSpeedBtn_Click"/>
<Label x:Name="gameSpeedLabel" Content="1.0x" HorizontalAlignment="Left" Height="35" Margin="423,108,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="White" RenderTransformOrigin="0.478,0.543" Background="#00000000"/>

</Grid>

Expand Down
61 changes: 57 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ public partial class MainWindow : Window
Timer updateTimer;
Process game;
public bool hooked = false;
DeepPointer cheatManagerDP, capsuleDP, charMoveCompDP, playerControllerDP, playerCharacterDP, worldDP, gameModeDP;
IntPtr xVelPtr, yVelPtr, zVelPtr, xPosPtr, yPosPtr, zPosPtr, vLookPtr, hLookPtr, ghostPtr, godPtr, noclipPtr, movePtr, clipmovePtr, airPtr, collisionPtr, sumPtr, injPtr;
DeepPointer cheatManagerDP, capsuleDP, charMoveCompDP, playerControllerDP, playerCharacterDP, worldDP, gameModeDP, worldSettingsDP;
IntPtr xVelPtr, yVelPtr, zVelPtr, xPosPtr, yPosPtr, zPosPtr, vLookPtr, hLookPtr, ghostPtr, godPtr, noclipPtr, movePtr, clipmovePtr, airPtr, collisionPtr, sumPtr, injPtr, gameSpeedPtr;

private void gameSpeedBtn_Click(object sender, RoutedEventArgs e)
{
ChangeGameSpeed();
}

private void teleBtn_Click(object sender, RoutedEventArgs e)
{
Expand All @@ -44,7 +49,7 @@ private void ghostBtn_Click(object sender, RoutedEventArgs e)
ToggleGhost();
}

float xVel, yVel, zVel, xPos, yPos, zPos, vLook, hLook;
float xVel, yVel, zVel, xPos, yPos, zPos, vLook, hLook, gameSpeed, prefGameSpeed;
bool ghost, god, noclip;
int charLFS;
float[] storedPos = new float[5] { 0f, 0f, 0f, 0f, 0f };
Expand All @@ -59,8 +64,12 @@ public MainWindow()
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F1);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F2);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F3);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F4);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F5);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F6);
kbHook.HookedKeys.Add(System.Windows.Forms.Keys.F7);

prefGameSpeed = 1.0f;

updateTimer = new Timer
{
Expand Down Expand Up @@ -105,11 +114,17 @@ private void Update(object sender, EventArgs e)
game.ReadValue<bool>(godPtr, out god);
game.ReadValue<bool>(ghostPtr, out ghost);
game.ReadValue<bool>(noclipPtr, out noclip);
game.ReadValue<float>(gameSpeedPtr, out gameSpeed);

Debug.WriteLine(gameSpeed.ToString());
SetLabel(god, godLabel);
SetLabel(ghost, ghostLabel);
SetLabel(noclip, noclipLabel);

SetGameSpeed();

gameSpeedLabel.Content = prefGameSpeed.ToString("0.0") + "x";

positionBlock.Text = (xPos/100).ToString("0.00") + "\n" + (yPos/100).ToString("0.00") + "\n" + (zPos/100).ToString("0.00");
speedBlock.Text = hVel.ToString("0.00") + " m/s";
}
Expand Down Expand Up @@ -152,6 +167,7 @@ private void SetPointersByModuleSize(int moduleSize)
cheatManagerDP = new DeepPointer(0x042DFED8, 0x0);
playerCharacterDP = new DeepPointer(0x042E16B8, 0x30, 0x0);
worldDP = new DeepPointer(0x042E1678, 0x1A8, 0x0);
worldSettingsDP = new DeepPointer(0x042E1678, 0x1A8, 0x20, 0x240, 0x0);
gameModeDP = new DeepPointer(0x0455C860, 0x128, 0x0);
break;
case 78036992:
Expand All @@ -162,6 +178,7 @@ private void SetPointersByModuleSize(int moduleSize)
cheatManagerDP = new DeepPointer(0x0430B3F0, 0x0);
playerCharacterDP = new DeepPointer(0x0430CC48, 0x30, 0x0);
worldDP = new DeepPointer(0x0430CC10, 0x1A8, 0x0);
worldSettingsDP = new DeepPointer(0x0430CC10, 0x1A8, 0x20, 0x240, 0x0);
gameModeDP = new DeepPointer(0x04587F20, 0x128, 0x0);
break;
case 77885440:
Expand All @@ -172,13 +189,14 @@ private void SetPointersByModuleSize(int moduleSize)
cheatManagerDP = new DeepPointer(0x042E88F8, 0x0);
playerCharacterDP = new DeepPointer(0x042EA0D0, 0x30, 0x0);
worldDP = new DeepPointer(0x042EA098, 0x1A8, 0x0);
worldSettingsDP = new DeepPointer(0x042EA098, 0x1A8, 0x20, 0x240, 0x0);
gameModeDP = new DeepPointer(0x04565320, 0x128, 0x0);
break;

default:
updateTimer.Stop();
Console.WriteLine(moduleSize.ToString());
System.Windows.Forms.MessageBox.Show("This game version is not supported.", "Unsupported Game Version");
System.Windows.Forms.MessageBox.Show("This game version ("+moduleSize.ToString()+") is not supported.", "Unsupported Game Version");
Environment.Exit(0);
break;
}
Expand Down Expand Up @@ -223,6 +241,10 @@ private void DerefPointers()
IntPtr worldPtr;
worldDP.DerefOffsets(game, out worldPtr);
injPtr = worldPtr + 0x28C;

IntPtr worldSettingsPtr;
worldSettingsDP.DerefOffsets(game, out worldSettingsPtr);
gameSpeedPtr = worldSettingsPtr + 0x2E8;
}

private void InputKeyDown(object sender, KeyEventArgs e)
Expand All @@ -238,6 +260,9 @@ private void InputKeyDown(object sender, KeyEventArgs e)
case Keys.F3:
ToggleNoclip();
break;
case Keys.F4:
ChangeGameSpeed();
break;
case Keys.F5:
StorePosition();
break;
Expand Down Expand Up @@ -335,5 +360,33 @@ private void InputKeyUp(object sender, KeyEventArgs e)
{
e.Handled = true;
}

private void ChangeGameSpeed()
{
switch (prefGameSpeed)
{
case 1.0f:
prefGameSpeed = 2.0f;
break;
case 2.0f:
prefGameSpeed = 4.0f;
break;
case 4.0f:
prefGameSpeed = 0.5f;
break;
case 0.5f:
prefGameSpeed = 1.0f;
break;
default:
prefGameSpeed = 1.0f;
break;
}
}

private void SetGameSpeed()
{
if((gameSpeed == 1.0f || gameSpeed == 2.0f || gameSpeed == 4.0f || gameSpeed == 0.5f) && gameSpeed != prefGameSpeed)
game.WriteBytes(gameSpeedPtr, BitConverter.GetBytes(prefGameSpeed));
}
}
}

0 comments on commit d660f67

Please sign in to comment.