User File #23888186150161194

Upload All User Files

#23888186150161194 - CrashGBA - v2.1.5-beta VBA

CrashGBA - v2.1.5-beta VBA.lua
1192 downloads
Uploaded 7/3/2015 7:02 PM by Dica (see all 7)
-- Crash Huge Adventure lua v2.1.5-beta Virtual Boy Advance
-- This is Community Work Please Help
-- Join in add updates of your own and add your name

-- Values found by: Spikestuff, Got4n, Dica
-- Script Edited by: Spikestuff, Ilari, Dica, TASEditor, RGamma, Warepire

function TableMerge(t1,t2)
	local t3 = {}
	for k,v in pairs(t1) do
		t3[k] = v
	end
	for k,v in pairs(t2) do
		t3[k] = v
	end
	return t3
end

auto = 0
x_pos = 0
y_pos = 0
x_pos_bonus = 0
y_pos_bonus = 0

while true do
area = memory.readbyte(0x3001644)
areab = memory.readbyte(0x200000E)
mask = memory.readbyte(0x200009C)
lvl = memory.readbyte(0x200000E)
ex = memory.readbyte(0x2003AB8)

x_pos_prev = x_pos
y_pos_prev = y_pos
x_pos = memory.readlong(0x2010A14)
y_pos = memory.readlong(0x2010A18)
x_speed = x_pos - x_pos_prev
y_speed = y_pos - y_pos_prev
real_speed = math.sqrt(x_speed*x_speed + y_speed*y_speed) -- do not trust during jumps!

old_y_speed = memory.readwordsigned(0x02010A78)
old_x_speed = memory.readwordsigned(0x02010A74)

x_pos_prev_bonus = x_pos_bonus
y_pos_prev_bonus = y_pos_bonus
x_pos_bonus = memory.readlong(0x2010E2C)
y_pos_bonus = memory.readlong(0x2010E30)
x_speed_bonus = x_pos_bonus - x_pos_prev_bonus
y_speed_bonus = y_pos_bonus - y_pos_prev_bonus
real_speed_bonus = math.sqrt(x_speed_bonus*x_speed_bonus + y_speed_bonus*y_speed_bonus) -- do not trust during jumps!

old_x_speed_bonus = memory.readwordsigned(0x2010E8C)
old_y_speed_bonus = memory.readwordsigned(0x2010E90)

if ex > 0 and ex <= 3 or area == 1 or area == 5 or area == 8 or area == 9 or area == 11 or area == 13 or area == 14 or area == 15 or area == 17 then
	auto = 0
else
	if input.get()["i"] or input.get()["I"] then
		auto = 1
	else if input.get()["o"] or input.get()["O"] then
		auto = 0
end end end

if auto == 1 then -- Automatic Slide Spin Script. Still needs to be worked on.
	direction = memory.readbytesigned(0x030007E0)
	dir = nil
	action = nil
	if area ~= 6 then -- Normal
		sli_spi_timer = memory.readwordsigned(0x2010DDC)
		spin_or_slide =  memory.readbyte(0x2010A1E)
		is_sliding = spin_or_slide == 20

		gui.text(2,24,"Automatic Mode","yellow")

		if direction == 16 then -- right
			dir = {right = true}
		elseif direction == 32 then -- left
			dir = {left = true}
		end
		if math.abs(old_x_speed) >= 256 and sli_spi_timer == 0 and old_y_speed == 0 and not is_sliding then
			action = {R = true}
		elseif sli_spi_timer == 10 and is_sliding then
			action = {B = true}
		end
		if action ~= nil and dir ~= nil then
			joypad.set(1, TableMerge(action, dir))
		end
	else -- Bonus Round
		sli_spi_timer = memory.readwordsigned(0x020111F4)
		spin_or_slide = memory.readbyte(0x2010E36)
		is_sliding = spin_or_slide == 20

		gui.text(2,24,"Automatic Mode","orange")

		if direction == 16 then -- right
			dir = {right = true}
		elseif direction == 32 then -- left
			dir = {left = true}
		end
		if math.abs(old_x_speed_bonus) >= 256 and sli_spi_timer == 0 and old_y_speed_bonus == 0 and not is_sliding then
			action = {R = true}
		elseif sli_spi_timer == 10 and is_sliding then
			action = {B = true}
		end
		if action ~= nil and dir ~= nil then
			joypad.set(1, TableMerge(action, dir))
		end
	end
end

if area == 11 or area == 13 or area == 14 or area == 15 or area == 16 or area == 17 then else
	if area == 5 or area == 9 then
			gui.text(2,32,memory.readwordsigned(0x3003F34),"orange")
		else
	if area == 2 and areab == 3 or area == 18 then
			gui.text(2,120,memory.readwordsigned(0x3001404),"yellow")
		else
			gui.text(2,120,memory.readwordsigned(0x300082C),"yellow")
end end end

if area == 9 then  -- N.Gin Fight
	bhealth = memory.readbyte(0x3004130)
	thealth = memory.readbyte(0x30040B0)
	lhealth = memory.readshort(0x30041B0)
	rhealth = memory.readshort(0x3004230)
	if bhealth ~= 255 and bhealth ~= -1 then
		gui.text(18,48,"Bomb: " .. (bhealth+1)/2) end
	if lhealth ~= 0 or rhealth ~= 0 then
		gui.text(6,56,"Rockets: " .. (lhealth/2) .. "/" .. (rhealth/2)) end
	if thealth ~= 255 and thealth ~= -1 then
		gui.text(10,64,"Turret: " .. (thealth+1)/2) end
end

if area == 8 then -- Dingodile Fight
	dshi = memory.readbyte(0x2003EFC)
	gui.text(2,24,"Shield: " .. ((dshi == 1) and "ON" or "OFF - " .. memory.readbyte(0x20118CC))); else
end

if area == 7 then -- Tiny Fight
	tatt = memory.readbyte(0x2011FDC)
	gui.text(2,24,"Can Hit: " .. ((tatt == 8) and "YES - " .. memory.readbyte(0x02011FF4) or "NO")); else
end

if area == 16 then
	slide_count = 0
	aku = memory.readbyte(0x200009C)
	gui.text(2,9,"Mask Level: " .. aku,"yellow") else
end

if area == 2 and areab == 3 then else
	if area == 11 or area == 13 or area == 14 or area == 15 or area == 16 or area == 17 then else
		if area == 6 then --Bonus
			gui.text(2,32,"Pixel X: " .. x_pos_bonus)
			gui.text(2,40,"Pixel Y: " .. y_pos_bonus)
			gui.text(2,48,"Speed X: " .. x_speed_bonus)
			gui.text(2,56,"Speed Y: " .. y_speed_bonus)
			gui.text(2,64,"RealSpd: " .. real_speed_bonus)
			gui.text(2,128,"Slide Time: 22/" .. memory.readwordsigned(0x20111F4),"orange")
			gui.text(2,136," Spin Time: 23/" .. memory.readwordsigned(0x20111F4),"orange")
		else
		if area == 5 or area == 9 then -- Flying Cooldown
			cdwn = memory.readbyte(0x30014E0)-1
			if cdwn ~= -1 then
				gui.text(2,40,"Cooldown: " .. cdwn)
			end
		else
		if area == 10 then -- Neo Cortex and Mega Mix
			gui.box(0,142,240,160,"black")
			gui.text(116,143,"Pixel X: " .. x_pos)
			gui.text(116,151,"Pixel Y: " .. y_pos)
			gui.text(188,143,"Speed X: " .. x_speed)
			gui.text(188,151,"Speed Y: " .. y_speed)
			gui.text(128,134,"Slide: 22| " .. memory.readwordsigned(0x2010DDC).. " |23 :Spin","yellow")
			gui.text(2,134,"Real Speed: " .. real_speed)
		else -- Normal
			gui.text(2,32,"Pixel X: " .. x_pos)
			gui.text(2,40,"Pixel Y: " .. y_pos)
			gui.text(2,48,"Speed X: " .. x_speed)
			gui.text(2,56,"Speed Y: " .. y_speed)
			gui.text(2,64,"RealSpd: " .. real_speed)
			if area == 1 or area == 8 then
				gui.text(2,136," Spin Dur.: 24/" .. memory.readwordsigned(0x2010DDC),"green")
			else
				gui.text(2,128,"Slide Time: 22/" .. memory.readwordsigned(0x2010DDC),"yellow")
				gui.text(2,136," Spin Time: 23/" .. memory.readwordsigned(0x2010DDC),"yellow") end
end end end end end

if not movie.active() then
	gui.drawbox(0,0,78,8, "red")
	gui.text(2,1, "MOVIE NOT RECORDING")
else
	gui.text(2,1,"RR: " .. movie.rerecordcount())
end

vba.frameadvance() end