Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/SNES/Super Ghouls N Ghost.lua
2 views
1
----------------------------------------------------
2
--Super Ghouls n' Ghosts Hitbox Display Lua Script--
3
----------------------------------------------------
4
5
--Author Pasky13
6
7
8
---Blue = Arthur's Hitbox
9
---Red = If this box touches arthur's he is damaged
10
---Green = Projectile vulnerability for enemies
11
---White = Arthurs magic and weapons
12
13
local left_edge = 0x15DD
14
local top_edge = 0x15E1
15
local xm
16
local ym
17
18
memory.usememorydomain("CARTROM")
19
20
function findbit(p)
21
return 2 ^ (p - 1)
22
end
23
24
function hasbit(x, p)
25
return x % (p + p) >= p
26
end
27
28
local function draw_axis(x,y)
29
gui.drawLine(x,y-2,x,y+2,0x80FFFFFF)
30
gui.drawLine(x-2,y,x+2,y,0x80FFFFFF)
31
end
32
33
local function draw_arthur()
34
local arthur = 0x43C
35
local pointoff = bit.lshift(bit.lshift(bit.band(mainmemory.read_u8(arthur + 0x09),0x01),1),1)
36
local yrad = memory.read_u8(0x3963 + pointoff)
37
local xrad = memory.read_u8(0x3963 + pointoff + 1)
38
local yoff = memory.read_s8(0x3965 + pointoff)
39
local xoff = memory.read_s8(0x3965 + pointoff + 1)
40
local x = mainmemory.read_u16_le(arthur + 0x1F)
41
local y = mainmemory.read_u16_le(arthur + 0x22)
42
43
x = x - mainmemory.read_u16_le(left_edge)
44
y = y - mainmemory.read_u16_le(top_edge)
45
gui.drawBox((x+xoff) - (xrad), (y+yoff) - (yrad), (x+xoff) + (xrad), (y+yoff) + (yrad),0xF00000FF,0x300000FF)
46
--Comment/Uncomment out next line to Show/hide arthur's hitbox center axis
47
--draw_axis(x,y)
48
end
49
50
local function draw_projvuln(x,y,xrad,yrad,base)
51
gui.drawBox(x - (xrad), y - (yrad), x + (xrad), y + (yrad),0xF02AFF00,0x402AFF00)
52
end
53
54
55
56
local function draw_enemies()
57
58
local ostart = 0x090F
59
local oend = 30
60
local base = 0
61
local pointoff = 0
62
local xrad = 0
63
local yrad = 0
64
local x = 0
65
local y = 0
66
67
for i = 0,oend,1 do
68
69
if i ~= 0 then
70
base = ostart + (0x41 * i)
71
else
72
base = ostart
73
end
74
75
76
if hasbit(mainmemory.read_u8(base + 0x09),findbit(7)) == true then
77
78
if mainmemory.read_u8(base+1) ~= 0 and mainmemory.read_u8(base) ~= 0 then
79
80
pointoff = bit.lshift(bit.band(mainmemory.read_u8(base + 0x06),0x00FF),1)
81
xrad = memory.read_u8(0x56E1 + pointoff)
82
yrad = memory.read_u8(0x56E2 + pointoff)
83
x = mainmemory.read_u16_le(base + 0x1F)
84
y = mainmemory.read_u16_le(base + 0x22)
85
86
life = mainmemory.read_u8(base + 0x0E)
87
88
x = x - mainmemory.read_u16_le(left_edge)
89
y = y - mainmemory.read_u16_le(top_edge)
90
91
--Red boxes
92
gui.drawBox(x - (xrad), y - (yrad), x + (xrad), y + (yrad),0xFFFF0000,0x70FF0000)
93
xrad = memory.read_u8(0x585D + pointoff)
94
yrad = memory.read_u8(0x585E + pointoff)
95
96
--Comment/Uncomment out next line to hide/show drawing the projectile vulnerability boxes
97
98
draw_projvuln(x,y,xrad,yrad,base)
99
100
if life > 0 then
101
--Comment out next line to hide HP display over objects
102
gui.text(x * xm, (y-10) * ym, life)
103
end
104
105
--Comment out next line to hide box center axis
106
draw_axis(x,y)
107
108
end
109
end
110
111
end
112
end
113
114
local function draw_weapons()
115
116
local ostart = 0x047D
117
local oend = 9
118
local base = 0
119
local weapon = 0x14D3
120
local dmg = 0
121
local pointoff = 0
122
local wep_xrad = 0
123
local wep_yrad = 0
124
local mag_xrad = 0
125
local mag_yrad = 0
126
local x = 0
127
local y = 0
128
129
pointoff = bit.lshift(mainmemory.read_u8(weapon),1)
130
wep_xrad = memory.read_u8(0x398b + pointoff)
131
wep_yrad = memory.read_u8(0x398c + pointoff)
132
mag_xrad = memory.read_u8(0x39ab + pointoff)
133
mag_yrad = memory.read_u8(0x39ac + pointoff)
134
135
for i = 0,oend,1 do
136
137
138
if i ~= 0 then
139
base = ostart + (0x41 * i)
140
else
141
base = ostart
142
end
143
144
if mainmemory.read_u8(base+1) ~= 0 and mainmemory.read_u8(base) ~= 0 then
145
x = mainmemory.read_u16_le(base + 0x1F)
146
y = mainmemory.read_u16_le(base + 0x22)
147
148
dmg = mainmemory.read_u8(base + 0x0E)
149
150
x = x - mainmemory.read_u16_le(left_edge)
151
y = y - mainmemory.read_u16_le(top_edge)
152
gui.drawBox(x - (wep_xrad), y - (wep_yrad), x + (wep_xrad), y + (wep_yrad),0xFFFFFFFF,0x40FFFFFF)
153
154
if dmg > 0 then
155
--Comment out next line to hide weapon DMG display over objects
156
gui.text(x * xm, (y-10) * ym, dmg)
157
end
158
--Comment out next line to hide box center axis
159
--draw_axis(x,y)
160
161
end
162
end
163
164
-- If we have the gold armor and not the magic bracelet, check for magic hitboxes
165
if mainmemory.read_u8(0x14BA) == 0x04 and mainmemory.read_u8(weapon) ~= 0x0E then
166
167
ostart = 0x0707
168
169
for i = 0,oend-2,1 do
170
171
if i ~= 0 then
172
base = ostart + (0x41 * i)
173
else
174
base = ostart
175
end
176
177
if mainmemory.read_u8(base+1) ~= 0 and mainmemory.read_u8(base) ~= 0 then
178
x = mainmemory.read_u16_le(base + 0x1F)
179
y = mainmemory.read_u16_le(base + 0x22)
180
181
dmg = mainmemory.read_u8(base + 0x0E)
182
183
x = x - mainmemory.read_u16_le(left_edge)
184
y = y - mainmemory.read_u16_le(top_edge)
185
gui.drawBox(x - (mag_xrad), y - (mag_yrad), x + (mag_xrad), y + (mag_yrad),0xFFFFFFFF,0x40FFFFFF)
186
187
if dmg > 0 then
188
--Comment out next line to hide magic DMG display over objects
189
gui.text(x * xm, (y-10) * ym, dmg)
190
end
191
--Comment out next line to hide box center axis
192
--draw_axis(x,y)
193
end
194
195
end
196
end
197
198
end
199
200
local function scaler()
201
xm = client.screenwidth() / 256
202
ym = client.screenheight() / 224
203
end
204
205
while true do
206
scaler()
207
draw_arthur()
208
draw_enemies()
209
draw_weapons()
210
emu.frameadvance()
211
end
212
213