User File #14027044970595970

Upload All User Files

#14027044970595970 - PSX Bugs Bunny - Lost in Time lua v3

bugsbunny.lua
943 downloads
Uploaded 4/15/2014 4:39 PM by Warepire (see all 18)
Most recent lua script for PSX Bugs Bunny - Lost in Time NTSC (SLUS-00838).
New: In-level total golden carrots, clocks and ACME boxes. Music-ability check from abilities.
--position and speed
local Xpos
local XposOld = 0
local Ypos
local YposOld = 0
local Zpos
local ZposOld = 0
local Xspeed = 0
local Yspeed = 0
local Zspeed = 0
--not really a need to look at Y-speed as it seems to be independent of XZ speed, might still be useful for jumping.
local XZspeed
local XZdirection = 0

--stats
local health
local inlvlCarrots
local inlvlGoldenCarrots
local inlvlClocks
local inlvlACME
local inlvlTotalGoldenCarrots
local inlvlTotalClocks
local inlvlTotalACME
local totalCarrots
local totalGoldenCarrots
local totalClocks
local abilities
local jump = false
local music = false
local sesame = false
local fan = false

local function hud()
	--Actual speed vector addresses, not very good as they show speed even when you're blocked by a wall etc.
	--addr 00069D30 X Speed [signed word]
	--addr 00069D34 Y Speed(?)  [signed word]
	--addr 00069D38 Z Speed [signed word]
	Xpos = memory.readdwordsigned(0x00069DC0)
	Ypos = memory.readdwordsigned(0x00069DC4)
	Zpos = memory.readdwordsigned(0x00069DC8)
	--will not show the proper speed on the first frame of a level
	--the game only runs at 30 fps.
	local tempXspeed = Xpos - XposOld
	local tempYspeed = Ypos - YposOld
	local tempZspeed = Zpos - ZposOld
	local tempXZdirection = ((math.atan2(tempZspeed, tempXspeed) / math.pi) * 180)
	if tempXspeed ~= 0 or tempYspeed ~= 0 or tempZspeed ~= 0 then
		Xspeed = math.abs(tempXspeed)
		Yspeed = math.abs(tempYspeed)
		Zspeed = math.abs(tempZspeed)
		XZdirection = tempXZdirection
	end
	
	XZspeed = math.sqrt(Xspeed*Xspeed + Zspeed*Zspeed)

	health = memory.readbyte(0x00010041)
	inlvlCarrots = memory.readbyte(0x00069525)
	inlvlGoldenCarrots = memory.readbyte(0x00069574)
	inlvlClocks = memory.readbyte(0x00069514)
	inlvlACME = memory.readbyte(0x00010044)
	inlvlTotalGoldenCarrots = memory.readbyte(0x000100F7)
	inlvlTotalClocks = memory.readbyte(0x000100F9)
	inlvlTotalACME = memory.readbyte(0x000100FA)
	totalCarrots = memory.readbyte(0x00010043)
	totalGoldenCarrots = (memory.readbyte(0x0001013C)*256) + memory.readbyte(0x00010047)
	totalClocks = memory.readbyte(0x00010045)
	abilities = memory.readbyte(0x00010048) --0x08 == SuperJump, 0x04 == Music
	if abilities >= 0x08 then
		jump = true
		abilities = abilities - 0x08
	end
	if abilities >= 0x04 then
		music = true
		abilities = abilities - 0x04
	end
	-- TODO: The rest of the abilities
	
	gui.opacity(1.0)
	gui.text(0,0,string.format("Pos (%6d,%6d,%6d)\n",Xpos,Ypos,Zpos)
		..string.format("Speed XZ: %3d    Angle: %3d\n",XZspeed,XZdirection)
		..string.format("Speed  Y: %3d\n\n",Yspeed)
		..string.format("Health: %d\n",health)
		..string.format("Carrots: %d\n",totalCarrots)
		..string.format("LVL Golden: %2d / %2d Total Golden: %3d / 333\n",inlvlGoldenCarrots,inlvlTotalGoldenCarrots,totalGoldenCarrots)
		..string.format("LVL Clocks: %2d / %2d Total Clocks: %3d / 124\n",inlvlClocks,inlvlTotalClocks,totalClocks)
		..string.format("ACME boxes: %2d / %2d\n\n",inlvlACME,inlvlTotalACME)
		..string.format("Jump:   %s\n",tostring(jump))
		..string.format("Music:  %s\n",tostring(music))
		..string.format("Sesame: %s\n",tostring(sesame))
		..string.format("Fan:    %s\n",tostring(fan)))

	XposOld = Xpos
	YposOld = Ypos
	ZposOld = Zpos
end

gui.register(hud)