-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacing_direction.lua
70 lines (58 loc) · 2.57 KB
/
facing_direction.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--[[
Draws an arrow over each sprite to tell you which way it's facing. That's it.
I need to combine some of these scripts into an ultimate hitbox script or something.
The original use case for this, btw, was to investigate a damage boost from a scworm,
which faces the same direction even though its little dance makes it look like its constantly flipping.
]]
local EmuYFix = 0
local drawBoxes = false
if arg == "-drawBoxes" then drawBoxes = true end
--These functions call gui.text and gui.box, automatically applying EmuYFix to the position
local function BOX(x1, y1, x2, y2, c1, c2)
gui.box(x1, y1 + EmuYFix, x2, y2 + EmuYFix, c1, c2)
end
local function TEXT(x, y, t)
gui.text(x, y + EmuYFix, t)
end
local function drawSpriteInfo()
local scX = memory.readbyte(0x20) * 256 + memory.readbyte(0x1F)
local scY = 0
for i = 0, 0x1F do
local x = memory.readbyte(0x0440 + i)*256 + memory.readbyte(0x0460 + i) - scX
local y = memory.readbyte(0x04A0 + i) - scY
local flags = memory.readbyte(0x0420 + i)
if flags >= 0x80 then --sprite is alive
local index = memory.readbyte(0x0400 + i)
local hp = memory.readbyte(0x06C0 + i)
if i < 0x10 and i ~= 1 then --Rockman & projectiles
if drawBoxes then
local tmp = memory.readbyte(0x0590 + i) --weapon hitbox type (0-4)
tmp = memory.readbyte(0xD4DC + tmp) --offset into property tables
local hitSizeX = memory.readbyte(0xD4E1+tmp) - 0xC + 4 --read from property tables
local hitSizeY = memory.readbyte(0xD581+tmp) - 0x14 + 4
BOX(x - hitSizeX, y - hitSizeY, x + hitSizeX, y + hitSizeY, "clear", "red")
end
local str
if AND(flags, 0x40) ~= 0 then
TEXT(x, y, "->")
else
TEXT(x, y, "<-")
end
else --regular enemies
if drawBoxes then
local tmp = memory.readbyte(0x06E0+i)
local hitSizeX = math.max(0, memory.readbyte(0xD501+tmp) - 4 )
local hitSizeY = math.max(0, memory.readbyte(0xD5A1+tmp) - 4 )
BOX(x - hitSizeX, y - hitSizeY, x + hitSizeX, y + hitSizeY, "clear", "green")
end
local str
if AND(flags, 0x40) ~= 0 then
TEXT(x, y, "->")
else
TEXT(x, y, "<-")
end
end
end
end
end
gui.register(drawSpriteInfo)