Changes to contra 3 lua

This commit is contained in:
pasky1382 2012-09-10 13:34:13 +00:00
parent e87bddc2ee
commit 259be1c607
1 changed files with 89 additions and 77 deletions

View File

@ -1,3 +1,19 @@
----------------------------------------------
-----Contra III hitbox viewer script SNES-----
----------------------------------------------
--Player Colors:
--Gold = Invuln
--Blue = Vulnerable
--Enemy colors:
--Red = Can be touched and hit with projectiles
--Green = Can be hit with projectiles but has no collision
--Yellow = Can touch you, cannot be hit with player projectiles
--White Axis in middle of box = Box is invulnerable
local xm
local ym
function findbit(p)
return 2 ^ (p - 1)
end
@ -6,55 +22,63 @@ function hasbit(x, p)
return x % (p + p) >= p
end
local function Player()
local x = mainmemory.read_u8(0x206)
local y = mainmemory.read_u8(0x210)
local x2 = mainmemory.read_u8(0x228)
local y2 = mainmemory.read_u8(0x22a)
local x_offscreen = mainmemory.read_u8(0x207)
local y_offscreen = mainmemory.read_u8(0x211)
local x2_offscreen = mainmemory.read_u8(0x229)
local y2_offscreen = mainmemory.read_u8(0x22b)
local active = mainmemory.read_u8(0x216)
-- Checks if the box went off screen and adjusts
if x2_offscreen == 1 then
x2 = 255 + x2
elseif x2_offscreen == 255 then
x2 = 0 -(255 - x2)
end
if y2_offscreen == 1 then
y2 = 255 + y
elseif y2_offscreen == 255 then
y2 = 0 - (255 - y2)
end
if x_offscreen == 1 then
x = 255 + x
elseif x_offscreen == 255 then
x = 0 -(255 - x)
end
local function check_offscreen(pos,val)
if y_offscreen == 1 then
y = 255 + y
elseif y_offscreen == 255 then
y = 0 - (255 - y)
end
if active > 0 then
if hasbit(active,findbit(2)) == true or mainmemory.read_u16_le(0x1F88) > 0 then
gui.drawBox(x,y,x2,y2,0xFFFDD017,0x35FDD017)
else
gui.drawBox(x,y,x2,y2,0xFF0000FF,0x350000FF)
if val ~= 0 then
if val == 1 then
pos = 255 + pos
elseif val == 255 then
pos = 0 -(255 - pos)
end
end
return pos
end
local function draw_invuln(x,y,xrad,yrad)
gui.drawLine(x + (xrad / 2), y, x + (xrad / 2), y + yrad)
gui.drawLine(x, y + (yrad / 2), x + xrad, y + (yrad / 2))
end
local function Player()
local pbase = 0x200
for i = 0,1,1 do
pbase = pbase + (i * 0x40)
local x = mainmemory.read_u8(pbase + 6)
local y = mainmemory.read_u8(pbase + 0x10)
local x2 = mainmemory.read_u8(pbase + 0x28)
local y2 = mainmemory.read_u8(pbase + 0x2A)
local x_offscreen = mainmemory.read_u8(pbase + 0x7)
local y_offscreen = mainmemory.read_u8(pbase + 0x11)
local x2_offscreen = mainmemory.read_u8(pbase + 0x29)
local y2_offscreen = mainmemory.read_u8(pbase + 0x2B)
local active = mainmemory.read_u8(pbase + 0x16)
-- Checks if the box went off screen and adjusts
x = check_offscreen(x,x_offscreen)
x2 = check_offscreen(x2,x2_offscreen)
y = check_offscreen(y,y_offscreen)
y2 = check_offscreen(y2,y2_offscreen)
if active > 0 then
if hasbit(active,findbit(2)) == true or mainmemory.read_u16_le(0x1F88 + (i * 0x40)) > 0 then
gui.drawBox(x,y,x2,y2,0xFFFDD017,0x35FDD017)
else
gui.drawBox(x,y,x2,y2,0xFF0000FF,0x350000FF)
end
end
end
end
local function Enemies()
local start = 0x240
local start = 0x280
local base = 0
local oend = 33
local oend = 32
local x
local x_offscreen
local y
@ -64,14 +88,11 @@ local function Enemies()
local active
local touch
local projectile
local invuln
local hp
for i = 0,oend,1 do
base = start
if i > 0 then
base = start + (i * 0x40)
end
base = start + (i * 0x40)
active = mainmemory.read_u8(base + 0x16)
hp = mainmemory.read_s16_le(base + 6)
@ -79,58 +100,49 @@ local function Enemies()
touch = hasbit(active,findbit(4))
projectile = hasbit(active,findbit(5))
invuln = hasbit(active,findbit(6))
x = mainmemory.read_u8(base + 0xa)
x2 = mainmemory.read_u8
x_offscreen = mainmemory.read_u8(base + 0xb)
y = mainmemory.read_u8(base + 0xe)
y_offscreen = mainmemory.read_u8(base + 0xf)
xrad = mainmemory.read_s16_le(base+0x28)
yrad = mainmemory.read_s16_le(base+0x2A)
x2 = x
-- Checks if the box went off screen and adjusts
if x_offscreen == 1 then
x = 255 + x
elseif x_offscreen == 255 then
x = 0 -(255 - x)
end
if y_offscreen == 1 then
y = 255 + y
elseif y_offscreen == 255 then
y = 0 - (255 - y)
end
x = check_offscreen(x,x_offscreen)
y = check_offscreen(y,y_offscreen)
if projectile and touch == true then
if projectile and touch then
gui.drawBox(x,y,x+ xrad,y+yrad,0xFFFF0000,0x35FF0000)
if hp > 0 then
gui.text((x-5) * xmult,(y-5) * ymult,"HP: " .. hp)
end
elseif projectile == true then
gui.drawBox(x,y,x+ xrad,y+yrad,0xFF00FF00,0x3500FF00)
if hp > 0 then
gui.text((x-5) * xmult,(y-5) * ymult,"HP: " .. hp)
end
elseif touch == true then
elseif projectile then
gui.drawBox(x,y,x + xrad,y+yrad,0xFF00FF00,0x3500FF00)
elseif touch then
gui.drawBox(x,y,x + xrad,y + yrad,0xFFFFFF00,0x35FFFF00)
if hp > 0 then
gui.text((x-5) * xmult,(y-5) * ymult,"HP: " .. hp)
end
end
if hp > 0 and invuln == false then
gui.text((x-5) * xm,(y-5) * ym,"HP: " .. hp)
end
if invuln then
draw_invuln(x,y,xrad,yrad)
end
end
end
end
local function scaler()
xmult = client.screenwidth() / 256
ymult = client.screenheight() / 224
xm = client.screenwidth() / 256
ym = client.screenheight() / 224
end
while true do
scaler()
Player()
Enemies()
local stage = mainmemory.read_u8(0x7E0086)
if stage ~= 2 and stage ~= 5 then
Player()
Enemies()
end
emu.frameadvance()
end