Skip to content

Commit

Permalink
feat: asac script file
Browse files Browse the repository at this point in the history
ASAC = as ace cheater
  • Loading branch information
allape committed Oct 26, 2024
1 parent 746dd90 commit 03bb95b
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 7 deletions.
64 changes: 61 additions & 3 deletions AsCheater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 03bb95b

Please sign in to comment.