diff --git a/AsCheater.rb b/AsCheater.rb index 2a8f24a..ca653de 100644 --- a/AsCheater.rb +++ b/AsCheater.rb @@ -8,6 +8,8 @@ module AsCheater MessageBox = Win32API.new("user32", "MessageBox", %w[i p p i], "i") # MessageBox.call(0, "message", "title", 0) + LoadableASACIndexes = %w[q w e] + # noinspection RubyResolve @state = DL::CPtr.new(DL.malloc(256), 256) @debounce = Time.now.to_f @@ -16,10 +18,34 @@ module AsCheater @saved_x = 0 @saved_y = 0 + @loaded_asac_files = {} + + def self.load_asac_files + LoadableASACIndexes.each do |index| + filename = "asac." + index + ".rb" + if File.exist?(filename) + @loaded_asac_files[index] = File.read(filename) + end + end + end + + def self.eval_asac_file(index) + if @loaded_asac_files[index] + eval(@loaded_asac_files[index]) + Sound.play_ok + else + Sound.play_buzzer + end + end + def self.pressed(key_code) return @state[key_code] & DOWN_STATE_MASK == DOWN_STATE_MASK end + def self.is_shift_key_pressed + return (@state[0xA0] & DOWN_STATE_MASK == DOWN_STATE_MASK) || (@state[0xA1] & DOWN_STATE_MASK == DOWN_STATE_MASK) + end + def self.gain_item(amount) if SceneManager.scene and SceneManager.scene.is_a?(Scene_ItemBase) if SceneManager.scene.item @@ -45,11 +71,16 @@ def self.update # https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes if pressed(0xC0) # ` > save at slot 2 + save_index = 1 if $game_party.all_members.length == 0 Sound.play_buzzer return end - DataManager.save_game_without_rescue(1) + if DataManager.respond_to?(:save_game_with_preview) + DataManager.save_game_with_preview(save_index) + else + DataManager.save_game_without_rescue(save_index) + end Sound.play_ok end @@ -97,11 +128,19 @@ def self.update end if pressed(0xBD) # - > decrease the amount of selected item - gain_item(-1) + if is_shift_key_pressed + gain_item(-10) + else + gain_item(-1) + end end if pressed(0xBB) # = > increase the amount of selected item - gain_item(1) + if is_shift_key_pressed + gain_item(10) + else + gain_item(1) + end end if pressed(0xDB) # [ -> Save current position @@ -119,5 +158,24 @@ def self.update Sound.play_buzzer end end + + if pressed(0x51) # Q -> Run asac.q.rb + eval_asac_file('q') + end + + if pressed(0x57) # W -> Run asac.w.rb + eval_asac_file('w') + end + + if pressed(0x45) # E -> Run asac.e.rb + eval_asac_file('e') + end + + if pressed(0x52) # R -> Reload all asac files + load_asac_files + Sound.play_ok + end end end + +AsCheater.load_asac_files diff --git a/README.md b/README.md index 62df6dc..b31b579 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,14 @@ # How to Patch on Windows ## Preparing + - Do NOT run patch under a path that contains non-english characters. - - `rvunpacker.exe` will fail with a path contains Japanese characters on `Windows 10` with Japanese encoding. + - `rvunpacker.exe` will fail with a path contains Japanese characters on `Windows 10` with Japanese encoding. ## Auto -- Download `RPG-Maker-ACE-Cheater-Patcher.exe` from https://github.com/allape/RPG-Maker-ACE-Cheater/releases, and put it in +- Download `RPG-Maker-ACE-Cheater-Patcher.exe` from https://github.com/allape/RPG-Maker-ACE-Cheater/releases, and put it + in the game folder. - Double click `RPG-Maker-ACE-Cheater-Patcher.exe` to patch the game. @@ -87,12 +89,19 @@ - `8`: Reserved - `9`: Reserved - `0`: Gain gold 10K -- `-`: Reduce the amount of current selected item by 1 +- `-`: Decrease the amount of current selected item by 1, by 10 if `Shift` is pressed - Should open `Menu` -> `Item List` first, and select the corresponding item -- `+`: Increase the amount of current selected item by 1 +- `+`: Increase the amount of current selected item by 1, by 10 if `Shift` is pressed - Should open `Menu` -> `Item List` first, and select the corresponding item - `[`: Save current position - `]`: Load saved position +- `q`: Execute `asac.q.rb` script file in the game root folder + - If script file contains runtime error, the game will crash +- `w`: Execute `asac.w.rb` script file in the game root folder + - If script file contains runtime error, the game will crash +- `e`: Execute `asac.e.rb` script file in the game root folder + - If script file contains runtime error, the game will crash +- `r`: Reload loaded `asac.*.rb` script files # Dev