Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 8385c0c

Browse files
author
maxensas
committed
Rocket crosshair : WIP
1 parent 1f3e425 commit 8385c0c

File tree

8 files changed

+167
-66
lines changed

8 files changed

+167
-66
lines changed

Lastgarriz/Util/Common.cs

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,46 @@ internal static bool IsMiddleButtonMousePushedOnce()
8888
return 0 != (Native.GetAsyncKeyState(Native.VK_MBUTTON) & 1);
8989
}
9090

91-
internal static string ConvertCursorPositionToRocketIndicator(int ordinate, int multiplier)
91+
internal static string ConvertWidthCursorPosition(int abscissa, int multiplier)
92+
{
93+
double calc = abscissa;
94+
calc = (calc / Global.HalfScreenWidth) * Global.SCALING_VALUE;
95+
int val = (Convert.ToInt32(calc) - Global.SCALING_VALUE) + Global.SCALING_VALUE * multiplier;
96+
if (val == 0)
97+
{
98+
return Strings.Aim.NOVALUE;
99+
}
100+
return val.ToString("G", CultureInfo.InvariantCulture);
101+
}
102+
103+
internal static int UpdateCrosshairAbscissa(int abscissa, int multiplier)
104+
{
105+
int valMin = -80, valMax = 80;
106+
107+
double calc = abscissa;
108+
calc = (calc / Global.HalfScreenWidth) * Global.SCALING_VALUE;
109+
int val = (Convert.ToInt32(calc) - Global.SCALING_VALUE) + Global.SCALING_VALUE * multiplier;
110+
111+
if (val < valMin)
112+
{
113+
return valMin;
114+
}
115+
if (val > valMax)
116+
{
117+
return valMax;
118+
}
119+
return val;
120+
}
121+
122+
internal static string ConvertHeightCursorPosition(int ordinate, int multiplier)
92123
{
93124
double calc = ordinate;
94125
calc = (calc / Global.HalfScreenHeight) * Global.SCALING_VALUE;
95126
int val = (Convert.ToInt32(calc) - Global.SCALING_VALUE) + Global.SCALING_VALUE * multiplier;
96127
//Trace.WriteLine(val);
97128
if (val == 0)
98129
{
99-
return "target";
130+
return Strings.Aim.NOVALUE;
100131
}
101132
val = Global.DataJson.Config.Options.InvertedMouse ? val : val * -1;
102133

@@ -111,14 +142,27 @@ internal static string ConvertCursorPositionToRocketIndicator(int ordinate, int
111142
convValue * Global.RATIO_PANZERSCHRECK : convValue * Global.RATIO_BAZOOKA;
112143

113144
val = Convert.ToInt32(convValue);
114-
145+
146+
return val.ToString("G", CultureInfo.InvariantCulture) + 'm';
147+
/*
115148
return Global.DataJson.Config.Options.SchreckZook ?
116-
val.ToString() + "m [schreck]" : val.ToString() + "m [bazooka]";
149+
val.ToString() + (Global.DataJson.Config.Options.SteadyAim ? Strings.Aim.SCHRECK_METER_STEADY : Strings.Aim.SCHRECK_METER)
150+
: val.ToString() + (Global.DataJson.Config.Options.SteadyAim ? Strings.Aim.BAZOOKA_METER_STEADY : Strings.Aim.BAZOOKA_METER);
151+
*/
117152
}
118-
119-
return val.ToString();
153+
return val.ToString("G", CultureInfo.InvariantCulture);
120154
}
121155

156+
internal static string GetRocketIndicatorKind()
157+
{
158+
if (Global.DataJson.Config.Options.ConvertIndicator)
159+
{
160+
return Global.DataJson.Config.Options.SchreckZook ?
161+
(Global.DataJson.Config.Options.SteadyAim ? Strings.Aim.SCHRECK_STEADY : Strings.Aim.SCHRECK)
162+
: (Global.DataJson.Config.Options.SteadyAim ? Strings.Aim.BAZOOKA_STEADY : Strings.Aim.BAZOOKA);
163+
}
164+
return string.Empty;
165+
}
122166
/*
123167
private static T FindChild<T>(DependencyObject parent, string childName) where T : DependencyObject
124168
{

Lastgarriz/Util/Global.cs

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,52 @@ namespace Lastgarriz.Util
99
internal static class Global
1010
{
1111
internal static readonly bool DEBUG_TIMERS = false;
12-
internal static readonly int SCALING_VALUE = 1000; // GOOD - DO NOT CHANGE
13-
internal static readonly double RATIO_BAZOOKA = 0.358; // TO CHECK & MODIFY
14-
internal static readonly double RATIO_PANZERSCHRECK = 0.3428; // TO CHECK & MODIFY
15-
internal static readonly double RATIO_WITHOUT_STEADY = 0.777; // TO CHECK & MODIFY
16-
12+
/*
13+
* old
14+
internal static readonly double RATIO_BAZOOKA = 0.358;
15+
internal static readonly double RATIO_PANZERSCHRECK = 0.3428;
16+
internal static readonly double RATIO_WITHOUT_STEADY = 0.777;
17+
*/
1718
/*
18-
-INGAME READINGS- - not precise enough : TO REDO-
19-
20-
PANZERSCHRECK :
21-
960m - 3000 (0.32)
22-
840m - 2525 (0.33267)
23-
720m - 2115 (0.3404)
24-
600m - 1750 (0.342857)
25-
480m - 1420 (0.3380)
26-
360m - 1050 (0.3428)
27-
240m - 700 (0.3428)
28-
120m - 350 (0.3428)
29-
30-
BAZOOKA :
31-
720m - 2080 (0.34615)
32-
600m - 1730 (0.34682)
33-
480m - 1340 (0.35820)
34-
360m - 1025 (0.35122)
35-
240m - 670 (0.35821)
36-
120m - 320 (0.375)
19+
-INGAME READINGS-
20+
21+
PANZERSCHRECK : -new-
22+
960m - 3585 (0.2378) -0.0422
23+
840m - 3000 (0.28) -0.0080
24+
720m - 2500 (0.288) -0.0046
25+
600m - 2050 (0.2926) -0.0018
26+
480m - 1630 (0.2944) -0.0056
27+
360m - 1200 (0.3) -0 (probably bad value)
28+
240m - 800 (0.3) -0.0287
29+
120m - 365 (0.3287) init
30+
31+
BAZOOKA : -old-
32+
720m - 2080 (0.34615) -0.00067
33+
600m - 1730 (0.34682) -0.01138
34+
480m - 1340 (0.35820) -0.00698
35+
360m - 1025 (0.35122) -0.00699
36+
240m - 670 (0.35821) -0.01679
37+
120m - 320 (0.375) init
3738
*/
3839

40+
// C:\Users\'user'\AppData\Local\HLL\Saved\Config\WindowsNoEditor\GameUserSettings.ini
41+
// to get inv mouse : InvertMouseFirstPerson=True/False
42+
/* Feature : Rocket distance indicator
43+
The displayed value depends on 3 variables:
44+
- In-game mouse sensitivity with ADS (ADSMouseSensitivity under GameUserSettings.ini)
45+
- Mouse cursor speed under windows (between 1 to 20, default:10)
46+
- Mouse DPI resolution (device driver, ex with logitech G502: 1500 DPI)
47+
48+
How to align CORRECTLY ping with marker :
49+
![ping-ig](https://user-images.githubusercontent.com/62154281/182184856-a7c5c26f-fb45-4d90-be55-be3fa41c9fa9.png)
50+
![ping-map](https://user-images.githubusercontent.com/62154281/182184874-1e2234f0-a805-4aa0-b136-32a52085dc96.png)
51+
*/
52+
internal static readonly double RATIO_BAZOOKA = 0.3012; // TO CHECK & MODIFY
53+
internal static readonly double RATIO_PANZERSCHRECK = 0.2782; // TO CHECK & MODIFY
54+
internal static readonly double RATIO_WITHOUT_STEADY = 1.24; // TO CHECK & MODIFY
55+
56+
internal static readonly int SCALING_VALUE = 1000; // GOOD - DO NOT CHANGE
57+
internal static readonly int INDICATOR_TIMER = 5000; // in milliseconds
3958
internal static bool Terminate { get; set; }
4059
internal static bool IsHotKey { get; set; }
4160
internal static bool IsSelectFocused { get; set; }

Lastgarriz/Util/Strings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ internal static class Strings // only const, no parameters
1212
internal static readonly string VersionUrl = "https://raw.githubusercontent.com/maxensas/lastgarriz/master/VERSION";
1313
internal const string KEYLOG = "keylog";
1414

15+
internal static class Aim
16+
{
17+
internal const string NOVALUE = "target";
18+
internal const string SCHRECK = "schreck";
19+
internal const string SCHRECK_STEADY = "steady schreck";
20+
internal const string BAZOOKA = "bazooka";
21+
internal const string BAZOOKA_STEADY = "steady bazooka";
22+
}
23+
1524
internal static class File
1625
{
1726
internal const string CONFIG = "Config.json";

Lastgarriz/Util/TaskManager.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ internal static void StartMouseCatcherTask(RocketViewModel vm) // mouse Y Axis
109109
try
110110
{
111111
Thread.Sleep(200);
112-
int interval = 5000; // 5s, add to globals
113-
System.Timers.Timer MouseCatcherTimer = new(interval);
112+
System.Timers.Timer MouseCatcherTimer = new(Global.INDICATOR_TIMER);
114113
//MouseCatcherTimer.Elapsed += (sender, e) => OnMouseCatcherTimedEvent(sender, e, vm);
115114
MouseCatcherTimer.AutoReset = false;
116115
bool reInit = false;
@@ -125,30 +124,34 @@ internal static void StartMouseCatcherTask(RocketViewModel vm) // mouse Y Axis
125124
vm.ShowDisclaimer = false;
126125
vm.ShowWindow = true;
127126

128-
int multiplier = 0;
129-
int maxPixels = (int)SystemParameters.PrimaryScreenHeight - 1;
130-
do
127+
int heightMultiplier = 0, widthMultiplier = 0;
128+
int maxHeightPixels = (int)SystemParameters.PrimaryScreenHeight - 1;
129+
int maxWidthPixels = (int)SystemParameters.PrimaryScreenWidth - 1;
130+
do // Consume some % processor
131131
{
132132
Native.GetCursorPos(out Native.POINT pos);
133133
//Trace.WriteLine($"[Mouse position] X: {pos.X} Y: {pos.Y}");
134134

135-
bool min = pos.Y == 0;
136-
bool max = pos.Y == maxPixels;
137-
if (min || max)
135+
bool heightMin = pos.Y == 0;
136+
bool heightMax = pos.Y == maxHeightPixels;
137+
bool widthMin = pos.X == 0;
138+
bool widthMax = pos.X == maxWidthPixels;
139+
if (heightMin || heightMax || widthMin || widthMax)
138140
{
139-
if (min)
140-
{
141-
multiplier--;
142-
}
143-
if (max)
144-
{
145-
multiplier++;
146-
}
147-
Native.SetCursorPos(Global.HalfScreenWidth, Global.HalfScreenHeight);
141+
if (heightMin) heightMultiplier--;
142+
if (heightMax) heightMultiplier++;
143+
if (widthMin) widthMultiplier--;
144+
if (widthMax) widthMultiplier++;
145+
146+
Native.SetCursorPos((widthMin || widthMax) ? Global.HalfScreenWidth : pos.X,
147+
(heightMin || heightMax) ? Global.HalfScreenHeight : pos.Y);
148148
Native.GetCursorPos(out pos);
149149
}
150150

151-
vm.Indicator = Common.ConvertCursorPositionToRocketIndicator(pos.Y, multiplier);
151+
vm.Indicator = Common.ConvertHeightCursorPosition(pos.Y, heightMultiplier);
152+
vm.Kind = Common.GetRocketIndicatorKind();
153+
vm.Xhair = Common.UpdateCrosshairAbscissa(pos.X, widthMultiplier);
154+
vm.CrosshairColor = (vm.Xhair < -8 || vm.Xhair > 8) ? Brushes.Red : Brushes.Lime;
152155

153156
//Thread.Sleep(1);
154157
if (Common.IsMiddleButtonMousePushedOnce())

Lastgarriz/ViewModels/RocketViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ namespace Lastgarriz.ViewModels
66
public sealed class RocketViewModel : BaseViewModel
77
{
88
private string indicator = string.Empty;
9+
private string kind = string.Empty;
910
private bool showWindow;
1011
private bool showDisclaimer = true;
1112
private string disclaimerText = "Rocket indicator activated";
1213
private SolidColorBrush disclaimerColor = Brushes.Lime;
14+
private SolidColorBrush crosshairColor = Brushes.Lime;
15+
private int xhair = 0;
1316

1417
public string Indicator { get => indicator; set => SetProperty(ref indicator, value); }
18+
public string Kind { get => kind; set => SetProperty(ref kind, value); }
1519
public bool ShowWindow { get => showWindow; set => SetProperty(ref showWindow, value); }
1620
public bool ShowDisclaimer { get => showDisclaimer; set => SetProperty(ref showDisclaimer, value); }
1721
public string DisclaimerText { get => disclaimerText; set => SetProperty(ref disclaimerText, value); }
1822
public SolidColorBrush DisclaimerColor { get => disclaimerColor; set => SetProperty(ref disclaimerColor, value); }
23+
public SolidColorBrush CrosshairColor { get => crosshairColor; set => SetProperty(ref crosshairColor, value); }
24+
public int Xhair { get => xhair; set => SetProperty(ref xhair, value); }
1925

2026
public RocketCommand Commands { get; private set; }
2127

Lastgarriz/Views/ConfigWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
</Grid>
7070
<CheckBox Margin="9,32,264,205" RenderTransformOrigin="0.357,1.269" Content="Disable startup message" ToolTip="Disable startup message" Foreground="{DynamicResource MaterialDesignBodyLight}" IsChecked="{Binding DisableStartup}"/>
7171
<CheckBox Margin="9,130,255,107" RenderTransformOrigin="0.357,1.269" Content="Mouse Y Axis inverted in-game" IsChecked="{Binding InvertedMouse}" ToolTip="Enable or disable to convert rocket distance value according to your in-game settings." Foreground="{DynamicResource MaterialDesignBodyLight}"/>
72-
<TextBlock Text="Rocket indicator : WIP" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Foreground="{DynamicResource MaterialDesignDarkForeground}" Margin="0,98,0,0"/>
73-
<CheckBox Margin="9,163,72,74" RenderTransformOrigin="0.357,1.269" Content="Convert indicator value to meters (approximate value)" IsChecked="{Binding ConvertIndicator}" ToolTip="Enable if you want to convert indicator value to approximate meters.&#x0a;&#x0a;The conversion allows to obtain the distance if the Z axis position (3D-Game)&#x0a;of the source and the target are ideally identical but this can never be always the case in game." Foreground="{DynamicResource MaterialDesignBodyLight}"/>
72+
<TextBlock Text="Rocket crosshair : WIP" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Foreground="{DynamicResource MaterialDesignDarkForeground}" Margin="0,98,0,0"/>
73+
<CheckBox Margin="9,163,72,74" RenderTransformOrigin="0.357,1.269" Content="Convert indicator value to meters (WIP - not working)" IsChecked="{Binding ConvertIndicator}" ToolTip="Enable if you want to convert indicator value to approximate meters.&#x0a;&#x0a;The conversion allows to obtain the distance if the Z axis position (3D-Game)&#x0a;of the source and the target are ideally identical but this can never be always the case in game." Foreground="{DynamicResource MaterialDesignBodyLight}"/>
7474
<CheckBox Margin="9,196,255,41" RenderTransformOrigin="0.357,1.269" Content="Steady aim values" IsChecked="{Binding SteadyAim}" IsEnabled="{Binding ConvertIndicator}" ToolTip="Enable or disable if you are using or not steady aim shortcut in-game with rocket indicator feature." Foreground="{DynamicResource MaterialDesignBodyLight}"/>
7575
<CheckBox Margin="9,229,34,8" RenderTransformOrigin="0.357,1.269" Content="Panzerschreck (enable) / Bazooka (disable)" IsChecked="{Binding SchreckZook}" IsEnabled="{Binding ConvertIndicator}" ToolTip="Switch to display values if you are using panzerschreck (enable) or bazooka (disable)" Foreground="{DynamicResource MaterialDesignBodyLight}"/>
7676
</Grid>
@@ -112,7 +112,7 @@
112112
</i:Interaction.Triggers>
113113
</TextBox>
114114

115-
<TextBlock Text="Rocket distance indicator (WIP)" Margin="0,130,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Foreground="{DynamicResource MaterialDesignDarkForeground}"/>
115+
<TextBlock Text="Rocket crosshair (WIP)" Margin="0,130,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Foreground="{DynamicResource MaterialDesignDarkForeground}"/>
116116

117117
<TextBlock Visibility="Hidden" Text="Show indicator" HorizontalAlignment="Left" Margin="143,165,0,0" VerticalAlignment="Top" ToolTip="Show rocket indicator near the center of the screen for a limited time." Foreground="{DynamicResource MaterialDesignBodyLight}" />
118118
<TextBox Visibility="Hidden" HorizontalAlignment="Left" Height="24" Margin="32,160,0,0" Text="{Binding Features.Rocket_start.Hotkey}" ToolTip="{Binding Features.Rocket_start.Hotkey}" Foreground="{DynamicResource MaterialDesignDarkForeground}" VerticalAlignment="Top" Width="106" Tag="textbox" FontFamily="Arial" HorizontalContentAlignment="Center" IsReadOnly="True">
@@ -127,7 +127,7 @@
127127

128128
</TextBox>
129129

130-
<TextBlock Text="Enable feature" HorizontalAlignment="Left" Margin="143,165,0,0" VerticalAlignment="Top" ToolTip="Enable or disable rocket distance indicator based on mouse cursor position.&#x0a;Hit middle mouse button to show rocket indicator near the center of the screen for a limited time.&#x0a;&#x0a;The displayed indicator is approximate and absolutely does not take into account game variables." Foreground="{DynamicResource MaterialDesignBodyLight}" />
130+
<TextBlock Text="Enable feature" HorizontalAlignment="Left" Margin="143,165,0,0" VerticalAlignment="Top" ToolTip="Enable or disable rocket crosshair overlay.&#x0a;Hit middle mouse button to show rocket crosshair for a limited time.&#x0a;&#x0a;The displayed indicators are approximates and absolutely does not take into account game variables." Foreground="{DynamicResource MaterialDesignBodyLight}" />
131131
<CheckBox Margin="9,162,467,75" RenderTransformOrigin="0.357,1.269" IsChecked="{Binding Features.Rocket_enable.IsEnable}"/>
132132
<TextBox HorizontalAlignment="Left" Height="24" Margin="32,160,0,0" IsEnabled="{Binding Features.Rocket_enable.IsEnable}" Text="{Binding Features.Rocket_enable.Hotkey}" ToolTip="{Binding Features.Rocket_enable.Hotkey}" Foreground="{DynamicResource MaterialDesignDarkForeground}" VerticalAlignment="Top" Width="106" Tag="textbox" FontFamily="Arial" HorizontalContentAlignment="Center" IsReadOnly="True">
133133
<i:Interaction.Triggers>

0 commit comments

Comments
 (0)