Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Golden Sun 2: The Lost Age utility script v1.0 for speedrunning. Would not be possible without the help of Fox aka teawater from the gs hacking community
- local AD1 = 0x02000A8A -- Felix PP
- local AD3 = (0x0200049A) -- Next Encounter
- local AD4 = (0x020054C8) -- Battle RN
- local AD5 = (0x030011BC) -- General RN
- local AD6 = (0x02030194) -- Encounter Rate
- local AD7 = (0x020004B4) -- Kraden gets mad counter, 4+ triggers event
- local EncounterRate = memory.readdword(0x02000498)
- local CurrentRate = 0
- local GoodRateThreshold = 0x900 -- Hex value between 0x100 and 0x16000
- local gcount = 0
- local brncount = 0
- local store = memory.readdword(0x030011BC)
- local bstore = memory.readdword(0x020054C8)
- local fleestore = 0
- local fleepercent = 0
- local mem = 0x2010000
- local memcount = 0
- local RNGvalue1 = 0x6733CCBF -- lower OW GRN limit, 1300 advances + load into game
- local RNGvalue2 = 0x19814424 -- upper OW GRN limit, 1309 advances + load into game
- -- Note, I actually fucked up here. load into game value differs between OW and dungeons :(
- -- For OW, I am 2 GRN behind the target
- -- 0x16A52B8D is 1030 advances
- local RNGvalue3 = 0xB91AAA65 -- Title screen GRN
- local j=1
- local k=1
- local trn={}
- local psbrn = 1
- local cbsbrn = 1
- local psc1 = 0
- local psc2 = 0
- local psc3 = 0
- local cbsc1 = 0
- local cbsc2 = 0
- local cbsc3 = 0
- local keypress = {}
- local state = false
- local brnadvancecounter = 0
- local brnreducecounter = 0
- local grnadvancecounter = 0
- local grnreducecounter = 0
- local valuestate = false
- local timerstate = false
- local timeron = false
- local fighttimer = 0
- local infight = false
- local fighttimertext = 0
- local fightlength = 0
- local pplock = false
- local ppstate = false
- local encounterlock = false
- local encounterstate = false
- local overlaystate = false
- local overlay = false
- local minorhudlock = true
- local minorhudstate = false
- local randomiserstate = false
- local randomisercounter = 0
- local menustate = false
- local menutimeron = false
- local menutimer = 0
- local menuopen = false
- local menutimertext = 0
- local menulength = 0
- local diagstate = false
- local diagnostics = false
- local memoryentry = {}
- local diagnostictimer = 0
- local extendeddiagtimer = 0
- local oldmemorydifferencelocation = {0,0}
- local areacomparisontimer = 0
- local areacomparisonexception = false
- local areacomparisontimerstate = false
- local encounterNumber = 0x0203018C
- local avoidstate = false
- local avoidInfo = false
- local globaltimerstate = false
- local globaltimeron = false
- local globaltimerpause = false
- local globaltimertext = 0
- local globallength = 0
- local globaltimerstore = {0,0,0}
- local globaltimerstoretimer = 0
- --eel = memory.readbyte(0x0203089E) -- venus res
- --eme = memory.readbyte(0x020308A2)
- --ema = memory.readbyte(0x020308A6)
- --eju = memory.readbyte(0x020308A8)
- -- Vulnerability Key
- --12 = Drop Def 25%
- --13 = Drop def 12%
- --16 = res drop 40
- --17 = res drop 20
- --20 = delusion
- --23 = stun
- local globaltimer = 0
- --24 = sleep
- --27 = death
- --31 = HP steal
- --32 = PP steal
- --60 = 50% dmg to health
- --69 = 10% dmg to PP
- print("Welcome to the Golden Sun: The Lost Age Utility Script")
- print("Commands:")
- print("shift+g: advances the GRN by one")
- print("shift+b: advances the BRN by one")
- print("shift+r: advance GRN/BRN by a random amount")
- print("shift+t: toggle battle timer")
- print("shift+y: force display of last fight length (timer must be on)")
- print("shift+m: toggle menu timer")
- print("shift+,: force display of last menu length (timer must be on)")
- print("shift+p: lock Felix's pp to 5")
- print("shift+e: toggle encounters")
- print("shift+o: toggle map data overlay")
- print("shift+a: toggle minor hud")
- print("shift+d: oob diagnostic tool")
- print("shift+l: avoid information toggle")
- print("shift+q: toggle global timer")
- --print("shift+d: toggle display of Isaac's party's djinn")
- while true do
- gui.text(160,00,"BRN: ".. (memory.readdword(AD4)))
- gui.text(160,10,"GRN: ".. (memory.readdword(AD5)))
- if memory.readword(0x02000420) == 0x8D then
- gui.text(160,20,"Item: ".. memory.readword(0x020004FC))
- gui.text(160,30,"409 = ring")
- end
- if mem <= 0x2008000 then
- mem = 0x2010000
- memcount=0
- end
- if memory.readdword(mem) ~= 0 then
- if memory.readdword(mem+0x4) ~=0 or memory.readdword(mem+0x8)~=0 or memory.readdword(mem+0xB)~=0 or memory.readdword(mem+0xF)~=0 or memory.readdword(mem+0x10)~=0 then
- mem = 0x2010000
- memcount=0
- end
- end
- while memcount <= 20000 and memory.readdword(mem) == 0 or mem==0x02010000 do
- mem = mem-0x4
- memcount = memcount+1
- end
- gui.text(0,30,"Nonzero Tile: " .. memcount)
- --gui.text(140,20,"X: " .. (memory.readdword(0x02030ec4))/1000000)
- --gui.text(140,30,"Y: " .. (memory.readdword(0x02030ecc))/1000000)
- --g = memory.readdword(AD5)
- --print(bit.tohex(g))
- -- RNG Functions
- function RNA (R) -- RN Advance Function
- g = R
- m1 = 0x4e6d
- m2 = 0x41c6
- g1 = g*m1
- g2 = g*m2
- g2 = bit.band(g2,0xFFFF)
- g = g1 + g2*0x10000
- g = bit.band(g,0xFFFFFFFF)
- c=0x3039
- g = g+c
- g = bit.band(g,0xFFFFFFFF)
- return g
- end
- function RNR (R) -- RN reverse Function
- gout = bit.band((R-0x3039),0xFFFFFFFF) -- or 0xFFFFFFFF? 0x80000000 seems to be the cap for the RNG
- multi = 0x41c64e6d
- g={}
- m={}
- a={}
- for i=1,32,1 do
- if bit.band(gout,2^(i-1)) == 0 then
- g[i] = 0
- else
- g[i] =1
- end
- if bit.band(multi,2^(i-1)) == 0 then
- m[i] = 0
- else
- m[i] = 1
- end
- end
- aleftover=0
- for i=1,32,1 do
- j=i
- adiff = 0
- while j>1 do
- adiff = adiff + a[i+1-j]*m[j]
- j=j-1
- end
- adiff = adiff + aleftover
- a[i] = (g[i] + adiff)%2
- aleftover = math.floor((a[i]+adiff)/2)
- end
- gin = 0
- for i=1,32,1 do
- gin = gin + 2^(i-1)*a[i]
- end
- gin = bit.band(gin, 0xFFFFFFFF)
- --gin = gin%0x80000000
- return gin
- end
- function RNB (R) -- RN Advance and reduce for use in RNG calculations
- g = R
- m1 = 0x4e6d
- m2 = 0x41c6
- g1 = g*m1
- g2 = g*m2
- g2 = bit.band(g2,0xFFFF)
- g = g1 + g2*0x10000
- c=0x3039
- g = g+c
- g = bit.lshift(g,8)
- g = bit.rshift(g,16)
- return g
- end
- -- Attacks First, Caught by Surprise Check
- function PS (R) -- Preemptive Strike Check, 0 = nothing, 1 = PS, 2= CBS
- R1=R
- R2 = RNB(R1)
- R1 = bit.lshift(R1,8)
- R1 = bit.rshift(R1,16)
- if bit.band(R1,0xF) == 0 then
- return 1
- else
- if bit.band(R2,0x1F) ==0 then
- return 2
- else
- return 0
- end
- end
- end
- -- Dec to Hex Function
- function DEC_HEX(IN)
- local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
- while IN>0 do
- I=I+1
- IN,D=math.floor(IN/B),math.mod(IN,B)+1
- OUT=string.sub(K,D,D)..OUT
- end
- return OUT
- end
- -- Encounter Rate Functions
- function NormalisedRate(IN) -- takes the encounter rate value returns a number between 0-100, 0 being low enc and 100 being high enc
- NormRate = memory.readdword(IN)
- --IsNegative = 0
- if NormRate == 0 then
- NormRate = ""
- return NormRate
- else
- if NormRate >= 0xFFFF0000 then
- NormRate = NormRate - 0xFFFFFFFF
- --IsNegative = 1
- end
- NormRate = math.floor((0xFFFF - NormRate)/0xFF0)
- return NormRate
- end
- end
- if CurrentRate ~= NormalisedRate(AD6) then
- -- print(CurrentRate)
- -- print(NormalisedRate(AD6))
- -- print(EncounterRate)
- -- print(memory.readdword(0x02000498))
- -- print(EncounterRate ~= memory.readdword(0x02000498))
- -- print(memory.readdword(0x02000498) < 0x100000)
- if memory.readdword(AD6) == 0 then
- CurrentRate = 0
- end
- if EncounterRate ~= memory.readdword(0x02000498) and memory.readdword(0x02000498) < 0x100000 then
- if store ~= memory.readdword(0x030011BC) then
- EncounterRate = memory.readdword(0x02000498)+1
- end
- ColorRate1 = memory.readdword(0x02000498)-EncounterRate
- ColorRateShade = 0
- ColorRate2 = {255,255,255}
- if ColorRate1 < 0 then
- EncounterRate = memory.readdword(0x02000498)
- ColorRate2 = {255,255,255}
- CurrentRate = 0
- else
- if memory.readword(0x02000420) ~= 2 then -- world map?
- GoodRateThreshold2 = GoodRateThreshold*1.5
- if memory.readword(0x020301A0)==0xCC then -- Is Felix Walking?
- GoodRateThreshold2 = GoodRateThreshold2 / 2
- end
- else
- GoodRateThreshold2 = GoodRateThreshold
- if memory.readword(0x020301A0)==0x66 then -- Is Felix Walking?
- GoodRateThreshold2 = GoodRateThreshold2 / 2
- end
- end
- if ColorRate1 >= GoodRateThreshold2 then
- ColorRate2= {255, 0, 0}
- EncounterRate = memory.readdword(0x02000498)
- CurrentRate = NormalisedRate(AD6)
- if NormalisedRate(AD6) == "" then
- ColorRate2= {255, 255, 255}
- end
- else
- ColorRateShade = math.floor((GoodRateThreshold2-ColorRate1)/GoodRateThreshold2*255)
- if ColorRateShade <= 63 then
- ColorRate2 = {255, 4*ColorRateShade, 0}
- elseif ColorRateShade <=191 then
- ColorRate2 = {255-255*(ColorRateShade-63)/128-1, 255, 0}
- else
- ColorRate2 = {0,255,0}
- end
- EncounterRate = memory.readdword(0x02000498)
- CurrentRate = NormalisedRate(AD6)
- end
- end
- end
- end
- -- begin enemy HP/encounter loops
- -- Encounter / Level up Stats
- if memory.readword(0x02000420) ~= 0x1FE then
- gui.text(0,20,"Encounter: ".. (memory.readword(AD3)))
- --gui.text(160,20,"Rate: ".. (DEC_HEX(memory.readdword(AD6))))
- gui.text(160,20,"Rate: ".. NormalisedRate(AD6), ColorRate2)
- gui.text(0,40,"PP Regen: ".. (math.floor((memory.readword(0x020301A0))/0xFFF)))
- if memory.readword(0x020004A6) ~= 0 then
- gui.text(0,50,"Avoid Counter: ".. (math.floor((memory.readword(0x020004A6)/24))))
- end
- if memory.readword(0x020026D0) ~= 0 then
- gui.text(0,50,"Akafubu Counter: ".. (math.floor((memory.readword(0x020026D0)/60))+1))
- end
- if minorhudlock == false then
- fagi=memory.readbyte(0x02000520+0x1C+0x14C*4)
- flv=memory.readbyte(0x02000520+0x14C*4+0xF)
- fagilv=-fagi+(flv-5)*4+0x1B -- imperfect levels ups discounting randomly rolled stats on new file
- jagi=memory.readbyte(0x02000520+0x1C+0x14C*5)
- jlv=memory.readbyte(0x02000520+0x14C*5+0xF)
- jagilv=-jagi+(jlv-5)*4+0x1B -- imperfect levels ups discounting randomly rolled stats on new file
- sagi=memory.readbyte(0x02000520+0x1C+0x14C*6)
- slv=memory.readbyte(0x02000520+0x14C*6+0xF)
- sagilv=-sagi+(slv-5)*4+0x1E -- imperfect levels ups discounting randomly rolled stats on new file
- pagi=memory.readbyte(0x02000520+0x1C+0x14C*7)
- plv=memory.readbyte(0x02000520+0x14C*7+0xF)
- pagilv=-pagi+(plv-18)*4+0x45 -- imperfect levels ups discounting randomly rolled stats on new file
- gui.text(0,140,"Missing Agi F:" .. fagilv .. " J:" .. jagilv .. " S:" .. sagilv .. " P:" .. pagilv) -- -ve numbers indicate gained agility through mint
- if memory.readbyte(0x02000040)==0xFF then -- only display this after the reunion
- iagi=memory.readbyte(0x02000520+0x1C+0x14C*0)
- ilv=memory.readbyte(0x02000520+0x14C*0+0xF)
- iagilv=-iagi+(ilv-28)*4+0x75 --
- gagi=memory.readbyte(0x02000520+0x1C+0x14C*1)
- glv=memory.readbyte(0x02000520+0x14C*1+0xF)
- gagilv=-gagi+(glv-28)*4+0x68 --
- vagi=memory.readbyte(0x02000520+0x1C+0x14C*2)
- vlv=memory.readbyte(0x02000520+0x14C*2+0xF)
- vagilv=-vagi+(vlv-28)*4+0x7B --
- magi=memory.readbyte(0x02000520+0x1C+0x14C*3)
- milv=memory.readbyte(0x02000520+0x14C*3+0xF)
- magilv=-magi+(milv-28)*4+0x6F
- gui.text(48,150,"I:" .. iagilv .. " G:" .. gagilv .. " V:" .. vagilv .. " M:" .. magilv)
- else
- gui.text(0,150,"Kraden Counter: " .. memory.readword(AD7))
- end
- end
- end
- -- begin RNG counters
- GRN = memory.readdword(AD5)
- BRN = memory.readdword(AD4)
- if GRN == 1710661176 then
- store = 1710661176
- gcount=0
- end
- store2 = store
- gcountstore = gcount
- gcountbase = 0
- while store ~= GRN and gcountbase <= 10000 do
- --print(store)
- store = RNA(store)
- if store <= 0 then
- store = 0xFFFFFFFF+store+1
- gcount = gcount +1
- gcountbase = gcountbase +1
- else
- gcount = gcount +1
- gcountbase = gcountbase +1
- end
- end
- if store == GRN then
- gcountbase = 0
- else
- store = GRN
- gcountbase = 0
- gcount = gcountstore
- while store2 ~= GRN and gcountbase <= 100 do
- --print(store)
- store2 = RNR(store2)
- gcount = gcount -1
- gcountbase = gcountbase +1
- end
- if store2 == GRN then
- gcountbase = 0
- else
- gcountbase = 0
- gcount = 0
- end
- end
- bcountbase = 0
- while bstore ~= BRN and bcountbase <= 100 do
- bstore = RNA(bstore)
- if bstore <= 0 then
- bstore = 0xFFFFFFFF+bstore+1
- brncount = brncount+1
- bcountbase = bcountbase+1
- else
- brncount = brncount+1
- bcountbase = bcountbase+1
- end
- end
- if bstore == BRN then
- bcountbase = 0
- else
- bstore = BRN
- bcountbase = 0
- brncount = 0
- end
- if BRN == 0 then -- reset BRN counter on loadstate
- bstore = BRN
- bcount = 0
- end
- -- RNG Gui display
- gui.text(0,10,"GRN count: " .. gcount)
- gui.text(0,00,"BRN count: " .. brncount)
- -- PS/CBS scripts
- if minorhudlock == false then -- inclusion in the minor hud
- psb=00
- cbsb=00
- if psbrn ~= BRN then
- psb = BRN
- psb = RNA(psb)
- psc1 = 0
- while PS(psb) ~= 1 do
- psb = RNA(psb)
- psc1 = psc1 + 1
- end
- psc2 = psc1+1
- psb = RNA(psb)
- while PS(psb) ~=1 do
- psb = RNA(psb)
- psc2 = psc2 + 1
- end
- psc3 = psc2+1
- psb = RNA(psb)
- while PS(psb) ~= 1 do
- psb = RNA(psb)
- psc3 = psc3 + 1
- end
- psbrn=BRN
- end
- if cbsbrn ~= BRN then
- cbsb = BRN
- cbsb = RNA(cbsb)
- cbsc1 = 0
- while PS(cbsb) ~= 2 do
- cbsb = RNA(cbsb)
- cbsc1 = cbsc1 + 1
- if cbsc1 == 100 then break end
- end
- cbsc2 = cbsc1+1
- cbsb = RNA(cbsb)
- while PS(cbsb) ~= 2 do
- cbsb = RNA(cbsb)
- cbsc2 = cbsc2 + 1
- if cbsc2 == 102 then break end
- end
- cbsc3 = cbsc2+1
- cbsb = RNA(cbsb)
- while PS(cbsb) ~= 2 do
- cbsb = RNA(cbsb)
- cbsc3 = cbsc3 + 1
- if cbsc3 == 104 then break end
- end
- cbsbrn = BRN
- end
- gui.text(0,80,"AF " .. psc1 .. " " .. psc2 .. " " .. psc3)
- gui.text(0,90,"CBS " .. cbsc1 .. " " .. cbsc2 .. " " .. cbsc3)
- end
- if minorhudlock == false then
- Roll = memory.readdword(AD4)
- Roll = bit.lshift(Roll,8)
- Roll = bit.rshift(Roll,16)
- Roll = Roll*100
- Roll = bit.rshift(Roll,16)
- gui.text(120,00,"Roll: ".. Roll)
- gui.text(80,0,"Area: ".. memory.readword(0x02000420))
- gui.text(80,10,"Door: ".. memory.readword(0x02000422))
- gui.text(80,20,"Retreat: ".. memory.readword(0x020004A0))
- end
- -- Begin Flee/Assassinate Scripts
- -- Level Calculations
- local el1 = memory.readbyte(0x020308D7) -- Enemy 1 Level
- local el2 = memory.readbyte(0x020308D7+0x14C) -- etc
- local el3 = memory.readbyte(0x020308D7+2*0x14C)
- local el4 = memory.readbyte(0x020308D7+3*0x14C)
- local party = memory.readbyte(0x02000040) -- Party member number
- local isl= memory.readbyte(0x0200052F) -- Isaac level, +14C *user ID to get rest.
- -- local gal= memory.readbyte(0x0200067b) -- etc
- -- local ivl= memory.readbyte(0x020007c7)
- -- local mil= memory.readbyte(0x02000913)
- -- local mil= memory.readbyte(0x020008F3)
- -- local mil= memory.readbyte(0x020008F3)
- -- local mil= memory.readbyte(0x020008F3)
- -- local mil= memory.readbyte(0x020008F3)
- if memory.readword(0x02000420) == 0x1FE then
- if memory.readword(0x02030A12+3*0x14C) ~= 0 then -- enemy4 index nonzero
- ela = (el1+el2+el3+el4)/4
- elseif memory.readword(0x02030A12+2*0x14C) ~=0 then
- ela = (el1+el2+el3)/3
- elseif memory.readword(0x02030A12+1*0x14C) ~=0 then
- ela = (el1+el2)/2
- else
- ela = el1
- end
- pc1 = memory.readbyte(0x02000458)
- pc2 = memory.readbyte(0x02000459)
- pc3 = memory.readbyte(0x0200045A)
- pc4 = memory.readbyte(0x0200045B)
- if party == 0x70 then
- ml = (memory.readbyte(0x02000520+0x14C*pc1+0xF)+memory.readbyte(0x02000520+0x14C*pc2+0xF)+memory.readbyte(0x02000520+0x14C*pc3+0xF))/3
- else
- ml = (memory.readbyte(0x02000520+0x14C*pc1+0xF)+memory.readbyte(0x02000520+0x14C*pc2+0xF)+memory.readbyte(0x02000520+0x14C*pc3+0xF)+memory.readbyte(0x02000520+0x14C*pc4+0xF))/4
- end
- LevelAve = ml-ela
- --Agility/HP Battle Scripts
- local pcag1=memory.readword(0x02030338+0x04)
- local pcag2=memory.readword(0x02030338+0x04+0x10)
- local pcag3=memory.readword(0x02030338+0x04+0x20)
- local pcag4=memory.readword(0x02030338+0x04+0x30)
- if memory.readbyte(0x02030368)==0xFF then -- Hacky way of checking if we are in fight menu or battle
- if pcag1 >= 1000 then
- pcag1 = 0
- end
- if pcag2 >= 1000 then
- pcag2 = 0
- end
- if pcag3 >= 1000 then
- pcag3 = 0
- end
- if pcag4 >= 1000 then
- pcag4 = 0
- end
- gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1) -- Displays agility of party member pc1
- gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
- gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
- gui.text(0,70,"PC" .. pc4 .. " Agi: " .. pcag4)
- if memory.readbyte(0x02030900)>0 then
- gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308E4)) -- If Enemy 1 has nonzero HP display E1 agility
- gui.text(110,40, "HP: " .. memory.readword(0x02030900))
- else
- end
- if memory.readbyte(0x02030900+0x14C)>0 then
- gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308E4+0x14C))
- gui.text(110,50, "HP: " .. memory.readword(0x02030900+0x14C))
- else
- end
- if memory.readbyte(0x02030900+0x14C*2)>0 then
- gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308E4+0x14C*2))
- gui.text(110,60, "HP: " .. memory.readword(0x02030900+0x14C*2))
- else
- end
- if memory.readbyte(0x02030900+0x14C*3)>0 then
- gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308E4+0x14C*3))
- gui.text(110,70, "HP: " .. memory.readword(0x02030900+0x14C*3))
- else
- end
- if memory.readbyte(0x02030900+0x14C*4)>0 then
- gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308E4+0x14C*4))
- gui.text(110,80, "HP: " .. memory.readword(0x02030900+0x14C*4))
- else
- end
- elseif memory.readbyte(0x02030368)==0xFF and memory.readbyte(0x02030358)==0xFF then -- Hacky way of accounting for three person party
- gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1)
- gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
- gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
- if memory.readbyte(0x02030900)>0 then
- gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308E4)) -- If Enemy 1 has nonzero HP display E1 agility
- gui.text(110,40, "HP: " .. memory.readword(0x02030900+0x14C*0))
- else
- end
- if memory.readbyte(0x02030900+0x14C)>0 then
- gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308E4+0x14C))
- gui.text(110,50, "HP: " .. memory.readbyte(0x02030900+0x14C*1))
- else
- end
- if memory.readbyte(0x02030900+0x14C*2)>0 then
- gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308E4+0x14C*2))
- gui.text(110,60, "HP: " .. memory.readbyte(0x02030900+0x14C*2))
- else
- end
- if memory.readbyte(0x02030900+0x14C*3)>0 then
- gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308E4+0x14C*3))
- gui.text(110,70, "HP: " .. memory.readbyte(0x02030900+0x14C*3))
- else
- end
- if memory.readbyte(0x02030900+0x14C*4)>0 then
- gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308E4+0x14C*4))
- gui.text(110,80, "HP: " .. memory.readbyte(0x02030900+0x14C*4))
- else
- end
- else -- otherwise, we are in a battle and do the following
- while memory.readbyte(0x0203033C+0x10*(j-1)) ~= 0 do --while loop which checks nonzero agilities and therefore count number of actors in the battle
- trn[j]= memory.readbyte(0x02030338+0x10*(j-1)) -- add the character index to the trn array in order
- if trn[j]==0xFF then -- if user has already acted then do nothing
- j=j+1
- else
- gui.text(30+15*k,40,trn[j]) -- if user hasn't acted then display user in the turn order queue
- j=j+1
- k=k+1
- end
- end
- j=1
- k=1
- gui.text(0,40, "Turn Order: ")
- if memory.readbyte(0x02030900)>0 then
- gui.text(70,50, "E1 HP: " .. memory.readword(0x02030900))
- end
- end
- -- Agility Bonus Calculator
- if minorhudlock == false then
- if memory.readbyte(0x0203033C)>0 then
- local l=1
- while memory.readbyte(0x02030328+0x10*l) ~= pc1 and l<15 do
- l=l+1
- end
- if l~=15 then
- pcntag1=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc1-5)))/memory.readbyte(0x02000BDC+0x14C*(pc1-5))*10000
- pcntag1= math.floor(pcntag1)/100
- gui.text(0,100,"PC" .. pc1 .. " Bonus: " .. pcntag1 .. "%")
- end
- local l=1
- while memory.readbyte(0x02030328+0x10*l) ~= pc2 and l<15 do
- l=l+1
- end
- if l~=15 then
- pcntag2=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc2-5)))/memory.readbyte(0x02000BDC+0x14C*(pc2-5))*10000
- pcntag2= math.floor(pcntag2)/100
- gui.text(0,110,"PC" .. pc2 .. " Bonus: " .. pcntag2 .. "%")
- end
- local l=1
- while memory.readbyte(0x02030328+0x10*l) ~= pc3 and l<15 do
- l=l+1
- end
- if l~=15 then
- pcntag3=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc3-5)))/memory.readbyte(0x02000BDC+0x14C*(pc3-5))*10000
- pcntag3= math.floor(pcntag3)/100
- gui.text(0,120,"PC" .. pc3 .. " Bonus: " .. pcntag3 .. "%")
- end
- if memory.readbyte(0x0200045B)==0 and memory.readbyte(0x0200045C)==0 then
- else
- local l=1
- while memory.readbyte(0x02030328+0x10*l) ~= pc4 and l<15 do
- l=l+1
- end
- if l~=15 then
- pcntag4=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc4-5)))/memory.readbyte(0x02000BDC+0x14C*(pc4-5))*10000
- pcntag4= math.floor(pcntag4)/100
- -- gui.text(0,130,"PC" .. pc4 .. " Bonus: " .. pcntag4 .. "% Roll " .. memory.readbyte(0x02030328+0x10*l+0x04))
- end
- end
- end
- end
- fleeFail = memory.readbyte(0x02030092)
- function flee(S) -- Flee Success Calculation
- g = S
- g = RNB(g)*10000
- fl = 5000 + (2000*fleeFail) + (LevelAve * 500)
- g = bit.rshift(g, 16)
- if fl >= g then
- return true
- else
- return false
- end
- end
- RN= memory.readdword(0x030011BC)
- count = 0
- while flee(RN) == false do -- Attack Cancel to Flee Calculation
- count = count + 1
- if count == 100 then break end
- RN= RNA(RN)
- end
- gui.text(160,30,"ACs to Run: " .. count)
- -- % Chance to Run
- fleecount = 0
- if fleestore ~= memory.readdword(AD5) then
- fleeRN = memory.readdword(AD5)
- for i=1,1000 do
- if flee(fleeRN) == true then
- fleecount= fleecount +1
- end
- fleeRN=RNA(fleeRN)
- end
- fleepercent = fleecount/10
- fleestore = memory.readdword(AD5)
- fev = fleepercent/100
- EV = (fev*1+ math.floor(fev+.20,1)*(1-fev)*2+ math.floor(fev+.40,1)*(1-math.floor(fev+.20,1))*(1-fev)*3+ math.floor(fev+.60,1)*(1-math.floor(fev+.40,1))*(1-math.floor(fev+.20,1))*(1-fev)*4+ math.floor(fev+.80,1)*(1-math.floor(fev+.60,1))*(1-math.floor(fev+.40,1))*(1-math.floor(fev+.20,1))*(1-fev)*5+ (1-math.floor(fev+.80,1))*(1-math.floor(fev+.60,1))*(1-math.floor(fev+.40,1))*(1-math.floor(fev+.20,1))*(1-fev)*6)
- gui.text(100,20,"Run EV: ".. EV)
- gui.text(160,20,"Run%: " .. fleepercent)
- else
- gui.text(100,20,"Run EV: ".. EV )
- gui.text(160,20,"Run%: " .. fleepercent)
- end
- evcount = 0
- function vuln (S)
- e1Ind = S
- vuln1 = memory.readbyte(0x080B9E7C + ((e1Ind - 8) * 0x4C) + 0x3E)
- vuln2 = memory.readbyte(0x080B9E7C + ((e1Ind - 8) * 0x4C) + 0x3F)
- vuln3 = memory.readbyte(0x080B9E7C + ((e1Ind - 8) * 0x4C) + 0x40)
- return vuln1, vuln2, vuln3
- end
- function enemy (S,Elm) -- Enemy Elemental Data Table
- elemInd = memory.readbyte(0x080B9E7C + ((S - 8) * 0x4C) + 0x2A)
- enemyelmlevel = memory.readbyte(0x080C6684 + (elemInd * 0x18) + 4+Elm)
- return enemyelmlevel
- end
- function bchance (E) -- base chance for status
- if E == 16 or E == 17 then
- c = 75
- elseif E == 23 then
- c = 40
- elseif E == 24 then
- c = 35
- elseif E == 27 then
- c = 20
- end
- return c
- end
- function effectproc (S,E,Elm,U) -- Random number, What effect is this, Elmemental Affinity 0 = Venus, 1 = Mercury, 2= Mars, 3 = Jupiter, Who is using this 0 = Isaac, 1 = Garet, 2 = Ivan, 3 = Mia
- uelm = memory.readbyte(0x0200061C+0x20+U*0x14C+Elm) -- Elemental Power of User
- eluc = memory.readbyte(0x020308E6) -- Enemy Luck
- eind = memory.readword(0x02030A12) -- Enemy Index
- eelm = enemy(eind,Elm) -- Enemy Elemental Levels
- vul1, vul2, vul3 = vuln(eind) -- Enemy Vulnerability
- if vul1 == E or vul2 == E or vul3 == E then -- Vulnerability key at top
- v=25
- else
- v=00
- end
- if memory.readbyte(0x080C0F4C + (U * 0xB4) + 0x92 + Elm) == 54 then
- elmaff = 5
- else
- elmaff = 0
- end
- proc = (((uelm + elmaff - eelm)-(math.floor(eluc/2))*3)+bchance(E)+v)
- g = RNB(S)*100
- g = bit.rshift(g,16)
- if proc >= g then
- return true
- else
- return false
- end
- end
- function unleash (S)
- g = S
- g = RNB(g)*100
- g = bit.rshift(g,16)
- if 35 >= g then
- return true
- else
- return false
- end
- end
- -- to add; themis axe, thanatos mace?, sleep bomb, stun, pirate sword
- if minorhudlock == false then-- inclusion in the minor hud
- psword=0
- for i=0,29 do
- --print(memory.readbyte(0x02000C74+i*0x2))
- if memory.readbyte(0x02000C74+i*0x2)==0x1F then -- Jenna inventory check for psword
- if memory.readbyte(0x02000C75+i*0x2)==0x3 then -- Equip check
- psword=1
- end
- elseif memory.readbyte(0x02000C74+i*0x2-0x14C)==0x1F then
- if memory.readbyte(0x02000C75+i*0x2-0x14C)==0x3 then -- Equip check
- psword=2
- end
- end
- end
- if psword==1 then -- Psword Proc Calc
- BRN = memory.readdword(0x020054C8)
- bcount=0
- while effectproc(RNA(BRN),24,1,5) == false or unleash(BRN) == false do
- bcount = bcount+1
- if bcount == 100 then break end
- BRN=RNA(BRN)
- end
- gui.text(160,40,"Psword Sleep: " .. bcount)
- end
- if psword==2 then -- Psword Proc Calc
- BRN = memory.readdword(0x020054C8)
- bcount=0
- while effectproc(RNA(BRN),24,1,4) == false or unleash(BRN) == false do
- bcount = bcount+1
- if bcount == 100 then break end
- BRN=RNA(BRN)
- end
- gui.text(160,40,"Psword Sleep: " .. bcount)
- end
- eindex=memory.readword(0x02030A12)
- sleepb=0
- sleepuser=0
- for i=0,29 do
- --print(memory.readbyte(0x02000C74+i*0x2))
- if memory.readbyte(0x02000C74+i*0x2)==0xE3 then
- sleepb=1
- sleepuser=5
- elseif memory.readbyte(0x02000C74+0x14C+i*0x2)==0xE3 then
- sleepb=1
- sleepuser=6
- elseif memory.readbyte(0x02000C74-0x14C+i*0x2)==0xE3 then
- sleepb=1
- sleepuser=4
- elseif memory.readbyte(0x02000C74+i*0x2+0x14C*2)==0xE3 then -- Inventory check for sleepbomb
- sleepb=1
- sleepuser=7
- end
- end
- if sleepb == 1 and eindex ~= 0x5B then
- bcount=0
- while effectproc(BRN,24,3,sleepuser) == false do
- bcount=bcount+1
- if bcount==100 then break end
- BRN=RNA(BRN)
- end
- gui.text(160,50,"Sleep bomb: " .. bcount)
- end
- if memory.readbyte(0x02000520+5*0x14C+0x129) >= 0x46 and memory.readbyte(0x02000520+5*0x14C+0x129) <= 0x54 then -- Jenna Class Check
- BRN = memory.readdword(0x020054C8)
- bcount=0
- while effectproc(BRN,16,3,5) == false do -- Weaken calculation
- bcount = bcount+1
- if bcount == 100 then break end
- BRN=RNA(BRN)
- end
- gui.text(160,50,"Jenna Weaken: " .. bcount)
- end
- if memory.readbyte(0x02000520+4*0x14C+0x129) >= 0x46 and memory.readbyte(0x02000520+4*0x14C+0x129) <= 0x54 then -- Felix Class Check
- BRN = memory.readdword(0x020054C8)
- bcount=0
- while effectproc(BRN,16,3,4) == false do -- Weaken calculation
- bcount = bcount+1
- if bcount == 100 then break end
- BRN=RNA(BRN)
- end
- gui.text(160,60,"Felix Weaken: " .. bcount)
- if eindex == 0x5B then
- Sour = memory.readdword(0x020054C8)
- Sour = RNA(Sour)
- bcount=0
- while effectproc(Sour,16,3,7) == false do
- bcount = bcount + 1
- if bcount == 100 then break end
- Sour = RNA(Sour)
- end
- gui.text(160,70, "Sour " .. bcount)
- end
- end
- end
- -- Drop Stuff
- function drop(S)
- return memory.readbyte(0x080B9E7C+((S-8)*0x4C+0x44)), memory.readbyte(0x080B9E7C+((S-8)*0x4C+0x46))
- end
- function itemdrop(S,C)
- g = RNB(S)*100
- g = bit.rshift(g,16)
- if C >= g then
- return true
- else
- return false
- end
- end
- function droprate(S,ch) -- enemy index, chance of drop
- BRN = memory.readdword(0x020054C8)
- bcount=0
- bcount2=0
- rate=bit.rshift(0x64,ch-1)
- rate2=bit.rshift(0x64,ch-3)
- while itemdrop(BRN,rate) == false do
- bcount=bcount+1
- if itemdrop(BRN,rate2) == true then
- bcount2=bcount
- end
- if bcount == 100 then break end
- BRN=(RNA(BRN))
- end
- return bcount, bcount2
- end
- if minorhudlock == false then -- including drop stuff within the minor hud
- if memory.readbyte(0x02030900)>0 then
- eindex=memory.readword(0x02030A12)
- dr,ch = drop(eindex)
- if dr == 0xE3 or dr == 0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb, 0x44 is staff of anubis
- A,B= droprate(eindex,ch)
- gui.text(140,80, "E1 Item: " .. dr .. " Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
- end
- end
- if memory.readbyte(0x02030900+0x14C)>0 then
- eindex2=memory.readword(0x02030A12+0x14C)
- dr,ch=drop(eindex2)
- if dr == 0xE3 or dr==0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb
- A,B= droprate(eindex,ch)
- gui.text(140,100, "E2 Item: " .. dr .. " Turns " .. A .. "|" .. B)
- end
- end
- if memory.readbyte(0x02030900+0x14C*2)>0 then
- eindex3=memory.readword(0x02030A12+0x14C*2)
- dr,ch=drop(eindex3)
- if dr == 0xE3 or dr==0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb
- A,B= droprate(eindex,ch)
- gui.text(140,120, "E3 Item: " .. dr .. " Turns " .. A .. "|" .. B)
- end
- end
- end
- --end
- -- if memory.readbyte(0x02000048)>=0x70 and memory.readbyte(0x02000155) < 0x14 then -- If you have mist, return mist information
- -- BRN = memory.readdword(0x020023A8)
- -- bcount=0
- -- while effectproc(RNA(BRN),24,1,3) == false or unleash(BRN) == false do -- mist calculation
- -- bcount = bcount+1
- -- if bcount == 100 then break end
- -- BRN=RNA(BRN)
- -- end
- -- gui.text(160,50,"Mist: " .. bcount)
- -- end
- --end
- end
- --eindex=memory.readword(0x02030A12)
- -- This code is for BRN / GRN advance via keypresses (note AD4 = BRN and AD5 = GRN)
- keypress = input.get()
- if state == true and keypress["G"] == nil and keypress["H"] == nil and keypress["B"] == nil and keypress["N"] == nil and keypress["plus"] == nil and keypress["minus"] == nil then
- state = false
- end
- if state == false and keypress["B"] == true and keypress["shift"] == true then
- memory.writedword(AD4,RNA(memory.readdword(AD4)))
- brnadvancecounter = 30
- state = true
- end
- if state == false and keypress["N"] == true and keypress["shift"] == true then
- memory.writedword(AD4,RNR(memory.readdword(AD4)))
- brnreducecounter = 30
- state = true
- bstore = memory.readdword(AD4)
- brncount = brncount - 1
- end
- if state == false and keypress["G"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
- memory.writedword(AD5,RNA(memory.readdword(AD5)))
- grnadvancecounter = 30
- state = true
- end
- if state == false and keypress["H"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
- memory.writedword(AD5,RNR(memory.readdword(AD5)))
- grnreducecounter = 30
- state = true
- store = memory.readdword(AD5)
- gcount = gcount - 1
- end
- if state == false and keypress["plus"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
- --if memory.readdword(AD5) == 0x80000000 then
- -- memory.writedword(AD5,0)
- --end
- memory.writedword(AD5,(memory.readdword(AD5)+1)%0x80000000) -- increase GRN by one
- grnadvancecounter = 30
- state = true
- end
- if state == false and keypress["minus"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
- --if memory.readdword(AD4) == 0x80000000 then
- -- memory.writedword(AD4,0)
- --end
- memory.writedword(AD4,(memory.readdword(AD4)+1)%0x80000000) -- increase BRN by one
- brnadvancecounter = 30
- state = true
- end
- if brnadvancecounter >= 1 then
- --gui.text(100,100, "BRN advanced by one","#00FF00")
- gui.text(225,00, "+1","#00FF00")
- brnadvancecounter = brnadvancecounter-1
- end
- if brnreducecounter >= 1 then
- --gui.text(100,100, "BRN advanced by one","#00FF00")
- gui.text(225,00, "-1","#FF0000")
- brnreducecounter = brnreducecounter-1
- end
- if grnadvancecounter >= 1 then
- --gui.text(100,100, "GRN advanced by one","#00FF00")
- gui.text(225,10, "+1","#00FF00")
- grnadvancecounter = grnadvancecounter-1
- end
- if grnreducecounter >= 1 then
- --gui.text(100,100, "GRN advanced by one","#00FF00")
- gui.text(225,10, "-1","#FF0000")
- grnreducecounter = grnreducecounter-1
- end
- -- This code is for setting the RNG to key values
- if valuestate == false and keypress["V"] == true and keypress["shift"] == true then
- -- memory.writedword(AD4, 0x0) -- BRN set to 0
- -- memory.writedword(0x02000498, 0) -- Encounter rate to 0
- -- memory.writedword(0x02030194, 0) -- Reset Encounter Generation
- if memory.readdword(0x02000420) == 0x00010001 then
- memory.writedword(AD5, bit.band(RNGvalue3,0xFFFFFFFF))
- print("GRN set to title screen value")
- valuestate = true
- else
- if memory.readdword(AD5) == RNGvalue1 then
- memory.writedword(AD5,RNGvalue2)
- print("GRN set to upper bound")
- --elseif memory.readdword(AD5) == RNGvalue2 then
- else
- memory.writedword(AD5,RNGvalue1)
- print("GRN set to lower bound")
- end
- valuestate = true
- end
- end
- if valuestate == true and keypress["V"] == nil then
- valuestate = false
- end
- -- This code is for a fight timer, toggled by shift+T
- -- This block is for toggling the timer on and off
- if timerstate == false and timeron == false and keypress["T"] == true and keypress["shift"] == true then
- timerstate = true
- timeron = true
- print("Timer enabled. Press t to reset the timer at any point.")
- end
- if timerstate == false and timeron == true and keypress["T"] == true and keypress["shift"] == true then
- timerstate = true
- timeron = false
- fighttimer = 0
- print("Timer disabled.")
- end
- if timerstate == false and timeron == true and keypress["T"] == true and keypress["shift"] == nil then
- fighttimer = 0
- timerstate = true
- --print("Timer reset.") -- this gets annoying to print after a while
- end
- if timerstate == true and keypress["T"] == nil then
- timerstate = false
- end
- -- This code is the fight timer
- if timeron == true then
- if memory.readbyte(0x02030468) == 0xFF then
- gui.text(0,20, "Timer " .. math.floor(fighttimer/60) .. "s")
- fighttimer = fighttimer+1
- infight = true
- end
- if infight == true and memory.readbyte(0x02030468) == 0x0 then
- fighttimertext = 360
- fightlength = fighttimer
- fighttimer = 0
- infight = false
- end
- if fighttimertext >= 1 then
- gui.text(0,100, "Last Fight " .. math.floor(fightlength/6)/10 .. "s (" .. fightlength .. " frames)","#00FF00")
- fighttimertext = fighttimertext - 1
- end
- if keypress["Y"] == true and keypress["shift"] == true then
- fighttimertext = 360
- end
- end
- -- This code is for a menu timer, toggled by shift+M
- -- This block is for toggling the timer on and off
- --if menustate == false and menutimeron == false and keypress["M"] == true and keypress["shift"] == true then
- -- menustate = true
- -- menutimeron = true
- -- print("Menu timer enabled.")
- --end
- --if menustate == false and menutimeron == true and keypress["M"] == true and keypress["shift"] == true then
- -- menustate = true
- -- menutimeron = false
- -- menutimer = 0
- -- print("Menu timer disabled.")
- --end
- --if menustate == true and keypress["M"] == nil then
- -- menustate = false
- --end
- -- This code is the menu timer
- -- if menutimeron == true then
- -- if memory.readword(0x02000060) == 0x50 then
- -- gui.text(160,20, "Menu Timer " .. math.floor(menutimer/60) .. "s")
- -- menutimer = menutimer+1
- -- menuopen = true
- -- end
- -- if menuopen == true and memory.readbyte(0x02000060) == 0x0 then
- -- menutimertext = 360
- -- menulength = menutimer
- -- menutimer = 0
- -- menuopen = false
- -- end
- -- if menutimertext >= 1 then
- -- gui.text(160,30, "Last Menu " .. math.floor(menulength/6)/10 .. "s","#00FF00")
- -- gui.text(160,40, "(" .. menulength .. " frames)","#00FF00")
- -- menutimertext = menutimertext - 1
- -- end
- -- if keypress["comma"] == true and keypress["shift"] == true then
- -- menutimertext = 360
- -- end
- --end
- -- This code is for locking Felix's pp
- if ppstate == false and keypress["P"]==true and keypress["shift"]==true and pplock == false then
- pplock = true
- ppstate = true
- print("Felix PP lock enabled")
- end
- if ppstate == false and keypress["P"]==true and keypress["shift"]==true and pplock == true then
- pplock = false
- ppstate = true
- print("Felix PP lock disabled")
- end
- if ppstate == true and keypress["P"]==nil then
- ppstate = false
- end
- if pplock == true then
- memory.writeword(AD1,0x5)
- end
- -- This code is for toggling encounters
- if encounterstate == false and keypress["E"]==true and keypress["shift"]==true and encounterlock == false then
- encounterlock = true
- encounterstate = true
- print("Encounters disabled")
- end
- if encounterstate == false and keypress["E"]==true and keypress["shift"]==true and encounterlock == true then
- encounterlock = false
- encounterstate = true
- print("Encounters enabled")
- end
- if encounterstate == true and keypress["E"]==nil then
- encounterstate = false
- end
- if encounterlock == true then
- memory.writeword(AD3,0x1)
- end
- -- This code is for the map data overlay
- if overlaystate == false and keypress["O"]==true and keypress["shift"]==true and overlay == false then
- overlay = true
- overlaystate = true
- print("Overlay enabled")
- end
- if overlaystate == false and keypress["O"]==true and keypress["shift"]==true and overlay == true then
- overlay = false
- overlaystate = true
- print("Overlay disabled")
- end
- if overlaystate == true and keypress["O"]==nil then
- overlaystate = false
- end
- if overlay == true and infight == false then
- tile = memory.readdword(0x020301A4)
- tile_value = memory.readword(tile)
- gui.text(130,20,"Tile Address: 0x".. string.format("%x",tile))
- gui.line(108, 98, 123, 98)
- gui.line(123, 98, 123, 108)
- gui.line(123, 108, 108, 108)
- gui.line(108, 108, 108, 98)
- isaacDataAddr = memory.readdword(memory.readdword(0x0300006C) + 0x24)
- isaacX = memory.readdword(isaacDataAddr + 0x8)
- isaacY = memory.readdword(isaacDataAddr + 0x10)
- isaacLayer = memory.readbyte(isaacDataAddr + 0x22)
- layerAddrH = memory.readdword((memory.readdword(0x03000020) + 0x13C + (isaacLayer * 0x38)))
- tileOffset = bit.rshift(isaacX, 0x14) + (bit.rshift(isaacY, 0x14) * 0x80)
- currentHeightTile = memory.readbyte(layerAddrH + tileOffset)
- --gui.text(122,30,"Height address: 0x" .. string.format("%x",layerAddrH+tileOffset))
- function HeightTile(Xcoord, Ycoord, Layer)
- layerAddrH = memory.readdword((memory.readdword(0x03000020) + 0x13C + (Layer * 0x38)))
- tileOffset = bit.rshift(Xcoord, 0x14) + (bit.rshift(Ycoord, 0x14) * 0x80)
- HeightT = memory.readbyte(layerAddrH + tileOffset)
- return HeightT
- end
- function compress(S)
- R = bit.rshift(memory.readdword(S),16)
- R = bit.band(R,0xFF)
- return R
- end
- function colortla(X,Y,Z)
- T = HeightTile(isaacX,isaacY,isaacLayer)
- U = HeightTile(X,Y,Z)
- if T == U then
- C= "white"
- elseif T < U then
- shade = math.min((U-T)/4*255,255)
- C = { 255, 255-shade, 255-shade}
- elseif T > U then
- shade = math.min((T-U)/4*255,255)
- C = { 255-shade, 255, 255}
- end
- return C
- end
- if memory.readword(0x02000420) == 2 then
- for i=-4,4 do
- for j=-4,4 do
- gui.text(110+j*15,100+i*15, compress(tile+0x80*i+0x4*j), colortla(memory.readdword(0x020322F4)+1000000*j,memory.readdword(0x020322FC)+1000000*i,isaacLayer))
- end
- end
- else
- for i=-4,4 do
- for j=-4,4 do
- gui.text(110+j*15,100+i*15, compress(tile+0x200*i+0x4*j), colortla(memory.readdword(0x020322F4)+1000000*j,memory.readdword(0x020322FC)+1000000*i,isaacLayer))
- end
- end
- end
- end
- -- This code is for toggling af / cbs / missing agility display
- if minorhudstate == false and keypress["A"]==true and keypress["shift"]==true and minorhudlock == false then
- minorhudlock = true
- minorhudstate = true
- print("Minor hud disabled")
- end
- if minorhudstate == false and keypress["A"]==true and keypress["shift"]==true and minorhudlock == true then
- minorhudlock = false
- minorhudstate = true
- print("Minor hud enabled")
- end
- if minorhudstate == true and keypress["A"]==nil then
- minorhudstate = false
- end
- --This code is for randomising the GRN/BRN by advancing the GRN/BRN a random number of times
- if randomiserstate == true and keypress["R"] == nil then
- randomiserstate = false
- end
- if randomiserstate == false and keypress["R"] == true and keypress["shift"] == true then
- randomisercounter = 50
- randomiserstate = true
- end
- if randomisercounter == 50 then
- grnrandomadvance = math.random(1,100)
- brnrandomadvance = math.random(1,100)
- for i=1,grnrandomadvance do
- memory.writedword(AD5,RNA(memory.readdword(AD5)))
- end
- for i=1,brnrandomadvance do
- memory.writedword(AD4,RNA(memory.readdword(AD4)))
- end
- end
- if randomisercounter >= 1 then
- --gui.text(100,100, "BRN advanced by one","#00FF00")
- gui.text(225,00, "+" .. brnrandomadvance,"#00FF00")
- gui.text(225,10, "+" .. grnrandomadvance,"#00FF00")
- randomisercounter = randomisercounter-1
- end
- -- This code is for the oob diagnostic tool
- if diagstate == false and keypress["D"]==true and keypress["shift"]==true and diagnostics == false then
- diagnostics = true
- currentarea = memory.readword(0x02000420)
- memorysnapshot = true
- diagstate = true
- memoryentry = {}
- oldmemorydifferencelocation = {0,0}
- print("OOB Diagnostis enabled")
- end
- if diagstate == false and keypress["D"]==true and keypress["shift"]==true and diagnostics == true then
- diagnostics = false
- diagstate = true
- print("OOB Diagnostis disabled")
- end
- if diagstate == true and keypress["D"]==nil then
- diagstate = false
- end
- if diagnostics == true then
- if memorysnapshot == true then -- take a snapshot of the memory for later comparisons
- for i=1,4096 do
- memorysum = 0
- memorysum = memorysum+memory.readword(0x02020000+0x4*i)
- memoryentry[i] = memorysum
- end
- memorysnapshot = false
- end
- if currentarea ~= memory.readword(0x02000420) then -- when area changes compare against snapshot
- if memory.readword(0x02000420) == 0x1FE and areacomparisonexception == false then -- battles have a 36 frame delay before memory is loaded, this script waits 36 frames for that to happen
- areacomparisontimer = 37
- areacomparisontimerstate = true
- areacomparisonexception = true
- end
- if memory.readword(0x02000420) ~= 0x1FE then
- areacomparisonexception = false
- end
- diagcounter = 0
- while diagcounter <= 4096 and areacomparisontimerstate == false do
- diagcounter = diagcounter + 1
- memorysum = 0
- memorysum = memorysum+memory.readword(0x02024000-0x4*diagcounter)
- memorycomparison = memorysum
- if memorycomparison ~= memoryentry[4096-diagcounter] then
- -- memorysnapshot = true
- memorydifferencelocation = 0x02024000-0x4*diagcounter
- oldmemorydifferencelocation[2] = oldmemorydifferencelocation[1]
- oldmemorydifferencelocation[1] = memorydifferencelocation
- diagnostictimer = 300
- break
- end
- end
- if areacomparisontimer == 1 then
- areacomparisontimerstate = false
- else
- areacomparisontimer = areacomparisontimer -1
- end
- if areacomparisontimer == 0 then
- currentarea = memory.readword(0x02000420)
- end
- end
- if diagnostictimer >= 1 then
- diagnostictimer = diagnostictimer - 1
- gui.text(60,90, "Tile difference at 0x" .. string.format("%x",memorydifferencelocation),"#FF0000")
- end
- if keypress["D"] == true and keypress["shift"] == nil then
- extendeddiagtimer = 300
- end
- if extendeddiagtimer >= 1 then
- extendeddiagtimer = extendeddiagtimer - 1
- gui.text(60,100, "Current difference at 0x" .. string.format("%x",oldmemorydifferencelocation[1]),"#FF0000")
- gui.text(60,110, "Previous difference at 0x" .. string.format("%x", oldmemorydifferencelocation[2]),"#FF0000")
- gui.text(60,120, "Delta: " .. string.format("%x", oldmemorydifferencelocation[1]-oldmemorydifferencelocation[2]),"#FF0000")
- end
- end
- -- This code is for the Avoid information
- if avoidstate == false and keypress["L"]==true and keypress["shift"]==true and avoidInfo == false then
- avoidInfo = true
- MobIndex = {0,0}
- PartySize = 0
- TargetLevel = 0
- avoidstate = true
- print("Avoid information enabled")
- end
- if avoidstate == false and keypress["L"]==true and keypress["shift"]==true and avoidInfo == true then
- avoidInfo = false
- avoidstate = true
- print("Avoid information disabled")
- end
- if avoidstate == true and keypress["L"]==nil then
- avoidstate = false
- end
- if avoidInfo == true then
- if MobIndex[1] ~= memory.readbyte(encounterNumber) or MobIndex[2]~=memory.readbyte(encounterNumber+1) then
- MobIndex = {memory.readbyte(encounterNumber),memory.readbyte(encounterNumber+1)}
- if MobIndex[1] ~= 0 then
- TargetLevel = memory.readword(0x080EDACC + MobIndex[1]*0x1C + 2)
- else
- TargetLevel = memory.readword(0x080EDACC + MobIndex[2]*0x1C + 2)
- end
- end
- if avoidcurrentarea ~= 0x1FE then
- if memory.readbyte(0x02000040) ~= PartySize then -- would have been better to bit.rshift this instead of this hacky way
- FelixInParty = bit.band(0x10,memory.readbyte(0x02000040))/0x10
- JennaInParty = bit.band(0x20,memory.readbyte(0x02000040))/0x20
- ShebaInParty = bit.band(0x40,memory.readbyte(0x02000040))/0x40
- PiersInParty = bit.band(0x80,memory.readbyte(0x02000040))/0x80
- IsaacInParty = bit.band(0x1,memory.readbyte(0x02000040))/0x1
- GaretInParty = bit.band(0x2,memory.readbyte(0x02000040))/0x2
- IvanInParty = bit.band(0x4,memory.readbyte(0x02000040))/0x4
- MiaInParty = bit.band(0x8,memory.readbyte(0x02000040))/0x8
- PartySize = memory.readbyte(0x02000040)
- end
- PartyLevel = math.floor((memory.readbyte(0x0200052F)*IsaacInParty + memory.readbyte(0x0200052F+0x14C)*GaretInParty +
- memory.readbyte(0x0200052F+0x14C*2)*IvanInParty + memory.readbyte(0x0200052F+0x14C*3)*MiaInParty +
- memory.readbyte(0x0200052F+0x14C*4)*FelixInParty + memory.readbyte(0x0200052F+0x14C*5)*JennaInParty +
- memory.readbyte(0x0200052F+0x14C*6)*ShebaInParty + memory.readbyte(0x0200052F+0x14C*7)*PiersInParty)/(
- IsaacInParty+GaretInParty+IvanInParty+MiaInParty+FelixInParty+JennaInParty+ShebaInParty+PiersInParty))
- gui.text(80,0,'Target Level: ' .. TargetLevel)
- gui.text(80,10,'Party Level: ' .. PartyLevel)
- end
- end
- -- This code is for a global timer, toggled by shift+Q
- -- This block is for toggling the timer on and off and pausing the timer
- if globaltimerstate == false and globaltimeron == false and keypress["Q"] == true and keypress["shift"] == true then
- globaltimerstate = true
- globaltimeron = true
- print("Global timer enabled.")
- print("Press q to reset the timer at any point.")
- print("Press w to pause or unpause the timer.")
- print("Press tab to record a time.")
- print("Press shift+w to display last three recorded times.")
- end
- if globaltimerstate == false and globaltimeron == true and keypress["Q"] == true and keypress["shift"] == true then
- globaltimerstate = true
- globaltimeron = false
- globaltimer = 0
- print("Global timer disabled.")
- end
- if globaltimerstate == false and globaltimeron == true and keypress["Q"] == true and keypress["shift"] == nil then
- globaltimer = 0
- globaltimerstate = true
- print("Global timer reset")
- end
- if globaltimerstate == false and globaltimeron == true and globaltimerpause == false and keypress["W"] == true and keypress["shift"] == nil then
- globaltimerpause = true
- globaltimerstate = true
- end
- if globaltimerstate == false and globaltimeron == true and globaltimerpause == true and keypress["W"] == true and keypress["shift"] == nil then
- globaltimerpause = false
- globaltimerstate = true
- end
- if globaltimerstate == true and keypress["W"] == nil and keypress["Q"] == nil and keypress["tab"] == nil then
- globaltimerstate = false
- end
- -- This code is the global timer
- if globaltimeron == true then
- if globaltimerpause == false then
- gui.text(0,120, "Timer " .. math.floor(globaltimer/60) .. "s")
- globaltimer = globaltimer+1
- end
- if globaltimerpause == true then
- gui.text(0,120, "Timer " .. math.floor(globaltimer/6)/10 .. "s " .. globaltimer .. " frames","#FFFF00")
- end
- if keypress["tab"] == true and globaltimerstate == false then
- globaltimerstore[3] = globaltimerstore[2]
- globaltimerstore[2] = globaltimerstore[1]
- globaltimerstore[1] = globaltimer
- globaltimer = 0
- globaltimerstate = true
- print("Time recorded")
- end
- if keypress["W"] == true and keypress["shift"] == true and globaltimerstate == false then
- globaltimerstoretimer = 360
- globaltimerstate = true
- end
- if globaltimerstoretimer >= 1 then
- if globaltimerstore[1] >= 1 then
- gui.text(0,90, "Time #1 " .. math.floor(globaltimerstore[1]/6)/10 .. "s " .. globaltimerstore[1] .. " frames","#00FF00")
- end
- if globaltimerstore[2] >= 1 then
- gui.text(0,100, "Time #2 " .. math.floor(globaltimerstore[2]/6)/10 .. "s " .. globaltimerstore[2] .. " frames","#00FF00")
- end
- if globaltimerstore[3] >= 1 then
- gui.text(0,110, "Time #3 " .. math.floor(globaltimerstore[3]/6)/10 .. "s " .. globaltimerstore[3] .. " frames","#00FF00")
- end
- globaltimerstoretimer = globaltimerstoretimer - 1
- end
- end
- vba.frameadvance();
- end
Add Comment
Please, Sign In to add comment