Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- --------------------------- --
- -- Final Fantasy IV LUA script --
- -- --
- -- By: Pasky13 --
- -- --------------------------- --
- -- Globals
- char_atbm = {0, 0, 0, 0, 0}
- enemy_atbm = {0, 0, 0, 0, 0, 0, 0, 0}
- local function ecords_y(y)
- local ex = bit.lshift(bit.band(y,0x0F),3) +0x0C - 0x16
- return ex
- end
- local function ecords_x(x)
- local ey = bit.rshift(bit.band(x,0xF0),1) + 8 + 0x10
- return ey
- end
- local function drawatb_e(x,y,atb,e)
- gui.box(x-3, y-4, x+17, y-1, 0x00000000, 0x000000FF)
- if atb == 0 then
- enemy_atbm[e] = 0
- gui.box(x-3, y-4, x+17, y-1, 0xFF0000C0, 0000000000)
- else
- if enemy_atbm[e] == 0 then
- enemy_atbm[e] = atb
- end
- gui.box(x-3, y-4, (x-3)+20-((20/enemy_atbm[e])*atb), y-1, 0xFF0000C0, 0000000000)
- gui.text(x-3,y-8, enemy_atb[e] .. "/" .. enemy_atbm[e]) -- KIRCH, originally commented out
- end
- end
- local function drawatb_c(x,y,atb,c)
- gui.box(x-3, y-4, x+17, y-1, 0x00000000, 0x000000FF)
- if atb == 0 then
- char_atbm[c] = 0
- gui.box(x-3, y-4, x+17, y-1, 0x0000FFC0, 0000000000)
- else
- if char_atbm[c] == 0 then
- char_atbm[c] = atb
- end
- gui.box(x-3, y-4, (x-3)+20-((20/char_atbm[c])*atb), y-1, 0xFFFF00C0, 0000000000)
- gui.text(x-3,y-8, character_atb[c] .. "/" .. char_atbm[c]) -- KIRCH, originally commented
- end
- end
- -- For who knows what reason, the data of the characters are not in order, so this fix it
- local function fix(character)
- fix_order = {3, 1, 5, 2, 4}
- return fix_order[character]
- end
- while true do
- character_atb = {}
- character_x = {}
- character_y = {}
- for c=1, 5 do
- character_atb[fix(c)] = memory.readbyte(0x7E2A07 + 0x15*(c-1))
- character_x[fix(c)] = memory.readbyte(0x7EEFC5 + 0x10*(c-1))
- character_y[fix(c)] = memory.readbyte(0x7EEFC6 + 0x10*(c-1))
- end
- enemy_atb = {}
- enemy_cur_hp = {}
- enemy_max_hp = {}
- enemy_xy = {}
- for e=1, 8 do
- enemy_atb[e] = memory.readbyte(0x7E2A70 + 0x15*(e-1))
- enemy_cur_hp[e] = memory.readword(0x7E2287 + 0x80*(e-1))
- enemy_max_hp[e] = memory.readword(0x7E2289 + 0x80*(e-1))
- enemy_xy[e] = memory.readbyte(0x7E29A5 + 0x01*(e-1))
- end
- battle = memory.readbyte(0x7E0201)
- attack = memory.readbyte(0x7E3581) -- normal 00, back 08
- if battle ~= 0x85 then
- for c=1, 5 do
- drawatb_c(character_x[c], character_y[c], character_atb[c], c)
- end
- for e=1, 8 do
- if enemy_cur_hp[e] > 0 then
- gui.text( ecords_x(enemy_xy[e]), ecords_y(enemy_xy[e]), e .. " " .. enemy_cur_hp[e] .. "/" .. enemy_max_hp[e] )
- drawatb_e(ecords_x(enemy_xy[e]), ecords_y(enemy_xy[e]), enemy_atb[e], e)
- end
- end
- else
- for i=1,5 do
- char_atbm[i] = 0
- end
- for i=1,8 do
- enemy_atbm[i] = 0
- end
- end
- snes9x.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement