Guest User

Untitled

a guest
Nov 15th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.14 KB | None | 0 0
  1. -- Crash Huge Adventure lua v2.2.0-beta Virtual Boy Advance
  2. -- This is Community Work Please Help
  3. -- Join in add updates of your own and add your name
  4.  
  5. -- Values found by: Spikestuff, Got4n, Dica
  6. -- Script Edited by: Spikestuff, Ilari, Dica, TASEditor, RGamma, Warepire, ThunderAxe
  7.  
  8. function TableMerge(t1,t2)
  9.     local t3 = {}
  10.     for k,v in pairs(t1) do
  11.         t3[k] = v
  12.     end
  13.     for k,v in pairs(t2) do
  14.         t3[k] = v
  15.     end
  16.     return t3
  17. end
  18.  
  19. auto = 0
  20. x_pos = 0
  21. y_pos = 0
  22. x_pos_bonus = 0
  23. y_pos_bonus = 0
  24. spd_average_frames = 0
  25. x_speed_average = 0
  26. y_speed_average = 0
  27. real_speed_average = 0
  28.  
  29. while true do
  30. area = memory.readbyte(0x3001644)
  31. areab = memory.readbyte(0x200000E)
  32. mask = memory.readbyte(0x200009C)
  33. lvl = memory.readbyte(0x200000E)
  34. ex = memory.readbyte(0x2003AB8)
  35.  
  36. x_pos_prev = x_pos
  37. y_pos_prev = y_pos
  38. x_pos = memory.readlong(0x2010A14)
  39. y_pos = memory.readlong(0x2010A18)
  40. x_speed = x_pos - x_pos_prev
  41. y_speed = y_pos - y_pos_prev
  42. real_speed = math.sqrt(x_speed*x_speed + y_speed*y_speed) -- do not trust during jumps!
  43.  
  44. old_y_speed = memory.readwordsigned(0x02010A78)
  45. old_x_speed = memory.readwordsigned(0x02010A74)
  46.  
  47. x_pos_prev_bonus = x_pos_bonus
  48. y_pos_prev_bonus = y_pos_bonus
  49. x_pos_bonus = memory.readlong(0x2010E2C)
  50. y_pos_bonus = memory.readlong(0x2010E30)
  51. x_speed_bonus = x_pos_bonus - x_pos_prev_bonus
  52. y_speed_bonus = y_pos_bonus - y_pos_prev_bonus
  53. real_speed_bonus = math.sqrt(x_speed_bonus*x_speed_bonus + y_speed_bonus*y_speed_bonus) -- do not trust during jumps!
  54.  
  55. old_x_speed_bonus = memory.readwordsigned(0x2010E8C)
  56. old_y_speed_bonus = memory.readwordsigned(0x2010E90)
  57.  
  58. spd_average_frames = spd_average_frames + 1
  59. x_speed_average = ( (x_speed_average * (spd_average_frames -1) ) +x_speed) / spd_average_frames
  60. y_speed_average = ( (y_speed_average * (spd_average_frames -1) ) +y_speed) / spd_average_frames
  61. real_speed_average = ( (real_speed_average * (spd_average_frames -1) ) +real_speed) / spd_average_frames
  62.  
  63. if ex > 0 and ex <= 3 or area == 1 or area == 5 or area == 8 or area == 9 or area == 11 or area == 13 or area == 14 or area == 15 or area == 17 then
  64.     auto = 0
  65. else
  66.     if input.get()["i"] or input.get()["I"] then
  67.         auto = 1
  68.     else if input.get()["o"] or input.get()["O"] then
  69.         auto = 0
  70.     else if input.get()["m"] or input.get()["M"] then
  71.             spd_average_frames = 0
  72.             x_speed_average = 0
  73.             y_speed_average = 0
  74.             real_speed_average = 0
  75. end end end end
  76.  
  77. if auto == 1 then -- Automatic Slide Spin Script. Still needs to be worked on.
  78.     direction = memory.readbytesigned(0x030007E0)
  79.     dir = nil
  80.     action = nil
  81.     if area ~= 6 then -- Normal
  82.         sli_spi_timer = memory.readwordsigned(0x2010DDC)
  83.         spin_or_slide = memory.readbyte(0x2010A1E)
  84.         is_sliding = spin_or_slide == 20
  85.  
  86.         gui.text(2,24,"Automatic Mode","yellow")
  87.  
  88.         if direction == 16 then -- right
  89.             dir = {right = true}
  90.         elseif direction == 32 then -- left
  91.             dir = {left = true}
  92.         end
  93.         if math.abs(old_x_speed) >= 256 and sli_spi_timer == 0 and old_y_speed == 0 and not is_sliding then
  94.             action = {R = true}
  95.         elseif sli_spi_timer == 10 and is_sliding then
  96.             action = {B = true}
  97.         end
  98.         if action ~= nil and dir ~= nil then
  99.             joypad.set(1, TableMerge(action, dir))
  100.         end
  101.     else -- Bonus Round
  102.         sli_spi_timer = memory.readwordsigned(0x020111F4)
  103.         spin_or_slide = memory.readbyte(0x2010E36)
  104.         is_sliding = spin_or_slide == 20
  105.  
  106.         gui.text(2,24,"Automatic Mode","orange")
  107.  
  108.         if direction == 16 then -- right
  109.             dir = {right = true}
  110.         elseif direction == 32 then -- left
  111.             dir = {left = true}
  112.         end
  113.         if math.abs(old_x_speed_bonus) >= 256 and sli_spi_timer == 0 and old_y_speed_bonus == 0 and not is_sliding then
  114.             action = {R = true}
  115.         elseif sli_spi_timer == 10 and is_sliding then
  116.             action = {B = true}
  117.         end
  118.         if action ~= nil and dir ~= nil then
  119.             joypad.set(1, TableMerge(action, dir))
  120.         end
  121.     end
  122. end
  123.  
  124. if area == 11 or area == 13 or area == 14 or area == 15 or area == 16 or area == 17 then else
  125.     if area == 5 or area == 9 then
  126.             gui.text(2,32,memory.readwordsigned(0x3003F34),"orange")
  127.         else
  128.     if area == 2 and areab == 3 or area == 18 then
  129.             gui.text(2,120,memory.readwordsigned(0x3001404),"yellow")
  130.         else
  131.             gui.text(2,120,memory.readwordsigned(0x300082C),"yellow")
  132. end end end
  133.  
  134. if area == 9 then  -- N.Gin Fight
  135.     bhealth = memory.readbyte(0x3004130)
  136.     thealth = memory.readbyte(0x30040B0)
  137.     lhealth = memory.readshort(0x30041B0)
  138.     rhealth = memory.readshort(0x3004230)
  139.     if bhealth ~= 255 and bhealth ~= -1 then
  140.         gui.text(18,48,"Bomb: " .. (bhealth+1)/2) end
  141.     if lhealth ~= 0 or rhealth ~= 0 then
  142.         gui.text(6,56,"Rockets: " .. (lhealth/2) .. "/" .. (rhealth/2)) end
  143.     if thealth ~= 255 and thealth ~= -1 then
  144.         gui.text(10,64,"Turret: " .. (thealth+1)/2) end
  145. end
  146.  
  147. if area == 8 then -- Dingodile Fight
  148.     dshi = memory.readbyte(0x2003EFC)
  149.     gui.text(2,24,"Shield: " .. ((dshi == 1) and "ON" or "OFF - " .. memory.readbyte(0x20118CC))); else
  150. end
  151.  
  152. if area == 7 then -- Tiny Fight
  153.     tatt = memory.readbyte(0x2011FDC)
  154.     gui.text(2,24,"Can Hit: " .. ((tatt == 8) and "YES - " .. memory.readbyte(0x02011FF4) or "NO")); else
  155. end
  156.  
  157. if area == 16 then
  158.     slide_count = 0
  159.     aku = memory.readbyte(0x200009C)
  160.     gui.text(2,9,"Mask Level: " .. aku,"yellow") else
  161. end
  162.  
  163. if area == 2 and areab == 3 then else
  164.     if area == 11 or area == 13 or area == 14 or area == 15 or area == 16 or area == 17 then else
  165.         if area == 6 then --Bonus
  166.             gui.text(2,32,"Pixel X: " .. x_pos_bonus)
  167.             gui.text(2,40,"Pixel Y: " .. y_pos_bonus)
  168.             gui.text(2,48,"Speed X: " .. x_speed_bonus)
  169.             gui.text(2,56,"Speed Y: " .. y_speed_bonus)
  170.             gui.text(2,64,"RealSpd: " .. real_speed_bonus)
  171.             gui.text(2,128,"Slide Time: 22/" .. memory.readwordsigned(0x20111F4),"orange")
  172.             gui.text(2,136," Spin Time: 23/" .. memory.readwordsigned(0x20111F4),"orange")
  173.         else
  174.         if area == 5 or area == 9 then -- Flying Cooldown
  175.             cdwn = memory.readbyte(0x30014E0)-1
  176.             if cdwn ~= -1 then
  177.                 gui.text(2,40,"Cooldown: " .. cdwn)
  178.             end
  179.         else
  180.         if area == 10 then -- Neo Cortex and Mega Mix
  181.             gui.box(0,142,240,160,"black")
  182.             gui.text(116,143,"Pixel X: " .. x_pos)
  183.             gui.text(116,151,"Pixel Y: " .. y_pos)
  184.             gui.text(188,143,"Speed X: " .. x_speed)
  185.             gui.text(188,151,"Speed Y: " .. y_speed)
  186.             gui.text(128,134,"Slide: 22| " .. memory.readwordsigned(0x2010DDC).. " |23 :Spin","yellow")
  187.             gui.text(2,134,"Real Speed: " .. real_speed)
  188.         else -- Normal
  189.             gui.text(2,32,"Pixel X: " .. x_pos)
  190.             gui.text(2,40,"Pixel Y: " .. y_pos)
  191.             gui.text(2,48,"Speed X: " .. x_speed)
  192.             gui.text(2,56,"Speed Y: " .. y_speed)
  193.             gui.text(2,64,"RealSpd: " .. real_speed)
  194.             gui.text(2,72,"S.X Avg: " .. x_speed_average)
  195.             gui.text(2,80,"S.Y Avg: " .. y_speed_average)
  196.             gui.text(2,88,"R.S.Avg: " .. real_speed_average)
  197.             if area == 1 or area == 8 then
  198.                 gui.text(2,136," Spin Dur.: 24/" .. memory.readwordsigned(0x2010DDC),"green")
  199.             else
  200.                 gui.text(2,128,"Slide Time: 22/" .. memory.readwordsigned(0x2010DDC),"yellow")
  201.                 gui.text(2,136," Spin Time: 23/" .. memory.readwordsigned(0x2010DDC),"yellow") end
  202. end end end end end
  203.  
  204. if not movie.active() then
  205.     gui.drawbox(0,0,78,8, "red")
  206.     gui.text(2,1, "MOVIE NOT RECORDING")
  207. else
  208.     gui.text(2,1,"RR: " .. movie.rerecordcount())
  209. end
  210.  
  211. vba.frameadvance() end
Add Comment
Please, Sign In to add comment