Advertisement
Plexa

GS2 Utility Script v1.1

Oct 8th, 2016
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.19 KB | None | 0 0
  1. -- Golden Sun 2: The Lost Age utility script v1.0 for speedrunning. Would not be possible without the help of Fox aka teawater from the gs hacking community
  2.  
  3. local AD3 = (0x0200049A) -- Next Encounter
  4. local AD4 = (0x020054C8) -- Battle RN
  5. local AD5 = (0x030011BC) -- General RN
  6. local gcount = 0
  7. local brncount = 0
  8. local store = memory.readdword(0x030011BC)
  9. local bstore = memory.readdword(0x020054C8)
  10. local fleestore = 0
  11. local fleepercent = 0
  12. local mem = 0x2010000
  13. local memcount = 0
  14.  
  15.  
  16.     --eel = memory.readbyte(0x0203089E) -- venus res
  17.     --eme = memory.readbyte(0x020308A2)
  18.     --ema = memory.readbyte(0x020308A6)
  19.     --eju = memory.readbyte(0x020308A8)
  20.    
  21.     -- Vulnerability Key
  22. --12 = Drop Def 25%
  23. --13 = Drop def 12%
  24. --16 = res drop 40
  25. --17 = res drop 20
  26. --20 = delusion
  27. --23 = stun
  28. --24 = sleep
  29. --27 = death
  30. --31 = HP steal
  31. --32 = PP steal
  32. --60 = 50% dmg to health
  33. --69 = 10% dmg to PP
  34.  
  35.    
  36. while true do
  37.  
  38. gui.text(160,00,"BRN: ".. (memory.readdword(AD4)))
  39. gui.text(160,10,"GRN: ".. (memory.readdword(AD5)))
  40.  
  41. if memory.readword(0x02000420) == 0x8D then
  42.     gui.text(160,20,"Item: ".. memory.readword(0x020004FC))
  43.     gui.text(160,30,"409 = ring")
  44. end
  45.  
  46. if mem <= 0x2008000 then
  47.     mem = 0x2010000
  48.     memcount=0
  49. end
  50. if memory.readdword(mem) ~= 0 then
  51.     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
  52.     mem = 0x2010000
  53.     memcount=0
  54. end
  55. end
  56. while memcount <= 20000 and memory.readdword(mem) == 0 or mem==0x02010000 do
  57.     mem = mem-0x4
  58.     memcount = memcount+1
  59. end
  60.  
  61. gui.text(0,30,"Nonzero Tile: " .. memcount)
  62.  
  63.  
  64. --gui.text(140,20,"X: " .. (memory.readdword(0x02030ec4))/1000000)
  65. --gui.text(140,30,"Y: " .. (memory.readdword(0x02030ecc))/1000000)
  66.  
  67. --g = memory.readdword(AD5)
  68. --print(bit.tohex(g))
  69.  
  70.     -- RNG Functions
  71.  
  72. function RNA (R) -- RN Advance Function
  73.    
  74.     g = R
  75.     m1 = 0x4e6d
  76.     m2 = 0x41c6
  77.     g1 = g*m1
  78.     g2 = g*m2
  79.     g2 = bit.band(g2,0xFFFF)
  80.     g = g1 + g2*0x10000
  81.     g = bit.band(g,0xFFFFFFFF)
  82.     c=0x3039
  83.     g = g+c
  84.     g = bit.band(g,0xFFFFFFFF)
  85.     return g
  86.  
  87. end
  88.  
  89. function RNB (R) -- RN Advance and reduce for use in RNG calculations
  90.    
  91.     g = R
  92.     m1 = 0x4e6d
  93.     m2 = 0x41c6
  94.     g1 = g*m1
  95.     g2 = g*m2
  96.     g2 = bit.band(g2,0xFFFF)
  97.     g = g1 + g2*0x10000
  98.     c=0x3039
  99.     g = g+c
  100.     g = bit.band(g,0xFFFFFFFF)
  101.     g = bit.lshift(g,8)
  102.     g = bit.rshift(g,16)
  103.     return g
  104.  
  105. end
  106.  
  107.  
  108.         -- begin enemy HP/encounter loops
  109.        
  110.  
  111.     -- Encounter / Level up Stats
  112.    
  113.  
  114. if memory.readword(0x02000420) ~= 0x1FE then
  115.     gui.text(0,20,"Encounter: ".. (memory.readword(AD3)))
  116.     gui.text(0,40,"PP Regen: ".. (math.floor((memory.readword(0x020301A0))/0xFFF)))
  117.     fagi=memory.readbyte(0x02000520+0x1C+0x14C*4)
  118.     flv=memory.readbyte(0x02000520+0x14C*4+0xF)
  119.     fagilv=-fagi+(flv-5)*4+0x1B -- imperfect levels ups discounting randomly rolled stats on new file
  120.     jagi=memory.readbyte(0x02000520+0x1C+0x14C*5)
  121.     jlv=memory.readbyte(0x02000520+0x14C*5+0xF)
  122.     jagilv=-jagi+(jlv-5)*4+0x1B -- imperfect levels ups discounting randomly rolled stats on new file
  123.     sagi=memory.readbyte(0x02000520+0x1C+0x14C*6)
  124.     slv=memory.readbyte(0x02000520+0x14C*6+0xF)
  125.     sagilv=-sagi+(slv-5)*4+0x1E -- imperfect levels ups discounting randomly rolled stats on new file
  126.     pagi=memory.readbyte(0x02000520+0x1C+0x14C*7)
  127.     plv=memory.readbyte(0x02000520+0x14C*7+0xF)
  128.     pagilv=-pagi+(plv-18)*4+0x45 -- imperfect levels ups discounting randomly rolled stats on new file
  129.     gui.text(0,140,"Missing Agi F:" .. fagilv .. " J:" .. jagilv .. " S:" .. sagilv .. " P:" .. pagilv) -- -ve numbers indicate gained agility through mint
  130.  
  131.     if memory.readbyte(0x02000040)==0xFF then -- only display this after the reunion
  132.     iagi=memory.readbyte(0x02000520+0x1C+0x14C*0)
  133.     ilv=memory.readbyte(0x02000520+0x14C*0+0xF)
  134.     iagilv=-iagi+(ilv-28)*4+0x75 --
  135.     gagi=memory.readbyte(0x02000520+0x1C+0x14C*1)
  136.     glv=memory.readbyte(0x02000520+0x14C*1+0xF)
  137.     gagilv=-gagi+(glv-28)*4+0x68 --
  138.     vagi=memory.readbyte(0x02000520+0x1C+0x14C*2)
  139.     vlv=memory.readbyte(0x02000520+0x14C*2+0xF)
  140.     vagilv=-vagi+(vlv-28)*4+0x7B --
  141.     magi=memory.readbyte(0x02000520+0x1C+0x14C*3)
  142.     milv=memory.readbyte(0x02000520+0x14C*3+0xF)
  143.     magilv=-magi+(milv-28)*4+0x6F
  144.     gui.text(48,150,"I:" .. iagilv .. " G:" .. gagilv .. " V:" .. vagilv .. " M:" .. magilv)
  145.     end
  146. end
  147.  
  148.         -- begin RNG counters
  149.  
  150.  
  151. GRN = memory.readdword(AD5)
  152. BRN = memory.readdword(AD4)
  153.  
  154. if GRN == 1710661176 then
  155. store = 1710661176
  156. gcount=0
  157. end
  158. gcountbase = 0
  159. while store ~= GRN and gcountbase <= 750 do
  160. --print(store)
  161. store = RNA(store)
  162. if store <= 0 then
  163. store = 0xFFFFFFFF+store+1
  164. gcount = gcount +1
  165. gcountbase = gcountbase +1
  166. else
  167. gcount = gcount +1
  168. gcountbase = gcountbase +1
  169. end
  170. end
  171.  
  172. if store == GRN then
  173. gcountbase = 0
  174. else
  175. store = GRN
  176. gcountbase = 0
  177. gcount = 0
  178. end
  179.  
  180. bcountbase = 0
  181.  
  182. while bstore ~= BRN and bcountbase <= 100 do
  183.     bstore = RNA(bstore)
  184.     if bstore <= 0 then
  185.         bstore = 0xFFFFFFFF+bstore+1
  186.         brncount = brncount+1
  187.         bcountbase = bcountbase+1
  188.     else
  189.         brncount = brncount+1
  190.         bcountbase = bcountbase+1
  191.     end
  192. end
  193.  
  194. if bstore == BRN then
  195.     bcountbase = 0
  196. else
  197.     bstore = BRN
  198.     bcountbase = 0
  199.     brncount = 0
  200. end
  201.  
  202.  
  203. if BRN == 0 then    -- reset BRN counter on loadstate
  204. bstore = BRN
  205. bcount = 0
  206. end
  207.  
  208.         -- RNG Gui display
  209.  
  210. gui.text(0,10,"GRN count: " .. gcount)
  211. gui.text(0,00,"BRN count: " .. brncount)
  212.  
  213.  
  214. Roll = memory.readdword(AD4)
  215. Roll = bit.lshift(Roll,8)
  216. Roll = bit.rshift(Roll,16)
  217. Roll = Roll*100
  218. Roll = bit.rshift(Roll,16)
  219.  
  220. gui.text(120,00,"Roll: ".. Roll)
  221.  
  222.         -- Begin Flee/Assassinate Scripts
  223.        
  224.     -- Level Calculations
  225.        
  226. local   el1 = memory.readbyte(0x020308D7) -- Enemy 1 Level
  227. local   el2 = memory.readbyte(0x020308D7+0x14C) -- etc
  228. local   el3 = memory.readbyte(0x020308D7+2*0x14C)
  229. local   el4 = memory.readbyte(0x020308D7+3*0x14C)
  230. local   party = memory.readbyte(0x02000040) -- Party member number
  231. local   isl= memory.readbyte(0x0200052F) -- Isaac level, +14C *user ID to get rest.
  232. -- local    gal= memory.readbyte(0x0200067b) -- etc
  233. -- local    ivl= memory.readbyte(0x020007c7)
  234. -- local    mil= memory.readbyte(0x02000913)
  235. -- local    mil= memory.readbyte(0x020008F3)
  236. -- local    mil= memory.readbyte(0x020008F3)
  237. -- local    mil= memory.readbyte(0x020008F3)
  238. -- local    mil= memory.readbyte(0x020008F3)
  239.  
  240. if memory.readword(0x02000420) == 0x1FE then
  241.  
  242. if el4 ~= 0 then
  243.     ela = (el1+el2+el3+el4)/4
  244. elseif el3 ~=0 then
  245.     ela = (el1+el2+el3)/3
  246. elseif el2 ~=0 then
  247.     ela = (el1+el2)/2
  248. else
  249.     ela = el1
  250. end
  251.  
  252. pc1 = memory.readbyte(0x02000458)
  253. pc2 = memory.readbyte(0x02000459)
  254. pc3 = memory.readbyte(0x0200045A)
  255. pc4 = memory.readbyte(0x0200045B)
  256. if party == 0x70 then
  257.     ml = (memory.readbyte(0x02000520+0x14C*pc1+0xF)+memory.readbyte(0x02000520+0x14C*pc2+0xF)+memory.readbyte(0x02000520+0x14C*pc3+0xF))/3
  258. else
  259.     ml = (memory.readbyte(0x02000520+0x14C*pc1+0xF)+memory.readbyte(0x02000520+0x14C*pc2+0xF)+memory.readbyte(0x02000520+0x14C*pc3+0xF)+memory.readbyte(0x02000520+0x14C*pc4+0xF))/4
  260. end
  261.  
  262. LevelAve = ml-ela
  263.  
  264.     --Agility/HP Battle Scripts
  265.  
  266.  
  267. local pcag1=memory.readword(0x02030338+0x04)
  268. local pcag2=memory.readword(0x02030338+0x04+0x10)
  269. local pcag3=memory.readword(0x02030338+0x04+0x20)
  270. local pcag4=memory.readword(0x02030338+0x04+0x30)
  271.  
  272. if  memory.readbyte(0x02030368)==0xFF then -- Hacky way of checking if we are in fight menu or battle
  273.     if pcag1 >= 1000 then
  274.     pcag1 = 0
  275.     end
  276.     if pcag2 >= 1000 then
  277.     pcag2 = 0
  278.     end
  279.     if pcag3 >= 1000 then
  280.     pcag3 = 0
  281.     end
  282.     if pcag4 >= 1000 then
  283.     pcag4 = 0
  284.     end
  285.     gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1) -- Displays agility of party member pc1
  286.     gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
  287.     gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
  288.     gui.text(0,70,"PC" .. pc4 .. " Agi: " .. pcag4)
  289.  
  290.     if memory.readbyte(0x02030900)>0 then
  291.         gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308E4)) -- If Enemy 1 has nonzero HP display E1 agility
  292.         gui.text(110,40, "HP: " .. memory.readword(0x02030900))
  293.     else
  294.     end
  295.    
  296.     if memory.readbyte(0x02030900+0x14C)>0 then
  297.         gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308E4+0x14C))
  298.         gui.text(110,50, "HP: " .. memory.readword(0x02030900+0x14C))
  299.     else
  300.     end
  301.    
  302.     if memory.readbyte(0x02030900+0x14C*2)>0 then
  303.         gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308E4+0x14C*2))
  304.         gui.text(110,60, "HP: " .. memory.readword(0x02030900+0x14C*2))
  305.     else
  306.     end
  307.    
  308.     if memory.readbyte(0x02030900+0x14C*3)>0 then
  309.         gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308E4+0x14C*3))
  310.         gui.text(110,70, "HP: " .. memory.readword(0x02030900+0x14C*3))
  311.     else
  312.     end
  313.                
  314.     if memory.readbyte(0x02030900+0x14C*4)>0 then
  315.         gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308E4+0x14C*4))
  316.         gui.text(110,80, "HP: " .. memory.readword(0x02030900+0x14C*4))
  317.     else
  318.     end
  319.    
  320. elseif memory.readbyte(0x02030368)==0xFF and memory.readbyte(0x02030358)==0xFF then -- Hacky way of accounting for three person party
  321.     gui.text(0,40,"PC" .. pc1 .. " Agi: " .. pcag1)
  322.     gui.text(0,50,"PC" .. pc2 .. " Agi: " .. pcag2)
  323.     gui.text(0,60,"PC" .. pc3 .. " Agi: " .. pcag3)
  324.    
  325.     if memory.readbyte(0x02030900)>0 then
  326.         gui.text(60,40, "E1 Agi: " .. memory.readbyte(0x020308E4)) -- If Enemy 1 has nonzero HP display E1 agility
  327.         gui.text(110,40, "HP: " .. memory.readword(0x02030900+0x14C*0))
  328.     else
  329.     end
  330.    
  331.     if memory.readbyte(0x02030900+0x14C)>0 then
  332.         gui.text(60,50, "E2 Agi: " .. memory.readbyte(0x020308E4+0x14C))
  333.         gui.text(110,50, "HP: " .. memory.readbyte(0x02030900+0x14C*1))
  334.     else
  335.     end
  336.    
  337.     if memory.readbyte(0x02030900+0x14C*2)>0 then
  338.         gui.text(60,60, "E3 Agi: " .. memory.readbyte(0x020308E4+0x14C*2))
  339.         gui.text(110,60, "HP: " .. memory.readbyte(0x02030900+0x14C*2))
  340.     else
  341.     end
  342.    
  343.     if memory.readbyte(0x02030900+0x14C*3)>0 then
  344.         gui.text(60,70, "E4 Agi: " .. memory.readbyte(0x020308E4+0x14C*3))
  345.         gui.text(110,70, "HP: " .. memory.readbyte(0x02030900+0x14C*3))
  346.     else
  347.     end
  348.                
  349.     if memory.readbyte(0x02030900+0x14C*4)>0 then
  350.         gui.text(60,80, "E5 Agi: " .. memory.readbyte(0x020308E4+0x14C*4))
  351.         gui.text(110,80, "HP: " .. memory.readbyte(0x02030900+0x14C*4))
  352.     else
  353.     end
  354.    
  355. else -- otherwise, we are in a battle and do the following
  356. local j=1
  357. local k=1
  358. local trn={}
  359.     while memory.readbyte(0x0203033C+0x10*(j-1)) ~= 0 do --while loop which checks nonzero agilities and therefore count number of actors in the battle
  360.         trn[j]= memory.readbyte(0x02030338+0x10*(j-1)) -- add the character index to the trn array in order
  361.         if trn[j]==0xFF then -- if user has already acted then do nothing
  362.             j=j+1
  363.         else
  364.             gui.text(30+15*k,40,trn[j]) -- if user hasn't acted then display user in the turn order queue
  365.             j=j+1
  366.             k=k+1
  367.         end
  368.     end
  369.  
  370. gui.text(0,40, "Turn Order: ")
  371. if memory.readbyte(0x02030900)>0 then
  372. gui.text(70,50, "E1 HP: " .. memory.readword(0x02030900))
  373. end
  374. end
  375.  
  376.     -- Agility Bonus Calculator
  377.    
  378. if memory.readbyte(0x0203033C)>0 then
  379.     local l=1
  380.     while memory.readbyte(0x02030328+0x10*l) ~= pc1 and l<15 do
  381.             l=l+1
  382.     end
  383.     if l~=15 then
  384.         pcntag1=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc1-5)))/memory.readbyte(0x02000BDC+0x14C*(pc1-5))*10000
  385.         pcntag1= math.floor(pcntag1)/100
  386.         gui.text(0,90,"PC" .. pc1 .. " Bonus: " .. pcntag1 .. "%")
  387.     end
  388.    
  389.     local l=1
  390.     while memory.readbyte(0x02030328+0x10*l) ~= pc2 and l<15 do
  391.         l=l+1
  392.     end
  393.     if l~=15 then
  394.         pcntag2=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc2-5)))/memory.readbyte(0x02000BDC+0x14C*(pc2-5))*10000
  395.         pcntag2= math.floor(pcntag2)/100
  396.         gui.text(0,100,"PC" .. pc2 .. " Bonus: " .. pcntag2 .. "%")
  397.     end
  398.    
  399.     local l=1
  400.     while memory.readbyte(0x02030328+0x10*l) ~= pc3 and l<15 do
  401.         l=l+1
  402.     end
  403.     if l~=15 then
  404.         pcntag3=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc3-5)))/memory.readbyte(0x02000BDC+0x14C*(pc3-5))*10000
  405.         pcntag3= math.floor(pcntag3)/100
  406.         gui.text(0,110,"PC" .. pc3 .. " Bonus: " .. pcntag3 .. "%")
  407.     end
  408.    
  409.     if memory.readbyte(0x0200045B)==0 and memory.readbyte(0x0200045C)==0 then
  410.     else
  411.         local l=1
  412.         while memory.readbyte(0x02030328+0x10*l) ~= pc4 and l<15 do
  413.             l=l+1
  414.         end
  415.         if l~=15 then
  416.             pcntag4=(memory.readbyte(0x02030328+0x10*l+0x04)-memory.readbyte(0x02000BDC+0x14C*(pc4-5)))/memory.readbyte(0x02000BDC+0x14C*(pc4-5))*10000
  417.             pcntag4= math.floor(pcntag4)/100
  418.             gui.text(0,120,"PC" .. pc4 .. " Bonus: " .. pcntag4 .. "% Roll " .. memory.readbyte(0x02030328+0x10*l+0x04))
  419.         end
  420.     end
  421.  
  422. end
  423.  
  424. fleeFail = memory.readbyte(0x02030092)
  425.  
  426. function flee(S) -- Flee Success Calculation
  427.     g = S
  428.     g = RNB(g)*10000
  429.     fl = 5000 + (2000*fleeFail) + (LevelAve * 500)
  430.     g = bit.rshift(g, 16)
  431.     if fl >= g then
  432.         return true
  433.     else
  434.         return false
  435.     end
  436. end
  437.  
  438. RN= memory.readdword(0x030011BC)
  439. count = 0
  440.  
  441. while flee(RN) == false do -- Attack Cancel to Flee Calculation
  442. count = count + 1
  443. if count == 100 then break end
  444. RN= RNA(RN)
  445. end
  446.  
  447. gui.text(160,30,"ACs to Run: " .. count)
  448.  
  449.         -- % Chance to Run
  450. fleecount = 0
  451. if fleestore ~= memory.readdword(AD5) then
  452.     fleeRN = memory.readdword(AD5)
  453.     for i=1,1000 do
  454.         if flee(fleeRN) == true then
  455.             fleecount= fleecount +1
  456.         end
  457.         fleeRN=RNA(fleeRN)
  458.     end
  459.     fleepercent = fleecount/10
  460.     fleestore = memory.readdword(AD5)
  461.     fev = fleepercent/100
  462.     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)
  463.     gui.text(100,20,"Run EV: ".. EV)
  464.     gui.text(160,20,"Run%: " .. fleepercent)
  465.     else
  466.     gui.text(100,20,"Run EV: ".. EV )
  467.     gui.text(160,20,"Run%: " .. fleepercent)
  468. end
  469.  
  470. evcount = 0
  471.  
  472.  
  473. function vuln (S)
  474.     e1Ind = S
  475.     vuln1 = memory.readbyte(0x080B9E7C  + ((e1Ind - 8) * 0x4C) + 0x3E)
  476.     vuln2 = memory.readbyte(0x080B9E7C  + ((e1Ind - 8) * 0x4C) + 0x3F)
  477.     vuln3 = memory.readbyte(0x080B9E7C  + ((e1Ind - 8) * 0x4C) + 0x40)
  478.     return vuln1, vuln2, vuln3
  479. end
  480.  
  481. function enemy (S,Elm) -- Enemy Elemental Data Table
  482.         elemInd = memory.readbyte(0x080B9E7C  + ((S - 8) * 0x4C) + 0x2A)
  483.         enemyelmlevel = memory.readbyte(0x080C6684  + (elemInd * 0x18) + 4+Elm)
  484.         return enemyelmlevel
  485. end
  486.  
  487. function bchance (E) -- base chance for status
  488.     if E == 16 or E == 17 then
  489.         c = 75
  490.     elseif E == 23 then
  491.     c = 40
  492.     elseif E == 24 then
  493.     c = 35
  494.     elseif E == 27 then
  495.     c = 20
  496.     end
  497.     return c
  498. end
  499.    
  500. 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
  501.     uelm = memory.readbyte(0x0200061C+0x20+U*0x14C+Elm) -- Elemental Power of User
  502.     eluc = memory.readbyte(0x020308E6) -- Enemy Luck
  503.     eind = memory.readword(0x02030A12) -- Enemy Index
  504.     eelm = enemy(eind,Elm) -- Enemy Elemental Levels
  505.     vul1, vul2, vul3 = vuln(eind) -- Enemy Vulnerability
  506.     if vul1 == E or vul2 == E or vul3 == E then -- Vulnerability key at top
  507.         v=25
  508.     else
  509.         v=00
  510.     end
  511.     if memory.readbyte(0x080C0F4C  + (U * 0xB4) + 0x92 + Elm) == 54 then
  512.         elmaff = 5
  513.     else
  514.         elmaff = 0
  515.     end
  516.     proc = (((uelm + elmaff - eelm)-(math.floor(eluc/2)))*3+bchance(E)+v)
  517.     g = RNB(S)*100
  518.     g = bit.rshift(g,16)
  519.     if proc >= g then
  520.         return true
  521.     else
  522.         return false
  523.     end
  524.     end
  525.    
  526. function unleash (S)
  527.     g = S
  528.     g = RNB(g)*100
  529.     g = bit.rshift(g,16)
  530.     if 35 >= g then
  531.         return true
  532.     else
  533.         return false
  534.     end
  535. end
  536.  
  537. -- to add; themis axe, thanatos mace?, sleep bomb, stun, pirate sword
  538.  
  539. psword=0
  540. for i=0,29 do
  541. --print(memory.readbyte(0x02000C74+i*0x2))
  542.     if memory.readbyte(0x02000C74+i*0x2)==0x1F then -- Jenna inventory check for psword
  543.         if memory.readbyte(0x02000C75+i*0x2)==0x3 then -- Equip check
  544.         psword=1
  545.         end
  546.     elseif memory.readbyte(0x02000C74+i*0x2-0x14C)==0x1F then
  547.         if memory.readbyte(0x02000C75+i*0x2-0x14C)==0x3 then -- Equip check
  548.         psword=2
  549.         end
  550.     end
  551. end
  552. if psword==1 then -- Psword Proc Calc
  553. BRN = memory.readdword(0x020054C8)
  554. bcount=0
  555.  
  556. while effectproc(RNA(BRN),24,1,5) == false or unleash(BRN) == false do
  557.     bcount = bcount+1
  558.     if bcount == 100 then break end
  559.     BRN=RNA(BRN)
  560. end
  561.  
  562. gui.text(160,40,"Psword Sleep: " .. bcount)
  563.  
  564. end
  565. if psword==2 then -- Psword Proc Calc
  566. BRN = memory.readdword(0x020054C8)
  567. bcount=0
  568.  
  569. while effectproc(RNA(BRN),24,1,4) == false or unleash(BRN) == false do
  570.     bcount = bcount+1
  571.     if bcount == 100 then break end
  572.     BRN=RNA(BRN)
  573. end
  574.  
  575. gui.text(160,40,"Psword Sleep: " .. bcount)
  576.  
  577. end
  578.  
  579. eindex=memory.readword(0x02030A12)
  580.  
  581. sleepb=0
  582. sleepuser=0
  583. for i=0,29 do
  584. --print(memory.readbyte(0x02000C74+i*0x2))
  585.     if memory.readbyte(0x02000C74+i*0x2)==0xE3 then
  586.     sleepb=1
  587.     sleepuser=5
  588.     elseif memory.readbyte(0x02000C74+0x14C+i*0x2)==0xE3 then
  589.     sleepb=1
  590.     sleepuser=6
  591.     elseif memory.readbyte(0x02000C74-0x14C+i*0x2)==0xE3 then
  592.     sleepb=1
  593.     sleepuser=4
  594.     elseif memory.readbyte(0x02000C74+i*0x2+0x14C*2)==0xE3 then -- Inventory check for sleepbomb
  595.     sleepb=1
  596.     sleepuser=7
  597.     end
  598. end
  599. if sleepb == 1 and eindex ~= 0x5B then
  600.     bcount=0
  601.     while effectproc(BRN,24,3,sleepuser) == false do
  602.     bcount=bcount+1
  603.     if bcount==100 then break end
  604.     BRN=RNA(BRN)
  605.     end
  606.     gui.text(160,50,"Sleep bomb: " .. bcount)
  607. end
  608.  
  609. if memory.readbyte(0x02000520+5*0x14C+0x129) >= 0x46 and memory.readbyte(0x02000520+5*0x14C+0x129) <= 0x54 then -- Jenna Class Check
  610.     BRN = memory.readdword(0x020054C8)
  611.     bcount=0
  612.  
  613.     while effectproc(BRN,16,3,5) == false do -- Weaken calculation
  614.         bcount = bcount+1
  615.         if bcount == 100 then break end
  616.         BRN=RNA(BRN)
  617.     end
  618.  
  619. gui.text(160,50,"Jenna Weaken: " .. bcount)
  620.  
  621. end
  622.  
  623. if memory.readbyte(0x02000520+4*0x14C+0x129) >= 0x46 and memory.readbyte(0x02000520+4*0x14C+0x129) <= 0x54 then -- Felix Class Check
  624.     BRN = memory.readdword(0x020054C8)
  625.     bcount=0
  626.  
  627.     while effectproc(BRN,16,3,4) == false do -- Weaken calculation
  628.         bcount = bcount+1
  629.         if bcount == 100 then break end
  630.         BRN=RNA(BRN)
  631.     end
  632.  
  633. gui.text(160,60,"Felix Weaken: " .. bcount)
  634.  
  635. if eindex == 0x5B then
  636.     Sour = memory.readdword(0x020054C8)
  637.     Sour = RNA(Sour)
  638.     bcount=0
  639.     while effectproc(Sour,16,3,7) == false do
  640.     bcount = bcount + 1
  641.     if bcount == 100 then break end
  642.     Sour = RNA(Sour)
  643.     end
  644.     gui.text(160,70, "Sour " .. bcount)
  645. end
  646.  
  647.  
  648. end
  649.  
  650.         -- Drop Stuff
  651.  
  652. function drop(S)
  653.     return memory.readbyte(0x080B9E7C+((S-8)*0x4C+0x44)), memory.readbyte(0x080B9E7C+((S-8)*0x4C+0x46))
  654. end
  655. function itemdrop(S,C)
  656.     g = S
  657.     g = RNB(g)*100
  658.     g = bit.rshift(g,16)
  659.     if C >= g then
  660.         return true
  661.     else
  662.         return false
  663.     end
  664. end
  665. function droprate(S,ch) -- enemy index, chance of drop
  666.     BRN = memory.readdword(0x020054C8)
  667.     bcount=0
  668.     bcount2=0
  669.     rate=bit.rshift(0x64,ch-1)
  670.     rate2=bit.rshift(0x64,ch-3)
  671.         while itemdrop(BRN,rate) == false do
  672.             bcount=bcount+1
  673.                 if itemdrop(BRN,rate2) == true then
  674.                 bcount2=bcount
  675.                 end
  676.                 if bcount == 100 then break end
  677.             BRN=(RNA(BRN))
  678.         end
  679.     return bcount, bcount2
  680. end
  681.  
  682. if memory.readbyte(0x02030900)>0 then
  683.     eindex=memory.readword(0x02030A12)
  684.     dr,ch = drop(eindex)
  685.     if dr == 0xE3 or dr == 0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb, 0x44 is staff of anubis
  686.         A,B= droprate(eindex,ch)
  687.     gui.text(140,80, "E1 Item: " .. dr .. " Turns " .. A .. "|" .. B) -- A=turns without djinn, B=turns with djinn
  688.     end
  689. end
  690.    
  691. if memory.readbyte(0x02030900+0x14C)>0 then
  692.     eindex2=memory.readword(0x02030A12+0x14C)
  693.     dr,ch=drop(eindex2)
  694.     if dr == 0xE3 or dr==0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb
  695.         A,B= droprate(eindex,ch)
  696.         gui.text(140,100, "E2 Item: " .. dr .. " Turns " .. A .. "|" .. B)
  697.     end
  698. end
  699.  
  700. if memory.readbyte(0x02030900+0x14C*2)>0 then
  701.     eindex3=memory.readword(0x02030A12+0x14C*2)
  702.     dr,ch=drop(eindex3)
  703.     if dr == 0xE3 or dr==0x44 then -- dropped item is something I care about, 0xE3 is sleep bomb
  704.         A,B= droprate(eindex,ch)
  705.         gui.text(140,120, "E3 Item: " .. dr .. " Turns " .. A .. "|" .. B)
  706.     end
  707. end
  708.  
  709. --end
  710.  
  711.  
  712. -- if memory.readbyte(0x02000048)>=0x70 and memory.readbyte(0x02000155) < 0x14 then -- If you have mist, return mist information
  713.  
  714. -- BRN = memory.readdword(0x020023A8)
  715. -- bcount=0
  716.  
  717. -- while effectproc(RNA(BRN),24,1,3) == false or unleash(BRN) == false do -- mist calculation
  718.     -- bcount = bcount+1
  719.     -- if bcount == 100 then break end
  720.     -- BRN=RNA(BRN)
  721. -- end
  722. -- gui.text(160,50,"Mist: " .. bcount)
  723. -- end
  724. --end
  725.  
  726. end
  727.  
  728. --eindex=memory.readword(0x02030A12)
  729.  
  730.  
  731.     vba.frameadvance();
  732.  
  733. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement