Skip to content

Commit

Permalink
Fix bug in process picker, make 8-key mode more restrictive and apply…
Browse files Browse the repository at this point in the history
… to 4-keys

Windowfinder was incorrectly continuing to search for valid windows,
breaking if the process was not "LoveRitmo". Fixed by exiting the loop
after a match is found (expected behaviour)

Changed eight-key mode to affect arrows (4-key mode) as well. If
eight-key mode and numlock is enabled, it will send the proper numpad
key (i.e numpad2 instead of arrow down). This is not necessary, but it
more closely represents how a human would play in 8-key mode (I guess)
  • Loading branch information
Sean committed Jun 21, 2016
1 parent 60b08ce commit 2b3b75a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions LoveBoot/BotLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ public BotLogic(string[] processNames)

foreach(string processName in processNames)
{
if (windowFinder.SetProcess(processName)) foundProcess = processName;
if (!windowFinder.SetProcess(processName)) continue;

foundProcess = processName;
break;
}

if(foundProcess.Length > 0)
Expand Down Expand Up @@ -274,27 +277,27 @@ private void PressKeys(int columnToPress)
{
Signal[] column = gameState[columnToPress];

bool numlock = Control.IsKeyLocked(Keys.NumLock);
bool numlock = EightKeyMode && Control.IsKeyLocked(Keys.NumLock);

for (int i = 0; i < column.Length; i++)
{
switch (column[i])
{
case Signal.Key_Down:
case Signal.Key_Down_Fever:
windowFinder.SendKeystroke((ushort)VirtualKeyCode.DOWN);
windowFinder.SendKeystroke((ushort)(numlock ? VirtualKeyCode.NUMPAD2 : VirtualKeyCode.DOWN));
break;
case Signal.Key_Left:
case Signal.Key_Left_Fever:
windowFinder.SendKeystroke((ushort)VirtualKeyCode.LEFT);
windowFinder.SendKeystroke((ushort)(numlock ? VirtualKeyCode.NUMPAD4 : VirtualKeyCode.LEFT));
break;
case Signal.Key_Right:
case Signal.Key_Right_Fever:
windowFinder.SendKeystroke((ushort)VirtualKeyCode.RIGHT);
windowFinder.SendKeystroke((ushort)(numlock ? VirtualKeyCode.NUMPAD6 : VirtualKeyCode.RIGHT));
break;
case Signal.Key_Up:
case Signal.Key_Up_Fever:
windowFinder.SendKeystroke((ushort)VirtualKeyCode.UP);
windowFinder.SendKeystroke((ushort)(numlock ? VirtualKeyCode.NUMPAD8 : VirtualKeyCode.UP));
break;

// 8 key
Expand Down

1 comment on commit 2b3b75a

@1994heber
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por favor podrías actualizar lo para LoveRtimo por favor u.u

Please sign in to comment.