Advertisement
Guest User

Untitled

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