View difference between Paste ID: fZgwqZAt and qCGDbZZZ
SHOW: | | - or go back to the newest paste.
1-
-- Version 0.33b
1+
-- Version 0.33a
2
-- OPTIONS -- OPTIONS -- OPTIONS -- Change to true or false
3
4-
Level_Blitz = false
4+
Level_Blitz = true
5
NoLeftMode = false
6-
DisableButton = "none"
6+
7
HardMode = false
8
ForceRetry = false
9
InfiniteLives = true
10-
InfiniteLives = false
10+
DeathTimer = false  -- When the star meter hits 0, you die. Combine with Hard Mode for Insane Mode (1-hit death)
11-
DeathTimer = true  -- When the star meter hits 0, you die. Combine with Hard Mode for Insane Mode (1-hit death)
11+
12
NoFlutter = false
13
NoTongue = false
14
Velcro = false
15
AlwaysFilledMouth = false -- Enter 2 for bubbles and 3 for melons. Enter false to disable
16
FullEggsStart = false
17-
FullEggsStart = true
17+
18
EggType = 43-- What eggs to start with (34 = flashing egg - 35 = red - 36 = yellow - 37 = green - 39 = key - 40 = chicken - 43 = big egg
19-
EggType = 37-- What eggs to start with (34 = flashing egg - 35 = red - 36 = yellow - 37 = green - 39 = key - 40 = chicken - 43 = big egg
19+
20
FastModeY = false
21
SpeedBoostX = 0 -- For fast mode, enter (-9) to 9 (higher is faster)
22-
SpeedBoostX = 5 -- For fast mode, enter (-9) to 9 (higher is faster)
22+
SpeedBoostY = 0
23-
SpeedBoostY = 8
23+
PoisonCoins = 0 -- Put 0 to disable. 10 = 1 star per coin. Negative values give stars.
24-
PoisonCoins = -10 -- Put 0 to disable. 10 = 1 star per coin. Negative values give stars.
24+
PoisonFlowers = 0
25-
PoisonFlowers = -50
25+
GroundIsLava = 0 -- Put 0 to disable. 20 = about 1 star per second
26-
GroundIsLava = 80 -- Put 0 to disable. 20 = about 1 star per second
26+
27
PoisonAir = 0 -- Just as GroundIsLava but in air instead.
28
PackMuleMode = false -- Only works when combined with Fast Mode
29
StarMeterSpeedMode = false -- poop, don't use yet. (it's poop)
30
31
-- Level Blitz Options -- Level Blitz Options --
32
33
AutoScrollers = false
34
ExtraStages = false
35
ExcludeStages = {68, 72}  -- seperate by a comma, write stages like 54 as 5-4
36-
ExcludeStages = {68, 72, 54}  -- seperate by a comma, write stages like 54 as 5-4
36+
37
NormalFortressOrder = false
38-
NormalFortressOrder = true
38+
NormalCastleOrder = false
39-
NormalCastleOrder = true
39+
RandomSeed = 4033
40-
RandomSeed = 18467
40+
41
Fortresses = true
42
Castles = true
43
World1 = true
44
World2 = true
45
World3 = true
46
World4 = true
47
World5 = true
48
World6 = true
49
50
-- Level Goals Options -- Level Goals Options --
51
52
CoinGoals = false		-- set true if you wan't to use it
53
MinimumCoins = true		-- set true if you want a minimum goal
54
MaximumCoins = false	-- set true if you wanta a maximum goal
55
MinCoinGoal = 25		-- set what minimum goal must be met
56-
MinCoinGoal = 200		-- set what minimum goal must be met
56+
57
DisplayCoin = true		-- whether to display on screen or not
58
59
StarGoals = false
60
MinimumStars = false
61
MaximumStars = true
62
MinStarGoal = 0
63
MaxStarGoal = 25
64
DisplayStar = true
65
66
FlowerGoals = false
67
MinimumFlowers = true
68
MaximumFlowers = true
69
MinFlowerGoal = 3
70
MaxFlowerGoal = 3
71
DisplayFlower = true
72
73
RedCoinGoals = false
74
MinimumRedCoins = true
75
MaximumRedCoins = false
76
MinRedCoinGoal = 4
77
MaxRedCoinGoal = 0
78
DisplayRed = true
79
80
JumpGoals = false
81
MinimumJumps = false
82
MaximumJumps = true
83
MinJumpGoal = 0
84
MaxJumpGoal = 100
85
DisplayJump = true
86
87
Egg_Goals = false
88
MinimumEggs = false
89-
MinimumEggs = true
89+
MaximumEggs = true
90-
MaximumEggs = false
90+
MinEggGoal = 5
91-
MinEggGoal = 25
91+
92
DisplayEggs = true
93
94
Fuzzy_Goals = false
95
MinimumFuzzies = false
96
MaximumFuzzies = true
97
MinFuzzyGoal = 5
98
MaxFuzzyGoal = 5
99
DisplayFuzzy = true
100
101
Lives_Goals = false
102
MinimumLives = true
103
MaximumLives = true
104
MinLivesGoal = 5
105
MaxLivesGoal = 5
106
DisplayLives = true
107
108
gui.opacity(0.8) -- set opacity for text displayed
109
110
-- OPTIONS End -- OPTIONS End -- OPTIONS End --
111
112
-- !Instructions! Instructions! Instructions! Instructions!
113
-- 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=
114
-- 2. Recommended ROM is (U) (1.0) (!) but others should work but they are untested
115
-- 3. Change options above and replace with true or false, RandomSeed is a number though, if it's a word, it's just random
116
-- 4. In Snes9x, load ROM then go File -> Lua Scripting -> New Lua Script Window... -> Load file -> Press Run
117
-- 5. You know you have loaded it right when the Lua Script window outputs what modes are on and what are false
118
-- 6. If you have changed the options, you have to restart the script for it to take effect
119
-- Newest version is always found at http://pastebin.com/qCGDbZZZ
120
------------------------------------------------
121
------------------------------------------------
122
------------------------------------------------
123
----------------Script starts here--------------
124
------------------------------------------------
125
------------------------------------------------
126
------------------------------------------------
127
------------------------------------------------
128
------------------------------------------------
129
function table.contains(table, element)
130
  for i, value in pairs(table) do
131
    if value == element then
132
      valpos = i
133
      return true
134
    end
135
  end
136
  return false
137
end
138
139
function deepcopy(t)
140
	if type(t) ~= 'table' then return t end
141
	local mt = getmetatable(t)
142
	local res = {}
143
	for k,v in pairs(t) do
144
		if type(v) == 'table' then
145
			v = deepcopy(v)
146
		end
147
		res[k] = v
148
	end
149
	setmetatable(res,mt)
150
	return res
151
end
152
153
function removetable(tab,tab2)
154
	table.sort(tab)
155
	table.sort(tab2)
156
	rem = 0
157
	tabcopy = deepcopy(tab)
158
		for cy, value in ipairs(tab) do
159
			  for cx, value2 in ipairs (tab2) do
160
				if value == value2 then
161
					table.remove(tabcopy,cy - rem)
162
					rem = rem + 1
163
				end
164
			  end
165
		end
166
	return tabcopy
167
end
168
169
function convertstages(tablelist)
170
	for i, stg in pairs(tablelist) do
171
		worldnumber = math.floor(stg/10)
172
		levelnumber = stg - worldnumber*10
173
		realstagevalue = (worldnumber - 1)*12 + levelnumber - 1
174
		tablelist[i] = realstagevalue
175
	end
176
end
177
------------------------------------------------
178
------------------------------------------------
179
------------------------------------------------
180
print("Version 0.33a")
181-
print("Version 0.33b")
181+
182
gpsn_value = 0
183
apsn_value = 0
184
psn_value = 0
185
eggcount = 0
186
keycount = 0
187
mouth_var = 0
188
packmulemodifier = 1
189
laststage = 0
190
lastworld = 0
191
scrollerslist = {4, 53, 64} -- This can be changed to include or exclude other stages depending on how you define an autoscroller
192
extralist = {8, 20, 32, 44, 56, 68}
193
castlelist = {7, 19, 31, 43, 55}
194
fortresslist = {3, 15, 27, 39, 51, 63}
195
world1list = {0, 1, 2, 3, 4, 5, 6, 7, 8 }
196
world2list = {12, 13, 14, 15, 16, 17, 18, 19, 20}
197
world3list = {24, 25, 26, 27, 28 ,29, 30, 31, 32}
198
world4list = {36, 37, 38, 39, 40, 41, 42, 43, 44}
199
world5list = {48, 49, 50, 51, 52, 53, 54, 55, 56}
200
world6list = {60, 61, 62, 63, 64, 65, 66, 68}
201
stageslist =
202
{0, 1, 2, 3, 4, 5, 6, 7, 8,
203
12, 13, 14, 15, 16, 17, 18, 19, 20,
204
24, 25, 26, 27, 28 ,29, 30, 31, 32,
205
36, 37, 38, 39, 40, 41, 42, 43, 44,
206
48, 49, 50, 51, 52, 53, 54, 55, 56,
207
60, 61, 62, 63, 64, 65, 66, 68}
208
-- Remove stages according to options
209
if AutoScrollers == false then
210
	stageslist = removetable(stageslist, scrollerslist)
211
end
212
213
if ExtraStages == false then
214
	stageslist = removetable(stageslist, extralist)
215
end
216
217
if World1 == false then
218
	stageslist = removetable(stageslist, world1list)
219
end
220
221
if World2 == false then
222
	stageslist = removetable(stageslist, world2list)
223
end
224
225
if World3 == false then
226
	stageslist = removetable(stageslist, world3list)
227
end
228
229
if World4 == false then
230
	stageslist = removetable(stageslist, world4list)
231
end
232
233
if World5 == false then
234
	stageslist = removetable(stageslist, world5list)
235
end
236
237
if World6 == false then
238
	stageslist = removetable(stageslist, world6list)
239
end
240
241
if Fortresses == false or NormalFortressOrder == true then
242
	stageslist = removetable(stageslist, fortresslist)
243
end
244
245
if Castles == false or NormalCastleOrder == true then
246
	stageslist = removetable(stageslist, castlelist)
247
end
248
249
convertstages(ExcludeStages)
250
stageslist = removetable(stageslist, ExcludeStages)
251
castlelist = removetable(castlelist, ExcludeStages)
252
fortresslist = removetable(fortresslist, ExcludeStages)
253
--
254
if RandomSeed ~= nil then
255
	math.randomseed(RandomSeed)
256
end
257
--
258
------------------------------------------------
259
--------------------GAMEMODES-------------------
260
------------------------------------------------
261
------------------------------------------------
262
if Level_Blitz == true then
263
	gen_levelblitz = {}
264
	numberofstages = #stageslist
265
	if Castles == true then
266
		numberofstages = numberofstages + #castlelist
267
	end
268
	if Fortresses == true then
269
		numberofstages = numberofstages + #fortresslist
270
	end
271
	instage = 0
272
	xlbgen = 1
273
274
	if SameStage == false then
275
		function SameStage(remstagelist)
276
			table.remove(remstagelist,gen_stgnr)
277
		end
278
	else
279
		function SameStage()
280
		end
281
	end
282
	if #CustomLevelOrder == 0 then
283
		while xlbgen <= numberofstages do
284
			if xlbgen%8 == 0 and #castlelist > 0 and NormalCastleOrder == true then
285
				gen_stgnr = math.random(#castlelist)
286
				gen_stage = castlelist[gen_stgnr]
287
				table.insert(gen_levelblitz,gen_stage)
288
				SameStage(castlelist)
289
			elseif xlbgen%4 == 0 and xlbgen%8 ~= 0 and #fortresslist > 0 and NormalFortressOrder == true then
290
				gen_stgnr = math.random(#fortresslist)
291
				gen_stage = fortresslist[gen_stgnr]
292
				table.insert(gen_levelblitz,gen_stage)
293
				SameStage(fortresslist)
294
			elseif #stageslist > 0 then
295
				gen_stgnr = math.random(#stageslist)
296
				gen_stage = stageslist[gen_stgnr]
297
				table.insert(gen_levelblitz,gen_stage)
298
				SameStage(stageslist)
299
			end
300
			xlbgen = xlbgen + 1
301
		end
302
	else
303
		convertstages(CustomLevelOrder)
304
		gen_levelblitz = CustomLevelOrder
305
		numberofstages = #gen_levelblitz
306
	end
307
308
	function LevelBlitz()
309
		stagenumber = memory.readbyte(0x7E1112)   --//or memory.readbyte(0x7E112E)
310
		worldnumber= memory.readbyte(0x7E0218)
311
		entering_stage = memory.readbyte(0x7E111D)
312
		overworld = memory.readbyte(0x7E0009)
313
		titlescreen = memory.readbyte(0x7E011C)
314
		if stagenumber < 8 and instage == 0 and entering_stage == 1 and titlescreen == 12 then
315
			laststage = stagenumber
316
			lastworld = worldnumber
317
			corresponding_stage = (worldnumber/2)*8 + stagenumber+1
318
			if corresponding_stage <= numberofstages then
319
				memory.writebyte(0x7E021A,gen_levelblitz[corresponding_stage])
320
			end
321
			instage = 1
322
		elseif overworld == 126 then
323
			memory.writebyte(0x7E021A, laststage+lastworld*6)
324
			memory.writebyte(0x7E0218, lastworld) -- This is not needed? Kept just in case
325
		elseif entering_stage ~= 1 then
326
			instage = 0
327
		end
328
	end
329
	print("Blitz Mode is ON")
330
else
331
	function LevelBlitz()
332
	end
333
	print("Blitz Mode is OFF")
334
end
335
-----------------------------------------------
336
------------------------------------------------
337
if NoLeftMode == true then
338
	function noleft()
339
		speed = memory.readwordsigned(0x7000B4)
340
		if speed < 0 and memory.readbyte(0x7000AC) == 0 then
341
			memory.writeword(0x7000B4,0)
342
		end
343
	end
344
	print("NoLeftMode is ON")
345
else
346
	function noleft()
347
	end
348
	print("NoLeftMode is OFF")
349
end
350
-------------------------------------------------
351
-------------------------------------------------
352
if DrunkMode == true then
353
	function drunk()
354
		if memory.readbyte(0x7E0118) == 16 or memory.readbyte(0x7E0118) == 57 then
355
			memory.writeword(0x701FE8, 0)
356
		else
357
			memory.writeword(0x701FE8, 10)
358
		end
359
	end
360
	print("Drunk Mode is ON")
361
else
362
	function drunk()
363
	end
364
	print("Drunk Mode is OFF")
365
end
366
-------------------------------------------------
367
-------------------------------------------------
368
if HardMode == true then
369
	timerreset = 1
370
	function hardmode()
371
		gamemode = memory.readbyte(0x7E0118)
372
		hit = memory.readbyte(0x701960)
373
		if hit == 85 and timerreset == 0 and gamemode == 15 then
374
			memory.writeword(0x7E03B6, 1)
375
			timerreset = 1
376
		elseif hit ~= 85 and timerreset == 1 then
377
			timerreset = 0
378
			memory.writeword(0x7E03B6, 100)
379
		end
380
	end
381
	print("Hard Mode is ON")
382
else
383
	function hardmode()
384
	end
385
	print("Hard Mode is OFF")
386
end
387
-------------------------------------------------
388
-------------------------------------------------
389
if ForceRetry == true then
390
	function forceretry()
391
		if memory.readbyte(0x7E0118) == 61 or memory.readbyte(0x7E0118) == 53 then
392
			memory.writebyte(0x704094, 0)
393
		end
394
	end
395
	print("Force Retry Mode is ON")
396
else
397
	function forceretry()
398
	end
399
	print("Force Retry Mode is OFF")
400
end
401
-------------------------------------------------
402
-------------------------------------------------
403
if InfiniteLives == true then
404
	function infinitelives()
405
		memory.writebyte(0x7E0379, 10)
406
	end
407
	print("Infinite Lives is ON")
408
else
409
	function infinitelives()
410
	end
411
	print("Infinite Lives is OFF")
412
end
413
-------------------------------------------------
414
-------------------------------------------------
415
-------------------------------------------------
416
-------------------------------------------------
417
function firedeath()
418
	memory.writebyte(0x7000AC, 40)
419
	memory.writebyte(0x7001B0, 40)
420
	memory.writebyte(0x7001D2, 34)
421
	memory.writebyte(0x002140, 07)
422
	yoshiisdead = false
423
	die = 0
424
end
425
if DeathTimer == true then
426
	yoshiisdead = false
427
	function deathtimer()
428
		startimer = memory.readword(0x7E03B6)
429
		gamemode = memory.readbyte(0x7E0118)
430
		if gamemode ~= 15 then
431
			die = 1
432
		end
433
		if startimer <= 1  and die == 1 and gamemode == 15 then
434
			yoshiisdead = true
435
		end
436
		if memory.readbyte(0x7001AE) == 0 and memory.readbyte(0x7000AC) == 0 and yoshiisdead == true then
437
			firedeath()
438
		end
439
	end
440
	print("Death Timer Mode is ON")
441
else
442
	function deathtimer()
443
	end
444
	print("Death Timer Mode is OFF")
445
end
446
-------------------------------------------------
447
-------------------------------------------------
448
if AlwaysExtendedFlutter == true then
449
	function extendedflutter()
450
		mario = memory.readbyte(0x7E0205)
451
		if mario == 1 then
452
			memory.writebyte(0x7000D3, 128)
453
		end
454
	end
455
	print("Always Extended Flutter is ON")
456
else
457
	function extendedflutter()
458
	end
459
	print("Always Extended Flutter is OFF")
460
end
461
-------------------------------------------------
462
-------------------------------------------------
463
if NoTongue == true then
464
	function notongue()
465
		memory.writebyte(0x700162, 126)
466
	end
467
	print("No Tongue Mode is ON")
468
else
469
	function notongue()
470
	end
471
	print("No Tongue Mode is OFF")
472
end
473
-------------------------------------------------
474
-------------------------------------------------
475
if NoFlutter == true then
476
	function noflutter()
477
		memory.writebyte(0x7000D2, 0)
478
	end
479
	print("No Flutter Mode is ON")
480
else
481
	function noflutter()
482
	end
483
	print("No Flutter Mode is OFF")
484
end
485
-------------------------------------------------
486
------------------------------------------------- -- Boss cutscenes are very slow, fix if people think it's a problem.
487
if Velcro == true then
488
	function velcromode()
489
		if memory.readbyte(0x7000C0) == 0 and memory.readbyte(0x7E0118) == 15 and math.abs(memory.readwordsigned(0x7000B4)) > 20 then
490
			memory.writeword(0x7000B4,0)
491
		end
492
	end
493
	print("Velcro Mode is ON")
494
else
495
	function velcromode()
496
	end
497
	print("Velcro Mode is OFF")
498
end
499
-------------------------------------------------
500
-------------------------------------------------
501
if AlwaysFilledMouth == false then
502
	function mouthmode()
503
	end
504
	print("Always Filled Mouth is OFF")
505
else
506
	if AlwaysFilledMouth == melon or AlwaysFilledMouth == melons or AlwaysFilledMouth == seeds or AlwaysFilledMouth == melonseeds or AlwaysFilledMouth == melonseed then
507
		mouth_var = 3
508
	end
509
	if AlwaysFilledMouth == bubble or AlwaysFilledMouth == bubbles then
510
		mouth_var = 2
511
	end
512
	function mouthmode()
513
	memory.writebyte(0x700162, 89)
514
	memory.writebyte(0x70016A, AlwaysFilledMouth)
515
	memory.writebyte(0x700170, 30)
516
	end
517
	print("Always Filled Mouth is ON")
518
end
519
-------------------------------------------------
520
-------------------------------------------------
521
if FullEggsStart == true then
522
	function eggstransitions()
523
		gamemode = memory.readbyte(0x7E0118)
524
		if gamemode == 12 then
525
			eggcount = memory.readbyte(0x7E5D98)
526
			for i = 0, eggcount, 2 do
527
				memory.writebyte(0x7E5D9A + i, memory.readbyte(0x7E5D9A + i))
528
			end
529
			for i = eggcount, NumberOfEggs, 2 do
530
				memory.writebyte(0x7E5D9A+i, EggType)
531
			end
532
			if eggcount > NumberOfEggs then
533
				memory.writebyte(0x7E5D98, eggcount)
534
			else
535
				memory.writebyte(0x7E5D98, NumberOfEggs)
536
			end
537
		end
538
	end
539
	print("Always Start With Full Eggs  is ON -", NumberOfEggs/2, "eggs")
540
else
541
	function eggstransitions()
542
	end
543
	print("Always Start With Full Eggs is OFF")
544
end
545
-------------------------------------------------
546
-------------------------------------------------
547
xposoffset = 0
548
if FastModeX == true then
549
	speedmodifierx = (SpeedBoostX/10)
550-
	speedmodifierx = 1000 - SpeedBoostX*100
550+
551
		if memory.readbyte(0x7E0118) == 15 and memory.readbyte(0x7E0387) == 0 then
552
			xspeed = memory.readwordsigned(0x7000B4)
553
			xposition = memory.readwordsigned(0x70008c)
554
			speed_modifier = (speedmodifierx + packmulemodifier/1)*xspeed/256
555-
			xposoffset = xspeed/speedmodifierx
555+
			xposoffset = xspeed/256 + speed_modifier
556
			gui.text(10,20, xposoffset)
557
			memory.writeword(0x70008c, xposition + xposoffset)
558
		end
559
	end
560
	print("Fast Mode is ON - Speed:",SpeedBoostX)
561
else
562
	function fastmodex()
563
	end
564
	print("Fast Mode is OFF")
565
end
566
-------------------------------------------------
567
-------------------------------------------------
568
if FastModeY == true then
569
	speedmodifiery = 1000 - SpeedBoostY*100
570
	function fastmodey()
571
		if memory.readbyte(0x7E0118) == 15 and memory.readbyte(0x7E0387) == 0 then
572
			yspeed = memory.readwordsigned(0x7000AA)
573
			yposition = memory.readwordsigned(0x700090)
574
			memory.writeword(0x700090, yposition + yspeed/speedmodifiery)
575
		end
576
	end
577
	print("Fast Mode is ON - Speed:",SpeedBoostY)
578
else
579
	function fastmodey()
580
	end
581
	print("Fast Mode is OFF")
582
end
583
-------------------------------------------------
584
-------------------------------------------------
585
if PoisonCoins ~= 0 then
586
	lastframecoins = memory.readbyte(0x7E037B)
587
	function poisoncoins()
588
		starcounter = memory.readword(0x7E03B6)
589
		if memory.readbyte(0x7E037B) > lastframecoins  then
590
			if starcounter > PoisonCoins then
591
				memory.writeword(0x7E03B6,  starcounter - PoisonCoins)
592
			else
593
				memory.writeword(0x7E03B6,  0)
594
			end
595
		end
596
		lastframecoins = memory.readbyte(0x7E037B)
597
	end
598
	print("Poison Coins Mode is ON")
599
else
600
	function poisoncoins()
601
	end
602
	print("Poison Coins Mode is OFF")
603
end
604
-------------------------------------------------
605
-------------------------------------------------
606
if PoisonFlowers ~= 0 then
607
	lastframeflowers = memory.readbyte(0x7E03B8)
608
	function poisonflowers()
609
		starcounter = memory.readword(0x7E03B6)
610
		if memory.readbyte(0x7E03B8) > lastframeflowers  then
611
			if starcounter > PoisonFlowers then
612
				memory.writeword(0x7E03B6,  starcounter - PoisonFlowers)
613
			else
614
				memory.writeword(0x7E03B6,  0)
615
			end
616
		end
617
		lastframeflowers = memory.readbyte(0x7E03B8)
618
	end
619
	print("Poison Flowers Mode is ON")
620
else
621
	function poisonflowers()
622
	end
623
	print("Poison Flowers Mode is OFF")
624
end
625
-------------------------------------------------
626
-------------------------------------------------
627
if GroundIsLava ~= 0 then
628
	GroundIsLava = GroundIsLava + 9
629
	function groundislava()
630
		starcounter = memory.readword(0x7E03B6)
631
		if memory.readbyte(0x7000C0) == 0 and memory.readbyte(0x7001AE) == 0 and memory.readbyte(0x7000AC) == 0 then
632
			if starcounter > 0 then
633
				if gpsn_value >= 1 or gpsn_value <= -1 then
634
					memory.writeword(0x7E03B6,  starcounter - gpsn_value)
635
					gpsn_value = 0
636
			    end
637
			gpsn_value = gpsn_value + 0.01*GroundIsLava
638
			else
639
				memory.writeword(0x7E03B6,  0)
640
			end
641
		end
642
	end
643
	print("Ground is Lava Mode is ON")
644
else
645
	function groundislava()
646
	end
647
	print("Ground is Lava is OFF")
648
end
649
-------------------------------------------------
650
-------------------------------------------------
651
if PoisonAir ~= 0 then
652
	PoisonAir = PoisonAir + 9
653
	function poisonair()
654
		starcounter = memory.readword(0x7E03B6)
655
		if memory.readbyte(0x7000C0) ~= 0 and memory.readbyte(0x7001AE) == 0 and memory.readbyte(0x7000AC) == 0 then
656
			if starcounter > 0 then
657
				if apsn_value >= 1 or apsn_value <= -1 then
658
					memory.writeword(0x7E03B6,  starcounter - apsn_value)
659
					apsn_value = 0
660
			    end
661
			apsn_value = apsn_value + 0.01*PoisonAir
662
			else
663
				memory.writeword(0x7E03B6,  0)
664
			end
665
		end
666
	end
667
	print("Poison Air Mode is ON")
668
else
669
	function poisonair()
670
	end
671
	print("Poison Air is OFF")
672
end
673
-------------------------------------------------
674
-------------------------------------------------
675
if TerminalMode ~= 0 then
676
	TerminalMode = TerminalMode + 9
677
	function terminalmode()
678
		starcounter = memory.readword(0x7E03B6)
679
		if memory.readbyte(0x7001AE) == 0 and memory.readbyte(0x7000AC) == 0 then
680
			if starcounter > 0 then
681
				if psn_value >= 1 or psn_value <= -1 then
682
					memory.writeword(0x7E03B6,  starcounter - psn_value)
683
					psn_value = 0
684
				end
685
				psn_value = psn_value + 0.01*TerminalMode
686
			else
687
				memory.writeword(0x7E03B6,  0)
688
			end
689
		end
690
	end
691
	print("Terminal Mode is ON")
692
else
693
	function terminalmode()
694
	end
695
	print("Terminal Mode is OFF")
696
end
697
-------------------------------------------------
698
-------------------------------------------------
699
if PackMuleMode == true then
700
	function packmule()
701
		packmulemodifier = (-1)*memory.readbyte(0x701DF6)/2
702
	end
703
	print("Pack Mule Mode is ON")
704
else
705
	packmulemodifier = 0
706
	function packmule()
707
	end
708
	print("Pack Mule Mode is OFF")
709
end
710
-------------------------------------------------
711
-------------------------------------------------
712
if StarMeterSpeedMode == true then
713
	starmetermodifier = 1
714
	function starmeterspeed()
715
		starmetermodifier = (memory.readword(0x7E03B6)*-1)
716
	end
717
	print("Star Meter Speed Mode is ON")
718
else
719
	starmetermodifier = 0
720
	function starmeterspeed()
721
	end
722
	print("Star Meter Speed Mode is OFF")
723
end
724
-------------------------------------------------
725-
if joypad.get(1)[DisableButton] ~= nil then
725+
726-
	function DisableButtonFunction(button)
726+
727-
		buttons_pressed = joypad.get(1)
727+
728-
		buttons_pressed[button] = false
728+
729-
		joypad.set(1, buttons_pressed)
729+
730
---------------------------------------------------
731-
	print("Disable Button Mode is ON ", DisableButton)
731+
732
function display_goals_gen(goalstring ,x_collect, mingoal, maxgoal, mingoalboolean, maxgoalboolean, y_offset)
733-
	function DisableButtonFunction(button)
733+
734
		if x_collect < mingoal then
735-
	print("Disable Button Mode is OFF")
735+
736
		else
737
			color = "green"
738
		end
739
		minstring = " min: "
740
	else
741
		mingoal = ""
742
		minstring = ""
743
	end
744
	if maxgoalboolean == true then
745
		if x_collect == maxgoal then
746
			color = "orange"
747
		elseif mingoalboolean == false then
748
			color = "yellow"
749
		end
750
		maxstring = " max: "
751
	else
752
		maxstring = ""
753
		maxgoal = ""
754
	end
755
gui.text(4, y_offset, goalstring .. x_collect .. " -" .. minstring .. mingoal .. maxstring .. maxgoal, color)
756
end
757
---------------------------------------------------
758
if DisplayCoin == true and CoinGoals == true then
759
	function coindisplay()
760
		display_goals_gen("Coins: ", collectedcoins, MinCoinGoal, MaxCoinGoal, MinimumCoins, MaximumCoins, y_offset_coin)
761
	end
762
	y_offset_coin = y_offset
763
	y_offset = y_offset + 8
764
else
765
	function coindisplay()
766
	end
767
end
768
---------------------------------------------------
769
if DisplayStar == true and StarGoals == true then
770
	function stardisplay()
771
		display_goals_gen("Stars: ", collectedstars, MinStarGoal, MaxStarGoal, MinimumStars, MaximumStars, y_offset_star)
772
	end
773
	y_offset_star = y_offset
774
	y_offset = y_offset + 8
775
else
776
	function stardisplay()
777
	end
778
end
779
---------------------------------------------------
780
if DisplayFlower == true and FlowerGoals == true then
781
	function flowerdisplay()
782
		display_goals_gen("Flowers: ", flowers, MinFlowerGoal, MaxFlowerGoal, MinimumFlowers, MaximumFlowers, y_offset_flower)
783
	end
784
	y_offset_flower = y_offset
785
	y_offset = y_offset + 8
786
else
787
	function flowerdisplay()
788
	end
789
end
790
---------------------------------------------------
791
if DisplayRed == true and RedCoinGoals == true then
792
	function reddisplay()
793
		display_goals_gen("Red Coins: ", redcoins, MinRedCoinGoal, MaxRedCoinGoal, MinimumRedCoins, MaximumRedCoins, y_offset_red)
794
	end
795
	y_offset_red = y_offset
796
	y_offset = y_offset + 8
797
else
798
	function reddisplay()
799
	end
800
end
801
---------------------------------------------------
802
if DisplayJump == true and JumpGoals == true then
803
	function jumpdisplay()
804
		display_goals_gen("Jumped: ", times_jumped, MinJumpGoal, MaxJumpGoal, MinimumJumps, MaximumJumps, y_offset_jump)
805
	end
806
	y_offset_jump = y_offset
807
	y_offset = y_offset + 8
808
else
809
	function jumpdisplay()
810
	end
811
end
812
---------------------------------------------------
813
if DisplayEggs == true and Egg_Goals == true then
814
	function eggdisplay()
815
		display_goals_gen("Eggs: ", eggs_made, MinEggGoal, MaxEggGoal, MinimumEggs, MaximumEggs, y_offset_egg)
816
	end
817
	y_offset_egg = y_offset
818
	y_offset = y_offset + 8
819
else
820
	function eggdisplay()
821
	end
822
end
823
---------------------------------------------------
824
if DisplayFuzzy == true and Fuzzy_Goals == true then
825
	function fuzdisplay()
826
		display_goals_gen("Fuzzies: ", touched_fuzzies, MinFuzzyGoal, MaxFuzzyGoal, MinimumFuzzies, MaximumFuzzies, y_offset_fuz)
827
	end
828
	y_offset_fuz = y_offset
829
	y_offset = y_offset + 8
830
else
831
	function fuzdisplay()
832
	end
833
end
834
---------------------------------------------------
835
if DisplayLives == true and Lives_Goals == true then
836
	function livesdisplay()
837
		display_goals_gen("Lives: ", extralives_gathered, MinLivesGoal, MaxLivesGoal, MinimumLives, MaximumLives, y_offset_lives)
838
	end
839
	y_offset_lives = y_offset
840
	y_offset = y_offset + 8
841
else
842
	function livesdisplay()
843
	end
844
end
845
---------------------------------------------------
846
function what_to_display()
847
	if gamemode == 15 then
848
		coindisplay()
849
		stardisplay()
850
		flowerdisplay()
851
		reddisplay()
852
		jumpdisplay()
853
		eggdisplay()
854
		fuzdisplay()
855
		livesdisplay()
856
	end
857
end
858
gui.register(what_to_display)
859
---------------------------------------------------
860
---------------------------------------------------
861
--------------------------------------------------- Start with goal functions.
862
---------------------------------------------------
863
---------------------------------------------------
864
if MinimumCoins == true then
865
	function mincoincheck()
866
		if collectedcoins < MinCoinGoal then
867
			if gamemode == 16 or memory.readbyte(0x7E004F) == 240 then
868
				firedeath()
869
			end
870
		end
871
	end
872
else
873
	function mincoincheck()
874
	end
875
end
876
---------------------------------------------------
877
if MaximumCoins == true then
878
	function maxcoincheck()
879
		if collectedcoins > MaxCoinGoal and memory.readbyte(0x7001AE) == 0 then
880
			firedeath()
881
			collectedcoins = 0
882
		end
883
	end
884
else
885
	function maxcoincheck()
886
	end
887
end
888
---------------------------------------------------
889
lastframecoins = memory.readbyte(0x7E037B)
890
collectedcoins = 0
891
function coincounter()
892
	gamemode = memory.readbyte(0x7E0118)
893
	if memory.readbyte(0x7E037B) > lastframecoins then
894
		collectedcoins = collectedcoins + memory.readbyte(0x7E037B) - lastframecoins
895
	elseif memory.readbyte(0x7E037B) < lastframecoins then
896
		collectedcoins = collectedcoins + 100 - lastframecoins + memory.readbyte(0x7E037B)
897
	end
898
	lastframecoins = memory.readbyte(0x7E037B)
899
end
900
---------------------------------------------------
901
if CoinGoals == true then
902
	function coingoals()
903
		savering = memory.readbyte(0x7E0B65)
904
		coincounter()
905
		if savering == 1 then
906
			MidRingCoins = collectedcoins
907
		end
908
		if gamemode == 61 or gamemode == 34 then
909
			collectedcoins = 0
910
		end
911
		if gamemode == 53 then
912
			collectedcoins = MidRingCoins
913
		end
914
		mincoincheck()
915
		maxcoincheck()
916
	end
917
else
918
	function coingoals()
919
	end
920
end
921
922
---------------------------------------------------
923
------------------------------------------------------
924
------------------------------------------------------
925
---------------------------------------------------
926
lastframestars = math.floor(memory.readword(0x7E03B6)/10)
927
collectedstars = 0
928
if MinimumStars == true then
929
	function minstarcheck()
930
		if collectedstars < MinStarGoal then
931
			if gamemode == 16 or memory.readbyte(0x7E004F) == 240 then
932
				firedeath()
933
			end
934
		end
935
	end
936
else
937
	function minstarcheck()
938
	end
939
end
940
------------------------------------------------------
941
if MaximumStars == true then
942
	function maxstarcheck()
943
		if collectedstars > MaxStarGoal and memory.readbyte(0x7001AE) == 0 then
944
			firedeath()
945
			collectedstars = 0
946
		end
947
	end
948
else
949
	function maxstarcheck()
950
	end
951
end
952
------------------------------------------------------
953
function starcounter()
954
	thisframestars = math.floor(memory.readword(0x7E03B6)/10)
955
	gamemode = memory.readbyte(0x7E0118)
956
	if thisframestars > lastframestars and gamemode == 15 then --
957
		collectedstars = collectedstars + thisframestars - lastframestars
958
	end
959
	lastframestars = math.floor(memory.readword(0x7E03B6)/10)
960
end
961
------------------------------------------------------
962
if StarGoals == true then
963
	function stargoals()
964
		memory.writeword(0x7EE23C, 10000)
965
		starcounter()
966
		savering = memory.readbyte(0x7E0B65)
967
		if savering == 1 then
968
			MidRingStars = collectedstars
969
		end
970
		if gamemode == 61 or gamemode == 34  then
971
			collectedstars = 0
972
		end
973
		if gamemode == 53 then
974
			collectedstars = MidRingStars
975
976
		end
977
		minstarcheck()
978
		maxstarcheck()
979
	end
980
else
981
	function stargoals()
982
	end
983
end
984
---------------------------------------------------
985
------------------------------------------------------
986
------------------------------------------------------
987
---------------------------------------------------
988
if MinimumFlowers == true then
989
	function minflowers()
990
			if flowers < MinFlowerGoal then
991
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
992
					firedeath()
993
				end
994
			end
995
	end
996
else
997
	function minflowers()
998
	end
999
end
1000
------------------------------------------------------
1001
if MaximumFlowers == true then
1002
	flowerdeath = false
1003
	function maxflowers()
1004
			if flowers > MaxFlowerGoal and memory.readbyte(0x7001AE) == 0 and flowerdeath == false and gamemode == 15 then
1005
				firedeath()
1006
				flowerdeath = true
1007
			elseif gamemode == 12 and flowerdeath == true then
1008
				flowerdeath = false
1009
			end
1010
	end
1011
else
1012
	function maxflowers()
1013
	end
1014
end
1015
------------------------------------------------------
1016
if FlowerGoals == true then
1017
	function flowergoals()
1018
		gamemode = memory.readbyte(0x7E0118)
1019
		flowers = memory.readbyte(0x7E03B8)
1020
		minflowers()
1021
		maxflowers()
1022
	end
1023
else
1024
	function flowergoals()
1025
	end
1026
end
1027
---------------------------------------------------
1028
------------------------------------------------------
1029
------------------------------------------------------
1030
---------------------------------------------------
1031
if MinimumRedCoins == true then
1032
	function minredcoins()
1033
			if redcoins < MinRedCoinGoal then
1034
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
1035
					firedeath()
1036
				end
1037
			end
1038
	end
1039
else
1040
	function minredcoins()
1041
	end
1042
end
1043
------------------------------------------------------
1044
if MaximumRedCoins == true then
1045
	redcoindeath = false
1046
	function maxredcoins()
1047
			if redcoins > MaxRedCoinGoal and memory.readbyte(0x7001AE) == 0 and redcoindeath == false then
1048
				firedeath()
1049
				redcoindeath = true
1050
			elseif gamemode == 12 and redcoindeath == true then
1051
				redcoindeath = false
1052
			end
1053
	end
1054
else
1055
	function maxredcoins()
1056
	end
1057
end
1058
------------------------------------------------------
1059
if RedCoinGoals == true then
1060
	function redcoingoals()
1061
		gamemode = memory.readbyte(0x7E0118)
1062
		redcoins = memory.readbyte(0x7E03B4)
1063
		minredcoins()
1064
		maxredcoins()
1065
	end
1066
else
1067
	function redcoingoals()
1068
	end
1069
end
1070
---------------------------------------------------
1071
------------------------------------------------------
1072
------------------------------------------------------
1073
---------------------------------------------------
1074
times_jumped = 0
1075
function jumpcounter()
1076
		soundtype = memory.readbyte(0x7E0055)
1077
		if soundtype == 73 or soundtype == 56 then
1078
			times_jumped = times_jumped + 1
1079
		end
1080
end
1081
------------------------------------------------------
1082
if MinimumJumps == true then
1083
	function minjumps()
1084
			if times_jumped < MinJumpGoal then
1085
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
1086
					firedeath()
1087
				end
1088
			end
1089
	end
1090
else
1091
	function minjumps()
1092
	end
1093
end
1094
------------------------------------------------------
1095
if MaximumJumps == true then
1096
	function maxjumps()
1097
			if times_jumped > MaxJumpGoal and memory.readbyte(0x7001AE) == 0 then
1098
				firedeath()
1099
				times_jumped = 0
1100
			end
1101
	end
1102
else
1103
	function maxjumps()
1104
	end
1105
end
1106
------------------------------------------------------
1107
if JumpGoals == true then
1108
	function jumpgoals()
1109
		gamemode = memory.readbyte(0x7E0118)
1110
		jumpcounter()
1111
		savering = memory.readbyte(0x7E0B65)
1112
		if savering == 1 then
1113
			MidRingJumps = times_jumped
1114
		end
1115
		if gamemode == 61 or gamemode == 34  then
1116
			times_jumped = 0
1117
		end
1118
		if gamemode == 53 then
1119
			times_jumped = MidRingJumps
1120
		end
1121
		minjumps()
1122
		maxjumps()
1123
	end
1124
else
1125
	function jumpgoals()
1126
	end
1127
end
1128
---------------------------------------------------
1129
------------------------------------------------------------------------------------------------------------
1130
------------------------------------------------------------------------------------------------------------
1131
---------------------------------------------------
1132
if MinimumEggs == true then
1133
	function mineggs()
1134
			if eggs_made < MinEggGoal then
1135
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
1136
					firedeath()
1137
				end
1138
			end
1139
	end
1140
else
1141
	function mineggs()
1142
	end
1143
end
1144
---------------------------------------------------
1145
if MaximumEggs == true then
1146
	function maxeggs()
1147
			if eggs_made > MaxEggGoal and memory.readbyte(0x7001AE) == 0 then
1148
				firedeath()
1149
				eggs_made = 0
1150
			end
1151
	end
1152
else
1153
	function maxeggs()
1154
	end
1155
end
1156
---------------------------------------------------
1157
eggs_made = 0
1158
swallowing_egg = false
1159
function enemies_swallowed_counter()
1160
	if memory.readbyte(0x700150) == 71 and swallowing_egg == false then  -- Issue if you get hit while making an egg, might be others too? Also counts when eating a fuzzy. Need new indicator!
1161
		eggs_made = eggs_made + 1
1162
		swallowing_egg = true
1163
	elseif memory.readbyte(0x700150) == 75 then
1164
		swallowing_egg = false
1165
	end
1166
end
1167
---------------------------------------------------
1168
if Egg_Goals == true then
1169
	function eggoals()
1170
		gamemode = memory.readbyte(0x7E0118)
1171
		enemies_swallowed_counter()
1172
		savering = memory.readbyte(0x7E0B65)
1173
		if savering == 1 then
1174
			MidRingEggs = eggs_made
1175
		end
1176
		if gamemode == 61 or gamemode == 34  then
1177
			eggs_made = 0
1178
		end
1179
		if gamemode == 53 then
1180
			eggs_made = MidRingEggs
1181
		end
1182
		mineggs()
1183
		maxeggs()
1184
	end
1185
else
1186
	function eggoals()
1187
	end
1188
end
1189
---------------------------------------------------
1190
------------------------------------------------------
1191
------------------------------------------------------
1192
---------------------------------------------------
1193
touched_fuzzies = 0
1194
function fuzzy_counter() -- very important that this is before drunk mode, else it won't work
1195
	if memory.readword(0x701FE8) == 1024 and touched_fuzzy == false then
1196
		touched_fuzzies = touched_fuzzies + 1
1197
		touched_fuzzy = true
1198
	elseif memory.readword(0x701FE8) < 1024 then
1199
		touched_fuzzy = false
1200
	end
1201
end
1202
------------------------------------------------------
1203
if MinimumFuzzies == true then
1204
	function minfuzzies()
1205
			if touched_fuzzies < MinEggGoal then
1206
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
1207
					firedeath()
1208
				end
1209
			end
1210
	end
1211
else
1212
	function minfuzzies()
1213
	end
1214
end
1215
------------------------------------------------------
1216
if MaximumFuzzies == true then
1217
	function maxfuzzies()
1218-
			if touched_fuzzies < MinFuzzyGoal then
1218+
1219
				firedeath()
1220
				touched_fuzzies = 0
1221
			end
1222
	end
1223
else
1224
	function maxfuzzies()
1225
	end
1226
end
1227
------------------------------------------------------
1228
if Fuzzy_Goals == true then
1229
	function fuzzygoals()
1230
		gamemode = memory.readbyte(0x7E0118)
1231
		fuzzy_counter()
1232
		savering = memory.readbyte(0x7E0B65)
1233
		if savering == 1 then
1234
			MidRingFuzzies = touched_fuzzies
1235
		end
1236
		if gamemode == 61 or gamemode == 34  then
1237
			touched_fuzzies = 0
1238
		end
1239
		if gamemode == 53 then
1240
			touched_fuzzies = MidRingFuzzies
1241
		end
1242
		minfuzzies()
1243
		maxfuzzies()
1244
	end
1245
else
1246
	function fuzzygoals()
1247
	end
1248
end
1249
---------------------------------------------------
1250
------------------------------------------------------
1251
------------------------------------------------------
1252
---------------------------------------------------
1253
current_extralives = memory.readword(0x7E0379)
1254
extralives_gathered = 0
1255
function extralives_counter()
1256
	extralives_difference = memory.readword(0x7E0379) - current_extralives
1257
	if extralives_difference > 0 then
1258
		extralives_gathered = extralives_gathered + extralives_difference
1259
	end
1260
	current_extralives = memory.readword(0x7E0379)
1261
end
1262
------------------------------------------------------
1263
if MinimumLives == true then
1264
	function minlives()
1265
			if extralives_gathered < MinLivesGoal then
1266
				if gamemode == 16  or memory.readbyte(0x7E004F) == 240 then
1267
					firedeath()
1268
				end
1269
			end
1270
	end
1271
else
1272
	function minlives()
1273
	end
1274
end
1275
------------------------------------------------------
1276
if MaximumLives == true then
1277
	function maxlives()
1278
			if extralives_gathered > MaxLivesGoal and memory.readbyte(0x7001AE) == 0 then
1279
				firedeath()
1280
				extralives_gathered = 0
1281
			end
1282
	end
1283
else
1284
	function maxlives()
1285
	end
1286
end
1287
------------------------------------------------------
1288
if Lives_Goals == true then
1289
	function livesgoals()
1290
		gamemode = memory.readbyte(0x7E0118)
1291
		extralives_counter()
1292
		savering = memory.readbyte(0x7E0B65)
1293
		if savering == 1 then
1294
			MidRingLives = extralives_gathered
1295
		end
1296
		if gamemode == 61 or gamemode == 34  then
1297
			extralives_gathered = 0
1298
		end
1299
		if gamemode == 53 then
1300
			extralives_gathered = MidRingLives
1301
		end
1302
		minlives()
1303
		maxlives()
1304
	end
1305
else
1306
	function livesgoals()
1307
	end
1308
end
1309
-------------------------------------------------
1310
-------------------------------------------------
1311
------------------MAIN---------------------------
1312
-------------------------------------------------
1313
-------------------------------------------------
1314
while true do
1315
--
1316
	LevelBlitz()
1317
	-- Goal stuff
1318
	coingoals()
1319
	stargoals()
1320
	flowergoals()
1321
	redcoingoals()
1322
	jumpgoals()
1323
	eggoals()
1324
	fuzzygoals()
1325
	livesgoals()
1326
	-- things
1327
	starmeterspeed()
1328
	packmule()
1329
	noleft()
1330
	drunk()
1331
	hardmode()
1332
	deathtimer()
1333
	forceretry()
1334
	infinitelives()
1335
	extendedflutter()
1336
	notongue()
1337
	noflutter()
1338
	velcromode()
1339
	mouthmode()
1340
	eggstransitions()
1341
	fastmodex()
1342
	fastmodey()
1343-
	DisableButtonFunction(DisableButton)
1343+
1344
	poisonflowers()
1345
	groundislava()
1346
	terminalmode()
1347
	poisonair()
1348
	coincounter()
1349
	--
1350
	emu.frameadvance()
1351
end
1352
-- END MAIN --
1353
-- Made by Arnethegreat - message me on #yoshi @ irc.speeddemosarchive.com if you want anything