Stranger of Sword City

Stranger of Sword City

Not enough ratings
Bonus Stat Auto-Roller
By Guideau
This is an AutoHotKey script to auto-roll for bonus stats at character creation.
   
Award
Favorite
Favorited
Unfavorite
Auto-Roller Script
This is my first guide so feel free to leave suggestions on how I can improve it.

If you're already familiar with AHK, you can just copy the script and ignore everything else; it's simple so you can figure it out.

For those that are not familiar with AHK, read carefully and let me know if you have any questions.

1.) Install AHK from: https://autohotkey.com/download/

2.) Copy the following script and paste it into a text file. Save it as "Reroll.ahk".
I recommend using Notepad++ for working with scripts: https://notepad-plus-plus.org/download/

#InstallKeybdHook #InstallMouseHook CoordMode, Window F1:: loop { PixelGetColor, color, 1224, 337, RGB ; Stops on a 1 or 2 in the 10's place ;PixelGetColor, color, 1243, 373, RGB ; Stops on a 2 in the 10's place If (color = 0x59493F) { MouseClick, Left, 1240, 500, 3 sleep, 1000 } else { Reload } } F2::Reload

3.) Save the script and run it.

You'll need to make some changes depending on your resolution and game window size.

4.) Run the game and adjust the window size and placement if desired.
5.) Right click on the AHK script in the System Tray and click "Window Spy"
6.) Click into the game window; at the Bonus Point screen, set the tip of the mouse to the center of the 0 in the 10's place. Where the green dot is.


7.) Look at Window Spy, under Mouse Position. Take note of the coordiates right of "Window".
8.) Now in the script, change the coordinates for the first "PixelGetColor" line to what was just noted in Window Spy.
9.) Click back into the game, mouse over "Re-Roll" and take note of the mouse coordinates once again.
10.) In the script, change the coordinates on the "MouseClick" line to match the position of the "Re-Roll" button.
11.) Save the script and press F2 to reload it.

Now if you click back into the game and press F1, the script will keep rolling until there's either a 1 or a 2 in the 10's place.

To set it up to only stop on a 2, we'll have to update the second "PixelGetColor" line, remove the colon and add it to the front of the first "PixelGetColor" line.

12.) So back on the Bonus Point screen get a 0 in the 10's place.
13.) Move the point of the mouse to where it lines up with the right side of the 0 as well as the bottom, in the brown area. Where the green dot is.


14.) Take note of these coordinates in Window Spy and update the second "PixelGetColor" line accordingly.
15.) Comment out the first "PixelGetColor" line and uncomment the second "PixelGetColor" line. (Move the semicolon up).
16.) Save the script and press F2 to reload it.

Now if you click back into the game and press F1, the script will keep rolling until there's either a 2 in the 10's place.
Some Notes
  • You can press F2 at any time to stop the script.
  • You can change F1 and F2 to whatever you want to use as the hotkeys.
  • If you're running the game as admin, you'll also need to run the script as admin.
  • Resizing the game window can break the script, requiring you to update the coordinates.
  • The window placement doesn't matter, you can move the game window around without breaking the script.
How Does it Work?
This script is configured to look for the background color (brownish) at the specified coordinates every 1 second. If the script finds specified color, it will click on Re-Roll, wait 1 second and repeat.
If it does not find that color, it will reload the script and stop.

So, if we have it check in the center of a 0, it will find white (ffffff) whenever that 0 changes to either a 1 or a 2.
In the above guide, we're also configuring a line to look for the bottom right piece of a "2" in order to stop only on 20+ rolls.

I have the script set to triple-click to make sure it rolls every time (it would occasionally skip an interval, thus slowing it down). You can change the "3" at the end of the MouseClick line to however many times you want it to click.
8 Comments
pitfall317 27 Oct, 2024 @ 10:47am 
Would love to use this but when I run the script it tells me that "CoordMode, Window" does not contain a recognized action.
Russ 2 Nov, 2023 @ 10:00am 
Hit the character limit on the below comment. The change in the script is that it takes advantage of the fact that clicking in and out of the next screen is near instant, and so it lets you reroll without waiting for the dice animation. You get far more rerolls per second.

There's a balance between the mouse and sleep settings to maintain consistency. Somehow clicking twice made everything vastly more stable. Anyhow, I left in the debug and other stuff I was using in case somebody wants to mod it further, a couple of years from now:
Russ 2 Nov, 2023 @ 9:58am 
Thanks for this. I tweaked it a little bit using a little trick I noticed while manually playing:

-----

#InstallKeybdHook
#InstallMouseHook
CoordMode, Window

PixelX := 925
PixelY := 256

PixelX2 := 938
PixelY2 := 283

FrameSleepTime := 100
MouseSleepTime := 50

MouseSpeed := 3
MouseClicks := 2

NextButtonX := 939
NextButtonY := 551

F1::
loop
{
Sleep, FrameSleepTime
;PixelGetColor, color, PixelX, PixelY, RGB ; Stops on a 1 or 2 in the 10's place
PixelGetColor, color, PixelX2, PixelY2, RGB ; Stops on a 2 in the 10's place

If (color = 0x59493F)
{
MouseClick, Left, NextButtonX-5, NextButtonY, MouseClicks, MouseSpeed
Sleep, MouseSleepTime
MouseClick, Right, NextButtonX+5, NextButtonY, MouseClicks, MouseSpeed
Sleep, MouseSleepTime
}
else
{
MsgBox "Got it. Color = %color%"
Reload
}
}

F2::Reload

F3::
{
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox The color at the current cursor position is %color%.
}

----
sigloxx 31 May, 2020 @ 11:32pm 
Had to tweak it a bit to get it to work, adding pauses. Here is the script I used in case someone else runs into the same issues :

#InstallKeybdHook
#InstallMouseHook
CoordMode, Window

F1::
loop
{
PixelGetColor, color, 1374, 380, RGB ; Stops on a 1 or 2 in the 10's place
;PixelGetColor, color, 1243, 373, RGB ; Stops on a 2 in the 10's place

If (color = 0x4F493F)
{
Click down, 1425, 525
Sleep 100
Click up
Sleep 100
SendInput {Enter, down}
Sleep 1000
}
else
{
Reload
}
}

F2::Reload
sigloxx 31 May, 2020 @ 8:23am 
I tried using Click instead of MouseClick, I tried adding Send {Enter, down} after it too (since the enter key works as well. But It keeps brining the mouse cursor to the Re-Roll and doing nothing :/ Very annoying issue :/
sigloxx 31 May, 2020 @ 7:57am 
I had to change the color code to #4F49F3. Also under Mouse position I had 3 possibitilites : Absolute, Rlative, Client. Apparently "Relative" is the correct one.
I still have an issue though.. It keeps putting the mouse cursor back on the reroll button regularly but it doesn't seem to actualy lick, it just moves the cursor there.. Any idea why?
Thoriek 24 Dec, 2019 @ 5:26am 
Useful not only for this game but for all sorts of "Roll your attributes" stuff.

Thank you very much.
Rainer 4 Jul, 2018 @ 8:25pm 
thank you thank you thank you! i would also add that if you are looking for more than a 10, you do have to reroll before starting the roller again as it will think its finished