Skip to content

Instantly share code, notes, and snippets.

@cecil
Created October 28, 2017 06:26
Show Gist options
  • Save cecil/51089ff18d5487ac1a02f8848bc505df to your computer and use it in GitHub Desktop.
Save cecil/51089ff18d5487ac1a02f8848bc505df to your computer and use it in GitHub Desktop.
Sailor Moon S Training scripts
axis_length = 4
function hud()
gui.text(24,30,"Life: " .. memory.read_u8(0x001049))
--Player 2
gui.text(196,30,"Life: " .. memory.read_u8(0x0010c9))
end
function p1pos()
--Player 1
p1x = memory.read_u8(0x01028)
p1y = memory.read_u8(0x0102A)
gui.text(64,40,p1x .. "," .. p1y)
gui.drawLine(p1x,p1y+axis_length,p1x,p1y-axis_length)
gui.drawLine(p1x+axis_length,p1y,p1x-axis_length,p1y)
end
function p2pos()
p2x = memory.read_u8(0x010A8)
p2y = memory.read_u8(0x010AA)
gui.text(164,40,p2x .. "," .. p2y)
gui.drawLine(p2x,p2y+axis_length,p2x,p2y-axis_length)
gui.drawLine(p2x+axis_length,p2y,p2x-axis_length,p2y)
end
function cheat()
--Timer
memory.write_u8(0x7e0803, 0x07)
memory.write_u8(0x7e0804, 0x00)
--Super
memory.write_u8(0x7e080e, 0x0e)
memory.write_u8(0x7e0810, 0x0e)
memory.write_u8(0x7e0812, 0x0e)
memory.write_u8(0x7e0814, 0x0e)
--P1 Health
if memory.read_u8(0x001049) <= 24 then
memory.write_u8(0x001049, 0x60)
memory.write_u8(0x000800, 0xC0)
end
--p2 health
if memory.read_u8(0x0010C9) <= 24 then
memory.write_u8(0x0010C9, 0x60)
memory.write_u8(0x000801, 0xC0)
end
end
while true do
hud()
p1pos()
p2pos()
cheat()
emu.frameadvance()
end
axis_length = 4
invalidTimer = 10
comboCount = 0
lastCombo = 0
lastDamage = 0
comboDamage = 0
damage = 0
function hud()
gui.text(24,30,"Life: " .. memory.read_u8(0x001049))
--Player 2
gui.text(196,30,"Life: " .. memory.read_u8(0x0010c9))
end
function p1pos()
--Player 1
p1x = memory.read_u8(0x01028)
p1y = memory.read_u8(0x0102A)
gui.text(64,40,p1x .. "," .. p1y)
gui.drawLine(p1x,p1y+axis_length,p1x,p1y-axis_length)
gui.drawLine(p1x+axis_length,p1y,p1x-axis_length,p1y)
end
function p2pos()
p2x = memory.read_u8(0x010A8)
p2y = memory.read_u8(0x010AA)
gui.text(164,40,p2x .. "," .. p2y)
gui.drawLine(p2x,p2y+axis_length,p2x,p2y-axis_length)
gui.drawLine(p2x+axis_length,p2y,p2x-axis_length,p2y)
end
function cheat()
--Timer
memory.write_u8(0x7e0803, 0x07)
memory.write_u8(0x7e0804, 0x00)
--Super
memory.write_u8(0x7e080e, 0x0e)
memory.write_u8(0x7e0810, 0x0e)
memory.write_u8(0x7e0812, 0x0e)
memory.write_u8(0x7e0814, 0x0e)
--P1 Health
if memory.read_u8(0x001049) <= 24 then
memory.write_u8(0x001049, 0x60)
memory.write_u8(0x000800, 0xC0)
end
--p2 health
if memory.read_u8(0x0010C9) <= 1 then
memory.write_u8(0x0010C9, 0x60)
memory.write_u8(0x000801, 0xC0)
end
end
function combocheck()
if memory.read_u8(0x0010D7) == 0 then
if memory.read_u8(0x0010C6) == 160 then
text = "Knockdown"
elseif memory.read_u8(0x0010D5) == 16 then
text = "Blockstun"
elseif memory.read_u8(0x0010D5) == 128 then
text = "Hitstun"
elseif lastFrame == 1 then
text = "Hitstun"
elseif memory.read_u8(0x0010D5) == 0 then
text = "Neutral"
if comboCount ~= 0 then
lastCombo = comboCount
lastDamage = comboDamage
end
comboCount = 0
comboDamage = 0
memory.write_u8(0x0010C9, 0x60)
end
lastFrame = 0
lastHealth = memory.read_u8(0x0010C9)
else
if lastFrame == 0 then
comboCount = comboCount + 1
damage = lastHealth - memory.read_u8(0x0010C9)
comboDamage = comboDamage + damage
end
if memory.read_u8(0x0010D5) < 128 then
text = "Hitstun"
end
lastFrame = memory.read_u8(0x0010D7)
end
gui.text(164,46,text)
if comboCount > 0 then
gui.text(164,52,"Current Combo:")
gui.text(164,58,comboCount .. " hits, " .. comboDamage .. " damage.")
else
gui.text(164,52,"Last Combo:")
gui.text(164,58,lastCombo .." hits, " .. lastDamage .. " damage.")
end
if lastState ~= text then
if lastState == "Hitstun" then
invalidTimer = 10
memory.write_u8(0x000801, 0xC0)
elseif lastState == "Neutral" then
if invalidTimer > 0 then
invalidState = true
else
invalidState = false
end
end
end
if invalidState == true then
gui.text(220,52,"INVALID!")
if text ~= "Neutral" then
invalidTimer = 30
end
end
if invalidTimer == 0 then
invalidState = false
else invalidTimer = invalidTimer - 1
end
lastState = text
end
while true do
hud()
p1pos()
p2pos()
cheat()
combocheck()
emu.frameadvance()
end
local wb, ww, wd = memory.write_u8, memory.write_u16_le, memory.write_u32_le
local rb, rbs, rw, rws, rd = memory.read_u8, memory.read_s8, memory.read_u16_le, memory.read_s16_le, memory.read_u32_le
--Box Colors
hurtfill = 0x60004080
hurtout = 0xFF0040ff
---------------------------
axis_length = 8
invalidTimer = 10
comboCount = 0
lastCombo = 0
lastDamage = 0
comboDamage = 0
damage = 0
function players()
adr = 0x0F80
for i = 0,3,1 do -- Repeats the set up
adr = adr + 0x80 -- Address offset(example 0x0F80 + 0x80 = player 1 0x1000 for player 2 it adds p1 address 0x1000 + 0x80)
--Data Player memory
local px = rb(adr + 0x28)
local py = rb(adr + 0x2A)
local life = rb(adr + 0x49)
local flipb = rb(adr + 0x09) -- Flip flag if byte is anything but zero means the sprite was fliped
local movex = rws(adr + 0x30) -- Movement Speed on X
local movey = rws(adr + 0x32) -- Movement Speed on Y
local damage = rb(adr + 0x45) -- How much Damage attacks do single hit
local atkflag = rb(adr + 0x44) -- Fire, Knockdown, Electric, etc..
if rb(adr) ~= 0 then -- If active
--Text
if i < 2 then -- Player Data
gui.text(24+i*128,30,"Life: " .. life)
gui.text(52+i*108,40,"X,Y: " .. px .. ", " .. py)
gui.text(52+i*128,212,"Move X: " .. movex)
gui.text(52+i*128,204,"Move Y: " .. movey)
else -- Projectile Data
gui.text(98,180+i*8,"PX, PY: " .. px .. "," .. py)
gui.text(98,140+i*8,"MX, MY: " .. movex .. "," .. movey)
end
--Axis
gui.drawLine(px,py+axis_length,px,py-axis_length)
gui.drawLine(px+axis_length,py,px-axis_length,py)
--Example Box Set up
--If boxes use one cordinate set up setup could be different though this is the usual set up I've seen in fighters
--[[
if flipb ~= 0 then
flip = -1
else
flip = 1
end
x1 = px + (-4 * flip)
x2 = x1 + (0x12 * flip)
y1 = py + 8
y2 = y1 - 80
gui.drawBox(x1,y1,x2,y2,hurtout,hurtfill)
--]]
end
end
end
function cheat()
--Timer
wb(0x7e0803, 0x07)
wb(0x7e0804, 0x00)
--Super
wb(0x7e080e, 0x0e)
wb(0x7e0810, 0x0e)
wb(0x7e0812, 0x0e)
wb(0x7e0814, 0x0e)
--P1 Health
if rb(0x001049) <= 24 then
wb(0x001049, 0x60)
wb(0x000800, 0xC0)
end
--p2 health
if rb(0x0010C9) <= 1 then
wb(0x0010C9, 0x60)
wb(0x000801, 0xC0)
end
end
function combocheck()
if memory.read_u8(0x0010D7) == 0 then
if memory.read_u8(0x0010C6) == 160 then
text = "Knockdown"
elseif memory.read_u8(0x0010D5) == 16 then
text = "Blockstun"
elseif memory.read_u8(0x0010D5) == 128 then
text = "Hitstun"
elseif lastFrame == 1 then
text = "Hitstun"
elseif memory.read_u8(0x0010D5) == 0 then
text = "Neutral"
if comboCount ~= 0 then
lastCombo = comboCount
lastDamage = comboDamage
end
comboCount = 0
comboDamage = 0
memory.write_u8(0x0010C9, 0x60)
end
lastFrame = 0
lastHealth = memory.read_u8(0x0010C9)
else
if lastFrame == 0 then
comboCount = comboCount + 1
damage = lastHealth - memory.read_u8(0x0010C9)
comboDamage = comboDamage + damage
end
if memory.read_u8(0x0010D5) < 128 then
text = "Hitstun"
end
lastFrame = memory.read_u8(0x0010D7)
end
gui.text(164,46,text)
if comboCount > 0 then
gui.text(164,52,"Current Combo:")
gui.text(164,58,comboCount .. " hits, " .. comboDamage .. " damage.")
else
gui.text(164,52,"Last Combo:")
gui.text(164,58,lastCombo .." hits, " .. lastDamage .. " damage.")
end
if lastState ~= text then
if lastState == "Hitstun" then
invalidTimer = 10
memory.write_u8(0x000801, 0xC0)
elseif lastState == "Neutral" then
if invalidTimer > 0 then
invalidState = true
else
invalidState = false
end
end
end
if invalidState == true then
gui.text(220,52,"INVALID!")
if text ~= "Neutral" then
invalidTimer = 30
end
end
if invalidTimer == 0 then
invalidState = false
else invalidTimer = invalidTimer - 1
end
lastState = text
end
while true do
players()
cheat()
combocheck()
emu.frameadvance()
end
axis_length = 4
function hud()
gui.text(24,30,"Life: " .. memory.readbyte(0x7e1049))
--Player 2
gui.text(196,30,"Life: " .. memory.readbyte(0x7e10c9))
end
function p1pos()
--Player 1
p1x = memory.readbyte(0x01028)
p1y = memory.readbyte(0x0102A)
gui.text(64,40,p1x .. "," .. p1y)
gui.drawline(p1x,p1y+axis_length,p1x,p1y-axis_length)
gui.drawline(p1x+axis_length,p1y,p1x-axis_length,p1y)
end
function p2pos()
p2x = memory.readbyte(0x010A8)
p2y = memory.readbyte(0x010AA)
gui.text(164,40,p2x .. "," .. p2y)
gui.drawline(p2x,p2y+axis_length,p2x,p2y-axis_length)
gui.drawline(p2x+axis_length,p2y,p2x-axis_length,p2y)
end
function cheat()
--Timer
memory.writebyte(0x7e0803, 0x07)
memory.writebyte(0x7e0804, 0x00)
--Hiding Timer
memory.writebyte(0x7e080e, 0x0e)
memory.writebyte(0x7e0810, 0x0e)
memory.writebyte(0x7e0812, 0x0e)
memory.writebyte(0x7e0814, 0x0e)
--P1 Health
if memory.readbyte(0x7e1049) <= 24 then
memory.writebyte(0x7e1049, 0x60)
memory.writebyte(0x7e0800, 0xC0)
end
if memory.readbyte(0x7e10c9) <= 24 then
memory.writebyte(0x7e10c9, 0x60)
memory.writebyte(0x7e0801, 0xC0)
end
end
while true do
gui.register(function()
hud()
p1pos()
p2pos()
end)
cheat()
emu.frameadvance()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment