-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathachievements.lua
644 lines (612 loc) · 18 KB
/
achievements.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
---@class Trail
---@field public name string|nil
---@field public model integer|ModelExtendedId|nil
---@class Reward
---@field public title string|nil
---@field public trail Trail|nil
---@class Achievement
---@field public name string
---@field public description string
---@field public reward Reward
---@field public initFunc function|nil
---@field public loopFunc function|nil
local marathonTimer = 0
local speedingTimer = 0
local speederPrevAmountOfTags = 0
spectatorAttemptCount = 0
achievements = {
---@type Achievement
{
name = "Welcome to Tag",
description = "Launch Tag!",
---@type Reward
reward = {
title = nil,
trail = nil,
},
initFunc = function ()
return true
end,
loopFunc = nil
},
---@type Achievement
{
name = "One match in!",
description = "Play your first game of Tag!",
---@type Reward
reward = {
title = "\\#dcdcdc\\Noob",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
local s = gPlayerSyncTable[0]
if (gGlobalSyncTable.roundState == ROUND_RUNNERS_WIN
or gGlobalSyncTable.roundState == ROUND_TAGGERS_WIN)
and s.state ~= SPECTATOR and s.state ~= -1 then
return true
end
end
},
---@type Achievement
{
name = "Your first tag!",
description = "Tag A Player!",
---@type Reward
reward = {
title = "\\#dcdcdc\\Beginner",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTags >= 1 then
return true
end
end
},
---@type Achievement
{
name = "Tagging away, I see...",
description = "Get 10 Tags!",
---@type Reward
reward = {
title = nil,
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTags >= 10 then
return true
end
end
},
---@type Achievement
{
name = "50 Tags? Keep it up!",
description = "Get 50 Tags!",
---@type Reward
reward = {
title = "\\#E82E2E\\Tagger",
trail = {
name = "Tagger Trail",
model = smlua_model_util_get_id("tagger_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTags >= 50 then
return true
end
end
},
---@type Achievement
{
name = "The Big Triple!",
description = "Get 100 Tags!",
---@type Reward
reward = {
title = "\\#A62D24\\Aggresive Tagger",
trail = {
name = "Aggresive Tagger Trail",
model = smlua_model_util_get_id("aggresive_tagger_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTags >= 100 then
return true
end
end
},
---@type Achievement
{
name = "4 digits? Chill with the tags!",
description = "Get 1000 Tags!",
---@type Reward
reward = {
title = "\\#E82E2E\\Expert Tagger",
trail = {
name = "Tagger Ring Trail",
model = smlua_model_util_get_id("tagger_ring_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTags >= 1000 then
return true
end
end
},
---@type Achievement
{
name = "An hour comes, a hour goes.",
description = "Play for 1 hour total!",
---@type Reward
reward = {
title = "\\#dcdcdc\\1 Hour In",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.playTime / 30 / 60 / 60 >= 1 then
return true
end
end
},
---@type Achievement
{
name = "Half a day in, you're going strong!",
description = "Play for 12 hours total!",
---@type Reward
reward = {
title = "\\#999999\\12 Hours In",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.playTime / 30 / 60 / 60 >= 12 then
return true
end
end
},
---@type Achievement
{
name = "First day in, enjoy the next!",
description = "Play for 24 hours total!",
---@type Reward
reward = {
title = "\\#636363\\24 Hours In",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.playTime / 30 / 60 / 60 >= 24 then
return true
end
end
},
---@type Achievement
{
name = "2 days in, you must be grinding!",
description = "Play for 48 hours total!",
---@type Reward
reward = {
title = "\\#FFD700\\Grinding Tag",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.playTime / 30 / 60 / 60 >= 48 then
return true
end
end
},
---@type Achievement
{
name = "Hey, maybe take a break?!",
description = "Play for 7 hours in a single session!",
---@type Reward
reward = {
title = "\\#732323\\Always Watching",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.playTime / 30 / 60 / 60 >= 48 then
return true
end
end
},
---@type Achievement
{
name = "Dang, a half a day, really?!",
description = "Play for 12 hours in a single session!",
---@type Reward
reward = {
title = "\\#316BE8\\Running For Days",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
local s = gPlayerSyncTable[0]
if s.state ~= SPECTATOR then
marathonTimer = marathonTimer + 1
end
if marathonTimer / 30 / 60 / 60 >= 12 then
return true
end
end
},
---@type Achievement
{
name = "Slow down, speeder!",
description = "Tag 5 players within 30 seconds!",
---@type Reward
reward = {
title = "\\#316BE8\\Speeding Tagger",
---@type Trail
trail = {
name = "Speeding Trail",
model = smlua_model_util_get_id("speeding_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
local s = gPlayerSyncTable[0]
if gGlobalSyncTable.roundState ~= ROUND_HOT_POTATO_INTERMISSION
and gGlobalSyncTable.roundState ~= ROUND_ACTIVE then
speederPrevAmountOfTags = 0
speedingTimer = 0
end
if s.amountOfTags and s.amountOfTags > speederPrevAmountOfTags then
speedingTimer = speedingTimer + 1
if s.amountOfTags - speederPrevAmountOfTags >= 5 then
return true
end
if speedingTimer > 30 * 30 then
speedingTimer = 0
speederPrevAmountOfTags = s.amountOfTags
end
else
speedingTimer = 0
end
end
},
---@type Achievement
{
name = "Welp, you've mastered Tag!",
description = "Get every achievement in Tag!",
---@type Reward
reward = {
title = "\\#8D4D8B\\Tag Master",
trail = {
name = "The Master Trail",
model = smlua_model_util_get_id("master_trail_geo"),
},
},
initFunc = nil,
loopFunc = function ()
local mastered = true
for i, achievement in pairs(achievements) do
if completedAchievements[i] ~= true
and achievement.reward.title ~= "Tag Master" then
mastered = false
end
end
if mastered then
return true
end
end
},
---@type Achievement
{
name = "You really wanna spectate I see...",
description = "Hit \"Toggle Spectate\" 100 times while in a match.",
---@type Reward
reward = {
title = "\\#4A4A4A\\Spectator Lover",
trail = nil,
},
initFunc = nil,
loopFunc = function ()
if gGlobalSyncTable.roundState ~= ROUND_ACTIVE
and gGlobalSyncTable.roundState ~= ROUND_HOT_POTATO_INTERMISSION then
spectatorAttemptCount = 0
end
if spectatorAttemptCount >= 100 then
return true
end
end
},
---@type Achievement
{
name = "You're pretty good at terminating people...",
description = "Win 10 Times as the Terminator!",
---@type Reward
reward = {
title = "\\#7D2A24\\Beginner Terminator",
trail = {
name = "Terminator Trail",
model = smlua_model_util_get_id("terminator_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
if stats[TERMINATOR].taggerVictories >= 10 then
return true
end
end
},
---@type Achievement
{
name = "Wow, you're very good with those terminations!",
description = "Win 50 Times as the Terminator!",
---@type Reward
reward = {
title = "\\#7D2A24\\Terminator",
trail = {
name = "Terminator Ring Trail",
model = smlua_model_util_get_id("terminator_ring_trail_geo")
},
},
initFunc = nil,
loopFunc = function ()
if stats[TERMINATOR].taggerVictories >= 10 then
return true
end
end
},
---@type Achievement
{
name = "Potato Wielder victories are just better!",
description = "Win 5 Times as a Potato Wielder!",
---@type Reward
reward = {
title = "\\#FC9003\\Potato Wielder",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[HOT_POTATO].taggerVictories >= 5 then
return true
end
end
},
---@type Achievement
{
name = "Juggernaut W",
description = "Win 5 times as the Juggernaut.",
---@type Reward
reward = {
title = nil,
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[JUGGERNAUT].runnerVictories >= 5 then
return true
end
end
},
---@type Achievement
{
name = "Now that's a Juggernaut",
description = "Win 20 times as the Juggernaut.",
---@type Reward
reward = {
title = "\\#42B0F5\\Juggernaut",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[JUGGERNAUT].runnerVictories >= 20 then
return true
end
end
},
---@type Achievement
{
name = "First Tournament W!",
description = "Win a Tournament.",
---@type Reward
reward = {
title = nil,
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTournamentWins >= 1 then
return true
end
end
},
---@type Achievement
{
name = "5 Tournament wins, nice!",
description = "Win 5 Tournaments.",
---@type Reward
reward = {
title = "Tournament Player",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTournamentWins >= 5 then
return true
end
end
},
---@type Achievement
{
name = "20 Tournament wins, now that's a gamer!",
description = "Win 20 Tournaments.",
---@type Reward
reward = {
title = "Tournament Victor",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats.globalStats.totalTournamentWins >= 20 then
return true
end
end
},
---@type Achievement
{
name = "5 Assassins wins, not quite an assassin!",
description = "Win 5 games of Assassins.",
---@type Reward
reward = {
title = nil,
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[ASSASSINS].taggerVictories >= 5 then
return true
end
end
},
---@type Achievement
{
name = "15 Assassins wins, now that's an assassin!",
description = "Win 15 games of Assassins.",
---@type Reward
reward = {
title = "\\#FF0000\\Assassin",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[ASSASSINS].taggerVictories >= 15 then
return true
end
end
},
---@type Achievement
{
name = "You're throwing an oddball!",
description = "Win 1 game of Oddball as the Oddball.",
---@type Reward
reward = {
title = nil,
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[ODDBALL].runnerVictories >= 1 then
return true
end
end
},
---@type Achievement
{
name = "Now that's an oddball!",
description = "Win 15 games of Oddball as the Oddball.",
---@type Reward
reward = {
title = "\\#919AA1\\Oddball",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[ODDBALL].runnerVictories >= 15 then
return true
end
end
},
---@type Achievement
{
name = "That's a freezer! (or saver)",
description = "Freeze 50 players in Freeze Tag.",
---@type Reward
reward = {
title = "\\#7EC0EE\\Freezer",
trail = nil
},
initFunc = nil,
loopFunc = function ()
if stats[FREEZE_TAG].totalTags >= 50 then
return true
end
end
},
}
local initializedAchievements = false
completedAchievements = {}
remoteCompletedAchievements = {}
local function completed_achievement(i)
completedAchievements[i] = true
local text = "\\#FFD700\\Achievement Unlocked\n" .. achievements[i].name
djui_popup_create(text, 2)
-- save achievement
save_bool("achievement_" .. tostring(i), true)
end
local function mario_update(m)
local np = gNetworkPlayers[m.playerIndex]
if m.playerIndex ~= 0 then return end
if not np.currAreaSyncValid then return end
-- loop thru all achievements
for i, achievement in ipairs(achievements) do
if completedAchievements[i] then goto continue end
if not initializedAchievements then
-- load achievements
local completed = load_bool("achievement_" .. tostring(i))
if completed == true then
completedAchievements[i] = true
goto continue
end
if achievement.initFunc then
if achievement.initFunc() == true then
completed_achievement(i)
goto continue
end
end
end
if achievement.loopFunc then
if achievement.loopFunc() == true then
completed_achievement(i)
end
end
::continue::
end
if not initializedAchievements then
-- load selected player title
local title = load_int("playerTitle")
if title ~= nil then
if (completedAchievements[title] ~= nil or title < 0)
and achievements[title] ~= nil
and achievements[title].reward ~= nil
and achievements[title].reward.title ~= nil then
gPlayerSyncTable[0].playerTitle = achievements[title].reward.title
else
gPlayerSyncTable[0].playerTitle = nil
end
end
-- load selected trail
local trail = load_int("playerTrail")
if trail ~= nil then
if completedAchievements[trail] ~= nil
and achievements[trail] ~= nil
and achievements[trail].reward ~= nil
and achievements[trail].reward.trail ~= nil then
gPlayerSyncTable[0].playerTrail = achievements[trail].reward.trail.model
else
gPlayerSyncTable[0].playerTrail = E_MODEL_BOOST_TRAIL
end
end
-- set owner and developer vars
isOwner = achievements[-1] ~= nil
isDeveloper = achievements[-2] ~= nil
-- print player's stats
if stats.globalStats.runnerVictories > 0 then
djui_chat_message_create_global(get_player_name(0) .. " \\#dcdcdc\\has won \\#FFE557\\" .. stats.globalStats.runnerVictories .. " \\#dcdcdc\\times as a \\#316BE8\\Runner")
end
if stats.globalStats.taggerVictories > 0 then
djui_chat_message_create_global(get_player_name(0) .. " \\#dcdcdc\\has won \\#FFE557\\" .. stats.globalStats.taggerVictories .. " \\#dcdcdc\\times as a \\#E82E2E\\Tagger")
end
end
initializedAchievements = true
end
hook_event(HOOK_MARIO_UPDATE, mario_update)