Advertisement
Plexa

Golden Sun Utility Script v2.1

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