forked from Steamodded/smods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathachievements.toml
117 lines (104 loc) · 3.77 KB
/
achievements.toml
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
[manifest]
version = "1.0.0"
dump_lua = true
priority = -10
## Achievement API
# fetch_achievements()
[[patches]]
[patches.regex]
target = "functions/common_events.lua"
pattern = '''(?<indent>[\t ]*)if G\.F_NO_ACHIEVEMENTS then return end\n\n[\s\S]{4}--\|FROM LOCAL SETTINGS FILE'''
position = 'before'
# match_indent = true
line_prepend = '$indent'
payload = '''
G.SETTINGS.ACHIEVEMENTS_EARNED = G.SETTINGS.ACHIEVEMENTS_EARNED or {}
for k, v in pairs(G.ACHIEVEMENTS) do
if not v.key then v.key = k end
for kk, vv in pairs(G.SETTINGS.ACHIEVEMENTS_EARNED) do
if G.ACHIEVEMENTS[kk] and G.ACHIEVEMENTS[kk].mod then
G.ACHIEVEMENTS[kk].earned = true
end
end
end'''
# check_for_unlock
[[patches]]
[patches.pattern]
target = "functions/common_events.lua"
pattern = '''if G.GAME.challenge then return end'''
position = "after"
payload = '''
fetch_achievements() -- Refreshes achievements
for k, v in pairs(G.ACHIEVEMENTS) do
if (not v.earned) and (v.unlock_condition and type(v.unlock_condition) == 'function') and v:unlock_condition(args) then
unlock_achievement(k)
end
end'''
match_indent = true
# unlock_achievement()
[[patches]]
[patches.pattern]
target = "functions/common_events.lua"
pattern = '''if G.PROFILES[G.SETTINGS.profile].all_unlocked then return end'''
position = "at"
payload = '''if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return end'''
match_indent = true
# unlock_achievement() - fix event queue leaking
# fixed smods achievements not unlocking due to above comment's memory leak fix
[[patches]]
[patches.pattern]
target = "functions/common_events.lua"
pattern = '''if G.F_NO_ACHIEVEMENTS then return end'''
position = "at"
payload = '''if G.F_NO_ACHIEVEMENTS and not (G.ACHIEVEMENTS[achievement_name] or {}).mod then return true end'''
match_indent = true
[[patches]]
[patches.regex]
target = "functions/common_events.lua"
pattern = '''(?<indent>[\t ]*)if G\.F_NO_ACHIEVEMENTS then return end\n[\s\S][\s\S]{16}--\|LOCAL SETTINGS FILE'''
position = 'before'
# match_indent = true
line_prepend = '$indent'
payload = '''
if not G.ACHIEVEMENTS then fetch_achievements() end
G.SETTINGS.ACHIEVEMENTS_EARNED[achievement_name] = true
G:save_progress()
if G.ACHIEVEMENTS[achievement_name] and G.ACHIEVEMENTS[achievement_name].mod then
if not G.ACHIEVEMENTS[achievement_name].earned then
--|THIS IS THE FIRST TIME THIS ACHIEVEMENT HAS BEEN EARNED
achievement_set = true
G.FILE_HANDLER.force = true
end
G.ACHIEVEMENTS[achievement_name].earned = true
end
if achievement_set then
notify_alert(achievement_name)
return true
end'''
# create_UIBox_notify_alert
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''local t_s = Sprite(0,0,1.5*(_atlas.px/_atlas.py),1.5,_atlas, _c and _c.pos or {x=3, y=0})'''
position = "before"
payload = '''if SMODS.Achievements[_achievement] then _c = SMODS.Achievements[_achievement]; _atlas = G.ASSET_ATLAS[_c.atlas] end'''
match_indent = true
# option to allow unlocks and discoveries in seeded runs
[[patches]]
[patches.regex]
target = 'functions/common_events.lua'
pattern = 'if G\.GAME\.seeded or G\.GAME\.challenge then return end'
position = 'at'
payload = 'if not SMODS.config.seeded_unlocks and (G.GAME.seeded or G.GAME.challenge) then return end'
[[patches]]
[patches.regex]
target = 'functions/common_events.lua'
pattern = 'if G\.GAME\.seeded then'
position = 'at'
payload = 'if false then'
[[patches]]
[patches.regex]
target = 'functions/common_events.lua'
pattern = 'if G\.GAME\.challenge then'
position = 'at'
payload = 'if false then'