Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This Lua Script is for Romancing SaGa 2 on snes9x.
- --memory.usememorydomain("CARTROM") -- BizHawk
- rng = {}
- for i = 0, 0xFF do
- rng[i+1] = memory.readbyte(0xC2EF04+i) --rng[i] = i-1 (rng[0] = 1, ... , rng[256] = 255)
- -- 0x02EF04-0x02F003
- end
- --memory.usememorydomain("WRAM") -- BizHawk
- black = 0x000000FF
- red = 0xC41F3BFF
- pink = 0xF58CBAFF
- orange = 0xFF7D0AFF
- yellow = 0xFFF569FF
- green = 0xABD473FF
- light_green = 0x00FF96FF
- dark_green = 0x008833FF
- aqua = 0x00FFFFFF
- blue = 0x0070DEFF
- light_blue = 0x69CCF0FF
- purple = 0x9482C9FF
- fuchsia = 0xFF00FFFF
- brown = 0xC79C6EFF
- gray = 0x808080FF
- white = 0xFFFFFFFF
- local msg1
- local msg0
- function msg() --for supporting scrollng text messages, imputting battle command
- msg1 = memory.readbyte(0x7E1F01)
- if msg1 == 0 and msg0 ~= 0 then
- print(emu.framecount())
- end
- msg0 = msg1
- end
- local EP
- local totalBattle
- local battle
- local safe
- local safe2 = {}
- local Hiraga
- function getParameter()
- EP = memory.readbyte(0x7EF693)
- totalBattle = memory.readword(0x7EF8AE)
- battle = memory.readbyte(0x7EF694)
- safe = memory.readbyte(0x7EF7A2) + 0x100 * memory.readbyte(0x7EF7A3) + 0x10000 * memory.readbyte(0x7EF7A4)
- safe2[1] = math.floor(safe/1000000)
- safe2[2] = math.floor((safe-(safe2[1]*1000000))/1000)
- safe2[3] = safe - (safe2[1]*1000000)-(safe2[2]*1000)
- Hiraga = memory.readbyte(0x7EF697)
- end
- function dispParameter()
- if safe2[1] ~= 0 then
- gui.text(216, 12, string.format("%3d,%03d,%03d", safe2[1], safe2[2], safe2[3]))
- elseif safe2[2] ~= 0 then
- gui.text(224, 12, string.format("%3d,%03d", safe2[2], safe2[3]))
- else
- gui.text(234, 12, string.format("%3d", safe2[3]))
- end
- gui.text(236, 20, string.format("EP %d", EP))
- gui.text(236, 28, string.format("%d/%d", battle, totalBattle))
- gui.text(236, 36, string.format("%dsei", Hiraga))
- local jump
- local battle16 = battle % 0x10
- if EP >= battle16 then
- if battle < 0x30 then
- jump = battle16 + 0x30
- else
- jump = battle
- end
- --~ gui.text(230, 68, string.format("jump%d", jump))
- --~ gui.text(218, 76, string.format("tBtl%d->%d", totalBattle, totalBattle + math.floor(jump/4)))
- --~ gui.text(216, 84, string.format("%dsei->%dsei", Hiraga, Hiraga + math.floor((jump/0x20) + (1/2))))
- end
- end
- rngMod = {}
- rngModCol = {}
- function rngMOD(x) -- for computing SP
- for i = 0, 0xFF do
- rngMod[i+1] = (rng[i+1] % x)
- end
- end
- rngCol = {}
- for i = 0, 0xFF do
- residue20 = (rng[i+1] % 0x20)
- residue40 = (rng[i+1] % 0x40)
- if residue20 == 0 then -- normal drop
- rngCol[i+1] = light_green
- elseif rng[i+1] < 0x1F then -- waza 7
- rngCol[i+1] = pink
- elseif rng[i+1] < 0x32 then -- waza same level
- rngCol[i+1] = yellow
- else
- rngCol[i+1] = white
- end
- if residue40 == 0 then -- rare drop
- rngCol[i+1] = blue
- end
- end
- function rngDisp()
- for j = 0, 0xF do
- for i = 0, 0xF do
- gui.text(32+i*12, 26+j*12, string.format("%2X", rng[1+i+0x10*j]), rngCol[1+i+0x10*j])
- end
- end
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.box(31-1+(currentRNG-16*math.floor(currentRNG/16))*12, 24+12*math.floor(currentRNG/16), 32-1+(currentRNG-16*math.floor(currentRNG/16))*12+9, 24+12*math.floor(currentRNG/16)+10, clear, yellow)
- end
- function rngDispMod()
- for j = 0, 0xF do
- for i = 0, 0xF do
- gui.text(32+i*12, 26+j*12, string.format("%2X", rngMod[1+i+0x10*j]), rngModCol[1+i+0x10*j])
- end
- end
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.box(31-1+(currentRNG-16*math.floor(currentRNG/16))*12, 24+12*math.floor(currentRNG/16), 32-1+(currentRNG-16*math.floor(currentRNG/16))*12+9, 24+12*math.floor(currentRNG/16)+10, clear, yellow)
- end
- function dispRNG2()
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- local countSP = 0
- for i = 1, numParty do
- gotSP[i] = memory.readbyte(0x7E0DD7 + (i-1))
- if gotSP[i] == 0 then
- countSP = countSP + 1
- end
- end
- if countSP == numParty or comSelect > numParty then
- rngDisp()
- end
- end
- function rngBar(n) -- n = 1 or 3
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.drawrect(128, 223-math.floor(rng[currentRNG+1]/8), 128+2*n, 223, rngCol[currentRNG+1], black)
- for i=0, 60/n do
- local k = (currentRNG+i+1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(130+i*2*n, 223-math.floor(rng[k]/8), 130+i*2*n+2*n, 223, rngCol[k], black)
- end
- for j=0, 63/n do
- local k = (currentRNG-j-1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(126-j*2*n, 223-math.floor(rng[k]/8), 126-j*2*n+2*n, 223, rngCol[k], black)
- end
- gui.drawrect(130, 176, 130+n-1, 176+48, light_green, light_green)
- gui.text(134,176,string.format("%2X->%2X", currentRNG, rng[currentRNG+1]), light_green)
- end
- gotSP = {}
- function dispRNGBar2()
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- local countSP = 0
- for i = 1, numParty do
- gotSP[i] = memory.readbyte(0x7E0DD7 + (i-1))
- if gotSP[i] == 0 then
- countSP = countSP + 1
- end
- end
- if countSP == numParty or comSelect > numParty then
- rngBar(1)
- end
- end
- agility = {}
- SP = {}
- SPCol = {}
- function getAgi()
- for i = 1, 5 do
- agility[i] = memory.readbyte(0x7EAA65+0x0100*(i-1))
- SP[i] = {}
- SPCol[i] = {}
- for j = 0, 0xFF do
- SP[i][j+1] = (agility[i])*2 + math.mod(rng[1+(j)], ((agility[i])*2)) + 1
- if (SP[i][j+1] > math.floor( agility[i] * (7/2)) ) then
- SPCol[i][j+1] = aqua
- elseif (SP[i][j+1] < math.floor( agility[i] * 5/2) ) then
- SPCol[i][j+1] = pink
- else
- SPCol[i][j+1] = white
- end
- end
- end
- end
- function dispSP()
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect >= 0 and comSelect < numParty then
- for j = 0, 0xF do
- for i = 0, 0xF do
- gui.text(32+i*12, 26+j*12, string.format("%2d", SP[comSelect+1][1+i+0x10*j]), SPCol[comSelect+1][1+i+0x10*j])
- end
- end
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.box(31-1+(currentRNG-16*math.floor(currentRNG/16))*12, 24+12*math.floor(currentRNG/16), 32-1+(currentRNG-16*math.floor(currentRNG/16))*12+9, 24+12*math.floor(currentRNG/16)+10, clear, yellow)
- end
- end
- gotSP = {}
- valueSP = { 0, 0, 0, 0, 0 }
- function gottenSP()
- local comSelect = memory.readbyte(0x7E0D1A)
- for i = 1, comSelect do
- gotSP[i] = memory.readbyte(0x7E0DD7 + (i-1))
- if gotSP[i] ~= 0 then
- valueSP[i] = gotSP[i]
- end
- end
- local numParty = memory.readbyte(0x7EF618)
- if countSP ~= numParty then
- if comSelect >= 0 and comSelect < numParty+1 then
- for i = 1, comSelect do
- gui.text(240, 172+(i-1)*8, string.format("%3d", valueSP[i]))
- end
- end
- end
- end
- local comparisonSP = 0
- function compSP(x)
- gottenSP()
- local numParty = memory.readbyte(0x7EF618)
- if x == 1 then
- for i = 2, numParty do
- if valueSP[1] < valueSP[i] then
- comparisonSP = comparisonSP + 1
- end
- end
- elseif x ~= 1 and x ~= numParty then
- for i = 1, x-1 do
- if valueSP[x] <= valueSP[i] then
- comparisonSP = comparisonSP + 1
- end
- end
- for i = x+1, numParty do
- if valueSP[x] < valueSP[i] then
- comparisonSP = comparisonSP + 1
- end
- end
- elseif x == numParty then
- for i = 1, x-1 do
- if valueSP[x] <= valueSP[i] then
- comparisonSP = comparisonSP + 1
- end
- end
- end
- end
- function gottenSPcoerce()
- local numParty = memory.readbyte(0x7EF618)
- for i = 1, numParty do
- gotSP[i] = memory.readbyte(0x7E0DD7 + (i-1))
- if gotSP[i] ~= 0 then
- valueSP[i] = gotSP[i]
- end
- end
- end
- function SPBar(n, a)
- local currentRNG = memory.readbyte(0x7E0D1F)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect >= 0 and comSelect < numParty then
- if currentRNG == 0xFF then
- currentRNG = 0
- end
- gui.drawrect(128, 223-math.floor(SP[comSelect+1][currentRNG+1]/a), 128+2*n, 223, SPCol[comSelect+1][currentRNG+1], black)
- local currentRNG = memory.readbyte(0x7E0D1F)
- for i=0, 60/n do
- k = (currentRNG+i+1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(130+i*2*n, 223-math.floor(SP[comSelect+1][k]/a), 130+i*2*n+2*n, 223, SPCol[comSelect+1][k], black)
- end
- for j=0, 63/n do
- k = (currentRNG-j-1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(126-j*2*n, 223-math.floor(SP[comSelect+1][k]/a), 126-j*2*n+2*n, 223, SPCol[comSelect+1][k], black)
- end
- gui.drawrect(130, 176, 130+n-1, 176+48, light_green, light_green)
- local comSelect = memory.readbyte(0x7E0D1A)
- numParty = memory.readbyte(0x7EF618)
- if comSelect >= 0 and comSelect < numParty then
- if currentRNG == 0xFF then
- currentRNG = 0
- end
- end
- gui.text(134,176,string.format("%2X->%2d", currentRNG, SP[comSelect+1][currentRNG+1]), light_green)
- end
- end
- SPTest = {}
- SPTestCol = {}
- function getTestAgi(x)
- local agilityTest = x
- for j = 0, 0xFF do
- SPTest[j+1] = (agilityTest)*2 + math.mod(rng[1+(j)], ((agilityTest)*2)) + 1
- if (SPTest[j+1] > math.floor( agilityTest * (7/2)) ) then
- SPTestCol[j+1] = aqua
- elseif (SPTest[j+1] < math.floor( agilityTest * 5/2) ) then
- SPTestCol[j+1] = pink
- else
- SPTestCol[j+1] = white
- end
- end
- end
- function dispTestSP()
- for j = 0, 0xF do
- for i = 0, 0xF do
- gui.text(32+i*12, 26+j*12, string.format("%2d", SPTest[1+i+0x10*j]), SPTestCol[1+i+0x10*j])
- end
- end
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.box(31-1+(currentRNG-16*math.floor(currentRNG/16))*12, 24+12*math.floor(currentRNG/16), 32-1+(currentRNG-16*math.floor(currentRNG/16))*12+9, 24+12*math.floor(currentRNG/16)+10, clear, yellow)
- end
- function SPTestBar(n, a)
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.drawrect(128, 223-math.floor(SPTest[currentRNG+1]/a), 128+2*n, 223, SPTestCol[currentRNG+1], black)
- for i=0, 60/n do
- local k = (currentRNG+i+1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(130+i*2*n, 223-math.floor(SPTest[k]/a), 130+i*2*n+2*n, 223, SPTestCol[k], black)
- end
- for j=0, 63/n do
- local k = (currentRNG-j-1+1) % 0x100
- if k == 0 then
- k = 0x100
- end
- gui.drawrect(126-j*2*n, 223-math.floor(SPTest[k]/a), 126-j*2*n+2*n, 223, SPTestCol[k], black)
- end
- gui.drawrect(130, 176, 130+n-1, 176+48, light_green, light_green)
- gui.text(134,176,string.format("%2X->%2d", currentRNG, SPTest[currentRNG+1]), light_green)
- end
- local gameMode
- function gMode()
- gameMode = memory.readbyte(0x7FAFC7)
- end
- function getBtlParameter()
- gMode()
- if gameMode == 1 then
- getAgi()
- dispRNGBar2()
- SPBar(1, 4)
- dispRNG2()
- dispSP()
- dispComSelect()
- gottenSP()
- getEnemyData()
- dispEnemyData()
- end
- dispCurrentRNG()
- end
- function getBtlParameter2()
- gMode()
- if gameMode == 1 then
- getAgi()
- rngBar(1)
- rngDisp()
- dispComSelect()
- gottenSP()
- getEnemyData()
- dispEnemyData()
- end
- dispCurrentRNG()
- end
- sel = 0
- ipg0 = {}
- ipg1 = {}
- function selAdd()
- gMode()
- ipg1 = joypad.get(1)
- if gameMode == 1 and ipg0.select == false and ipg1.select == true then
- sel = sel + 1
- end
- ipg0 = joypad.get(1)
- end
- function dispBtlParameter()
- if (sel % 2) == 0 then
- getBtlParameter()
- else
- getBtlParameter2()
- end
- end
- local waza = {}
- function getWaza()
- for i = 1, 5 do
- waza[i] = {}
- for j = 1, 8 do
- waza[i][j] = memory.readbyte(0x7EAA3D + 0x100*(i-1) + (j-1))
- end
- end
- end
- local newWaza = {}
- function getNewWaza()
- for i = 1, 5 do
- newWaza[i] = {}
- for j = 1, 8 do
- newWaza[i][j] = memory.readbyte(0x7EAA3D + 0x100*(i-1) + (j-1))
- end
- end
- end
- HP = {}
- function getHP()
- for i = 1, 5 do
- HP[i] = memory.readword(0x7EAA0E + 0x100*(i-1))
- end
- end
- condA = {}
- condB = {}
- condC = {}
- eCond = {}
- function getCondition()
- for i = 1, 5 do
- condA[i] = memory.readbyte(0x7EAA04 + 0x100*(i-1))
- condB[i] = memory.readbyte(0x7EAA05 + 0x100*(i-1))
- condC[i] = memory.readbyte(0x7EAA06 + 0x100*(i-1))
- end
- for j = 1, 3 do
- eCond[j] = memory.readbyte(0x7EA004 + (j-1))
- end
- end
- local expHP = {}
- function getExpHP()
- for i = 1, 5 do
- expHP[i] = memory.readbyte(0xF068 + (i-1)*0x100)
- end
- end
- local item ={}
- function getItem()
- for i=1, 32 do
- item[i] = memory.readbyte(0x7EF621 + (i-1)*2)
- end
- end
- local newItem ={}
- function getNewItem()
- for i=1, 32 do
- newItem[i] = memory.readbyte(0x7EF621 + (i-1)*2)
- end
- end
- local numItem = {}
- function getNumItem()
- for j = 1, 32 do
- numItem[j] = memory.readbyte(0x7EF622 + (j-1)*2)
- end
- end
- local numNewItem = {}
- function getNumNewItem()
- for j = 1, 32 do
- numNewItem[j] = memory.readbyte(0x7EF622 + (j-1)*2)
- end
- end
- eHP = {}
- eMHP = {}
- eAgi = {}
- eEXP = {}
- eWaza={}
- monsID = {}
- local monNum
- function getEnemyData()
- monNum = memory.readbyte(0x7E0D22)
- --for i=1, monNum do
- for i=1, 6 do
- eHP[i] = memory.readword(0x7EA00E+0x100*(i-1))
- eMHP[i] = memory.readbyte(0x7EA010+0x100*(i-1))
- eAgi[i] = memory.readbyte(0x7EA065 + 0x100*(i-1))
- eWaza[i] = memory.readbyte(0x7EA018 + 0x100*(i-1))
- monsID[i] = memory.readword(0x7E1203 + 0x5*(i))
- end
- end
- eHP2 = {}
- function getEHP2()
- monNum = memory.readbyte(0x7E0D22)
- for i=1, 6 do
- eHP2[i] = memory.readword(0x7EA00E+0x100*(i-1))
- end
- end
- function dispEnemyData()
- monNum = memory.readbyte(0x7E0D22)
- getEnemyData()
- if monNum > 6 then
- monNum = 6
- end
- for i=1, monNum do
- gui.text(222, 100 + 8*(i-1), string.format("%2d", eHP[i]))
- gui.text(2, 100+8*(i-1), string.format("%d", eAgi[i]))
- gui.text(244, 100 + 8*(i-1), string.format("%2d", eWaza[i]))
- end
- end
- function chkMons(x)
- if eWaza[x] ~= 0xFF then
- return true
- end
- end
- function chkMonsID(x)
- if monsID[x] >= 0 and monsID[x] <= 0x133 then
- return true
- else
- return false
- end
- end
- function killCount()
- getEnemyData()
- local deathCount = 0
- for i=1, monNum do
- if eHP[i] == 0 then
- deathCount = deathCount + 1
- end
- end
- return deathCount
- end
- function killCountAlly()
- local numParty = memory.readbyte(0x7EF618)
- getHP()
- deathCountAlly = 0
- for i = 1, numParty do
- if HP[i] == 0 then
- deathCountAlly = deathCountAlly + 1
- end
- end
- return deathCountAlly
- end
- local btlOn = 1
- local lastStart = 0
- local lastEnd = 0
- function btlEnd()
- local gameMode = memory.readbyte(0x7FAFC7)
- local t = emu.framecount()
- if btlOn ~= gameMode and gameMode ~= 1 then
- lastEnd = t
- btlTime = lastEnd - lastStart
- print(string.format("btlEnd %d, btlTime %d", t, btlTime))
- end
- if btlOn ~= gameMode and gameMode ~= 0 then
- lastStart = t
- print(string.format("btlStart %d", t))
- end
- btlOn = gameMode
- end
- take = 0
- function skip(x)
- while x > 0 do
- emu.frameadvance()
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.text(4,32, string.format("take %3d", take))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- x = x-1
- end
- end
- function skips(x)
- while x > 0 do
- emu.frameadvance()
- x = x-1
- end
- end
- function AB(x)
- while x>0 do
- joypad.set({A=1}, 1)
- skips(20)
- joypad.set({B=1}, 1)
- skips(20)
- x = x-1
- end
- currentRNG = memory.readbyte(0x7E0D1F)
- print(string.format("RNG %X", currentRNG))
- emu.pause()
- end
- function ABtil(x)
- local currentRNG = memory.readbyte(0x7E0D1F)
- while currentRNG ~= x do
- joypad.set({A=1}, 1)
- skips(20)
- joypad.set({B=1}, 1)
- skips(20)
- currentRNG = memory.readbyte(0x7E0D1F)
- end
- print(string.format("RNG %X", currentRNG))
- emu.pause()
- end
- function ABnonStop(x)
- while x>0 do
- joypad.set({A=1}, 1)
- skips(20)
- joypad.set({B=1}, 1)
- skips(20)
- x = x-1
- end
- end
- function btlCommand(left, right, up, down, R, A)
- if left > 0 then
- for i = 1, left do
- joypad.set({left=1}, 1)
- skip(20)
- end
- end
- if right > 0 then
- for i = 1, right do
- joypad.set({right=1}, 1)
- skip(20)
- end
- end
- if up > 0 then
- for i = 1, up do
- joypad.set({up=1}, 1)
- skip(20)
- end
- end
- if down > 0 then
- for i = 1, down do
- joypad.set({down=1}, 1)
- skip(20)
- end
- end
- if R == 1 then
- joypad.set({R=1}, 1)
- skip(20)
- end
- if A == 1 then
- joypad.set({A=1}, 1)
- end
- if A == 2 then
- joypad.set({A=1}, 1)
- skip(20)
- joypad.set({A=1}, 1)
- end
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect ~= numParty - 1 then
- skip(60)
- end
- end
- function btlComOnlyMov(left, right, up, down)
- if left > 0 then
- for i = 1, left do
- joypad.set({left=1}, 1)
- skip(20)
- end
- end
- if right > 0 then
- for i = 1, right do
- joypad.set({right=1}, 1)
- skip(20)
- end
- end
- if up > 0 then
- for i = 1, up do
- joypad.set({up=1}, 1)
- skip(20)
- end
- end
- if down > 0 then
- for i = 1, down do
- joypad.set({down=1}, 1)
- skip(20)
- end
- end
- joypad.set({A=1}, 1)
- skip(20)
- end
- function attack()
- joypad.set({A=1}, 1)
- skip(20)
- joypad.set({A=1}, 1)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect ~= numParty - 1 then
- skip(60)
- end
- end
- function attackALL()
- joypad.set({A=1}, 1)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect ~= numParty - 1 then
- skip(60)
- end
- end
- function defence()
- joypad.set({R=1}, 1)
- skip(20)
- joypad.set({A=1}, 1)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- if comSelect ~= numParty - 1 then
- skip(60)
- end
- end
- local numParty
- function dispComSelect()
- local comSelect = memory.readbyte(0x7E0D1A)
- local currentRNG = memory.readbyte(0x7E0D1F)
- local numParty = memory.readbyte(0x7EF618)
- if numParty < 6 then
- if comSelect >=0 and comSelect < numParty then
- gui.text(228, 164, string.format("%2X->%2d", currentRNG, SP[comSelect+1][currentRNG+1]), SPCol[comSelect+1][currentRNG+1])
- end
- end
- end
- local Xpos
- local Ypos
- function playerPos()
- Xpos = memory.readbyte(0x7E1342)
- Ypos = memory.readbyte(0x7E13D6)
- gui.text(228, 4, string.format("(%X,%X)", Xpos, Ypos))
- end
- function dispChiretsugeki()
- local chiretsugeki = memory.readbyte(0x7E0D80)
- gui.text(228, 140, string.format("chi %d", chiretsugeki))
- end
- function dispCurrentRNG()
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.text(228, 148, string.format("%2X->%2X", currentRNG, rng[currentRNG+1]), yellow)
- local preRNG = (currentRNG-1) % 0x100
- gui.text(228, 156, string.format("%2X->%2X", preRNG, rng[preRNG+1]), gray)
- end
- local take = 0
- function encParty(direction)
- function skip(x)
- while x > 0 do
- emu.frameadvance()
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.text(4,32, string.format("take %3d", take))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- x = x-1
- end
- end
- print("Script start ! ")
- label = string.format("tBtl\ttake\tinitial RNG\tmonNum\teHP[1]\teHP[2]\teHP[3]\teHP[4]\teHP[5]\teHP[6]\tfinal RNG")
- print(label)
- emu.speedmode("turbo")
- save = savestate.create()
- savestate.save(save)
- savestate.load(save)
- while take < 0x102 do
- joypad.set({A=1}, 1)
- skip(100)
- --1 run
- joypad.set({L=1}, 1)
- skip(20)
- joypad.set({A=1}, 1)
- skip(10)
- local currentRNG = memory.readbyte(0x7E0D1F)
- for i = 1, 391 do
- if direction == "up" then
- joypad.set({up=1}, 1)
- elseif direction == "down" then
- joypad.set({down=1}, 1)
- elseif direction == "left" then
- joypad.set({left=1}, 1)
- elseif direction == "right" then
- joypad.set({right=1}, 1)
- end
- emu.frameadvance()
- end
- getEnemyData()
- local endRNG = memory.readbyte(0x7E0D1F)
- local tBtl = memory.readbyte(0x7EF8AE)
- local monNum = memory.readbyte(0x7E0D22)
- local result = string.format("%d\t%d\t%X\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%X", tBtl, take, currentRNG, monNum, eHP[1], eHP[2], eHP[3], eHP[4], eHP[5], eHP[6], endRNG)
- --if (eHP[2] >1000 and eHP[2] < 2000) then -- for NightHead
- print(result)
- --end
- take = take + 1
- savestate.load(save)
- emu.frameadvance()
- savestate.save(save)
- end
- print("Done !")
- emu.pause()
- end
- function chk7HeroForm()
- heroForm = memory.readbyte(0x7E0D64)
- if heroForm == 2 then
- printHero = "Bokuoon"
- elseif heroForm == 3 then
- printHero = "Kujinshii"
- elseif heroForm == 4 then
- printHero = "Wagnus"
- elseif heroForm == 5 then
- printHero = "Dantaagu"
- else
- printHero = "Others"
- end
- end
- function btlSim()
- local take = 0
- function skip(x)
- while x > 0 do
- emu.frameadvance()
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.text(4,32, string.format("take %3d", take))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- x = x-1
- end
- end
- print("Script start ! ")
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- getEHP2()
- getEnemyData()
- preEHP = eHP[1]
- if comSelect == 0 or comSelect == 85 then
- print("Aずらし")
- elseif comSelect == numParty - 1 then
- print("ABC")
- end
- print(action)
- print(label)
- emu.speedmode("turbo")
- --rngDisp()
- save = savestate.create()
- savestate.save(save)
- savestate.load(save)
- while take < 0x102 do
- emu.frameadvance()
- local currentRNG = memory.readbyte(0x7E0D1F)
- local initialFr = emu.framecount()
- local comSelect = memory.readbyte(0x7E0D1A)
- --~ if comSelect == 0 or comSelect == 85 then
- if comSelect == 0 or comSelect == 85 or comSelect == 5 then
- joypad.set({A=1}, 1)
- skip(100)
- --1
- --~ btlCommand(0, 0, 1, 0, 0, 2)
- --~ btlComOnlyMov(0, 0, 0, 1)
- --~ attackALL()
- attack()
- --~ defence()
- --2
- --~ btlCommand(1, 0, 1, 0, 0, 2)
- --~ attack()
- --~ btlComOnlyMov(0, 1, 0, 0)
- defence()
- --3 taiken
- --~ btlCommand(1, 0, 0, 1, 0, 2)
- --~ btlComOnlyMov(0, 1, 0, 0)
- defence()
- --~ attack()
- --4
- --~ btlCommand(2, 0, 1, 0, 0, 2)
- --~ attack()
- defence()
- end
- --5
- --~ btlCommand(1, 0, 0, 1, 0, 2)
- --~ defence()
- attack()
- getWaza()
- getItem()
- getNumItem()
- for i = 1, 30 do
- getAgi()
- gottenSP()
- getHP()
- emu.frameadvance()
- end
- local startHP = {}
- for i = 1, 5 do
- startHP[i] = HP[i]
- end
- local comparisonSP = 0
- compSP(1)
- local numParty = memory.readbyte(0x7EF618)
- local comSelect = numParty
- local chiretsugeki = memory.readbyte(0x7E0D80)
- local gameMode = memory.readbyte(0x7FAFC7)
- local chkHP = 0
- local chkHP1 = 0
- local chkHP3 = 0
- local dC = 0
- local reverse = 0
- local chkEHP = 0
- while gameMode == 1 and comSelect == numParty do
- --~ while gameMode == 1 and comSelect == numParty and dC < 2 and reverse == 0 do
- --~ while gameMode == 1 and comSelect == numParty and dC < 2 do
- gui.text(4,32, string.format("take %3d", take))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- emu.frameadvance()
- gui.text(4,32, string.format("take %3d", take))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- joypad.set({A=1}, 1)
- emu.frameadvance()
- comSelect = memory.readbyte(0x7E0D1A)
- gameMode = memory.readbyte(0x7FAFC7)
- getHP()
- --~ for i = 1, numParty do
- --~ if startHP[i] > HP[i] then
- --~ chkHP = chkHP + 1
- --~ end
- --~ end
- if startHP[1] > HP[1] then
- chkHP1 = chkHP1 + 1
- end
- if startHP[3] > HP[3] then
- chkHP3 = chkHP3 + 1
- end
- dC = killCountAlly()
- getEnemyData()
- if preEHP < eHP[1] then
- reverse = reverse + 1
- end
- if preEHP < 6000 and eHP[1] == 6000 then
- chkEHP = chkEHP + 1
- end
- preEHP = eHP[1]
- preEHP = eHP[1]
- end
- local t = emu.framecount()
- local time = t - initialFr
- getEnemyData()
- getNewWaza()
- getNewItem()
- getNumNewItem()
- getHP()
- getAgi()
- getCondition()
- chk7HeroForm()
- local printWaza = {}
- local wazaCount = 0
- for i = 1, 5 do
- printWaza[i] = 0xFF
- for j = 1, 8 do
- if newWaza[i][j] ~= waza[i][j] then
- printWaza[i] = newWaza[i][j]
- wazaCount = wazaCount + 1
- --~ break
- end
- end
- end
- local printItem = 0xFF
- local itemCount = 0
- for i = 1, 32 do
- if newItem[i] ~= item[i] then
- printItem = newItem[i]
- itemCount = itemCount + 1
- end
- end
- local printNumItem = 0
- local itemNumCount = 0
- for i = 1, 32 do
- if numNewItem[i] ~= numItem[i] then
- printNumItem = newItem[i]
- itemNumCount = itemNumCount + 1
- end
- end
- damage = {}
- for i = 1, monNum do
- damage[i] = eHP2[i]-eHP[i]
- end
- local chiretsugeki = memory.readbyte(0x7E0D80)
- local deathCount = killCount()
- local endRNG = memory.readbyte(0x7E0D1F)
- local muddleCount = 0
- for i = 1, numParty do
- if condA[i] == 0x01 then
- muddleCount = muddleCount + 1
- end
- end
- local result = string.format("%d\t%X\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%X\t%X\t%X\t%X\t%X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%d\t%X\t%d\t%d\t%d\t%d\t%X", take, currentRNG, initialFr, printHero, chkEHP, eHP[1], dC, HP[1], HP[2], HP[3], HP[4], HP[5], valueSP[1], valueSP[2], valueSP[3], valueSP[4], valueSP[5], wazaCount, printWaza[1], printWaza[2], printWaza[3], printWaza[4], printWaza[5], condA[1], condB[1], condC[1], condA[2], condB[2], condC[2], condA[3], condB[3], condC[3], condA[4], condB[4], condC[4], condA[5], condB[5], condC[5], reverse, endRNG, t, time, damage[1], printNumItem, printItem)
- local MeiRyoku = memory.readbyte(0x7EA064)
- dC = killCountAlly()
- --~ if (wazaCount ~= 0 or dC < 2) and wazaCount ~= 40 then
- --~ if ((wazaCount ~= 0 or dC < 2) and wazaCount ~= 40) or killCount == 1 then
- --~ if wazaCount ~= 40 and (wazaCount ~= 0 or killCount == 1) then
- print(result)
- --~ end
- take = take + 1
- savestate.load(save)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- getEnemyData()
- preEHP = eHP[1]
- local reverse = 0
- if comSelect == numParty - 1 then
- emu.frameadvance()
- ABnonStop(1)
- end
- emu.frameadvance()
- savestate.save(save)
- end
- print("Done !")
- emu.pause()
- end
- function btlStart(n)
- take = 1
- print("Script start ! ")
- emu.speedmode("turbo")
- local currentRNG = memory.readbyte(0x7E0D1F)
- local N = n-4-currentRNG
- if N < 0 then
- N = N + 0x100 - 1
- end
- totalTake = (N+4)*(N+3)*(N+2)*(N+1)/24 -- max: 180352320
- print(string.format("total Take\t%d\t%2X/%2X", totalTake, currentRNG, n))
- print(action)
- print(label2)
- for a = 0, N do
- for b = 0, N-a do
- for c = 0, N-a-b do
- for d = 0, N-a-b-c do
- e = N-a-b-c-d
- btlSim2(a, b, c, d, e)
- end
- end
- end
- end
- print("Done !")
- emu.pause()
- end
- function btlSim2(a, b, c, d, e)
- function skip(x)
- while x > 0 do
- emu.frameadvance()
- local currentRNG = memory.readbyte(0x7E0D1F)
- gui.text(4,32, string.format("take %3d/%d (%d, %d, %d, %d, %d)", take, totalTake, a, b, c, d, e))
- gui.text(12,44, string.format("RNG %2X", currentRNG))
- x = x-1
- end
- end
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- getEHP2()
- getEnemyData()
- preEHP = eHP[1]
- --rngDisp()
- save = savestate.create()
- savestate.save(save)
- savestate.load(save)
- emu.frameadvance()
- local comSelect = memory.readbyte(0x7E0D1A)
- local initialFr = emu.framecount()
- --1
- local firstRNG = memory.readbyte(0x7E0D1F)
- ABnonStop(a)
- --~ btlCommand(2, 0, 0, 1, 0, 2)
- --~ btlComOnlyMov(0, 2, 0, 1)
- --~ attackALL()
- attack()
- --~ defence()
- --2
- ABnonStop(b)
- btlCommand(0, 1, 0, 0, 0, 2)
- --~ attack()
- --~ btlComOnlyMov(0, 1, 0, 0)
- --~ defence()
- --3
- skip(10)
- ABnonStop(c)
- btlCommand(0, 0, 1, 0, 0, 2)
- --~ btlComOnlyMov(0, 1, 0, 0)
- --~ defence()
- --~ attack()
- --4
- ABnonStop(d)
- --~ btlCommand(0, 2, 1, 0, 0, 2)
- attack()
- --~ defence()
- --5
- ABnonStop(e)
- local currentRNG = memory.readbyte(0x7E0D1F)
- btlCommand(1, 0, 0, 0, 0, 2)
- --~ defence()
- --~ attack()
- getWaza()
- getItem()
- getNumItem()
- for i = 1, 30 do
- getAgi()
- gottenSP()
- getHP()
- emu.frameadvance()
- end
- local startHP = {}
- for i = 1, 5 do
- startHP[i] = HP[i]
- end
- local comparisonSP = 0
- compSP(1)
- local numParty = memory.readbyte(0x7EF618)
- local comSelect = numParty
- local chiretsugeki = memory.readbyte(0x7E0D80)
- local gameMode = memory.readbyte(0x7FAFC7)
- local chkHP = 0
- local chkHP1 = 0
- local chkHP3 = 0
- local dC = 0
- local reverse = 0
- local chkEHP = 0
- while gameMode == 1 and comSelect == numParty do
- --~ while gameMode == 1 and comSelect ~= 0 do
- --~ while gameMode == 1 and comSelect == numParty and dC < 2 and reverse == 0 do
- --~ while gameMode == 1 and comSelect == numParty and dC < 2 do
- gui.text(4,32, string.format("take %3d/%d (%d, %d, %d, %d, %d)", take, totalTake, a, b, c, d, e))
- gui.text(12,44, string.format("RNG %2X/%2X", firstRNG, currentRNG))
- emu.frameadvance()
- gui.text(4,32, string.format("take %3d/%d (%d, %d, %d, %d, %d)", take, totalTake, a, b, c, d, e))
- gui.text(12,44, string.format("RNG %2X/%2X", firstRNG, currentRNG))
- joypad.set({A=1}, 1)
- emu.frameadvance()
- comSelect = memory.readbyte(0x7E0D1A)
- gameMode = memory.readbyte(0x7FAFC7)
- getHP()
- --~ for i = 1, numParty do
- --~ if startHP[i] > HP[i] then
- --~ chkHP = chkHP + 1
- --~ end
- --~ end
- if startHP[1] > HP[1] then
- chkHP1 = chkHP1 + 1
- end
- if startHP[3] > HP[3] then
- chkHP3 = chkHP3 + 1
- end
- dC = killCountAlly()
- getEnemyData()
- if preEHP < eHP[1] then
- reverse = reverse + 1
- end
- if preEHP < 6000 and eHP[1] == 6000 then
- chkEHP = chkEHP + 1
- end
- preEHP = eHP[1]
- end
- local t = emu.framecount()
- local time = t - initialFr
- getEnemyData()
- getNewWaza()
- getNewItem()
- getNumNewItem()
- getHP()
- getAgi()
- getCondition()
- chk7HeroForm()
- local printWaza = {}
- local wazaCount = 0
- for i = 1, 5 do
- printWaza[i] = 0xFF
- for j = 1, 8 do
- if newWaza[i][j] ~= waza[i][j] then
- printWaza[i] = newWaza[i][j]
- wazaCount = wazaCount + 1
- --~ break
- end
- end
- end
- local printItem = 0xFF
- local itemCount = 0
- for i = 1, 32 do
- if newItem[i] ~= item[i] then
- printItem = newItem[i]
- itemCount = itemCount + 1
- end
- end
- local printNumItem = 0
- local itemNumCount = 0
- for i = 1, 32 do
- if numNewItem[i] ~= numItem[i] then
- printNumItem = newItem[i]
- itemNumCount = itemNumCount + 1
- end
- end
- damage = {}
- for i = 1, monNum do
- damage[i] = eHP2[i]-eHP[i]
- end
- local chiretsugeki = memory.readbyte(0x7E0D80)
- local deathCount = killCount()
- local endRNG = memory.readbyte(0x7E0D1F)
- local muddleCount = 0
- for i = 1, numParty do
- if condA[i] == 0x01 then
- muddleCount = muddleCount + 1
- end
- end
- local MeiRyoku = memory.readbyte(0x7EA064)
- dC = killCountAlly()
- local result = string.format("%d\t%2X\t%d\t%d\t%d\t%d\t%d\t%X\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%X\t%X\t%X\t%X\t%X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%02X%02X%02X\t%d\t%X\t%d\t%d\t%d\t%d\t%X", take, firstRNG, a, b, c, d, e, currentRNG, initialFr, printHero, chkEHP, eHP[1], dC, HP[1], HP[2], HP[3], HP[4], HP[5], valueSP[1], valueSP[2], valueSP[3], valueSP[4], valueSP[5], wazaCount, printWaza[1], printWaza[2], printWaza[3], printWaza[4], printWaza[5], condA[1], condB[1], condC[1], condA[2], condB[2], condC[2], condA[3], condB[3], condC[3], condA[4], condB[4], condC[4], condA[5], condB[5], condC[5], reverse, endRNG, t, time, damage[1], printNumItem, printItem)
- --~ if (wazaCount ~= 0 or dC < 2) and wazaCount ~= 40 then
- --~ if ((wazaCount ~= 0 or dC < 2) and wazaCount ~= 40) or killCount == 1 then
- print(result)
- --~ end
- take = take + 1
- savestate.load(save)
- local comSelect = memory.readbyte(0x7E0D1A)
- local numParty = memory.readbyte(0x7EF618)
- getEnemyData()
- preEHP = eHP[1]
- local reverse = 0
- if comSelect == numParty - 1 then
- emu.frameadvance()
- ABnonStop(1)
- end
- emu.frameadvance()
- savestate.save(save)
- end
- function chkInitialHP()
- local take = 0
- print("Script start !")
- print("take\tレオン\tジェラール\tベア\tジェイムズ\tテレーズ")
- local HP = {}
- local function getInitialHP()
- for i = 1, 5 do
- HP[i] = memory.readword(0x7EF010 + 0x100*(i-1))
- end
- end
- emu.speedmode("turbo")
- save = savestate.create()
- savestate.save(save)
- savestate.load(save)
- while take < 0x102 do
- gui.text(4, 32, string.format("take %3d", take))
- joypad.set({start=1}, 1)
- emu.frameadvance()
- getInitialHP()
- while HP[5] == 0 do
- emu.frameadvance()
- gui.text(4, 32, string.format("take %3d", take))
- getInitialHP()
- end
- --~ if HP[3] > 79 then
- print(string.format("%d\t%d\t%d\t%d\t%d\t%d", take, HP[1], HP[2], HP[3], HP[4],HP[5]))
- --~ emu.pause()
- --~ end
- take = take + 1
- savestate.load(save)
- emu.frameadvance()
- savestate.save(save)
- end
- print("Done !")
- emu.pause()
- end
- function makeSaves(x, y)
- t = emu.framecount()
- for i = 1, 10 do
- if t == x + y*i then
- save = savestate.create(i)
- savestate.save(save)
- print("Saved at "..t.."f.")
- end
- end
- if t >= x + y*10 then
- emu.frameadvance()
- pause(x + y*9)
- end
- end
- function pause(x)
- local t = emu.framecount()
- if t >= x-1 then
- t = t+1
- print("Paused at "..t.."f.")
- emu.pause()
- end
- end
- defP = {}
- function getDefP()
- for i = 1, 5 do
- defP[i] = {}
- for j = 1, 8 do
- defP[i][j] = memory.readbyte(0x7EF055 + 0x100*(i-1) + j-1) -- joined order
- --~ defP[i][j] = memory.readbyte(0x7EAA55 + 0x100*(i-1) + j-1) -- order in battles
- end
- end
- end
- function dispDefP()
- local x = 58
- local y = 60
- local gap = 10
- gui.text(x, y, "sword")
- gui.text(x, y+gap, "axe")
- gui.text(x, y+gap*2, "spear")
- gui.text(x, y+gap*3, "arrow")
- gui.text(x, y+gap*4, "heat")
- gui.text(x, y+gap*5, "cold")
- gui.text(x, y+gap*6, "elec")
- gui.text(x, y+gap*7, "spirit")
- getDefP()
- for i = 1, 5 do
- for j = 1, 8 do
- gui.text(x+20+24*i, y+gap*(j-1), defP[i][j])
- end
- end
- end
- while true do
- --~ makeSaves(400, 100)
- --~ pause(1500)
- --~ dispDefP()
- playerPos()
- --msg()
- btlEnd()
- getParameter()
- dispParameter()
- --dispChiretsugeki()
- dispCurrentRNG()
- --~ getBtlParameter()
- --~ getBtlParameter2()
- selAdd()
- dispBtlParameter()
- --~ rngMOD(4)
- --~ rngDispMod()
- --~ getTestAgi(16)
- --~ SPTestBar(1, 4)
- --~ dispTestSP()
- --~ AB(0x50)
- --~ ABtil(0xD4)
- --encParty("down")
- action = "nabla\tnabla\tnabla\tnabla\tnabla"
- label = "take\tinitial RNG\tinitial Fr\t七英雄形態\t形態変化数\teHP[1]\t死者数\tあ\tイングリット\tジャンヌ\tパーシアス\tフランクリン\tあSP[1]\tイングリットP[2]\tジャンヌP[3]\tパーシアスP[4]\tPランクリンSP[5]\t新技数\tあ技\tイングリット\tジャンヌ技\tパーシアス技\tフランクリン技\tあ状態\tイングリット状態\tジャンヌ状態\tパーシアス状態\tフランクリン状態\t敵状態\tfinal RNG\tFr\tTime\tダメージ\t既持ドロップ\tドロップ\(new\)"
- --~ btlSim()
- label2 = "take\t皇帝RNG\ta\tb\tc\td\te\t5人目RNG\tinitial Fr\t七英雄形態\t形態変化数\teHP[1]\t死者数\tあ\tイングリット\tジャンヌ\tパーシアス\tフランクリン\tあSP[1]\tイングリットSP[2]\tジャンヌSP[3]\tパーシアスSP[4]\tフランクリンSP[5]\t新技数\tあ技\tイングリット技\tジャンヌ技\tパーシアス技\tフランクリン技\tあ状態\tイングリット状態\tジャンヌ状態\tパーシアス状態\tフランクリン状態\t敵状態\tfinal RNG\tFr\tTime\tダメージ\t既持ドロップ\tドロップ\(new\)"
- -- Wagnus Prism Light (0x01, 0x09, 0x0B, 0x14, 0x22, 0x25, 0x27, 0x34, 0x3B, 0x40, 0x4E, 0x54, 0x55, 0x65, 0x6A, 0x93, 0x94, 0xAC, 0xBC, 0xBD, 0xBE, 0xCB, 0xE0, 0xE2, 0xE3, 0xE6, 0xE7)
- --~ btlStart(0x5E)
- --~ chkInitialHP()
- emu.frameadvance();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement