Advertisement
Plexa

Golden Sun Uility Script v1.2 with Flee%

Dec 31st, 2016
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.73 KB | None | 0 0
  1. local AD3 = 0x0200047A -- Next Encounter
  2. local AD4 = 0x020023A8 -- Battle RN
  3. local AD5 = 0x03001CB4 -- General RN
  4. local gcount = 0
  5. local bcounter = 0
  6. local store = memory.readdword(0x03001CB4)
  7. local bstore = memory.readdword(0x020023A8)
  8. local brncount=0
  9. local fleestore = 0
  10. local fleepercent = 0
  11.  
  12.  
  13.     --eel = memory.readbyte(0x0203089E) -- venus res
  14.     --eme = memory.readbyte(0x020308A2)
  15.     --ema = memory.readbyte(0x020308A6)
  16.     --eju = memory.readbyte(0x020308A8)
  17.    
  18.     -- Vulnerability Key
  19. --12 = Drop Def 25%
  20. --13 = Drop def 12%
  21. --16 = res drop 40
  22. --17 = res drop 20
  23. --20 = delusion
  24. --23 = stun
  25. --24 = sleep
  26. --27 = death
  27. --31 = HP steal
  28. --32 = PP steal
  29. --60 = 50% dmg to health
  30. --69 = 10% dmg to PP
  31.  
  32.    
  33. while true do
  34.  
  35. gui.text(160,00,"BRN: ".. (memory.readdword(AD4)))
  36. gui.text(160,10,"GRN: ".. (memory.readdword(AD5)))
  37.  
  38.  
  39.     -- RNG Functions
  40.  
  41. function RNA (R) -- RN Advance Function
  42.    
  43.     g = R
  44.     m1 = 0x4e6d
  45.     m2 = 0x41c6
  46.     g1 = g*m1
  47.     g2 = g*m2
  48.     g2 = bit.band(g2,0xFFFF)
  49.     g = g1 + g2*0x10000
  50.     g = bit.band(g,0xFFFFFFFF)
  51.     c=0x3039
  52.     g = g+c
  53.     g = bit.band(g,0xFFFFFFFF)
  54.     return g
  55.  
  56. end
  57.  
  58. function RNB (R) -- RN Advance and reduce for use in RNG calculations
  59.    
  60.     g = R
  61.     m1 = 0x4e6d
  62.     m2 = 0x41c6
  63.     g1 = g*m1
  64.     g2 = g*m2
  65.     g2 = bit.band(g2,0xFFFF)
  66.     g = g1 + g2*0x10000
  67.     c=0x3039
  68.     g = g+c
  69.     g = bit.band(g,0xFFFFFFFF)
  70.     g = bit.lshift(g,8)
  71.     g = bit.rshift(g,16)
  72.     return g
  73.  
  74. end
  75.  
  76. --gui.text(140,20,"X: " .. (memory.readdword(0x02030ec4))/1000000)
  77. --gui.text(140,30,"Y: " .. (memory.readdword(0x02030ecc))/1000000)
  78.  
  79. --g = memory.readdword(AD5)
  80. --print(bit.tohex(g))
  81.  
  82.  
  83.         -- begin enemy HP/encounter loops
  84.        
  85.  
  86.  
  87.         -- HP/encounter display
  88.  
  89. if memory.readbyte(0x020309a0) >= 1 then
  90. gui.text(0,20,"Enemy 1 HP: " .. (memory.readword(0x020308B0)))
  91. else
  92. gui.text(0,20,"Encounter: ".. (memory.readword(AD3)))
  93. gui.text(0,30,"Isaac PP: ".. (memory.readbyte(0x0200053A)))
  94. gui.text(0,40,"PP Regen: ".. (math.floor((memory.readbyte(0x020301B5))/0xF)))
  95. end
  96.  
  97. if memory.readbyte(0x02030AEC) >= 1 then
  98. gui.text(0,30,"Enemy 2 HP: " .. (memory.readword(0x020309FC)))
  99. end
  100.  
  101. if memory.readbyte(0x02030C38) >= 1 then
  102. gui.text(0,40,"Enemy 3 HP: " .. (memory.readword(0x02030B48)))
  103. end
  104.  
  105. if memory.readbyte(0x02030D84) >= 1 then
  106. gui.text(0,50,"Enemy 4 HP: " .. (memory.readword(0x02030c94)))
  107. end
  108.  
  109.         -- begin RNG counters
  110.  
  111.  
  112. GRN = memory.readdword(AD5)
  113. BRN = memory.readdword(AD4)
  114.  
  115. if GRN == 1710661176 then
  116. store = 1710661176
  117. gcount=0
  118. end
  119. gcountbase = 0
  120. while store ~= GRN and gcountbase <= 10000 do
  121. --print(store)
  122. store = RNA(store)
  123. if store <= 0 then
  124. store = 0xFFFFFFFF+store+1
  125. gcount = gcount +1
  126. gcountbase = gcountbase +1
  127. else
  128. gcount = gcount +1
  129. gcountbase = gcountbase +1
  130. end
  131. end
  132.  
  133. if store == GRN then
  134. gcountbase = 0
  135. else
  136. store = GRN
  137. gcountbase = 0
  138. gcount = 0
  139. end
  140.  
  141. bcountbase = 0
  142.  
  143. while bstore ~= BRN and bcountbase <= 1000 do
  144.     bstore = RNA(bstore)
  145.     if bstore <= 0 then
  146.         bstore = 0xFFFFFFFF+bstore+1
  147.         brncount = brncount+1
  148.         bcountbase = bcountbase+1
  149.     else
  150.         brncount = brncount+1
  151.         bcountbase = bcountbase+1
  152.     end
  153. end
  154.  
  155. if bstore == BRN then
  156.     bcountbase = 0
  157. else
  158.     bstore = BRN
  159.     bcountbase = 0
  160.     brncount = 0
  161. end
  162.  
  163.  
  164. if BRN == 0 then    -- reset BRN counter on loadstate
  165. bstore = BRN
  166. bcount = 0
  167. end
  168.  
  169.         -- Gui display
  170.  
  171. gui.text(0,10,"GRN count: " .. gcount)
  172. gui.text(0,00,"BRN count: " .. bcounter)
  173.  
  174.         -- Begin Flee/Assassinate Scripts
  175.        
  176. local   el1 = memory.readbyte(0x02030887) -- Enemy 1 Level
  177. local el2 = memory.readbyte(0x020309d3) -- etc
  178. local   el3 = memory.readbyte(0x02030B1F)
  179. local   el4 = memory.readbyte(0x02030c6b)
  180. local   party = memory.readbyte(0x02000040) -- Party member number
  181. local   isl= memory.readbyte(0x0200050F) -- Isaac level
  182. local   gal= memory.readbyte(0x0200065b) -- etc
  183. local   ivl= memory.readbyte(0x020007a7)
  184. local   mil= memory.readbyte(0x020008F3)
  185.  
  186. if (memory.readbyte(0x020309a0)) >= 1 then
  187.  
  188. if el4 ~= 0 then
  189.     ela = (el1+el2+el3+el4)/4
  190. elseif el3 ~=0 then
  191.     ela = (el1+el2+el3)/3
  192. elseif el2 ~=0 then
  193.     ela = (el1+el2)/2
  194. else
  195.     ela = el1
  196. end
  197.  
  198. if party == 15 then
  199.     ml = (isl+gal+ivl+mil)/4
  200. elseif party == 7 then
  201.     ml = (isl+gal+ivl)/3
  202. else
  203.     ml = (isl+gal)/2
  204. end
  205.  
  206. LevelAve = ml-ela
  207.  
  208. function RNA (R) -- RN Advance Function
  209.    
  210.     g = R
  211.     m1 = 0x4e6d
  212.     m2 = 0x41c6
  213.     g1 = g*m1
  214.     g2 = g*m2
  215.     g2 = bit.band(g2,0xFFFF)
  216.     g = g1 + g2*0x10000
  217.     g = bit.band(g,0xFFFFFFFF)
  218.     c=0x3039
  219.     g = g+c
  220.     g = bit.band(g,0xFFFFFFFF)
  221.     return g
  222.  
  223. end
  224.  
  225. function RNB (R) -- RN Advance and reduce for use in RNG calculations
  226.    
  227.     g = R
  228.     m1 = 0x4e6d
  229.     m2 = 0x41c6
  230.     g1 = g*m1
  231.     g2 = g*m2
  232.     g2 = bit.band(g2,0xFFFF)
  233.     g = g1 + g2*0x10000
  234.     c=0x3039
  235.     g = g+c
  236.     g = bit.band(g,0xFFFFFFFF)
  237.     g = bit.lshift(g,8)
  238.     g = bit.rshift(g,16)
  239.     return g
  240.  
  241. end
  242.  
  243. fleeFail = memory.readbyte(0x02030092)
  244.  
  245. function flee(S) -- Flee Success Calculation
  246.     g = S
  247.     g = RNB(g)*10000
  248.     fl = 5000 + (2000*fleeFail) + (LevelAve * 500)
  249.     g = bit.rshift(g, 16)
  250.     if fl >= g then
  251.         return true
  252.     else
  253.         return false
  254.     end
  255. end
  256.  
  257. RN= memory.readdword(0x03001CB4)
  258. count = 0
  259.  
  260. while flee(RN) == false do -- Attack Cancel to Flee Calculation
  261. count = count + 1
  262. if count == 100 then break end
  263. RN= RNA(RN)
  264. end
  265.  
  266. gui.text(160,30,"ACs to Run: " .. count)
  267.  
  268.         -- % Chance to Run
  269. fleecount = 0
  270. if fleestore ~= memory.readdword(AD5) then
  271.     fleeRN = memory.readdword(AD5)
  272.     for i=1,1000 do
  273.         if flee(fleeRN) == true then
  274.             fleecount= fleecount +1
  275.         end
  276.         fleeRN=RNA(fleeRN)
  277.     end
  278.     fleepercent = fleecount/10
  279.     fleestore = memory.readdword(AD5)
  280.     fev = fleepercent/100
  281.     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)
  282.     gui.text(100,20,"Run EV: ".. EV)
  283.     gui.text(160,20,"Run%: " .. fleepercent)
  284.     else
  285.     gui.text(100,20,"Run EV: ".. EV )
  286.     gui.text(160,20,"Run%: " .. fleepercent)
  287. end
  288.  
  289. function vuln (S)
  290.     e1Ind = S
  291.     vuln1 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x48)
  292.     vuln2 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x49)
  293.     vuln3 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x4A)
  294.     return vuln1, vuln2, vuln3
  295. end
  296.  
  297. function enemy (S,Elm) -- Enemy Elemental Data Table
  298.         elemInd = memory.readbyte(0x08080EC8 + ((S - 8) * 0x54) + 0x34)
  299.         enemyelmlevel = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 4+Elm)
  300.         return enemyelmlevel
  301. end
  302.  
  303. function bchance (E) -- base chance for status
  304.     if E == 16 or E == 17 then
  305.         c = 75
  306.     elseif E == 23 then
  307.     c = 40
  308.     elseif E == 24 then
  309.     c = 45
  310.     elseif E == 27 then
  311.     c = 20
  312.     end
  313.     return c
  314. end
  315.    
  316. 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
  317.     uelm = memory.readbyte(0x0200061C+U*0x14C+Elm) -- Elemental Power of User
  318.     eluc = memory.readbyte(0x020308BA) -- Enemy Luck
  319.     eind = memory.readbyte(0x020309a0) -- Enemy Index
  320.     eelm = enemy(eind,Elm) -- Enemy Elemental Levels
  321.     vul1, vul2, vul3 = vuln(eind) -- Enemy Vulnerability
  322.     if vul1 == E or vul2 == E or vul3 == E then -- Vulnerability key at top
  323.         v=25
  324.     else
  325.         v=00
  326.    
  327.     end
  328.     if memory.readbyte(0x080844EC + (U * 0xB4) + 0x92 + Elm) == 54 then
  329.         elmaff = 5
  330.     else
  331.         elmaff = 0
  332.     end
  333.     proc = (((uelm + elmaff - eelm)-(math.floor(eluc/2)))*3+bchance(E)+v)
  334.     g = RNB(S)*100
  335.     g = bit.rshift(g,16)
  336.     if proc >= g then
  337.         return true
  338.     else
  339.         return false
  340.     end
  341.     end
  342.    
  343. function unleash (S)
  344.     g = S
  345.     g = RNB(g)*100
  346.     g = bit.rshift(g,16)
  347.     if 35 >= g then
  348.         return true
  349.     else
  350.         return false
  351.     end
  352. end
  353.  
  354. if memory.readbyte(0x0200010F) == 0x8A then -- Check quest progression, if past kraken only return A Blade information.
  355.  
  356. BRN = memory.readdword(0x020023A8)
  357. bcount=0
  358.  
  359. while effectproc(RNA(BRN),27,0,0) == false or unleash(BRN) == false do -- A Blade calculation
  360.     bcount = bcount+1
  361.     if bcount == 100 then break end
  362.     BRN=RNA(BRN)
  363. end
  364.  
  365. gui.text(160,40,"Ablade Kill: " .. bcount)
  366.  
  367. end
  368.  
  369. if memory.readbyte(0x02000168) >= 0x06 then -- Check quest progression, if Hammet freed then return Cyclone Slash information
  370.  
  371. BRN = memory.readdword(0x020023A8)
  372. bcount=0
  373.  
  374. while effectproc(RNA(BRN),16,2,3) == false or unleash(BRN) == false do -- Cyclone calculation
  375.     bcount = bcount+1
  376.     if bcount == 100 then break end
  377.     BRN=RNA(BRN)
  378. end
  379.  
  380. gui.text(160,50,"Cyclone Slash: " .. bcount)
  381.  
  382. end
  383.  
  384. if party == 15 and memory.readbyte(0x02000155) < 0x14 then -- Check question progression, if have Mia and before getting off boat then return WWand information
  385.  
  386. BRN = memory.readdword(0x020023A8)
  387. bcount=0
  388.  
  389. while effectproc(RNA(BRN),23,3,3) == false or unleash(BRN) == false do -- WWand calculation
  390.     bcount = bcount+1
  391.     if bcount == 100 then break end
  392.     BRN=RNA(BRN)
  393. end
  394.  
  395. gui.text(160,40,"WWand Stun: " .. bcount)
  396.  
  397. end
  398.  
  399. if memory.readbyte(0x0200050F) >= 9 and memory.readbyte(0x02000155) < 0x14 then -- Isaac level >= 9 and before getting off boat
  400.     BRN = memory.readdword(0x020023A8)
  401.     bcount=0
  402.  
  403.     while effectproc(BRN,16,3,0) == false do -- Weaken calculation
  404.         bcount = bcount+1
  405.         if bcount == 100 then break end
  406.         BRN=RNA(BRN)
  407.     end
  408.  
  409. gui.text(160,60,"Weaken: " .. bcount)
  410.  
  411. end
  412.  
  413. if memory.readbyte(0x02000048)>=0x70 and memory.readbyte(0x02000155) < 0x14 then -- If you have mist, return mist information
  414.  
  415. BRN = memory.readdword(0x020023A8)
  416. bcount=0
  417.  
  418. while effectproc(RNA(BRN),24,1,3) == false do --or unleash(BRN) == false do -- mist calculation
  419.     bcount = bcount+1
  420.     if bcount == 100 then break end
  421.     BRN=RNA(BRN)
  422. end
  423. gui.text(160,50,"Mist: " .. bcount)
  424. end
  425. end
  426.  
  427.  
  428.  
  429.     vba.frameadvance();
  430.  
  431. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement