User File #638026432839756103

Upload All User Files

#638026432839756103 - Legend of Dragoon lua script

Legend of Dragoon, The (USA) (Disc 1).lua
1258 downloads
Uploaded 10/29/2022 12:28 PM by lapogne36 (see all 25)
Script to display RNG, Danger value, items, ...


client.SetGameExtraPadding(270, 81, 0, 81)

local RNG ={}
local INDEX = 1
local SIZE = 0
local TIMER = 0
local TIMER_OLD = 0
local DANGER = 0
local X = 0
local Y = 0
local XSPD = 0
local YSPD = 0
local SPEED = 0

local ITEMS = {
"B. Sword";"";"";"";"";"";"";"";"";""; --00 09
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";""; --100 109
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"";"";"";"";"";
"";"";"";"";"";"Burn Out";"";"";"";"";
"";"";"";"Healing P.";"";"";"Body Pur.";"";"";"Gushing M."; --200 209
"";"";"";"";"";"";"";"";"";"";
"";"";"";"Charm P.";"";"";"";"";"";"";
"";"";"";"";"Moon S.";"";"Power Down";"";"";"";
"";"";"";"Frozen Jet";"";"";"";"";"";"";
"P. Bomb X";"";"";"";"";"-"
}

local function REV_RNG(IND)
	RNG[IND] = RNG[IND+1] - 0x3711
	while (RNG[IND] % 9) ~= 0 do
		RNG[IND] = RNG[IND]+0x100000000
	end
	RNG[IND] = RNG[IND]/9
end

local function CALC_RNG()

	OLD = memory.read_u32_le(0x4DD44)

	while true do
		if ((OLD % 81)==3 and ((OLD-3)/81) <= memory.read_u32_le(0x5462C)+174) or (OLD % 0x1000)==0 then break end
	
		NEW = OLD - 0x3711
		while (NEW % 9) ~= 0 do
			NEW = NEW+0x100000000
		end
		NEW = NEW/9
		OLD = NEW
		
	end
	
	RNG[1] = OLD
	if RNG[1]/81 > 1000000 then RNG[1] = 3 end
	if RNG[1]==0 then RNG[1] = 3 end
	
	for i=2, 8000 do
		RNG[i] = (RNG[i-1]*9 + 0x3711) % 0x100000000
		if (RNG[i] % 0x1000)==0 then  
			SIZE = i
			break
		end
	end
	
	for i=(SIZE+1), (SIZE+5) do
		RNG[i] = 0
	end
end

CALC_RNG()

while true do

	if emu.framecount()<=397856 then

	local RN = memory.read_u32_le(0x4DD44)
	for i=INDEX, (SIZE+1) do
		if i<=SIZE then
			if RN==RNG[i] then
				INDEX = i
				break
			end
		else
			INDEX = 0
		end
	end
	if INDEX==0 then
		CALC_RNG()
		for i=INDEX, (SIZE+1) do
			if i<=SIZE then
				if RN==RNG[i] then
					INDEX = i
					break
				end
			else
				INDEX = 1
			end
		end
	end
	
	TIMER = memory.read_u32_le(0xBB0FC)
	if TIMER ~= TIMER_OLD then
		DANGER = memory.read_u16_le(0xC6AE8)
		XSPD = memory.read_s16_le(0xC68F4)-X
		YSPD = memory.read_s16_le(0xC68FC)-Y
		SPEED = math.sqrt(XSPD^2 + YSPD^2)
		X = memory.read_s16_le(0xC68F4)
		Y = memory.read_s16_le(0xC68FC)
		TIMER_OLD = TIMER
	end
	
	-- gui.text(1, 60, string.format("%4s", X) .. "/" .. string.format("%4s", Y) .. "/ " .. string.format("%4.2f", SPEED))
	-- gui.text(1, 80, string.format("%4s", XSPD) .. "/" .. string.format("%4s", YSPD))
	
	if DANGER>9999 then DANGER = 0 end
	gui.text(1, 100, "DANGER: " .. string.format("%4s", DANGER) .. "/5130")
	if DANGER<9999 then
		local COLDAN = "lightblue"
		if DANGER>3847 then COLDAN = "red"
		elseif DANGER>2565 then COLDAN = "yellow"
		end
		gui.drawRectangle(1, 120, DANGER/30, 20, "black", COLDAN)
	end
	gui.drawRectangle(1, 120, 5130/30, 20)
	
	-- gui.text(1, 120, string.format("%8X", RNG[1]))
	-- gui.text(1, 120, string.format("%8X", RNG[INDEX]) .. " " .. string.format("%8X", RNG[INDEX+1]) .. " " .. string.format("%8X", RNG[INDEX+2]))
	-- gui.text(1, 120, string.format("%8X", memory.read_u32_le(0xBC1D8)-0x80000000-0x23C))
	
	if RNG[1] == 0 then RNG[1] = 3 end
	if RNG[1]/81 > 1000000 then RNG[1] = 3 end
	gui.text(1, 170, "Next seed:          " .. string.format("%10s", memory.read_u32_le(0x5462C)+174))
	gui.text(1, 190, "Current seed:       " .. string.format("%10s", (RNG[1]-3)/81))
	gui.text(1, 210, "RN#               " .. string.format("%5s", INDEX) .. " / " .. string.format("%4s", SIZE))


	gui.text(101, 250, "Used items")
	for i=1, 32 do
		local ID_ITEM = memory.read_u8(0xBAEB0 + i) + 1
		gui.text(1 + ((i-1)%2)*160, 280+math.floor((i-1)/2)*20, string.format("%2s", i) .. "  " .. ITEMS[ID_ITEM])
	end










	if memory.read_u32_le(0xBC1D8)~=0 then

		local ATB_P1 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000+0x14C)
		local ATB_P2 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000-0x23C)
		local ATB_P3 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000-0x5C4)
		local ATB_E1 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000+0x14C)
		local ATB_E2 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000-0x23C)
		local ATB_E3 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000-0x5C4)

		
		if ATB_P1<300 and ATB_P1>0 then
		
			if ATB_P1<300 and ATB_P1>0 then
				local HP_P1 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000+0x14C-0x44)
				gui.text(420+15, 565, "Player 1")
				gui.text(420, 585, "HP " .. string.format("%8s", HP_P1))
				gui.text(420, 601, "ATB " .. string.format("%3s", ATB_P1) .. "/217")
				gui.drawRectangle(420, 618, ATB_P1/2, 20, "black", "#D5A600")
				gui.drawRectangle(420, 618, 217/2, 20)
			end
			
			if ATB_P2<300 and ATB_P2>0 and (emu.framecount()<245500 or emu.framecount()>257800) then --Manual correction for Doel fight
				local HP_P2 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000-0x23C-0x44)
				gui.text(620+15, 565, "Player 2")
				gui.text(620, 585, "HP " .. string.format("%8s", HP_P2))
				gui.text(620, 601, "ATB " .. string.format("%3s", ATB_P2) .. "/217")
				gui.drawRectangle(620, 618, ATB_P2/2, 20, "black", "#D5A600")
				gui.drawRectangle(620, 618, 217/2, 20)
			end
			
			if ATB_P3<300 and ATB_P3>0 then
				local HP_P3 = memory.read_u16_le(memory.read_u32_le(0xBC1D8)-0x80000000-0x5C4-0x44)
				gui.text(820+15, 565, "Player 3")
				gui.text(820, 585, "HP " .. string.format("%8s", HP_P3))
				gui.text(820, 601, "ATB " .. string.format("%3s", ATB_P3) .. "/217")
				gui.drawRectangle(820, 618, ATB_P3/2, 20, "black", "#D5A600")
				gui.drawRectangle(820, 618, 217/2, 20)
			end
			
			if ATB_E1<300 and ATB_E1>0 then
				local HP_E1 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000+0x14C-0x44)
				gui.text(420+20, 2, "Enemy 1")
				gui.text(420, 22, "HP " .. string.format("%8s", HP_E1))
				gui.text(420, 38, "ATB " .. string.format("%3s", ATB_E1) .. "/217")
				gui.drawRectangle(420, 55, ATB_E1/2, 20, "black", "#D5A600")
				gui.drawRectangle(420, 55, 217/2, 20)
			end
			
			if ATB_E2<300 and ATB_E2>0 then
				local HP_E2 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000-0x23C-0x44)
				gui.text(620+20, 2, "Enemy 2")
				gui.text(620, 22, "HP " .. string.format("%8s", HP_E2))
				gui.text(620, 38, "ATB " .. string.format("%3s", ATB_E2) .. "/217")
				gui.drawRectangle(620, 55, ATB_E2/2, 20, "black", "#D5A600")
				gui.drawRectangle(620, 55, 217/2, 20)
			end
			
			if ATB_E3<300 and ATB_E3>0 then
				local HP_E3 = memory.read_u16_le(memory.read_u32_le(0xBC1EC)-0x80000000-0x5C4-0x44)
				gui.text(820+20, 2, "Enemy 3")
				gui.text(820, 22, "HP " .. string.format("%8s", HP_E3))
				gui.text(820, 38, "ATB " .. string.format("%3s", ATB_E3) .. "/217")
				gui.drawRectangle(820, 55, ATB_E3/2, 20, "black", "#D5A600")
				gui.drawRectangle(820, 55, 217/2, 20)
			end
		
		end
	
	end
	
	end --emu.framecount()
	
	emu.frameadvance()
	gui.clearGraphics()
	
end