I've made a few changes to your script:
- Only enemies will be displayed (rather than any object)
- Magic sword power is taken into account
- There is now a damage done field as well as a HP field
- I've made some small tweaks to the damage boost / RNG formula to better match the actual game code
I've yet to work out whether the damage done field (including damage boost) is accurate, and at what time the damage boost is taken during an attack.
--lua script for gens rerecording+lua: http://code.google.com/p/gens-rerecording/
--purpose: HUD in Landstalker (U).
--written by Truncated 2015-05-03.
--
enemy_table = {[0x3C] = "BUBBLE1", [0x3D] = "BUBBLE2", [0x3E] = "BUBBLE3", [0x29] = "SKELETON1",[0x2A] = "SKELETON2",[0x2B] = "SKELETON3",
[0x04] = "ORC1", [0x05] = "ORC2", [0x06] = "ORC3", [0x07] = "WORM1", [0x08] = "WORM2", [0x09] = "WORM3",
[0x17] = "NINJA1", [0x18] = "NINJA2", [0x19] = "NINJA3", [0x1A] = "LIZARD1", [0x1B] = "LIZARD2", [0x1C] = "LIZARD3",
[0x1D] = "SOLDIER1",[0x1E] = "SOLDIER2",[0x1F] = "SOLDIER3",[0x20] = "GHOST1", [0x21] = "GHOST2", [0x22] = "GHOST3",
[0x23] = "MUMMY1", [0x24] = "MUMMY2", [0x25] = "MUMMY3", [0x26] = "UNICORN1", [0x27] = "UNICORN2", [0x28] = "UNICORN3",
[0x2C] = "MIMIC1", [0x2D] = "MIMIC2", [0x2E] = "MIMIC3", [0x36] = "MUSHROOM1",[0x37] = "MUSHROOM2",[0x38] = "MUSHROOM3",
[0x39] = "GIANT1", [0x3A] = "GIANT2", [0x3B] = "GIANT3", [0x81] = "BUBBLE4", [0x82] = "BUBBLE5", [0x83] = "BUBBLE6",
[0x7D] = "BIRD1", [0x7E] = "BIRD2", [0x7F] = "BIRD3", [0x88] = "REAPER1", [0x89] = "REAPER2", [0x8A] = "REAPER3",
[0x8F] = "GHOSTGN1",[0x90] = "GHOSTGN2",[0x91] = "GHOSTGN3",[0x92] = "GOLEM1", [0x93] = "GOLEM2", [0x94] = "GOLEM3",
[0x95] = "SPECTRE1",[0x96] = "SPECTRE2",[0x97] = "SPECTRE3",[0x7C] = "MIR", [0x70] = "DUKE", [0x85] = "ZAK",
[0xA0] = "IFRIT", [0x9D] = "SPINNER1",[0x9F] = "MIRO", [0xA7] = "S.WARR1", [0xAB] = "S.WARR2", [0xAA] = "SPINNER2",
[0xA5] = "NOLE", [0xA2] = "GOLA"}
sword_modifiers = {1.75,1.50,2.00,1.25}
GetDecimalVal = function(val)
frac = val % 0x100
intg = math.floor(val / 0x100)
frac = math.ceil(frac * 100 / 0x100) / 100
return intg + frac
end
gui.register( function ()
--bonus damage
crit = memory.readwordunsigned(0xFF0FAA)
crit = math.floor((math.floor(crit * 13 + 7) % 0x10000)*0x60)/0x10000
crit = crit / 0x100 * 100
message1 = string.format("DMG: %05.2f", crit)
gui.text(150, 184, message1.."%", "white", "black")
--Sword damage
modifier = 1
dmgcol = "white"
sword = memory.readbyteunsigned(0xFF114E)
chg = memory.readwordunsigned(0xFF120A)
if sword > 0 and chg == 0x3200 then
modifier = sword_modifiers[sword]
dmgcol = "red"
end
--enemy HP
start = 0xFF5480
healthoff = 0x3E
healthmaxoff = 0x7E
enemytypeoff = 0x3B
defoff = 0x7C
nextoff = 0x80
count = 0
nigelhealth = GetDecimalVal(memory.readwordunsigned(0xFF5400 + healthmaxoff))
for i = 0, 10 do
enemytype = memory.readbyteunsigned(start + enemytypeoff + i*nextoff)
if enemy_table[enemytype] ~= nil then
--whole = memory.readbyteunsigned(start + i*offset)
--frac = memory.readbyteunsigned(start + i*offset + 1) --/0x100*100
--gui.text(100, 110+i*10, string.format("%d: %d.%02d", i, whole, frac), "white", "black") --gives rounding errors
maxhealth = GetDecimalVal(memory.readwordunsigned(start + healthmaxoff + i*nextoff))
health = GetDecimalVal(memory.readwordunsigned(start + healthoff + i*nextoff))
def = GetDecimalVal(memory.readwordunsigned(start + defoff + i*nextoff))
dmg = math.max(1, math.floor((nigelhealth - def*4)*100)/400)
dmg = dmg + math.floor(dmg) * crit / 100
dmg = dmg * modifier
gui.text(100, 110+count*10, string.format("%9s: %4.2f / %4.2f", enemy_table[enemytype], health, maxhealth), "white", "black")
gui.text(220, 110+count*10, string.format("%4.2f", dmg), dmgcol, "black")
count = count + 1
end
end
if count > 0 then
gui.text(100, 100, "Enemy HP", "white", "black")
end
end)