Skip to content

Instantly share code, notes, and snippets.

@asiansteev
Created January 10, 2012 05:00
Show Gist options
  • Save asiansteev/1587073 to your computer and use it in GitHub Desktop.
Save asiansteev/1587073 to your computer and use it in GitHub Desktop.
SCRIPT_TITLE = "Mega Man 3 - Weapon Select"
SCRIPT_VERSION = "1.0"
require "m_utils"
m_require("m_utils",0)
--[[
Just a quick script to allow Mega Man to cycle through his weapons with the select button without having to pause.
It works, but it's pretty buggy.
Mega Man does not change weapon sprites with this method, so the weapons look like garbage.
His colors do not change from the weapon you start with.
You can cycle through weapons you haven't unlocked yet.
Otherwise it's a lot of fun. Really!
TODO: Fix weapon sprites, Mega Man's colors, "fix" cycling to currently locked weapons.
-steev
-]]
weapon_names = {"Arm Cannon", "Gemini Laser", "Needle Cannon", "Hard Knuckle", "Magnet Missle", "Top Spin", "Search
Snake", "Rush Coil", "Spark Shock", "Rush Marine", "Shadow Blade", "Rush Jet"}
primary_colors = {17, 21, 17, 25, 0, 37, 20, 24, 38, 22, 22, 22}
secondary_colors = {44, 40, 48, 48, 48, 52, 52, 55, 48, 48, 48, 48}
function update_weapons(prev_select)
j = joypad.read(1).select
if j and prev_select == false then
next_weapon = current_weapon + 1
if next_weapon >= #weapon_names then next_weapon = 0 end
-- weapon
memory.writebyte(0x00A0, next_weapon)
if next_weapon < 6 then
memory.writebyte(0x00B4, 0) -- menu page
memory.writebyte(0x00A1, next_weapon) -- position on the menu
else
memory.writebyte(0x00B4, 6)
memory.writebyte(0x00A1, next_weapon - 6)
end
end
end
function display_weapon(current_weapon)
gui.text(16,8, weapon_names[current_weapon+1])
gui.text(16,16, current_weapon)
gui.text(16,24, #weapon_names)
end
while(true) do
current_weapon = memory.readbyte(0x00A0)
display_weapon(current_weapon)
update_weapons(prev_select)
prev_select = joypad.read(1).select
EMU.frameadvance()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment