Advertisement
Arnethegreat

Meow

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