Plexa

Golden Sun Utility Script v2.2.lua

Nov 10th, 2020 (edited)
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 57.68 KB | None | 0 0
  1. local AD1 = 0x0200053a -- Isaac PP
  2. local AD3 = 0x0200047A -- Next Encounter
  3. local AD4 = 0x020023A8 -- Battle RN
  4. local AD5 = 0x03001CB4 -- General RN
  5. local AD6 = (0x020301A8) -- Encounter Step Counter
  6. local EncounterRate = memory.readdword(0x02000478)
  7. local gcount = 0
  8. local bcounter = 0
  9. local store = memory.readdword(0x03001CB4)
  10. local bstore = memory.readdword(0x020023A8)
  11. local brncount=0
  12. local fleestore = 0
  13. local fleepercent = 0
  14. local mem = 0x2010000
  15. local memcount = 0
  16. local keypress = {}
  17. local state = false
  18. local brnadvancecounter = 0
  19. local brnreducecounter = 0
  20. local grnadvancecounter = 0
  21. local grnreducecounter = 0
  22. local timerstate = false
  23. local timeron = false
  24. local fighttimer = 0
  25. local infight = false
  26. local fighttimertext = 0
  27. local fightlength = 0
  28.  
  29. local pplock = false
  30. local ppstate = false
  31.  
  32. local encounterlock = false
  33. local encounterstate = false
  34.  
  35. local minorhudlock = true
  36. local minorhudstate = false
  37.  
  38. local overlaystate = false
  39. local overlay = false
  40.  
  41. local randomisercounter = 0
  42. local   randomiserstate = false
  43. local grnrandomisercounter = 0
  44. local   grnrandomiserstate = false
  45.  
  46. local nosq = false
  47. local nosqstate = false
  48.  
  49. local debugmode = false
  50. local debugmodestate = false
  51.  
  52. local BRN_temp = 0
  53. local BRN_temps = 0
  54. local BRN_tempss = 0
  55. local BRN_tempsss = 0
  56. local BRN_tempssss = 0
  57.  
  58. local RatePredictionRNGStore = 0
  59. local RatePredictionVectorStore = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}
  60. local tableVariableStore = 0
  61.  
  62. local globaltimerstate = false
  63. local globaltimeron = false
  64. local globaltimerpause = false
  65. local globaltimer = 0
  66. local globaltimertext = 0
  67. local globallength = 0
  68. local globaltimerstore = {0,0,0}
  69. local globaltimerstoretimer = 0
  70.  
  71. local BaseHP = 0x02000510
  72. local BasePP = 0x02000512
  73. local BaseAtk = 0x02000518
  74. local BaseDef = 0x0200051A
  75. local BaseAgi = 0x0200051C
  76. local BaseLuc = 0x0200051E -- readbyte for this entry
  77. local Cursor = (0x050003CA) -- alternatively, 0x03007DE4 which gives slot in part, not character
  78. --local CursorGaret = (0x020333F0) -- as above
  79. --local CursorIvan = (0x02033428)
  80. --local CursorMia = (0x02033460)
  81. local CharMemDiff = 0x14C -- gap between character memory values
  82. local CurrentChar = 0
  83. local CurrentName = ""
  84. local CharEXP = 0
  85. local IsaacLevels = {0,24,67,144,283,519,873,1369,2039,2910,3999,5306,6861,8696,10843,13334,16224,19548,23371,27767,32778,38491,45004,52429,60893,70457}--26 levels
  86. local GaretLevels = {0,30,84,176,332,582,957,1482,2191,3113,4265,5647,7292,9233,11504,14138,17193,20706,24746,29271,34339,40015,46372,53492,61894,71808}
  87. local IvanLevels = {0,32,90,194,350,568,895,1418,2150,3102,4292,5720,7419,9424,11770,14491,17647,21276,25449,30248,35719,41956,49066,57171,66411,76852}
  88. local MiaLevels = {0,31,87,188,350,609,997,1540,2273,3226,4341,5657,7197,8999,11107,13594,16529,19992,24078,28899,34395,40660,47802,55944,65226,75715}
  89. local levelstore = 1
  90. local statstate = false
  91. local StatColor = {"#00FF00","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"}
  92. local SelectedStat = 0
  93. local StatToChange = 0
  94. local IsaacGoals = {{30,182},{20,80},{13,86},{6,38},{8,86}}
  95. local GaretGoals = {{33,191},{18,76},{11,83},{8,41},{6,76}}
  96. local IvanGoals = {{28,166},{24,92},{8,76},{4,35},{11,91}}
  97. local MiaGoals = {{29,173},{23,90},{9,79},{5,37},{7,80}}
  98. local CurrentGoals = {{0,0},{0,0},{0,0},{0,0},{0,0}}
  99.  
  100. local StatusMenuOpen = false
  101.  
  102. function LevelCalculator(CurrentCharacter)
  103.   CharEXP = memory.readdword(0x02000624+CharMemDiff*CurrentCharacter)
  104.   levelstore = 1
  105.   if CurrentCharacter == 0 then
  106.     CharLevels = IsaacLevels
  107.   elseif CurrentCharacter == 1 then
  108.     CharLevels = GaretLevels
  109.   elseif CurrentCharacter == 2 then
  110.     CharLevels = IvanLevels
  111.   elseif CurrentCharacter == 3 then
  112.     CharLevels = MiaLevels
  113.   end
  114.   while CharEXP - CharLevels[levelstore+1] > 0 do
  115.     levelstore = levelstore + 1
  116.   end
  117.   return levelstore
  118. end
  119.  
  120. function WhichStat(S,C) -- SelectedStat, CurrentChar
  121.   if S == 0 then
  122.     return BaseHP+CharMemDiff*C
  123.   elseif S == 1 then
  124.     return BasePP+CharMemDiff*C
  125.   elseif S == 2 then
  126.     return BaseAtk+CharMemDiff*C
  127.   elseif S == 3 then
  128.     return BaseDef+CharMemDiff*C
  129.   elseif S == 4 then
  130.     return BaseAgi+CharMemDiff*C
  131.   end
  132. end
  133. --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  134. -- New things from TLA Utility Script 2.2
  135.  
  136. -- Good Rate analysis
  137. local GoodRateThreshold = 0xC00 -- Hex value between 0x100 and 0x16000
  138. local CurrentRate = 0
  139. local encounteranalysisstate = false
  140. local encounteranalysis = false
  141.  
  142. local encounterColor = {0,0,0}
  143. local encounterValue = memory.readdword(0x02000478)
  144. local encounterPreviousvalue = memory.readdword(0x02000478)
  145.  
  146. -- Exploratory Rate analysis
  147. local OldRate = 0
  148. local NewRate = 0
  149. local RateRate = 0
  150. local WorldMapOffset = 0
  151. local StepGRNOffset = 0
  152. local moveList = {"Base", "Move", "Frost", "Growth", "Douse / Halt", "Lift / Carry", "Mind Read"}
  153. local grnAdvanceList = {0, 295, 96, 63, 80, 72, 0}
  154. local tableVariable = 1
  155. local tableVairabletemp = 1
  156. local tableState = false
  157.  
  158.  
  159.              function NormalisedRate(IN) -- takes the encounter rate value returns a number between 0-100, 0 being low enc and 100 being high enc
  160.                  NormRate = memory.readdword(IN)
  161.                  --IsNegative = 0
  162.                  if NormRate == 0 then
  163.                      NormRate = ""
  164.                      return NormRate
  165.                  else
  166.                      if NormRate >= 0xFFFF0000 then
  167.                          NormRate = NormRate - 0xFFFFFFFF
  168.                          --IsNegative = 1
  169.                      end
  170.                      NormRate = math.floor((0xFFFF - NormRate)/0xFF0)
  171.                      return NormRate
  172.                  end
  173.              end
  174.  
  175.        function NormalisedRate2(IN) -- takes the encounter rate value returns a number between 0-100, 0 being low enc and 100 being high enc
  176.          NormRate = IN
  177.          --IsNegative = 0
  178.          if NormRate == 0 then
  179.            NormRate = ""
  180.            return NormRate
  181.            else
  182.            NormRate = math.floor((0xFFFF - NormRate)/0xFF0)
  183.            return NormRate
  184.          end
  185.        end
  186.  
  187.        function NormalisedRate3(IN) -- takes the encounter rate value returns a number between 0-100, 0 being low enc and 100 being high enc
  188.           NormRate = IN
  189.          --IsNegative = 0
  190.           NormRate = math.floor((0xFFFF - NormRate)/0xFF0)
  191.           return NormRate
  192.        end
  193.  
  194.        --------------------------------------------------- NEW SHIT STARTS HERE
  195.        function RNC(R)   -- RN concactenate
  196.          g = R
  197.          g = bit.lshift(g,8)
  198.          g = bit.band(g,0xFFFFFFFF)
  199.          g = bit.rshift(g,16)
  200.          return g
  201.        end
  202.  
  203.  
  204.        function RatePrediction(IN)
  205.          RatePred1 = math.floor(RNC(RNA(IN)))
  206.          RatePred2 = math.floor(RNC(RNA(RNA(IN))))
  207.          RatePred3 = math.floor(RNC(RNA(RNA(RNA(IN)))))
  208.          RatePred4 = math.floor(RNC(RNA(RNA(RNA(RNA(IN))))))
  209.          RatePred =  math.floor(RatePred1 - RatePred2 + RatePred3 - RatePred4)/2
  210.          return RatePred
  211.        end
  212.  
  213.        function RatePsyCalc(IN,ADV)
  214.          R = IN
  215.          N = ADV
  216.          if N >= 0 then
  217.            for i = 1,N,1 do
  218.              R = RNA(R)
  219.            end
  220.          else
  221.            N=-N
  222.            for i = 1,N,1 do
  223.              R = RNR(R)
  224.            end
  225.          end
  226.          R=RatePrediction(R)
  227.          R=NormalisedRate3(R)
  228.          return R
  229.        end
  230.  
  231.        function ColorRate(R) -- R = ColorRate1
  232.              ColorRateS= {255, 0, 0}
  233.              ColorRateShade = math.floor((22-R)/22*255)
  234.              if ColorRateShade <= 63 then
  235.                ColorRateS = {255, 4*ColorRateShade, 0}
  236.              elseif ColorRateShade <=191 then
  237.                ColorRateS = {255-255*(ColorRateShade-63)/128-1, 255, 0}
  238.              else
  239.                ColorRateS = {0,255,0}
  240.              end
  241.            return ColorRateS
  242.          end
  243.  
  244.  
  245.          function PercentRoll(RNG,Percent)
  246.              rollTemp = RNG
  247.              rollTemp = bit.lshift(rollTemp,8)
  248.              rollTemp = bit.rshift(rollTemp,16)
  249.              rollTemp = rollTemp*Percent
  250.              rollTemp = bit.rshift(rollTemp,16)
  251.              return rollTemp
  252.            end
  253.            function RNR (R) -- RN reverse Function
  254.             gout = bit.band((R-0x3039),0xFFFFFFFF) -- or 0xFFFFFFFF? 0x80000000 seems to be the cap for the RNG
  255.             multi = 0x41c64e6d
  256.             g={}
  257.             m={}
  258.             a={}
  259.             for i=1,32,1 do
  260.               if bit.band(gout,2^(i-1)) == 0 then
  261.                 g[i] = 0
  262.               else
  263.                 g[i] =1
  264.               end
  265.               if bit.band(multi,2^(i-1)) == 0 then
  266.                 m[i] = 0
  267.               else
  268.                 m[i] = 1
  269.               end
  270.             end
  271.             aleftover=0
  272.             for i=1,32,1 do
  273.               j=i
  274.               adiff = 0
  275.               while j>1 do
  276.                 adiff = adiff + a[i+1-j]*m[j]
  277.                 j=j-1
  278.               end
  279.               adiff = adiff + aleftover
  280.               a[i] = (g[i] + adiff)%2
  281.               aleftover = math.floor((a[i]+adiff)/2)
  282.             end
  283.             gin = 0
  284.             for i=1,32,1 do
  285.                gin = gin + 2^(i-1)*a[i]
  286.             end
  287.             gin = bit.band(gin, 0xFFFFFFFF)
  288.             --gin = gin%0x80000000
  289.              return gin
  290.             end
  291.  
  292.  
  293.  
  294.     --eel = memory.readbyte(0x0203089E) -- venus res
  295.     --eme = memory.readbyte(0x020308A2)
  296.     --ema = memory.readbyte(0x020308A6)
  297.     --eju = memory.readbyte(0x020308A8)
  298.  
  299.     -- Vulnerability Key
  300. --12 = Drop Def 25%
  301. --13 = Drop def 12%
  302. --16 = res drop 40
  303. --17 = res drop 20
  304. --20 = delusion
  305. --23 = stun
  306. --24 = sleep
  307. --27 = death
  308. --31 = HP steal
  309. --32 = PP steal
  310. --60 = 50% dmg to health
  311. --69 = 10% dmg to PP
  312. print("Welcome to the Golden Sun Utility Script")
  313. print("Commands:")
  314. print("shift+g: advances the GRN by one")
  315. print("shift+b: advances the BRN by one")
  316. print("shift+r: advance BRN/GRN by a random amount")
  317. print("shift+a: toggle minor hud")
  318. print("shift+t: toggle battle timer")
  319. print("shift+y: force display of last fight length (timer must be on)")
  320. print("shift+p: lock Isaac's pp to 5")
  321. print("shift+e: toggle encounters")
  322. print("shift+o: toggle map data overlay")
  323. print("shift+q: toggle global timer")
  324. print("shift+k: toggle no s&q probabilities")
  325. print("In the status menu, use 'I' and 'K' to select a stat to change. 'L' to advance the stat by 1, 'J' to decrease the stat by 1.")
  326.  
  327. function RNA (R) -- RN Advance Function
  328.  
  329.     g = R
  330.     m1 = 0x4e6d
  331.     m2 = 0x41c6
  332.     g1 = g*m1
  333.     g2 = g*m2
  334.     g2 = bit.band(g2,0xFFFF)
  335.     g = g1 + g2*0x10000
  336.     g = bit.band(g,0xFFFFFFFF)
  337.     c=0x3039
  338.     g = g+c
  339.     g = bit.band(g,0xFFFFFFFF)
  340.     return g
  341.  
  342. end
  343.  
  344. function RNB (R) -- RN Advance and reduce for use in RNG calculations
  345.  
  346.     g = R
  347.     m1 = 0x4e6d
  348.     m2 = 0x41c6
  349.     g1 = g*m1
  350.     g2 = g*m2
  351.     g2 = bit.band(g2,0xFFFF)
  352.     g = g1 + g2*0x10000
  353.     c=0x3039
  354.     g = g+c
  355.     g = bit.band(g,0xFFFFFFFF)
  356.     g = bit.lshift(g,8)
  357.     g = bit.rshift(g,16)
  358.     return g
  359.  
  360. end
  361.  
  362. while true do
  363. keypress = input.get()
  364. gui.text(160,00,"BRN: ".. (memory.readdword(AD4)))
  365. gui.text(160,10,"GRN: ".. (memory.readdword(AD5)))
  366.  
  367. if minorhudlock==false then
  368. if mem <= 0x2008000 then
  369.     mem = 0x2010000
  370.     memcount=0
  371. end
  372. if memory.readdword(mem) ~= 0 then
  373.     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
  374.     mem = 0x2010000
  375.     memcount=0
  376. end
  377. end
  378. while memcount <= 20000 and memory.readdword(mem) == 0 or mem==0x02010000 do
  379.     mem = mem-0x4
  380.     memcount = memcount+1
  381. end
  382.  
  383. gui.text(70,0,"Nonzero Tile: " .. memcount)
  384. gui.text(70,10,"Roll: " .. PercentRoll(RNA(memory.readdword(AD4)),8))
  385. end
  386.  
  387. -- Attacks First, Caught by Surprise Check
  388.  
  389. function PS (R) -- Preemptive Strike Check, 0 = nothing, 1 = PS, 2= CBS
  390.     R1=R
  391.     R2 = RNB(R1)
  392.     R1 = bit.lshift(R1,8)
  393.     R1 = bit.rshift(R1,16)
  394.     if bit.band(R1,0xF) == 0 then
  395.         return 1
  396.     else
  397.         if bit.band(R2,0x1F) ==0 then
  398.             return 2
  399.         else
  400.             return 0
  401.         end
  402.     end
  403. end
  404.  
  405. --gui.text(140,20,"X: " .. (memory.readdword(0x02030ec4))/1000000)
  406. --gui.text(140,30,"Y: " .. (memory.readdword(0x02030ecc))/1000000)
  407.  
  408. --g = memory.readdword(AD5)
  409. --print(bit.tohex(g))
  410.  
  411. pc1 = memory.readbyte(0x02000438)
  412. pc2 = memory.readbyte(0x02000439)
  413. pc3 = memory.readbyte(0x0200043A)
  414. pc4 = memory.readbyte(0x0200043B)
  415.  
  416.         -- Missing Agility Scripts
  417.  
  418. if memory.readword(0x02000400) ~= 0x1FE and minorhudlock==false and StatusMenuOpen == false then
  419.     iagi=memory.readbyte(0x02000500+0x1C+0x14C*0)
  420.     ilv=memory.readbyte(0x02000500+0x14C*0+0xF)
  421.     iagilv=-iagi+(ilv-1)*4+0xC -- imperfect levels ups discounting randomly rolled stats on new file
  422.     gagi=memory.readbyte(0x02000500+0x1C+0x14C*1)
  423.     glv=memory.readbyte(0x02000500+0x14C*1+0xF)
  424.     gagilv=-gagi+(glv-1)*4+0xA -- imperfect levels ups discounting randomly rolled stats on new file
  425.     vagi=memory.readbyte(0x02000500+0x1C+0x14C*2)
  426.     vlv=memory.readbyte(0x02000500+0x14C*2+0xF)
  427.     vagilv=-vagi+(vlv-4)*4+0x1B -- imperfect levels ups discounting randomly rolled stats on new file
  428.     magi=memory.readbyte(0x02000500+0x1C+0x14C*3)
  429.     mlv=memory.readbyte(0x02000500+0x14C*3+0xF)
  430.     magilv=-magi+(mlv-10)*4+0x2C -- imperfect levels ups discounting randomly rolled stats on new file
  431.     gui.text(0,150,"Missing Agi I:" .. iagilv .. " G:" .. gagilv .. " V:" .. vagilv .. " M:" .. magilv)
  432. end
  433.  
  434.         -- begin enemy HP/encounter loops
  435.  
  436.     --Agility Battle Scripts
  437.  
  438.  
  439. local pcag1=memory.readword(0x0203033C)
  440. local pcag2=memory.readword(0x0203033C+0x10)
  441. local pcag3=memory.readword(0x0203033C+0x20)
  442. local pcag4=memory.readword(0x0203033C+0x30)
  443.  
  444. if  memory.readbyte(0x02030368)==0xFF and memory.readbyte(0x02030368+0x02)==0 then -- Hacky way of checking if we are in fight menu or battle
  445.     if pcag1 >= 1000 then
  446.     pcag1 = memory.readbyte(0x02000540+0x14C*pc1)
  447.     end
  448.     if pcag2 >= 1000 then
  449.     pcag2 = memory.readbyte(0x02000540+0x14C*pc2)
  450.     end
  451.     if pcag3 >= 1000 then
  452.     pcag3 = memory.readbyte(0x02000540+0x14C*pc3)
  453.     end
  454.     if pcag4 >= 1000 then
  455.     pcag4 = memory.readbyte(0x02000540+0x14C*pc4)
  456.     end
  457.     gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1) -- Displays agility of party member pc1
  458.     gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
  459.     gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
  460.     gui.text(0,70,"PC" .. pc4 .. " Agi: " .. pcag4)
  461.  
  462.     if memory.readbyte(0x020308B0)>0 then
  463.         gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308B0+0x8)) -- If Enemy 1 has nonzero HP display E1 agility
  464.         gui.text(110,40, "HP: " .. memory.readword(0x020308B0))
  465.     else
  466.     end
  467.  
  468.     if memory.readbyte(0x020308B0+0x14C)>0 then
  469.         gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308B0+0x8+0x14C))
  470.         gui.text(110,50, "HP: " .. memory.readword(0x020308B0+0x14C))
  471.     else
  472.     end
  473.  
  474.     if memory.readbyte(0x020308B0+0x14C*2)>0 then
  475.         gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308B0+0x8+0x14C*2))
  476.         gui.text(110,60, "HP: " .. memory.readword(0x020308B0+0x14C*2))
  477.     else
  478.     end
  479.  
  480.     if memory.readbyte(0x020308B0+0x14C*3)>0 then
  481.         gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308B0+0x8+0x14C*3))
  482.         gui.text(110,70, "HP: " .. memory.readword(0x020308B0+0x14C*3))
  483.     else
  484.     end
  485.  
  486.     if memory.readbyte(0x020308B0+0x14C*4)>0 then
  487.         gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308B0+0x8+0x14C*4))
  488.         gui.text(110,80, "HP: " .. memory.readword(0x020308B0+0x14C*4))
  489.     else
  490.     end
  491.  
  492. -- elseif memory.readbyte(0x02030368)==0xFF and memory.readbyte(0x02030358)==0xFF then -- Hacky way of accounting for three person party
  493.     -- gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1)
  494.     -- gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
  495.     -- gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
  496.  
  497.     -- if memory.readbyte(0x02030900)>0 then
  498.         -- gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308E4)) -- If Enemy 1 has nonzero HP display E1 agility
  499.         -- gui.text(110,40, "HP: " .. memory.readbyte(0x02030900+0x14C*0))
  500.     -- else
  501.     -- end
  502.  
  503.     -- if memory.readbyte(0x02030900+0x14C)>0 then
  504.         -- gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308E4+0x14C))
  505.         -- gui.text(110,50, "HP: " .. memory.readbyte(0x02030900+0x14C*1))
  506.     -- else
  507.     -- end
  508.  
  509.     -- if memory.readbyte(0x02030900+0x14C*2)>0 then
  510.         -- gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308E4+0x14C*2))
  511.         -- gui.text(110,60, "HP: " .. memory.readbyte(0x02030900+0x14C*2))
  512.     -- else
  513.     -- end
  514.  
  515.     -- if memory.readbyte(0x02030900+0x14C*3)>0 then
  516.         -- gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308E4+0x14C*3))
  517.         -- gui.text(110,70, "HP: " .. memory.readbyte(0x02030900+0x14C*3))
  518.     -- else
  519.     -- end
  520.  
  521.     -- if memory.readbyte(0x02030900+0x14C*4)>0 then
  522.         -- gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308E4+0x14C*4))
  523.         -- gui.text(110,80, "HP: " .. memory.readbyte(0x02030900+0x14C*4))
  524.     -- else
  525.     -- end
  526.  
  527. elseif memory.readword(0x02000400)==0x1FE then -- otherwise, we are in a battle and do the following
  528. local j=1
  529. local k=1
  530. local trn={}
  531.     while memory.readbyte(0x02030338+0x04+0x10*(j-1)) ~= 0 do --while loop which checks nonzero agilities and therefore count number of actors in the battle
  532.         trn[j]= memory.readbyte(0x02030338+0x10*(j-1)) -- add the character index to the trn array in order
  533.         if trn[j]==0xFF then -- if user has already acted then do nothing
  534.             j=j+1
  535.         else
  536.             gui.text(30+15*k,40,trn[j]) -- if user hasn't acted then display user in the turn order queue
  537.             j=j+1
  538.             k=k+1
  539.         end
  540.     end
  541.  
  542. gui.text(0,40, "Turn Order: ")
  543. if memory.readbyte(0x020308B0)>0 then -- display enemy 1 HP during fight sequence
  544.     gui.text(0,30, "E1 HP: " .. memory.readword(0x020308B0))
  545. else
  546. end
  547. end
  548.  
  549.     -- Agility Bonus Calculator
  550.  
  551. if memory.readbyte(0x0203033C-0x50)>0 then
  552.     local l=1
  553.     while memory.readbyte(0x02030328-0x50+0x10*l) ~= pc1 and l<15 do
  554.             l=l+1
  555.     end
  556.     if l~=15 then
  557.         pcntag1=(memory.readbyte(0x02030328-0x50+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc1-5)))/memory.readbyte(0x02000BDC+0x14C*(pc1-5))*10000
  558.         pcntag1= math.floor(pcntag1)/100
  559.         gui.text(0,90,"PC" .. pc1 .. " Bonus: " .. pcntag1 .. "%")
  560.     end
  561.  
  562.     local l=1
  563.     while memory.readbyte(0x02030328+0x10*l) ~= pc2 and l<15 do
  564.         l=l+1
  565.     end
  566.     if l~=15 then
  567.         pcntag2=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc2-5)))/memory.readbyte(0x02000BDC+0x14C*(pc2-5))*10000
  568.         pcntag2= math.floor(pcntag2)/100
  569.         gui.text(0,100,"PC" .. pc2 .. " Bonus: " .. pcntag2 .. "%")
  570.     end
  571.  
  572.     local l=1
  573.     while memory.readbyte(0x02030328+0x10*l) ~= pc3 and l<15 do
  574.         l=l+1
  575.     end
  576.     if l~=15 then
  577.         pcntag3=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc3-5)))/memory.readbyte(0x02000BDC+0x14C*(pc3-5))*10000
  578.         pcntag3= math.floor(pcntag3)/100
  579.         gui.text(0,110,"PC" .. pc3 .. " Bonus: " .. pcntag3 .. "%")
  580.     end
  581.  
  582.     if memory.readbyte(0x0200045B)==0 and memory.readbyte(0x0200045C)==0 then
  583.     else
  584.         local l=1
  585.         while memory.readbyte(0x02030328+0x10*l) ~= pc4 and l<15 do
  586.             l=l+1
  587.         end
  588.         if l~=15 then
  589.             pcntag4=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc4-5)))/memory.readbyte(0x02000BDC+0x14C*(pc4-5))*10000
  590.             pcntag4= math.floor(pcntag4)/100
  591.             gui.text(0,120,"PC" .. pc4 .. " Bonus: " .. pcntag4 .. "% Roll " .. memory.readbyte(0x02030328+0x10*l+0x04))
  592.         end
  593.     end
  594.  
  595. end
  596.  
  597.  
  598.  
  599.         -- HP/encounter display
  600.  
  601.     -- Colorrate stuff
  602.     -- Encounter Rate Functions
  603.     if CurrentRate ~= NormalisedRate(AD6) then
  604.       if memory.readdword(AD6) == 0 then
  605.         CurrentRate = 0
  606.       end
  607.       if EncounterRate ~= memory.readdword(0x02000478) and memory.readdword(0x02000478) < 0x100000 then
  608.         if store ~= memory.readdword(AD5) then
  609.           EncounterRate = memory.readdword(0x02000478)+1
  610.         end
  611.         ColorRate1 = memory.readdword(0x02000478)-EncounterRate
  612.         ColorRateShade = 0
  613.         ColorRate2 = {255,255,255}
  614.         if ColorRate1 < 0 then
  615.           EncounterRate = memory.readdword(0x02000478)
  616.           ColorRate2 = {255,255,255}
  617.           CurrentRate = 0
  618.         else
  619.           if memory.readword(0x02000400) ~= 2 then -- world map?
  620.             GoodRateThreshold2 = GoodRateThreshold*1.3
  621.             if memory.readword(0x020301B4)==0xCC then -- Is Felix Walking?
  622.               GoodRateThreshold2 = GoodRateThreshold2 / 2
  623.             end
  624.           else
  625.             GoodRateThreshold2 = GoodRateThreshold
  626.             if memory.readword(0x020301B4)==0x66 then -- Is Felix Walking?
  627.               GoodRateThreshold2 = GoodRateThreshold2 / 2
  628.             end
  629.           end
  630.           if ColorRate1 >= GoodRateThreshold2 then
  631.             ColorRate2= {255, 0, 0}
  632.             EncounterRate = memory.readdword(0x02000478)
  633.             CurrentRate = NormalisedRate(AD6)
  634.             if NormalisedRate(AD6) == "" then
  635.               ColorRate2= {255, 255, 255}
  636.             end
  637.           else
  638.             ColorRateShade = math.floor((GoodRateThreshold2-ColorRate1)/GoodRateThreshold2*255)
  639.             if ColorRateShade <= 63 then
  640.               ColorRate2 = {255, 4*ColorRateShade, 0}
  641.             elseif ColorRateShade <=191 then
  642.               ColorRate2 = {255-255*(ColorRateShade-63)/128-1, 255, 0}
  643.             else
  644.               ColorRate2 = {0,255,0}
  645.             end
  646.             EncounterRate = memory.readdword(0x02000478)
  647.             CurrentRate = NormalisedRate(AD6)
  648.           end
  649.         end
  650.       end
  651.     end
  652.  
  653.  if memory.readbyte(0x020309a0) >= 1 then
  654. -- gui.text(0,20,"Enemy 1 HP: " .. (memory.readword(0x020308B0)))
  655.  else
  656.  gui.text(0,20,"Encounter: ".. (memory.readword(AD3)), encounterColor)
  657.  gui.text(0,30,"Isaac PP: ".. (memory.readbyte(0x0200053A)))
  658.  gui.text(160,20,"Rate: ".. NormalisedRate(AD6), ColorRate2)
  659.  gui.text(0,40,"PP Regen: ".. (math.floor((memory.readbyte(0x020301B5))/0xF)))
  660.  end
  661.  
  662. -- Encounter Value Increasing if loop
  663. encounterValue = memory.readdword(0x02000478)
  664. if encounterValue == 0 and encounterPreviousvalue ~= 0 then
  665.   encounterPreviousvalue = 0
  666.   encounterColor = {255,255,255}
  667. elseif encounterValue ~= encounterPreviousvalue then
  668.   encounterColor = {0,255,0}
  669.   encounterPreviousvalue = memory.readdword(0x02000478)
  670. else
  671.   encounterColor = {255,255,255}
  672.   encounterPreviousvalue = memory.readdword(0x02000478)
  673. end
  674. -- if memory.readbyte(0x02030AEC) >= 1 then
  675. -- gui.text(0,30,"Enemy 2 HP: " .. (memory.readword(0x020309FC)))
  676. -- end
  677.  
  678. -- if memory.readbyte(0x02030C38) >= 1 then
  679. -- gui.text(0,40,"Enemy 3 HP: " .. (memory.readword(0x02030B48)))
  680. -- end
  681.  
  682. -- if memory.readbyte(0x02030D84) >= 1 then
  683. -- gui.text(0,50,"Enemy 4 HP: " .. (memory.readword(0x02030c94)))
  684. -- end
  685.  
  686.         -- begin RNG counters
  687.  
  688.  
  689. GRN = memory.readdword(AD5)
  690. BRN = memory.readdword(AD4)
  691.  
  692. if GRN == 1710661176 then
  693. store = 1710661176
  694. gcount=0
  695. end
  696. gcountbase = 0
  697. while store ~= GRN and gcountbase <= 10000 do
  698. --print(store)
  699. store = RNA(store)
  700. if store <= 0 then
  701. store = 0xFFFFFFFF+store+1
  702. gcount = gcount +1
  703. gcountbase = gcountbase +1
  704. else
  705. gcount = gcount +1
  706. gcountbase = gcountbase +1
  707. end
  708. end
  709.  
  710. if store == GRN then
  711. gcountbase = 0
  712. else
  713. store = GRN
  714. gcountbase = 0
  715. gcount = 0
  716. end
  717.  
  718. bcountbase = 0
  719.  
  720. while bstore ~= BRN and bcountbase <= 1000 do
  721.     bstore = RNA(bstore)
  722.     if bstore <= 0 then
  723.         bstore = 0xFFFFFFFF+bstore+1
  724.         brncount = brncount+1
  725.         bcountbase = bcountbase+1
  726.     else
  727.         brncount = brncount+1
  728.         bcountbase = bcountbase+1
  729.     end
  730. end
  731.  
  732. if bstore == BRN then
  733.     bcountbase = 0
  734. else
  735.     bstore = BRN
  736.     bcountbase = 0
  737.     brncount = 0
  738. end
  739.  
  740.  
  741. if BRN == 0 then    -- reset BRN counter on loadstate
  742. bstore = BRN
  743. bcount = 0
  744. end
  745.  
  746.         -- Gui display
  747.  
  748. gui.text(0,10,"GRN count: " .. gcount)
  749. gui.text(0,00,"BRN count: " .. brncount)
  750.  
  751.         -- PS/CBS scripts
  752.         if minorhudlock == false then
  753. psb=00
  754. cbsb=00
  755.  
  756. if psbrn ~= BRN then
  757.     psb = BRN
  758.     psb = RNA(psb)
  759.     psc1 = 0
  760.     while PS(psb) ~= 1 do
  761.         psb = RNA(psb)
  762.         psc1 = psc1 + 1
  763.     end
  764.     psc2 = psc1+1
  765.     psb = RNA(psb)
  766.     while PS(psb) ~=1 do
  767.         psb = RNA(psb)
  768.         psc2 = psc2 + 1
  769.     end
  770.     psc3 = psc2+1
  771.     psb = RNA(psb)
  772.     while PS(psb) ~= 1 do
  773.         psb = RNA(psb)
  774.         psc3 = psc3 + 1
  775.     end
  776.     psbrn=BRN
  777. end
  778.  
  779. if cbsbrn ~= BRN then
  780.     cbsb = BRN
  781.     cbsb = RNA(cbsb)
  782.     cbsc1 = 0
  783.     while PS(cbsb) ~= 2 do
  784.         cbsb = RNA(cbsb)
  785.         cbsc1 = cbsc1 + 1
  786.         if cbsc1 == 100 then break end
  787.     end
  788.     cbsc2 = cbsc1+1
  789.     cbsb = RNA(cbsb)
  790.     while PS(cbsb) ~= 2 do
  791.         cbsb = RNA(cbsb)
  792.         cbsc2 = cbsc2 + 1
  793.         if cbsc2 == 102 then break end
  794.     end
  795.     cbsc3 = cbsc2+1
  796.     cbsb = RNA(cbsb)
  797.     while PS(cbsb) ~= 2 do
  798.         cbsb = RNA(cbsb)
  799.         cbsc3 = cbsc3 + 1
  800.         if cbsc3 == 104 then break end
  801.     end
  802.     cbsbrn = BRN
  803. end
  804.  
  805.     gui.text(0,80,"AF  " .. psc1 .. " " .. psc2 .. " " .. psc3)
  806.     gui.text(0,90,"CBS " .. cbsc1 .. " " .. cbsc2 .. " " .. cbsc3)
  807. end
  808.  
  809.         -- Begin Flee/Assassinate Scripts
  810.  
  811. local   el1 = memory.readbyte(0x02030887) -- Enemy 1 Level
  812. local el2 = memory.readbyte(0x020309d3) -- etc
  813. local   el3 = memory.readbyte(0x02030B1F)
  814. local   el4 = memory.readbyte(0x02030c6b)
  815. local   party = memory.readbyte(0x02000040) -- Party member number
  816. local   isl= memory.readbyte(0x0200050F) -- Isaac level
  817. local   gal= memory.readbyte(0x0200065b) -- etc
  818. local   ivl= memory.readbyte(0x020007a7)
  819. local   mil= memory.readbyte(0x020008F3)
  820.  
  821. if (memory.readbyte(0x020309a0)) >= 1 then
  822.  
  823.     if el4 ~= 0 then
  824.         ela = (el1+el2+el3+el4)/4
  825.     elseif el3 ~=0 then
  826.         ela = (el1+el2+el3)/3
  827.     elseif el2 ~=0 then
  828.         ela = (el1+el2)/2
  829.     else
  830.         ela = el1
  831.     end
  832.  
  833.     if party == 15 then
  834.         ml = (isl+gal+ivl+mil)/4
  835.     elseif party == 7 then
  836.         ml = (isl+gal+ivl)/3
  837.     else
  838.         ml = (isl+gal)/2
  839.     end
  840.  
  841.     LevelAve = ml-ela
  842.  
  843.     fleeFail = memory.readbyte(0x02030092)
  844.  
  845.     function flee(S) -- Flee Success Calculation
  846.         g = S
  847.         g = RNB(g)*10000
  848.         fl = 5000 + (2000*fleeFail) + (LevelAve * 500)
  849.         g = bit.rshift(g, 16)
  850.         if fl >= g then
  851.             return true
  852.         else
  853.             return false
  854.         end
  855.     end
  856.  
  857.     RN= memory.readdword(0x03001CB4)
  858.     count = 0
  859.  
  860.     while flee(RN) == false do -- Attack Cancel to Flee Calculation
  861.     count = count + 1
  862.     if count == 100 then break end
  863.     RN= RNA(RN)
  864.     end
  865.  
  866.     gui.text(160,30,"ACs to Run: " .. count)
  867.  
  868.         -- % Chance to Run
  869.     if nosq == true then
  870.         fleecount = 0
  871.         if fleestore ~= memory.readdword(AD5) then
  872.             fleeRN = memory.readdword(AD5)
  873.             for i=1,1000 do
  874.                 if flee(fleeRN) == true then
  875.                     fleecount= fleecount +1
  876.                 end
  877.                 fleeRN=RNA(fleeRN)
  878.             end
  879.             fleepercent = fleecount/10
  880.             fleestore = memory.readdword(AD5)
  881.             fev = fleepercent/100
  882.             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)
  883.             gui.text(100,20,"Run EV: ".. EV)
  884.             gui.text(160,20,"Run%: " .. fleepercent)
  885.             else
  886.             gui.text(100,20,"Run EV: ".. EV )
  887.             gui.text(160,20,"Run%: " .. fleepercent)
  888.         end
  889.     end
  890.  
  891.     function vuln (S)
  892.         e1Ind = S
  893.         vuln1 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x48)
  894.         vuln2 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x49)
  895.         vuln3 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x4A)
  896.         return vuln1, vuln2, vuln3
  897.     end
  898.  
  899.     function enemy (S,Elm) -- Enemy Elemental Data Table
  900.             elemInd = memory.readbyte(0x08080EC8 + ((S - 8) * 0x54) + 0x34)
  901.             enemyelmlevel = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 4+Elm)
  902.             return enemyelmlevel
  903.     end
  904.  
  905.     function bchance (E) -- base chance for status
  906.         if E == 16 or E == 17 then
  907.             c = 75
  908.         elseif E == 23 then
  909.         c = 40
  910.         elseif E == 24 then
  911.         c = 45
  912.         elseif E == 27 then
  913.         c = 20
  914.         end
  915.         return c
  916.     end
  917.  
  918.     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
  919.         uelm = memory.readbyte(0x0200061C+U*0x14C+Elm) -- Elemental Power of User
  920.         eluc = memory.readbyte(0x020308BA) -- Enemy Luck
  921.         eind = memory.readbyte(0x020309a0) -- Enemy Index
  922.         eelm = enemy(eind,Elm) -- Enemy Elemental Levels
  923.         vul1, vul2, vul3 = vuln(eind) -- Enemy Vulnerability
  924.         if vul1 == E or vul2 == E or vul3 == E then -- Vulnerability key at top
  925.             v=25
  926.             else
  927.             v=00
  928.         end
  929.         if memory.readbyte(0x080844EC + (U * 0xB4) + 0x92 + Elm) == 54 then
  930.             elmaff = 5
  931.             else
  932.             elmaff = 0
  933.         end
  934.         proc = (((uelm + elmaff - eelm)-(math.floor(eluc/2)))*3+bchance(E)+v)
  935.         g = RNB(S)*100
  936.         g = bit.rshift(g,16)
  937.         if proc >= g then
  938.             return true
  939.             else
  940.             return false
  941.         end
  942.     end
  943.  
  944.     function unleash (S)
  945.         g = S
  946.         g = RNB(g)*100
  947.         g = bit.rshift(g,16)
  948.         if 35 >= g then
  949.             return true
  950.         else
  951.             return false
  952.         end
  953.     end
  954.  
  955. if nosq == false then -- normal any% probabilities follow from here
  956.     if memory.readbyte(0x0200010F) == 0x8A then -- Check quest progression, if past kraken only return A Blade information.
  957.         BRN = memory.readdword(0x020023A8)
  958.         bcount=0
  959.  
  960.         while effectproc(RNA(BRN),27,0,0) == false or unleash(BRN) == false do -- A Blade calculation
  961.       bcount = bcount+1
  962.             if bcount == 100 then break end
  963.             BRN=RNA(BRN)
  964.         end
  965.  
  966.         gui.text(160,40,"Ablade Kill: " .. bcount)
  967.     end
  968.  
  969.     if memory.readbyte(0x02000168) >= 0x06 then -- Check quest progression, if Hammet freed then return Cyclone Slash information
  970.     BRN = memory.readdword(0x020023A8)
  971.     bcount=0
  972.     while effectproc(RNA(BRN),16,2,3) == false or unleash(BRN) == false do -- Cyclone calculation
  973.         bcount = bcount+1
  974.         if bcount == 100 then break end
  975.         BRN=RNA(BRN)
  976.     end
  977.     gui.text(160,50,"Cyclone Slash: " .. bcount)
  978.     end
  979.  
  980.     if party == 15 and memory.readbyte(0x02000155) < 0x14 then -- Check question progression, if have Mia and before getting off boat then return WWand information
  981.         BRN = memory.readdword(0x020023A8)
  982.         bcount=0
  983.         while effectproc(RNA(BRN),23,3,3) == false or unleash(BRN) == false do -- WWand calculation
  984.             bcount = bcount+1
  985.             if bcount == 100 then break end
  986.             BRN=RNA(BRN)
  987.         end
  988.         gui.text(160,40,"WWand Stun: " .. bcount)
  989.     end
  990.  
  991.     if memory.readbyte(0x0200050F) >= 9 and memory.readbyte(0x02000155) < 0x14 then -- Isaac level >= 9 and before getting off boat
  992.         BRN = memory.readdword(0x020023A8)
  993.         bcount=0
  994.         while effectproc(BRN,16,3,0) == false do -- Weaken calculation
  995.             bcount = bcount+1
  996.             if bcount == 100 then break end
  997.             BRN=RNA(BRN)
  998.         end
  999.         gui.text(160,60,"Weaken: " .. bcount)
  1000.     end
  1001.  
  1002.     if memory.readbyte(0x02000048)>=0x70 and memory.readbyte(0x02000155) < 0x14 then -- If you have mist, return mist information
  1003.         BRN = memory.readdword(0x020023A8)
  1004.         bcount=0
  1005.         while effectproc(RNA(BRN),24,1,3) == false do --or unleash(BRN) == false do -- mist calculation
  1006.             bcount = bcount+1
  1007.             if bcount == 100 then break end
  1008.             BRN=RNA(BRN)
  1009.         end
  1010.         gui.text(160,50,"Mist: " .. bcount)
  1011.     end
  1012.  
  1013.     if memory.readword(0x02000400)==0x1FE and memory.readword(0x02000404)==0x88 then -- If you are in Colosso return the following calculation
  1014.         BRN = memory.readdword(0x020023A8)
  1015.         bcount=0
  1016.         while effectproc(RNA(BRN),23,0,2) == false do --or unleash(BRN) == false do -- mist calculation
  1017.             bcount = bcount+1
  1018.             if bcount == 100 then break end
  1019.             BRN=RNA(BRN)
  1020.         end
  1021.         gui.text(160,50,"Scorch: " .. bcount)
  1022.     end
  1023. end
  1024.  
  1025.     if nosq == true then
  1026.         if memory.readbyte(0x020309A0)==0x79 then -- If in Kraken fight, return Vulcan Axe stun chances
  1027.             BRN = memory.readdword(0x020023A8)
  1028.             success = 0
  1029.             if BRN_tempssss ~= BRN then
  1030.                 for i=1,1000 do -- mist calculation
  1031.                     if unleash(BRN_tempssss) == true then
  1032.                         if effectproc(RNA(BRN_tempssss),24,2,1) == true then
  1033.                             success = success + 1
  1034.                         end
  1035.                     end
  1036.                     BRN_tempssss=RNA(BRN_tempssss)
  1037.                     vulcan_success = success/10
  1038.                 end
  1039.             end
  1040.             gui.text(160,100,"Vulcan: " .. vulcan_success .. "%")
  1041.             BRN_tempssss = BRN
  1042.         end
  1043.         if memory.readbyte(0x02000048)>=0x70 and memory.readbyte(0x02000155) < 0x14 then -- If you have mist, return mist information
  1044.             BRN = memory.readdword(0x020023A8)
  1045.             success = 0
  1046.             if BRN_temp ~= BRN then
  1047.                 for i=1,1000 do -- mist calculation
  1048.                     if effectproc(RNA(BRN_temp),24,1,0) == true then
  1049.                         success = success + 1
  1050.                     end
  1051.                     BRN_temp=RNA(BRN_temp)
  1052.                     mist_success = success/10
  1053.                 end
  1054.             end
  1055.             gui.text(160,50,"Mist: " .. mist_success .. "%")
  1056.             BRN_temp = BRN
  1057.         end
  1058.  
  1059.         if memory.readbyte(0x020309A0)==0x79 then -- If in the Kraken fight, do the scorch calc
  1060.             BRN = memory.readdword(0x020023A8)
  1061.             success = 0
  1062.             if BRN_temps ~= BRN then
  1063.                 for i=1,1000 do -- mist calculation
  1064.                     if effectproc(RNA(BRN_temps),23,2,1) == true then
  1065.                         success = success + 1
  1066.                     end
  1067.                     BRN_temps=RNA(BRN_temps)
  1068.                     scorch_success = success/10
  1069.                 end
  1070.             end
  1071.             gui.text(160,60,"Scorch: " .. scorch_success .. "%")
  1072.             BRN_temps = BRN
  1073.         end
  1074.  
  1075.         if memory.readword(0x020008BC) >= 2150 then -- If Ivan level 9, do the sleep calc
  1076.             BRN = memory.readdword(0x020023A8)
  1077.             success = 0
  1078.             if BRN_tempss ~= BRN then
  1079.                 for i=1,1000 do -- mist calculation
  1080.                     if effectproc(RNA(BRN_tempss),24,3,2) == true then
  1081.                         success = success + 1
  1082.                     end
  1083.                     BRN_tempss=RNA(BRN_tempss)
  1084.                     sleep_success = success/10
  1085.                 end
  1086.             end
  1087.             gui.text(160,40,"Sleep: " .. sleep_success .. "%")
  1088.             BRN_tempss = BRN
  1089.         end
  1090.  
  1091.         if memory.readbyte(0x020309A0)==0x79 then -- If in the Kraken fight, do the sleep bomb calc
  1092.             BRN = memory.readdword(0x020023A8)
  1093.             success = 0
  1094.             if BRN_tempsss ~= BRN then
  1095.                 for i=1,1000 do -- mist calculation
  1096.                     if effectproc(RNA(BRN_tempsss),24,3,3) == true then
  1097.                         success = success + 1
  1098.                     end
  1099.                     BRN_tempsss=RNA(BRN_tempsss)
  1100.                     sleepb_success = success/10
  1101.                 end
  1102.             end
  1103.             gui.text(160,80,"SleepB: " .. sleepb_success .. "%")
  1104.             --gui.text(160,90,"TotalB: " .. (100-math.abs(math.floor(1-(1-sleepb_success/100)*(1-sleep_success/100)*(1-mist_success/100)*(1-scorch_success/100)*10000))/100)  .. "%")
  1105.             --gui.text(160,70,"Total: " .. (100+math.floor(1-(1-sleep_success/100)*(1-mist_success/100)*(1-scorch_success/100)*10000)/100)  .. "%")
  1106.             BRN_tempsss = BRN
  1107.         end
  1108.  
  1109.         if memory.readword(0x02000400)==0x1FE and memory.readword(0x02000404)==0x88 then -- If you are in Colosso return the following calculation
  1110.  
  1111.             BRN = memory.readdword(0x020023A8)
  1112.             bcount=0
  1113.  
  1114.             while effectproc(RNA(BRN),23,2,0) == false do --or unleash(BRN) == false do -- mist calculation
  1115.                 bcount = bcount+1
  1116.                 if bcount == 100 then break end
  1117.                 BRN=RNA(BRN)
  1118.                 end
  1119.                 gui.text(160,50,"Scorch: " .. bcount)
  1120.         end
  1121.     end
  1122.  
  1123. function itemdrop(S,C)
  1124.     g = S
  1125.     g = RNB(g)*100
  1126.     g = bit.rshift(g,16)
  1127.     if C >= g then
  1128.         return true
  1129.     else
  1130.         return false
  1131.     end
  1132. end
  1133. function droprate(ch) -- enemy index, chance of drop
  1134.     BRN = memory.readdword(0x020023A8)
  1135.     bcount=0
  1136.     bcount2=0
  1137.     rate=bit.rshift(0x64,ch-1)
  1138.     rate2=bit.rshift(0x64,ch-3)
  1139.         while itemdrop(BRN,rate) == false do
  1140.             bcount=bcount+1
  1141.                 if itemdrop(BRN,rate2) == true then
  1142.                 bcount2=bcount
  1143.                 end
  1144.                 if bcount == 100 then break end
  1145.             BRN=(RNA(BRN))
  1146.         end
  1147.     return bcount, bcount2
  1148. end
  1149.     if nosq == false and minorhudlock==false then -- drop chances only when nosq stats are off and minor hud is on
  1150.         if memory.readbyte(0x020309A0)>0 then
  1151.             eindex=memory.readword(0x020309A0)
  1152.             if eindex == 0x47 or eindex == 0x44 then -- Mole Enemy or Siren
  1153.                 A,B= droprate(5)
  1154.             gui.text(180,80, "E1 Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
  1155.             end
  1156.         end
  1157.  
  1158.         if memory.readbyte(0x020309A0+0x14C)>0 then
  1159.             eindex2=memory.readword(0x020309A0+0x14C)
  1160.             if eindex2 == 0x47 or eindex == 0x44 then  -- Mole Enemy or Siren
  1161.                 A,B= droprate(5)
  1162.             gui.text(180,90, "E2 Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
  1163.             end
  1164.         end
  1165.  
  1166.         if memory.readbyte(0x020308B0+0x14C*2)>0 then
  1167.             eindex3=memory.readword(0x020309A0+2*0x14C)
  1168.             if eindex3 == 0x47 or eindex == 0x44 then -- Mole Enemy or Siren
  1169.                 A,B= droprate(5)
  1170.             gui.text(180,100, "E3 Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
  1171.             end
  1172.         end
  1173.  
  1174.         if memory.readbyte(0x020308B0+0x14C*3)>0 then
  1175.             eindex4=memory.readword(0x020309A0+3*0x14C)
  1176.             if eindex4 == 0x47 or eindex == 0x44 then -- Mole Enemy or Siren
  1177.                 A,B= droprate(5)
  1178.             gui.text(180,110, "E4 Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
  1179.             end
  1180.         end
  1181.     end
  1182. end
  1183. -- This code is for BRN / GRN advance via keypresses (note AD4 = BRN and AD5 = GRN)
  1184.  
  1185. 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
  1186.     state = false
  1187. end
  1188. if state == false and keypress["B"] == true and keypress["shift"] == true then
  1189.     memory.writedword(AD4,RNA(memory.readdword(AD4)))
  1190.     brnadvancecounter = 30
  1191.     state = true
  1192. end
  1193. if state == false and keypress["N"] == true and keypress["shift"] == true then
  1194.     memory.writedword(AD4,RNR(memory.readdword(AD4)))
  1195.     brnreducecounter = 30
  1196.     state = true
  1197.     bstore = memory.readdword(AD4)
  1198.     brncount = brncount - 1
  1199. end
  1200. if state == false and keypress["G"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
  1201.     memory.writedword(AD5,RNA(memory.readdword(AD5)))
  1202.     grnadvancecounter = 30
  1203.     state = true
  1204. end
  1205.  
  1206.     if state == false and keypress["H"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
  1207.         memory.writedword(AD5,RNR(memory.readdword(AD5)))
  1208.         grnreducecounter = 30
  1209.         state = true
  1210.         store = memory.readdword(AD5)
  1211.         gcount = gcount - 1
  1212.     end
  1213. if state == false and keypress["plus"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
  1214.     --if memory.readdword(AD5) == 0x80000000 then
  1215.     --  memory.writedword(AD5,0)
  1216.     --end
  1217.     memory.writedword(AD5,(memory.readdword(AD5)+1)%0x80000000) -- increase GRN by one
  1218.     grnadvancecounter = 30
  1219.     state = true
  1220. end
  1221. if state == false and keypress["minus"] == true and keypress["shift"] == true then -- remove the shift condition is two buttons are annoying
  1222.     --if memory.readdword(AD4) == 0x80000000 then
  1223.     --  memory.writedword(AD4,0)
  1224.     --end
  1225.     memory.writedword(AD4,(memory.readdword(AD4)+1)%0x80000000) -- increase BRN by one
  1226.     brnadvancecounter = 30
  1227.     state = true
  1228. end
  1229.  
  1230. if brnadvancecounter >= 1 then
  1231.     --gui.text(100,100, "BRN advanced by one","#00FF00")
  1232.     gui.text(225,00, "+1","#00FF00")
  1233.     brnadvancecounter = brnadvancecounter-1
  1234. end
  1235. if brnreducecounter >= 1 then
  1236.     --gui.text(100,100, "BRN advanced by one","#00FF00")
  1237.     gui.text(225,00, "-1","#FF0000")
  1238.     brnreducecounter = brnreducecounter-1
  1239. end
  1240. if grnadvancecounter >= 1 then
  1241.     --gui.text(100,100, "GRN advanced by one","#00FF00")
  1242.     gui.text(225,10, "+1","#00FF00")
  1243.     grnadvancecounter = grnadvancecounter-1
  1244. end
  1245. if grnreducecounter >= 1 then
  1246.     --gui.text(100,100, "GRN advanced by one","#00FF00")
  1247.     gui.text(225,10, "-1","#FF0000")
  1248.     grnreducecounter = grnreducecounter-1
  1249. end
  1250.  
  1251. -- This code is for locking Felix's pp
  1252. if ppstate == false and keypress["P"]==true and keypress["shift"]==true and pplock == false then
  1253.     pplock = true
  1254.     ppstate = true
  1255.     print("Isaac PP lock enabled")
  1256. end
  1257. if ppstate == false and keypress["P"]==true and keypress["shift"]==true and pplock == true then
  1258.     pplock = false
  1259.     ppstate = true
  1260.     print("Isaac PP lock disabled")
  1261. end
  1262. if ppstate == true and keypress["P"]==nil then
  1263.     ppstate = false
  1264. end
  1265. if pplock == true then
  1266.     memory.writeword(AD1,0x5)
  1267. end
  1268. -- This code is for toggling encounters
  1269. if encounterstate == false and keypress["E"]==true and keypress["shift"]==true and encounterlock == false then
  1270.     encounterlock = true
  1271.     encounterstate = true
  1272.     print("Encounters disabled")
  1273. end
  1274. if encounterstate == false and keypress["E"]==true and keypress["shift"]==true and encounterlock == true then
  1275.     encounterlock = false
  1276.     encounterstate = true
  1277.     print("Encounters enabled")
  1278. end
  1279. if encounterstate == true and keypress["E"]==nil then
  1280.     encounterstate = false
  1281. end
  1282. if encounterlock == true then
  1283.     memory.writeword(AD3,0x1)
  1284. end
  1285. -- This code is for the map data overlay
  1286.  
  1287. if overlaystate == false and keypress["O"]==true and keypress["shift"]==true and overlay == false then
  1288.     overlay = true
  1289.     overlaystate = true
  1290.     print("Overlay enabled")
  1291. end
  1292. if overlaystate == false and keypress["O"]==true and keypress["shift"]==true and overlay == true then
  1293.     overlay = false
  1294.     overlaystate = true
  1295.     print("Overlay disabled")
  1296. end
  1297. if overlaystate == true and keypress["O"]==nil then
  1298.     overlaystate = false
  1299. end
  1300. if overlay == true and infight == false then
  1301.  
  1302.     tile = memory.readdword(0x020301B8)
  1303.     tile_value = memory.readword(tile)
  1304.  
  1305.     gui.line(108, 98, 123, 98)
  1306.     gui.line(123, 98, 123, 108)
  1307.     gui.line(123, 108, 108, 108)
  1308.     gui.line(108, 108, 108, 98)
  1309.  
  1310.     function compress(S)
  1311.         R = bit.rshift(memory.readdword(S),16)
  1312.         R = bit.band(R,0xFF)
  1313.         return R
  1314.         end
  1315.  
  1316.     function tile_height(X)
  1317.             X = bit.rshift(X,24)
  1318.             X = 0x202C000+X*4
  1319.             X = memory.readdword(X)
  1320.             return X
  1321.             end
  1322.  
  1323.     function signed(X)
  1324.         if X >= 0x80 then
  1325.             Y = X - 0x100
  1326.         else Y=X
  1327.         end
  1328.         return Y
  1329.     end
  1330.  
  1331.     function extract_height(S)
  1332.             if bit.band(S,0xF)==0 then
  1333.                 height = bit.band(bit.rshift(S,8),0xFF)
  1334.                 height = signed(height)
  1335.             elseif bit.band(S,0xF)==1 or bit.band(S,0xF)==2 or bit.band(S,0xF)==3 or bit.band(S,0xF)==4 or bit.band(S,0xF)==8 or bit.band(S,0xF)==9 then
  1336.                 ha = bit.band(bit.rshift(S,8),0xFF)
  1337.                 ha = signed(ha)
  1338.                 hb = bit.band(bit.rshift(S,16),0xFF)
  1339.                 hb = signed(hb)
  1340.                 height = (ha+hb)/2
  1341.             else
  1342.                  height = bit.band(bit.rshift(S,8),0xFF)
  1343.                  height = signed(height)
  1344.           end
  1345.  
  1346.             return height
  1347.         end
  1348.  
  1349.  
  1350.     eventtable = memory.readdword(0x2030010)
  1351.     function interesting_event()
  1352.             E = eventtable
  1353.             while memory.readdword(E) ~= 0xFFFFFFFF do
  1354.                 if memory.readbyte(E+0x4) > 0 then
  1355.                     if bit.band(memory.readdword(E),0xF) == 1 then
  1356.                         table.insert(doorlist, memory.readbyte(E+0x4))
  1357.                     elseif bit.band(memory.readdword(E),0xF) == 3 then
  1358.                         table.insert(objectlist, memory.readbyte(E+0x4))
  1359.                     else
  1360.                         table.insert(eventlist, memory.readbyte(E+0x4))
  1361.                     end
  1362.                 end
  1363.                 E = E+0xC
  1364.             end
  1365.     end
  1366.  
  1367.     if area ~= memory.readword(0x2000408) and eventtable > 0 and memory.readdword(0x020301B8) > 0x02000000 and memory.readword(0x2000400)~=0 then
  1368.         eventlist = {}
  1369.         objectlist = {}
  1370.         doorlist = {}
  1371.         interesting_event()
  1372.         area = memory.readword(0x2000408)
  1373.         print("Area " .. area .. " door list: (green)")
  1374.         print(doorlist)
  1375.         print("Area " .. area .. " interaction list: (yellow)")
  1376.         print(objectlist)
  1377.         print("Area " .. area .. " event list: (pink)")
  1378.         print(eventlist)
  1379.     end
  1380.  
  1381.     function eventcheck(element,tablu)
  1382.       for _, value in pairs(tablu) do
  1383.         if value == element then
  1384.           return true
  1385.         end
  1386.       end
  1387.       return false
  1388.     end
  1389.  
  1390.     function color(S)
  1391.             T = tile_height(memory.readdword(memory.readdword(0x020301B8)))
  1392.             U = tile_height(memory.readdword(S))
  1393.             if extract_height(T) == extract_height(U) then
  1394.                 C = "white"
  1395.             elseif extract_height(T) < extract_height(U) then
  1396.                 shade = math.min((extract_height(U) - extract_height(T))/4*255,255)
  1397.                 C = { 255, 255-shade, 255-shade}
  1398.             elseif extract_height(T) > extract_height(U) then
  1399.                 shade = math.min((extract_height(T) - extract_height(U))/4*255,255)
  1400.                 C = { 255-shade, 255, 255}
  1401.             end
  1402.             return C
  1403.             end
  1404. --      if memory.readword(0x02000400) == 2 then    --- This code doesn't work because for some reason the world map is storing tile info differently to dungeons
  1405. --          WorldMapFactor = 1/4
  1406. --        else
  1407. --          WorldMapFactor = 1
  1408. --        end
  1409.     for i=-4,4 do
  1410.       for j=-4,4 do
  1411.         gui.text(110+j*15,100+i*15, compress(tile+0x200*i+0x4*j), color(tile+0x200*i+0x4*j))
  1412.             if eventcheck(compress(tile+0x200*i+0x4*j),objectlist) == true then
  1413.                 gui.line(108+j*15, 98+i*15, 123+j*15, 98+i*15, "#FFFF00")
  1414.                 gui.line(123+j*15, 98+i*15, 123+j*15, 108+i*15, "#FFFF00")
  1415.                 gui.line(123+j*15, 108+i*15, 108+j*15, 108+i*15, "#FFFF00")
  1416.                 gui.line(108+j*15, 108+i*15, 108+j*15, 98+i*15, "#FFFF00")
  1417.             elseif eventcheck(compress(tile+0x200*i+0x4*j),doorlist) == true then
  1418.                 gui.line(108+j*15, 98+i*15, 123+j*15, 98+i*15, "#00FF00")
  1419.                 gui.line(123+j*15, 98+i*15, 123+j*15, 108+i*15, "#00FF00")
  1420.                 gui.line(123+j*15, 108+i*15, 108+j*15, 108+i*15, "#00FF00")
  1421.                 gui.line(108+j*15, 108+i*15, 108+j*15, 98+i*15, "#00FF00")
  1422.             elseif eventcheck(compress(tile+0x200*i+0x4*j),eventlist) == true then
  1423.                 gui.line(108+j*15, 98+i*15, 123+j*15, 98+i*15, "#FF00FF")
  1424.                 gui.line(123+j*15, 98+i*15, 123+j*15, 108+i*15, "#FF00FF")
  1425.                 gui.line(123+j*15, 108+i*15, 108+j*15, 108+i*15, "#FF00FF")
  1426.                 gui.line(108+j*15, 108+i*15, 108+j*15, 98+i*15, "#FF00FF")
  1427.             end
  1428.       end
  1429.     end
  1430. end
  1431.  
  1432. --This code is for randomising the GRN/BRN by advancing the GRN/BRN a random number of times
  1433. if randomiserstate == true and keypress["R"] == nil then
  1434.     randomiserstate = false
  1435. end
  1436. if randomiserstate == false and keypress["R"] == true and keypress["shift"] == true then
  1437.     randomisercounter = 50
  1438.     randomiserstate = true
  1439. end
  1440. if randomisercounter == 50 then
  1441.     grnrandomadvance = math.random(1,100)
  1442.     brnrandomadvance = math.random(1,100)
  1443.     for i=1,grnrandomadvance do
  1444.         memory.writedword(AD5,RNA(memory.readdword(AD5)))
  1445.     end
  1446.     for i=1,brnrandomadvance do
  1447.         memory.writedword(AD4,RNA(memory.readdword(AD4)))
  1448.     end
  1449. end
  1450. if randomisercounter >= 1 then
  1451.     --gui.text(100,100, "BRN advanced by one","#00FF00")
  1452.     gui.text(225,00, "+" .. brnrandomadvance,"#00FF00")
  1453.     gui.text(225,10, "+" .. grnrandomadvance,"#00FF00")
  1454.     randomisercounter = randomisercounter-1
  1455. end
  1456.  
  1457. --And because I need GRN randomiser for FD this code exists!
  1458. if grnrandomiserstate == true and keypress["Y"] == nil then
  1459.   grnrandomiserstate = false
  1460. end
  1461. if grnrandomiserstate == false and keypress["Y"] == true and keypress["shift"] == true then
  1462.   grnrandomisercounter = 50
  1463.   grnrandomiserstate = true
  1464. end
  1465. if grnrandomisercounter == 50 then
  1466.   grnrandomadvance = math.random(1,100)
  1467.   for i=1,grnrandomadvance do
  1468.     memory.writedword(AD5,RNA(memory.readdword(AD5)))
  1469.   end
  1470. end
  1471. if grnrandomisercounter >= 1 then
  1472.   gui.text(225,10, "+" .. grnrandomadvance, "#00FF00")
  1473.   grnrandomisercounter = grnrandomisercounter-1
  1474. end
  1475. --- turn on debug mode
  1476. if debugmodestate == false and keypress["U"]==true and keypress["shift"]==true and debugmode == false then
  1477.     debugmode = true
  1478.     debugmodestate = true
  1479.     print("Debug Mode Activated")
  1480. end
  1481. if debugmodestate == false and keypress["U"]==true and keypress["shift"]==true and debugmode == true then
  1482.     debugmode = false
  1483.   debugmodestate = true
  1484.   print("Debug Mode Deactivated")
  1485. end
  1486. if debugmodestate == true and keypress["U"]==nil then
  1487.     debugmodestate = false
  1488. end
  1489. if debugmode == true then
  1490.   memory.writebyte(0x03001F54,1)
  1491. else
  1492.   memory.writebyte(0x03001F54,0)
  1493. end
  1494.  
  1495. --- no s&q probabilities
  1496. if nosqstate == false and keypress["K"]==true and keypress["shift"]==true and nosq == false then
  1497.     nosq = true
  1498.     nosqstate = true
  1499.     print("No S&Q probabilities enabled")
  1500. end
  1501. if nosqstate == false and keypress["K"]==true and keypress["shift"]==true and nosq == true then
  1502.     nosq = false
  1503.     nosqstate = true
  1504.     print("No S&Q probabilities disabled")
  1505. end
  1506. if nosqstate == true and keypress["K"]==nil then
  1507.     nosqstate = false
  1508. end
  1509. -- This code is for a global timer, toggled by shift+Q
  1510. -- This block is for toggling the timer on and off and pausing the timer
  1511. if globaltimerstate == false and globaltimeron == false and keypress["Q"] == true and keypress["shift"] == true then
  1512.     globaltimerstate = true
  1513.     globaltimeron = true
  1514.     print("Global timer enabled.")
  1515.     print("Press q to reset the timer at any point.")
  1516.     print("Press w to pause or unpause the timer.")
  1517.     print("Press tab to record a time.")
  1518.     print("Press shift+w to display last three recorded times.")
  1519. end
  1520. if globaltimerstate == false and globaltimeron == true and keypress["Q"] == true and keypress["shift"] == true then
  1521.     globaltimerstate = true
  1522.     globaltimeron = false
  1523.     globaltimer = 0
  1524.     print("Global timer disabled.")
  1525. end
  1526. if globaltimerstate == false and globaltimeron == true and keypress["Q"] == true and keypress["shift"] == nil then
  1527.     globaltimer = 0
  1528.     globaltimerstate = true
  1529.     print("Global timer reset")
  1530. end
  1531. if globaltimerstate == false and globaltimeron == true and globaltimerpause == false and keypress["W"] == true and keypress["shift"] == nil then
  1532.     globaltimerpause = true
  1533.     globaltimerstate = true
  1534. end
  1535. if globaltimerstate == false and globaltimeron == true and globaltimerpause == true and keypress["W"] == true and keypress["shift"] == nil then
  1536.     globaltimerpause = false
  1537.     globaltimerstate = true
  1538. end
  1539. if globaltimerstate == true and keypress["W"] == nil and keypress["Q"] == nil and keypress["tab"] == nil then
  1540.     globaltimerstate = false
  1541. end
  1542. -- This code is the global timer
  1543. if globaltimeron == true then
  1544.     if globaltimerpause == false then
  1545.         gui.text(0,120, "Timer " .. math.floor(globaltimer/60) .. "s")
  1546.         globaltimer = globaltimer+1
  1547.     end
  1548.     if globaltimerpause == true then
  1549.         gui.text(0,120, "Timer " .. math.floor(globaltimer/6)/10 .. "s " .. globaltimer .. " frames","#FFFF00")
  1550.     end
  1551.     if keypress["tab"] == true and globaltimerstate == false then
  1552.         globaltimerstore[3] = globaltimerstore[2]
  1553.         globaltimerstore[2] = globaltimerstore[1]
  1554.         globaltimerstore[1] = globaltimer
  1555.         globaltimer = 0
  1556.         globaltimerstate = true
  1557.         print("Time recorded")
  1558.     end
  1559.     if keypress["W"] == true and keypress["shift"] == true and globaltimerstate == false then
  1560.         globaltimerstoretimer = 360
  1561.         globaltimerstate = true
  1562.     end
  1563.     if globaltimerstoretimer >= 1 then
  1564.         if globaltimerstore[1] >= 1 then
  1565.             gui.text(0,90, "Time #1 " .. math.floor(globaltimerstore[1]/6)/10 .. "s " .. globaltimerstore[1] .. " frames","#00FF00")
  1566.         end
  1567.         if globaltimerstore[2] >= 1 then
  1568.             gui.text(0,100, "Time #2 " .. math.floor(globaltimerstore[2]/6)/10 .. "s " .. globaltimerstore[2] .. " frames","#00FF00")
  1569.         end
  1570.         if globaltimerstore[3] >= 1 then
  1571.             gui.text(0,110, "Time #3 " .. math.floor(globaltimerstore[3]/6)/10 .. "s " .. globaltimerstore[3] .. " frames","#00FF00")
  1572.         end
  1573.         globaltimerstoretimer = globaltimerstoretimer - 1
  1574.     end
  1575. end
  1576. if memory.readbyte(0x030009A4) == 0x9C and memory.readbyte(0x0200006A) == 0x4 and memory.readbyte(0x02030468) ~= 0xFF then -- memory.readbyte(0x02032C5E) == 0x31 then --memory.readbyte(0x06012593) == 0xB0 then -- status menu open check
  1577.   -- this block works out what character the cursor is on
  1578.   StatusMenuOpen = true
  1579.   if memory.readword(Cursor) == 0x12F then
  1580.     CurrentChar = 0
  1581.     CurrentName = " Isaac"
  1582.     CurrentGoals = IsaacGoals
  1583.   elseif memory.readword(Cursor) == 0x6B then
  1584.     CurrentChar = 1
  1585.     CurrentName = " Garet"
  1586.     CurrentGoals = GaretGoals
  1587.   elseif memory.readword(Cursor) == 0xED then
  1588.     CurrentChar = 2
  1589.     CurrentName = " Ivan"
  1590.     CurrentGoals = IvanGoals
  1591.   elseif memory.readword(Cursor) == 0x1903 then
  1592.     CurrentChar = 3
  1593.     CurrentName = " Mia"
  1594.     CurrentGoals = MiaGoals
  1595.   end
  1596.   -- displays characters base stat value i.e. without class or equipment modifiers
  1597.   gui.text(0,100,CurrentName .. " Level " .. LevelCalculator(CurrentChar))
  1598.   gui.text(0,110, " HP: " .. memory.readword(BaseHP+CharMemDiff*CurrentChar), StatColor[1])
  1599.   gui.text(0,120, " PP: " .. memory.readword(BasePP+CharMemDiff*CurrentChar), StatColor[2])
  1600.   gui.text(0,130, " Atk: " .. memory.readword(BaseAtk+CharMemDiff*CurrentChar), StatColor[3])
  1601.   gui.text(0,140, " Def: " .. memory.readword(BaseDef+CharMemDiff*CurrentChar), StatColor[4])
  1602.   gui.text(0,150, " Agi: " .. memory.readword(BaseAgi+CharMemDiff*CurrentChar), StatColor[5])
  1603.   --gui.text(0,160, " Luc: " .. memory.readbyte(BaseLuc+CharMemDiff*CurrentChar), StatColor[6])
  1604.  
  1605.   -- This code is for stat selection
  1606.   if keypress["I"]==true and keypress["K"]==nil and statstate == false then -- moves the highlghted stat up
  1607.     statstate = true
  1608.     StatColor[6]=StatColor[1]
  1609.     for i=1,5 do
  1610.       StatColor[i] = StatColor[i+1] -- 1<-2,2<-3...6<-1 -- 7
  1611.     end
  1612.     SelectedStat = SelectedStat-1 - math.floor((SelectedStat-1)/5)*5
  1613.   end
  1614.   if keypress["K"]==true and keypress["I"]==nil and statstate == false then -- moves the highlighted stat down
  1615.     statstate = true
  1616.     for i=1,5 do
  1617.       StatColor[7-i] = StatColor[6-i] -- 6=5, 5=4,... 2=1, then 1=6
  1618.     end
  1619.     StatColor[1]=StatColor[6]
  1620.     SelectedStat = SelectedStat+1 - math.floor((SelectedStat+1)/5)*5
  1621.   end
  1622.  
  1623.   -- This code is for stat manipulation
  1624.   if keypress["L"]==true and statstate == false then
  1625.     statstate = true
  1626.     memory.writeword(WhichStat(SelectedStat,CurrentChar),memory.readword(WhichStat(SelectedStat,CurrentChar))+1)
  1627.   end
  1628.   if keypress["J"]==true and statstate == false then
  1629.     statstate = true
  1630.     memory.writeword(WhichStat(SelectedStat,CurrentChar),memory.readword(WhichStat(SelectedStat,CurrentChar))-1)
  1631.   end
  1632.  
  1633.   -- Reset statstate
  1634.   if keypress["I"]==nil and keypress["K"]==nil and  keypress["J"]==nil and  keypress["L"]==nil and statstate == true then
  1635.     statstate = false
  1636.   end
  1637.  
  1638.  
  1639.   -- displays characters base stat value i.e. without class or equipment modifiers
  1640.   gui.text(40,110, " [" .. math.floor((CurrentGoals[1][2]-CurrentGoals[1][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[1][1] .. "-" .. math.floor((CurrentGoals[1][2]-CurrentGoals[1][1]+19)/20)*LevelCalculator(CurrentChar)+CurrentGoals[1][1] .. "]", StatColor[1])
  1641.   gui.text(40,120, " [" .. math.floor((CurrentGoals[2][2]-CurrentGoals[2][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[2][1] .. "-" .. math.floor((CurrentGoals[2][2]-CurrentGoals[2][1]+19)/20)*LevelCalculator(CurrentChar)+CurrentGoals[2][1] .. "]", StatColor[2])
  1642.   gui.text(40,130, " [" .. math.floor((CurrentGoals[3][2]-CurrentGoals[3][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[3][1] .. "-" .. math.floor((CurrentGoals[3][2]-CurrentGoals[3][1]+19)/20)*LevelCalculator(CurrentChar)+CurrentGoals[3][1] .. "]", StatColor[3])
  1643.   gui.text(40,140, " [" .. math.floor((CurrentGoals[4][2]-CurrentGoals[4][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[4][1] .. "-" .. math.floor((CurrentGoals[4][2]-CurrentGoals[4][1]+19)/20)*LevelCalculator(CurrentChar)+CurrentGoals[4][1] .. "]", StatColor[4])
  1644.   gui.text(40,150, " [" .. math.floor((CurrentGoals[5][2]-CurrentGoals[5][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[5][1] .. "-" .. math.floor((CurrentGoals[5][2]-CurrentGoals[5][1]+19)/20)*LevelCalculator(CurrentChar)+CurrentGoals[5][1] .. "]", StatColor[5])
  1645.   gui.text(90,110, "E:" .. math.floor((((CurrentGoals[1][2]-CurrentGoals[1][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[1][1])*10)/10, StatColor[1])
  1646.   gui.text(90,120, "E:" .. math.floor((((CurrentGoals[2][2]-CurrentGoals[2][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[2][1])*10)/10, StatColor[2])
  1647.   gui.text(90,130, "E:" .. math.floor((((CurrentGoals[3][2]-CurrentGoals[3][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[3][1])*10)/10, StatColor[3])
  1648.   gui.text(90,140, "E:" .. math.floor((((CurrentGoals[4][2]-CurrentGoals[4][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[4][1])*10)/10, StatColor[4])
  1649.   gui.text(90,150, "E:" .. math.floor((((CurrentGoals[5][2]-CurrentGoals[5][1])/20)*LevelCalculator(CurrentChar)+CurrentGoals[5][1])*10)/10, StatColor[5])
  1650. else
  1651.   StatusMenuOpen = false
  1652. end
  1653.  
  1654. -- This code is for toggling af / cbs / missing agility display
  1655. if minorhudstate == false and keypress["A"]==true and keypress["shift"]==true and minorhudlock == false then
  1656.     minorhudlock = true
  1657.     minorhudstate = true
  1658.     print("Minor hud disabled")
  1659. end
  1660. if minorhudstate == false and keypress["A"]==true and keypress["shift"]==true and minorhudlock == true then
  1661.     minorhudlock = false
  1662.     minorhudstate = true
  1663.     print("Minor hud enabled")
  1664. end
  1665. if minorhudstate == true and keypress["A"]==nil then
  1666.     minorhudstate = false
  1667. end
  1668.  
  1669. -- This code toggle encounter analysis information
  1670. if encounteranalysisstate == false and keypress["M"]==true and keypress["shift"]==true and encounteranalysis == false then
  1671.     encounteranalysis = true
  1672.     encounteranalysisstate = true
  1673.     print("Encounter analysis enabled")
  1674. end
  1675. if encounteranalysisstate == false and keypress["M"]==true and keypress["shift"]==true and encounteranalysis == true then
  1676.     encounteranalysis = false
  1677.     encounteranalysisstate = true
  1678.     print("Encounter analysis disabled")
  1679. end
  1680. if encounteranalysisstate == true and keypress["M"]==nil then
  1681.     encounteranalysisstate = false
  1682. end
  1683.  
  1684. if encounteranalysis == true then
  1685.     --gui.text(160,0,"GRN: ".. (memory.readdword(AD5)))
  1686.  
  1687.  
  1688.     -- Encounter Rate Functions
  1689.       RateRate = bit.band(RatePrediction(memory.readdword(AD5)))
  1690.       if NewRate ~= RateRate then
  1691.         OldRate = NewRate
  1692.         NewRate = RateRate
  1693.       end
  1694.         RateCalcBase = memory.readdword(AD5)
  1695.       -- TABLE VARIABLE CONTROLLER
  1696.       if keypress["L"]==true and keypress["J"]==nil and tableState == false then
  1697.         tableState = true
  1698.         tableVariable = (tableVariable - math.floor(tableVariable/7) * 7) + 1
  1699.       end
  1700.       if keypress["J"]==true and keypress["L"]==nil and tableState == false then
  1701.         tableState = true
  1702.         tableVariable = (tableVariable+5 - math.floor((tableVariable+5)/7) * 7)
  1703.         tableVariable = tableVariable + 1
  1704.       end
  1705.       if keypress["J"]==nil and keypress["L"]==nil and tableState == true then
  1706.         tableState = false
  1707.       end
  1708.       if keypress["J"]==true and keypress["L"]==true and tableState == false then
  1709.         tableState = true
  1710.         tableVariable = 1
  1711.         print("Psynergy Selector Reset")
  1712.       end
  1713.  
  1714.          -- Display --
  1715.  
  1716.          -- GUI DISPLAY FOR GRN THINGY
  1717.     if RatePredictionRNGStore ~= memory.readdword(AD5) or tableVariableStore ~= tableVariable then
  1718.       tableVariableStore = tableVariable
  1719.       RatePredictionRNGStore = memory.readdword(AD5)
  1720.       WorldMapGRN = 47 - bit.band(memory.readword(0x0200004A), 0x400)/0x400 - bit.band(memory.readword(0x02000114), 0x8)/0x8 - bit.band(memory.readword(0x02000112), 0x8000)/0x8000
  1721.       if memory.readword(0x02000400) == 0x2 then
  1722.         WorldMapOffset=1
  1723.       else
  1724.         WorldMapOffset=0
  1725.       end
  1726.       if memory.readdword(0x020301A8) == 0 then
  1727.         StepGRNOffset = 0
  1728.       else
  1729.         StepGRNOffset = 1
  1730.       end
  1731.       if tableVariable == 1 then
  1732.         BaseOffset = 0
  1733.       else
  1734.         BaseOffset = 1
  1735.       end
  1736.       for i=1,10,1 do
  1737.         RatePredictionVectorStore[i][1] = RatePsyCalc(memory.readdword(AD5),grnAdvanceList[tableVariable]+i+WorldMapGRN*WorldMapOffset*BaseOffset-4*StepGRNOffset-1)
  1738.         RatePredictionVectorStore[i][2] = ColorRate(RatePredictionVectorStore[i][1])
  1739.       end
  1740.     end
  1741.     if memory.readword(0x02000400)~=0x1FE then
  1742.       gui.text(160,30,moveList[tableVariable])
  1743.       for i=0,9,1 do
  1744.         gui.text(160,40+10*i,"+".. i .. " Rate " .. RatePredictionVectorStore[i+1][1], RatePredictionVectorStore[i+1][2])
  1745.       end
  1746.     end
  1747. end
  1748.  
  1749.     vba.frameadvance();
  1750. end
  1751.  
Add Comment
Please, Sign In to add comment