jamesjlinden
6/26/2016 - 11:27 PM

Super Ghouls n Ghosts lua script (Original Author: ConHuevos)

Super Ghouls n Ghosts lua script (Original Author: ConHuevos)

----------------------------------------------------
--Super Ghouls n' Ghosts Hitbox Display Lua Script--
----------------------------------------------------


---Blue = Arthur's Hitbox
---Red = Touch damage, if red touches arthur's blue hitbox he is damaged.
---Green = Projectile vulnerability for enemies
---White = Arthurs magic and weapons

local left_edge = 0x7e15DD
local top_edge = 0x7E15E1

function findbit(p) 
	return 2 ^ (p - 1)
end

function hasbit(x, p) 
	return x % (p + p) >= p 
end

local function draw_axis(x,y)
	gui.line(x,y-2,x,y+2,0xFFFFFF80)
	gui.line(x-2,y,x+2,y,0xFFFFFF80)
end

local function draw_arthur()
	local arthur = 0x043C
	local pointoff = bit.lshift(bit.lshift(bit.band(memory.readbyte(arthur + 0x09),0x01),1),1)
	local yrad = memory.readbyte(0xB963 + pointoff)
	local xrad = memory.readbyte(0xB963 + pointoff + 1)
	local yoff = memory.readbytesigned(0xB965 + pointoff)
	local xoff = memory.readbytesigned(0xB965 + pointoff + 1)
	local x = memory.readword(arthur + 0x1F)
	local y = memory.readword(arthur + 0x22)
	
	x = x - memory.readword(left_edge)
	y = y - memory.readword(top_edge)
	gui.box((x+xoff) - (xrad), (y+yoff) - (yrad), (x+xoff) + (xrad), (y+yoff) + (yrad),0x0000FF30,0x0000FFF0)
	--Comment out next line to hide arthur's hitbox center axis
	draw_axis(x,y)
end

local function draw_projvuln(x,y,xrad,yrad,base)
		gui.box(x - (xrad), y - (yrad), x + (xrad), y + (yrad),0x2AFF0040,0x2AFF00F0)
end



local function draw_enemies()

	local ostart = 0x090F
	local oend = 30
	local base = 0
	local pointoff = 0
	local xrad = 0
	local yrad = 0
	local x = 0
	local y = 0
		
	for i = 0,oend,1 do
	
		if i ~= 0 then
			base = ostart + (0x41 * i)
		else
			base = ostart
		end
		
		
		if hasbit(memory.readbyte(base + 0x09),findbit(7)) == true then
			
			if memory.readbyte(base+1) ~= 0 and memory.readbyte(base) ~= 0 then
			
				pointoff = bit.lshift(bit.band(memory.readbyte(base + 0x06),0x00FF),1)
				xrad = memory.readbyte(0xD6E1 + pointoff)
				yrad = memory.readbyte(0xD6E2 + pointoff)
				x = memory.readword(base + 0x1F)
				y = memory.readword(base + 0x22)
				
				life = memory.readbyte(base + 0x0E)
				
				x = x - memory.readword(left_edge)
				y = y - memory.readword(top_edge)
				
				--Red boxes
				gui.box(x - (xrad), y - (yrad), x + (xrad), y + (yrad),0xFF000070,0xFF0000FF)
				xrad = memory.readbyte(0xD85D + pointoff)
				yrad = memory.readbyte(0xD85E + pointoff)
				
				--Comment/Uncomment out next line to hide/show drawing the projectile vulnerability boxes
				
				draw_projvuln(x,y,xrad,yrad,base)
				
				if life > 0 then
				--Comment out next line to hide HP display over objects
				  gui.text(x, y-10, life)
				end
				
				--Comment out next line to hide box center axis
				draw_axis(x,y)
				
			end
		end
		
	end
end

local function draw_weapons()

	local ostart = 0x047D
	local oend = 9
	local base = 0
	local weapon = 0x14D3
	local dmg = 0
	local pointoff = 0
	local wep_xrad = 0
	local wep_yrad = 0
	local mag_xrad = 0
	local mag_yrad = 0
	local x = 0
	local y = 0
	
	pointoff = bit.lshift(memory.readbyte(weapon),1)
	wep_xrad = memory.readbyte(0xb98b + pointoff)
	wep_yrad = memory.readbyte(0xb98c + pointoff)
	mag_xrad = memory.readbyte(0xb9ab + pointoff)
	mag_yrad = memory.readbyte(0xb9ac + pointoff)
		
	for i = 0,oend,1 do
	
	
		if i ~= 0 then
			base = ostart + (0x41 * i)
		else
			base = ostart
		end
		
		if memory.readbyte(base+1) ~= 0 and memory.readbyte(base) ~= 0 then
			x = memory.readword(base + 0x1F)
			y = memory.readword(base + 0x22)
		
			dmg = memory.readbyte(base + 0x0E)
			
			x = x - memory.readword(left_edge)
			y = y - memory.readword(top_edge)
			gui.box(x - (wep_xrad), y - (wep_yrad), x + (wep_xrad), y + (wep_yrad),0xFFFFFF40,0xFFFFFFFF)
			
			if dmg > 0 then
			--Comment out next line to hide weapon DMG display over objects
				gui.text(x, y-10, dmg)
			end
			--Comment out next line to hide box center axis
			--draw_axis(x,y)

		end
	end
	
	-- If we have the gold armor and not the magic bracelet, check for magic hitboxes
	if memory.readbyte(0x7E14BA) == 0x04 and memory.readbyte(weapon) ~= 0x0E then 
		
		ostart = 0x0707
		
		for i = 0,oend-2,1 do
		
			if i ~= 0 then
				base = ostart + (0x41 * i)
			else
				base = ostart
			end
			
			if memory.readbyte(base+1) ~= 0 and memory.readbyte(base) ~= 0 then
				x = memory.readword(base + 0x1F)
				y = memory.readword(base + 0x22)
		
				dmg = memory.readbyte(base + 0x0E)
			
				x = x - memory.readword(left_edge)
				y = y - memory.readword(top_edge)
				gui.box(x - (mag_xrad), y - (mag_yrad), x + (mag_xrad), y + (mag_yrad),0xFFFFFF40,0xFFFFFFFF)

				if dmg > 0 then
				--Comment out next line to hide magic DMG display over objects
					gui.text(x, y-10, dmg)
				end
				--Comment out next line to hide box center axis
				--draw_axis(x,y)
			end

		end
	end

end

gui.register(function()
	draw_arthur()
	draw_enemies()
	draw_weapons()
end)