Author Topic: I made some helpful (kinda cheaty) AutoHotkey scripts  (Read 3541 times)

Goldom

  • Whee
I made some helpful (kinda cheaty) AutoHotkey scripts
« on: February 20, 2013, 10:19:56 PM »
I've been learning to write AHK script and in doing so have tried to use it to make easier a number of annoyances I have with certain Touhou games, most of which stem from my inability to press the C button reliably.

So, I've got a script here to share with five features - if you want to use some but not others, it should be fairly clear which section to delete. To use this, you need AutoHotkey. Paste the code in a text file, save with extension .ahk and run; it sits in the taskbar. If you don't use NP21 for your PC98, you'll need to change the line that contains the emu title near the end.

1. PC98 dialogue skip - Cheatyness: none
-Hold LCtrl to skip dialogue in the PC98 games!

2. GFW autofire - Cheatyness: Low
-Pressing C toggles fire on and off instead of requiring it held. You'll need to toggle it off for LCtrl to skip dialogue.

3. TD bomb key switch - Cheatyness: Mid
-Press NumpadInsert with your pinky to swap the X and C keys. In other words, soon as you have trance available, hit it, then hit it again after you next use trance, and never need to fumble for C in a sudden emergency. If you lose track of which way it's set, NumpadEnd will reset it to the default keys.

4. TD AutoYoumu - Cheatyness: High
-Press NumpadDel to enable autofiring of Youmu's sword attack without having to let go of Shift or Z. This doesn't quite produce as much damage as doing it manually, because you lose out on the unfocused shots you normally get in between each slash, but it lets you keep firing slashes even in those times when you're too focused to keep letting one of your fingers up. (Maybe it's just me? I really can't stand using her at all normally because of that, but I admit it's totally a cheat).

5. SoEW / PoD.D extreme rapid fire - Cheatyness: LOL
-I don't actually use this, it's just a sideeffect of the dialogue skip feature, but if you hold LCtrl to fire, you can do some pretty superhuman levels of damage.

I tried once to make a single keypress perform the option shift on SA's Marisa/Patchy, but no matter what I tried, it would randomly not work or double fire 20% of the time. Maybe someday I'll work it out.

Code and a note follows:
Code: [Select]
SetTitleMatchMode 2
Hotkey $*c, cswitch, Off
Hotkey $*x, xswitch, Off
Hotkey $*c up, cswitchup, Off
Hotkey $*x up, xswitchup, Off
Hotkey *~LShift, Youmu, Off
Return

#IfWinActive Yousei Daisensou ahk_class BASE
c::
if yousei
{
SendInput {c up}
yousei--
}
else
{
SendInput {c down}
yousei++
}
Return

#IfWinActive Touhou Shinreibyou ahk_class BASE
*NumpadEnd::
Hotkey $*c, Off
Hotkey $*x, Off
Hotkey $*c up, Off
Hotkey $*x up, Off
Hotkey *~LShift, Off
Return
cswitch:
SetKeyDelay -1
SendEvent {blind}{x downtemp}
Return
xswitch:
SetKeyDelay -1
SendEvent {blind}{c downtemp}
Return
cswitchup:
SetKeyDelay -1
SendEvent {blind}{x up}
Return
xswitchup:
SetKeyDelay -1
SendEvent {blind}{c up}
Return
*NumpadIns::
Hotkey $*c, toggle
Hotkey $*x, toggle
Hotkey $*x up, toggle
Hotkey $*c up, toggle
Return
NumpadDel::Hotkey *~LShift, toggle
Youmu:
while GetKeyState("z","p")
{
SetKeyDelay -1
Loop 12
{
Sleep 100
if !GetKeyState("LShift","p")
{
broken = 1
Break
}
else if broken = 1
broken = 0
}
if broken
Break
SendEvent {blind}{z up}
Sleep 50
SendEvent {blind}{z downtemp}
Loop 4
{
Sleep 110
if !GetKeyState("LShift","p")
{
broken = 1
Break
}
else if broken = 1
broken = 0
}
if broken
Break
}
Return

#IfWinActive Neko Project 21 ;change this to the window title of your preferred PC98 emulator
$LCtrl::
while GetKeyState("LCtrl","p")
{
SendEvent {blind}{z down}
SendEvent {blind}{z up}
Sleep 50
}
Return

#IfWinActive ;for some reason the TD key switch fails without this at the end

If anyone knows a bit about AHK, the scripting may look a little long-winded and silly, but there is a reason (and the same reason that option shift failed) - some of these games are really wacky about reporting which keys are pressed (and accepting keypresses from AHK). For example, TD absolutely refuses to recognize SendInput, SendEvent or SendPlay, unless the commands are written just like a regular keybinding with the whole {blind}{downtemp} business. And GetKeyState totally misses whether you're holding LShift in TD about 20% of the time, prompting me to make a loop to check every 100ms rather than incorporating it in the while loop.
« Last Edit: February 20, 2013, 10:33:30 PM by Goldom »

Goldom

  • Whee
Re: I made some helpful (kinda cheaty) AutoHotkey scripts
« Reply #1 on: February 20, 2013, 10:32:40 PM »
 oops I hit quote instead of modify  :blush:

marukyuu

  • "Why always ATAI?"
  • The strongest striker...?
Re: I made some helpful (kinda cheaty) AutoHotkey scripts
« Reply #2 on: February 20, 2013, 11:44:59 PM »
The PC-98 dialogue skip hotkey looks pretty useful. Thanks for the script!
<-- Sig by Suikama