Advertisement
Arnethegreat

Use this please

Apr 5th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.69 KB | None | 0 0
  1. -- Version 0.19d
  2. -- OPTIONS -- OPTIONS -- OPTIONS -- Change to true or false
  3.  
  4. Level_Blitz = true
  5. NoLeftMode = false
  6. DrunkMode = false
  7. HardMode = false
  8. ForceRetry = true
  9. DeathTimer = false  --combine with Hard Mode for Insane Mode (1-hit death)
  10. AlwaysExtendedFlutter = false
  11. NoFlutter = false
  12. NoTongue = false
  13. Velcro = false
  14. AlwaysFilledMouth = false -- Enter 2 for bubbles and 3 for melons. Enter false to disable
  15. FullEggsStart = false
  16. NumberOfEggs = 6 -- For FullEggsStart, how many to start with - choose between 1-6
  17. EggType = 37  -- What eggs to start with (34 = flashing egg - 35 = red - 36 = yellow - 37 = green - 39 = key - 40 = flashing egg
  18. FastMode = false
  19. SpeedBoost = 5 -- For fast mode, enter 0-9 (higher is faster)
  20.  
  21. -- Level Blitz Options -- Level Blitz Options --
  22.  
  23. AutoScrollers = false
  24. ExtraStages = false
  25. ExcludeStages = {67, 100}  -- seperate stages by a comma ","
  26. NormalFortressOrder = true
  27. NormalCastleOrder = true
  28. RandomSeed = 8906
  29. SameStage = false
  30. Fortresses = true
  31. Castles = true
  32. World1 = true
  33. World2 = true
  34. World3 = true
  35. World4 = true
  36. World5 = true
  37. World6 = true
  38.  
  39. -- OPTIONS End -- OPTIONS End -- OPTIONS End --
  40.  
  41. -- !Instructions! Instructions! Instructions! Instructions!
  42. -- 1. You must use a lua compatible Snes9x emulator. Recommended is -> http://code.google.com/p/snes9x-rr/downloads/detail?name=snes9x-1.51-rerecording-svn147.zip&can=2&q=
  43. -- 2. Recommended ROM is (U) (1.0) (!) but others should work but they are untested
  44. -- 3. Change options above and replace with true or false, RandomSeed is a number though, if it's a word, it's just random
  45. -- 4. In Snes9x, load ROM then go File -> Lua Scripting -> New Lua Script Window... -> Load file -> Press Run
  46. -- 5. You know you have loaded it right when the Lua Script window outputs what modes are on and what are false
  47. -- 6. If you have changed the options, you have to restart the script for it to take effect
  48. -- Newest version is always found at http://pastebin.com/qCGDbZZZ
  49. ------------------------------------------------
  50. ------------------------------------------------
  51. ------------------------------------------------
  52. ----------------Script starts here--------------
  53. ------------------------------------------------
  54. ------------------------------------------------
  55. ------------------------------------------------
  56. ------------------------------------------------
  57. ------------------------------------------------
  58. function table.contains(table, element)
  59.   for i, value in pairs(table) do
  60.     if value == element then
  61.       valpos = i
  62.       return true
  63.     end
  64.   end
  65.   return false
  66. end
  67.  
  68. function deepcopy(t)
  69.     if type(t) ~= 'table' then return t end
  70.     local mt = getmetatable(t)
  71.     local res = {}
  72.     for k,v in pairs(t) do
  73.         if type(v) == 'table' then
  74.             v = deepcopy(v)
  75.         end
  76.         res[k] = v
  77.     end
  78.     setmetatable(res,mt)
  79.     return res
  80. end
  81.  
  82. function removetable(tab,tab2)
  83.     table.sort(tab)
  84.     table.sort(tab2)
  85.     rem = 0
  86.     tabcopy = deepcopy(tab)
  87.         for cy, value in ipairs(tab) do
  88.               for cx, value2 in ipairs (tab2) do       
  89.                 if value == value2 then
  90.                     table.remove(tabcopy,cy - rem)
  91.                     rem = rem + 1
  92.                 end
  93.               end
  94.         end
  95.     return tabcopy
  96. end
  97. ------------------------------------------------
  98. ------------------------------------------------
  99. ------------------------------------------------
  100. print("Version 0.19")
  101. NumberOfEggs = NumberOfEggs*2
  102. eggcount = 0
  103. keycount = 0
  104. mouth_var = 0
  105. instage = 0
  106. enteredstage = 0
  107. laststage = 0
  108. lastworld = 0
  109. stage = 0
  110. levelsplayed = {}
  111. scrollerslist = {4, 53, 64} -- This can be changed to include or exclude other stages depending on how you define an autoscroller
  112. extralist = {8, 20, 32, 44, 56, 68}
  113. castlelist = {7, 19, 31, 43, 55}
  114. fortresslist = {3, 15, 27, 39, 51, 63}
  115. world1list = {0, 1, 2, 3, 4, 5, 6, 7, 8 }
  116. world2list = {12, 13, 14, 15, 16, 17, 18, 19, 20}
  117. world3list = {24, 25, 26, 27, 28 ,29, 30, 31, 32}                                  
  118. world4list = {36, 37, 38, 39, 40, 41, 42, 43, 44}
  119. world5list = {48, 49, 50, 51, 52, 53, 54, 55, 56}
  120. world6list = {60, 61, 62, 63, 64, 65, 66, 68}
  121. stageslist = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27, 28 ,29, 30, 31, 32, 36, 37, 38, 39, 40, 41, 42, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 60, 61, 62, 63, 64, 65, 66, 68}
  122. -- Remove stages according to options
  123. if AutoScrollers == false then
  124.     stageslist = removetable(stageslist, scrollerslist)
  125. end
  126.  
  127. if ExtraStages == false then
  128.     stageslist = removetable(stageslist, extralist)
  129. end
  130.  
  131. if World1 == false then
  132.     stageslist = removetable(stageslist, world1list)
  133. end
  134.  
  135. if World2 == false then
  136.     stageslist = removetable(stageslist, world2list)
  137. end
  138.  
  139. if World3 == false then
  140.     stageslist = removetable(stageslist, world3list)
  141. end
  142.  
  143. if World4 == false then
  144.     stageslist = removetable(stageslist, world4list)
  145. end
  146.  
  147. if World5 == false then
  148.     stageslist = removetable(stageslist, world5list)
  149. end
  150.  
  151. if World6 == false then
  152.     stageslist = removetable(stageslist, world6list)
  153. end
  154.  
  155. if Fortresses == false or NormalFortressOrder == true then
  156.     stageslist = removetable(stageslist, fortresslist)
  157. end
  158.  
  159. if Castles == false or NormalCastleOrder == true then
  160.     stageslist = removetable(stageslist, castlelist)
  161. end
  162.  
  163. stageslist = removetable(stageslist, ExcludeStages)
  164. --
  165. if RandomSeed ~= nil then
  166.     math.randomseed(RandomSeed)
  167. end
  168. --
  169. ------------------------------------------------
  170. --------------------GAMEMODES-------------------
  171. ------------------------------------------------
  172. ------------------------------------------------
  173. if Level_Blitz == true then
  174.     function LevelBlitz()
  175.         levelamount = #stageslist
  176.         stage = memory.readbyte(0x7E021A)
  177.         stagenumber = memory.readbyte(0x7E1112)   --//or memory.readbyte(0x7E112E)
  178.         worldnumber= memory.readbyte(0x7E0218)
  179.         overworld = memory.readbyte(0x7E0009)
  180.         entering_stage = memory.readbyte(0x7E111D)
  181.         titlescreen = memory.readbyte(0x7E011C)
  182.         --
  183.         if entering_stage == 1 and enteredstage == 0 and titlescreen == 12 then
  184.             laststage = stagenumber
  185.             lastworld = worldnumber
  186.             if NormalFortressOrder == true and table.contains(fortresslist, laststage+lastworld*6) == true then
  187.                 randstage = fortresslist[math.random(1,#fortresslist)]
  188.             elseif NormalCastleOrder == true and table.contains(castlelist, laststage+lastworld*6) == true then
  189.                 randstage = castlelist[math.random(1,#castlelist)]
  190.             else
  191.                 randstage = stageslist[math.random(1,levelamount)]
  192.             end
  193.             memory.writebyte(0x7E021A,randstage )
  194.             stagecompleted = stage + 1
  195.             enteredstage = 1
  196.             instage = 1
  197.             print("Randomizes", randstage, " ", levelamount)
  198.         elseif overworld == 126 then
  199.             if SameStage == false and instage == 1 then
  200.                 table.insert(levelsplayed, stage)
  201.                 if NormalFortressOrder == true and table.contains(fortresslist, laststage+lastworld*6) == true then
  202.                     fortresslist = removetable(fortresslist, levelsplayed)
  203.                 elseif NormalCastleOrder == true and table.contains(castlelist, laststage+lastworld*6) == true then
  204.                     castlelist = removetable(castlelist, levelsplayed)
  205.                 else
  206.                     stageslist = removetable(stageslist, levelsplayed)
  207.                 end
  208.                 print(levelsplayed)
  209.                 print(stageslist)
  210.                 instage = 0
  211.                 levelsplayed = {}
  212.                 print("Removing Stage")
  213.             end
  214.             memory.writebyte(0x7E021A, laststage+lastworld*6)
  215.             memory.writebyte(0x7E0218, lastworld) -- This is not needed? Kept just in case
  216.         elseif overworld == 64 and entering_stage ~= 1 then
  217.             enteredstage = 0
  218.         end
  219.     end
  220.     print("Blitz Mode is ON")
  221. else
  222.     function LevelBlitz()
  223.     end
  224.     print("Blitz Mode is OFF")
  225. end
  226. -----------------------------------------------
  227. ------------------------------------------------
  228. if NoLeftMode == true then
  229.     function noleft()
  230.         speed = memory.readwordsigned(0x7000B4)
  231.         if speed < 0 and memory.readbyte(0x7000AC) == 0 then
  232.             memory.writeword(0x7000B4,0)
  233.         end
  234.     end
  235.     print("NoLeftMode is ON")
  236. else
  237.     function noleft()
  238.     end
  239.     print("NoLeftMode is OFF")
  240. end
  241. -------------------------------------------------
  242. -------------------------------------------------
  243. if DrunkMode == true then
  244.     function drunk()
  245.         if memory.readbyte(0x7E0118) == 16 or memory.readbyte(0x7E0118) == 57 then
  246.             memory.writeword(0x701FE8, 0)
  247.         else
  248.             memory.writeword(0x701FE8, 10)
  249.         end
  250.     end
  251.     print("Drunk Mode is ON")
  252. else
  253.     function drunk()
  254.     end
  255.     print("Drunk Mode is OFF")
  256. end
  257. -------------------------------------------------
  258. -------------------------------------------------
  259. if HardMode == true then
  260.     timerreset = 1
  261.     function hardmode()
  262.         gamemode = memory.readbyte(0x7E0118)
  263.         hit = memory.readbyte(0x701960)
  264.         if hit == 85 and timerreset == 0 and gamemode == 15 then
  265.             memory.writeword(0x7E03B6, 1)
  266.             timerreset = 1
  267.         elseif hit ~= 85 and timerreset == 1 then
  268.             timerreset = 0
  269.             memory.writeword(0x7E03B6, 100)
  270.         end
  271.     end
  272.     print("Hard Mode is ON")
  273. else
  274.     function hardmode()
  275.     end
  276.     print("Hard Mode is OFF")
  277. end
  278. -------------------------------------------------
  279. -------------------------------------------------
  280. if ForceRetry == true then
  281.     function forceretry()
  282.         memory.writebyte(0x704094, 0)
  283.         memory.writebyte(0x7E0379, 1)
  284.     end
  285.     print("Force Retry Mode is ON")
  286. else
  287.     function forceretry()
  288.     end
  289.     print("Force Retry Mode is OFF")
  290. end
  291. -------------------------------------------------
  292. -------------------------------------------------
  293. if DeathTimer == true then
  294.     function deathtimer()
  295.         startimer = memory.readword(0x7E03B6)
  296.         gamemode = memory.readbyte(0x7E0118)
  297.         if gamemode ~= 15 then
  298.             die = 1
  299.         end
  300.         if startimer == 0 and die == 1 and gamemode == 15 then
  301.             memory.writebyte(0x7000AC, 40)
  302.             memory.writebyte(0x7001B0, 40)
  303.             memory.writebyte(0x7001D2, 34)
  304.             memory.writebyte(0x002140, 07)
  305.             die = 0
  306.         end
  307.     end
  308.     print("Death Timer Mode is ON")
  309. else
  310.     function deathtimer()
  311.     end
  312.     print("Death Timer Mode is OFF")
  313. end
  314. -------------------------------------------------
  315. -------------------------------------------------
  316. if AlwaysExtendedFlutter == true then
  317.     function extendedflutter()
  318.         mario = memory.readbyte(0x7E0205)
  319.         if mario == 1 then
  320.             memory.writebyte(0x7000D3, 128)
  321.         end
  322.     end
  323.     print("Always Extended Flutter is ON")
  324. else
  325.     function extendedflutter()
  326.     end
  327.     print("Always Extended Flutter is OFF")
  328. end
  329. -------------------------------------------------
  330. -------------------------------------------------
  331. if NoTongue == true then
  332.     function notongue()
  333.         memory.writebyte(0x700162, 126)
  334.     end
  335.     print("No Tongue Mode is ON")
  336. else
  337.     function notongue()
  338.     end
  339.     print("No Tongue Mode is OFF")
  340. end
  341. -------------------------------------------------
  342. -------------------------------------------------
  343. if NoFlutter == true then
  344.     function noflutter()
  345.         memory.writebyte(0x7000D2, 0)
  346.     end
  347.     print("No Flutter Mode is ON")
  348. else
  349.     function noflutter()
  350.     end
  351.     print("No Flutter Mode is OFF")
  352. end
  353. -------------------------------------------------
  354. ------------------------------------------------- -- Boss cutscenes are very slow, fix if people think it's a problem.
  355. if Velcro == true then
  356.     function velcromode()
  357.         if memory.readbyte(0x7000C0) == 0 and memory.readbyte(0x7E0118) == 15 and math.abs(memory.readwordsigned(0x7000B4)) > 20 then
  358.             memory.writeword(0x7000B4,0)
  359.         end
  360.     end
  361.     print("Velcro Mode is ON")
  362. else
  363.     function velcromode()
  364.     end
  365.     print("Velcro Mode is OFF")
  366. end
  367. -------------------------------------------------
  368. -------------------------------------------------
  369. if AlwaysFilledMouth == false then
  370.     function mouthmode()
  371.     end
  372.     print("Always Filled Mouth is OFF")
  373. else
  374.     if AlwaysFilledMouth == melon or AlwaysFilledMouth == melons or AlwaysFilledMouth == seeds or AlwaysFilledMouth == melonseeds or AlwaysFilledMouth == melonseed then
  375.         mouth_var = 3
  376.     end
  377.     if AlwaysFilledMouth == bubble or AlwaysFilledMouth == bubbles then
  378.         mouth_var = 2
  379.     end
  380.     function mouthmode()
  381.     memory.writebyte(0x700162, 89)
  382.     memory.writebyte(0x70016A, AlwaysFilledMouth)
  383.     memory.writebyte(0x700170, 30)
  384.     end
  385.     print("Always Filled Mouth is ON")
  386. end
  387. -------------------------------------------------
  388. -------------------------------------------------
  389. if FullEggsStart == true then
  390.     function eggstransitions()
  391.         gamemode = memory.readbyte(0x7E0118)
  392.         if gamemode == 12 then
  393.             eggcount = memory.readbyte(0x7E5D98)
  394.             for i = 0, eggcount, 2 do
  395.                 memory.writebyte(0x7E5D9A + i, memory.readbyte(0x7E5D9A + i))
  396.             end
  397.             for i = eggcount, NumberOfEggs, 2 do
  398.                 memory.writebyte(0x7E5D9A+i, EggType)
  399.             end
  400.             if eggcount > NumberOfEggs then
  401.                 memory.writebyte(0x7E5D98, eggcount)
  402.             else
  403.                 memory.writebyte(0x7E5D98, NumberOfEggs)
  404.             end
  405.         end
  406.     end
  407.     print("Always Start With Full Eggs  is ON -", NumberOfEggs/2, "eggs")
  408. else
  409.     function eggstransitions()
  410.     end
  411.     print("Always Start With Full Eggs is OFF")
  412. end
  413. -------------------------------------------------
  414. -------------------------------------------------
  415. if FastMode == true then
  416.     speedmodifier = 1000 - SpeedBoost*100
  417.     function fastmode()
  418.         if memory.readbyte(0x7E0118) == 15 and memory.readbyte(0x7E0387) == 0 then
  419.             speed = memory.readwordsigned(0x7000B4)
  420.             xposition = memory.readwordsigned(0x70008c)
  421.             memory.writeword(0x70008c, xposition + speed/speedmodifier)
  422.         end
  423.     end
  424.     print("Fast Mode is ON - Speed:",SpeedBoost)
  425. else
  426.     function fastmode()
  427.     end
  428.     print("Fast Mode is OFF")
  429. end
  430. -------------------------------------------------
  431. -------------------------------------------------
  432. ------------------MAIN---------------------------
  433. while true do
  434. --
  435.     LevelBlitz()
  436.     noleft()
  437.     drunk()
  438.     hardmode()
  439.     deathtimer()
  440.     forceretry()
  441.     extendedflutter()
  442.     notongue()
  443.     noflutter()
  444.     velcromode()
  445.     mouthmode()
  446.     eggstransitions()
  447.     fastmode()
  448. --
  449.     emu.frameadvance()
  450. end
  451. -- END MAIN --
  452.  
  453. -- Yes I'm a bad programmer, I never really done anything before so I improvise and try to learn.
  454. -- Made by Arnethegreat - message me on #speedrunslive if you want anything
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement