forked from InertSteak/Pokermon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokermon.lua
More file actions
411 lines (362 loc) · 12.5 KB
/
pokermon.lua
File metadata and controls
411 lines (362 loc) · 12.5 KB
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
if SMODS.current_mod then
local loaded, config = pcall(require, "pokermon.setup")
if not loaded then
error("Pokermon did not load correctly. Please make sure the Pokermon folder isn't nested within the Mods folder and that you have everything installed properly.")
end
end
pokermon = {}
SMODS.current_mod.optional_features = { quantum_enhancements = true }
--Undiscovered sprites, mostly for testing some localization things since the game crashes without them
--This can probably have a better integration or just be removed altogether since everything is discovered anyways
-- -Jevonn
SMODS.UndiscoveredSprite({
key = "Energy",
atlas = "unergy",
path = "unergy.png",
pos = { x = 0, y = 0 },
px = 71,
py = 95,
}):register()
SMODS.UndiscoveredSprite({
key = "Item",
atlas = "unitem",
path = "unitem.png",
pos = { x = 0, y = 0 },
px = 71,
py = 95,
}):register()
--Get mod path and load other files
mod_dir = ''..SMODS.current_mod.path
pokermon_config = SMODS.current_mod.config
--Load Joker Display if the mod is enabled
if (SMODS.Mods["JokerDisplay"] or {}).can_load then
local jokerdisplays = NFS.getDirectoryItems(mod_dir.."jokerdisplay")
for _, file in ipairs(jokerdisplays) do
sendDebugMessage ("The file is: "..file)
local helper, load_error = SMODS.load_file("jokerdisplay/"..file)
if load_error then
sendDebugMessage ("The error is: "..load_error)
else
helper()
end
end
end
--Load Custom Rarities
SMODS.Rarity{
key = "safari",
default_weight = 0,
badge_colour = HEX("F2C74E"),
pools = {["Joker"] = true},
get_weight = function(self, weight, object_type)
return weight
end,
}
SMODS.Rarity{
key = "mega",
default_weight = 0,
-- color from bulbapedia (effect color around Mega Blaziken artwork: https://bulbapedia.bulbagarden.net/wiki/File:Blaziken_Mega_Evolution.png)
badge_colour = HEX("E8578E"),
pools = {["Joker"] = true},
get_weight = function(self, weight, object_type)
return weight
end,
}
--Load helper function files
assert(SMODS.load_file("functions/pokeconstants.lua"))()
assert(SMODS.load_file("functions/pokeutils.lua"))()
assert(SMODS.load_file("functions/pokefamily.lua"))()
assert(SMODS.load_file("functions/pokefunctions.lua"))()
assert(SMODS.load_file("functions/energyfunctions.lua"))()
assert(SMODS.load_file("functions/pokeanimations.lua"))()
assert(SMODS.load_file("functions/dex_order.lua"))()
assert(SMODS.load_file("functions/uifunctions.lua"))()
--Load Draw Logic file
assert(SMODS.load_file("functions/pokedraw.lua"))()
--Load Debuff logic
assert(SMODS.load_file("functions/debufffunctions.lua"))()
--Load API
assert(SMODS.load_file("functions/apifunctions.lua"))()
--Load Sprites Load
assert(SMODS.load_file("functions/pokespriteload.lua"))()
--Load Sprites file
assert(SMODS.load_file("pokesprites.lua"))()
--Load InputManager file
assert(SMODS.load_file("functions/inputmanager.lua"))()
--Load DisplayCard file
assert(SMODS.load_file("functions/displaycard.lua"))()
--Load UI file
assert(SMODS.load_file("pokeui.lua"))()
--Load quip file
assert(SMODS.load_file("pokequips.lua"))()
local load_directory = function(dirname, map_item, auto_discovery)
local pfiles = NFS.getDirectoryItems(mod_dir .. dirname)
for _, file in ipairs(pfiles) do
sendDebugMessage ("The file is: "..file)
local result, load_error = SMODS.load_file(dirname .. "/" ..file)
if not result then
sendDebugMessage ("The error is: "..load_error)
else
local items = result()
if items.init then items:init() end
if items.list and #items.list > 0 then
for _, item in ipairs(items.list) do
if auto_discovery and not item.poke_always_unlocked then
item.discovered = not pokermon_config.pokemon_discovery
end
map_item(item)
end
end
end
end
end
--Load pokemon file
load_directory("pokemon", pokermon.load_pokemon)
--This is a new comment
----Don't believe his lies
--Load consumable types
load_directory("consumable types", SMODS.ConsumableType, true)
--Load consumables
load_directory("consumables", SMODS.Consumable, true)
--Load boosters
load_directory("boosters", SMODS.Booster, true)
--Load seals
load_directory("seals", SMODS.Seal, true)
--Load stickers
load_directory("stickers", function (item)
item.hide_badge = true
SMODS.Sticker(item)
end, true)
-- Sets custom skins according to config on load
G.E_MANAGER:add_event(Event({
func = function()
G.FUNCS.toggle_pokermon_skins()
return true
end
}))
--Load editions
load_directory("editions", SMODS.Edition, true)
--Load enhancements
load_directory("enhancements", SMODS.Enhancement, true)
--Load vouchers
load_directory("vouchers", SMODS.Voucher, true)
--Load blinds
load_directory("blinds", SMODS.Blind, true)
--Load tags
load_directory("tags", SMODS.Tag, true)
--Load backs
load_directory("backs", SMODS.Back)
--Load Sleeves
if (SMODS.Mods["CardSleeves"] or {}).can_load then
--Load Sleeves
load_directory("sleeves", CardSleeves.Sleeve)
end
--Load challenges file
load_directory("challenges", SMODS.Challenge)
local set_edition = Card.set_edition
function Card:set_edition(edition, immediate, silent)
if (edition and edition == "e_poke_shiny" and not pokermon_config.shiny_playing_cards) and (self.ability.set ~= 'Joker' and self.ability.set ~= 'Edition') then return end
return set_edition(self, edition, immediate, silent)
end
--Add Jirachi's Negative rate increase
local previous_neg_get_weight = G.P_CENTERS.e_negative.get_weight
G.P_CENTERS.e_negative.get_weight = function(self)
return previous_neg_get_weight(self) + ((G.GAME.negative_edition_rate or 1) - 1) * G.P_CENTERS.e_negative.weight
end
-- polychrome steals negative's chances with the Hone / Glow Up voucher, so we're gonna steal it back (won't decrease past base weight)
local previous_poly_get_weight = G.P_CENTERS.e_polychrome.get_weight
G.P_CENTERS.e_polychrome.get_weight = function(self)
return math.max(G.P_CENTERS.e_polychrome.weight, previous_poly_get_weight(self) - ((G.GAME.negative_edition_rate or 1) - 1) * G.P_CENTERS.e_negative.weight)
end
--To support Debris sleeve combo
local card_set_ability_old = Card.set_ability
function Card:set_ability(center, initial, delay_sprites)
if G.GAME.modifiers.negative_hazards and self.config.center and self.config.center.key == "m_poke_hazard" and self.ability and self.ability.card_limit then
self.ability.card_limit = self.ability.card_limit - 1
end
local ret = card_set_ability_old(self, center, initial, delay_sprites)
if G.GAME.modifiers.negative_hazards and self.config.center and self.config.center.key == "m_poke_hazard" then
if not self.ability then self.ability = {} end
self.ability.card_limit = (self.ability.card_limit or 0) + 1
end
return ret
end
function SMODS.current_mod.reset_game_globals(run_start)
if run_start then
if G.GAME.modifiers.no_energy then
G.GAME.energy_rate = 0
end
end
local rank_resets = {'bulb1card', 'sneaselcard', 'bramblincard'}
for i = 1, #rank_resets do
poke_reset_rank(rank_resets[i])
end
reset_espeon_card()
reset_gligar_suit()
poke_reset_type('cattype', {'skitty', 'delcatty'})
end
--Tutorial WIP
--[[
local gu = Game.update
function Game:update(dt)
gu(self, dt)
if not G.PROFILES[G.SETTINGS.profile].poke_intro_complete then
G.FUNCS.poke_intro_controller()
end
end
G.FUNCS.poke_intro_controller = function()
G.PROFILES[G.SETTINGS.profile].poke_intro_progress = G.PROFILES[G.SETTINGS.profile].poke_intro_progress
or {
state = "start",
completed = {},
}
if not G.SETTINGS.paused and not G.PROFILES[G.SETTINGS.profile].poke_intro_complete then
if G.STATE == G.STATES.MENU and not G.PROFILES[G.SETTINGS.profile].poke_intro_progress.completed.start then
G.PROFILES[G.SETTINGS.profile].poke_intro_progress.section = "start"
G.FUNCS.poke_intro_part("start")
G.PROFILES[G.SETTINGS.profile].poke_intro_progress.completed.start = true
G:save_progress()
end
end
end
G.FUNCS.poke_intro_part = function(_part)
local step = 1
G.SETTINGS.paused = true
if _part == "start" then
step = poke_info({
text_key = 'poke_intro_1',
attach = {major = G.ROOM_ATTACH, type = 'cm', offset = {x = 0, y = 0}},
step = step,
})
end
G.E_MANAGER:add_event(Event({
blockable = false,
timer = 'REAL',
func = function()
G.E_MANAGER:clear_queue("tutorial")
if G.OVERLAY_TUTORIAL.content then
G.OVERLAY_TUTORIAL.content:remove()
end
if G.OVERLAY_TUTORIAL.Jimbo then
G.OVERLAY_TUTORIAL.Jimbo:remove_button()
G.OVERLAY_TUTORIAL.Jimbo:remove_speech_bubble()
end
G.OVERLAY_TUTORIAL.step = nil
end
}), 'tutorial')
G.SETTINGS.paused = false
end
function poke_info(args)
poke_debug("start poke info")
local overlay_colour = { 0.32, 0.36, 0.41, 0 }
ease_value(overlay_colour, 4, 0.6, nil, "REAL", true, 0.4)
G.OVERLAY_TUTORIAL = G.OVERLAY_TUTORIAL
or UIBox({
definition = {
n = G.UIT.ROOT,
config = { align = "cm", padding = 32.05, r = 0.1, colour = overlay_colour, emboss = 0.05 },
nodes = {},
},
config = {
align = "cm",
offset = { x = 0, y = 3.2 },
major = G.ROOM_ATTACH,
bond = "Weak",
},
})
G.OVERLAY_TUTORIAL.step = G.OVERLAY_TUTORIAL.step or 1
G.OVERLAY_TUTORIAL.step_complete = false
local row_dollars_chips = G.HUD and G.HUD:get_UIE_by_ID("row_dollars_chips") or G.ROOM_ATTACH
local align = args.align or "tm"
local step = args.step or 1
local attach = args.attach or { major = row_dollars_chips, type = "tm", offset = { x = 0, y = -0.5 } }
local pos = args.pos or { x = attach.major.T.x + attach.major.T.w / 2, y = attach.major.T.y + attach.major.T.h / 2 }
local button = args.button or { button = localize("b_next"), func = "tut_next" }
args.highlight = args.highlight or {}
G.E_MANAGER:add_event(
Event({
trigger = "after",
delay = 0.3,
func = function()
if G.OVERLAY_TUTORIAL and G.OVERLAY_TUTORIAL.step == step and not G.OVERLAY_TUTORIAL.step_complete then
if args.on_start then
args.on_start()
end
G.CONTROLLER.interrupt.focus = true
G.OVERLAY_TUTORIAL.Jimbo = G.OVERLAY_TUTORIAL.Jimbo or Card_Character(pos)
if type(args.highlight) == "function" then
args.highlight = args.highlight()
end
args.highlight[#args.highlight + 1] = G.OVERLAY_TUTORIAL.Jimbo
if args.text_key then
G.OVERLAY_TUTORIAL.Jimbo:add_speech_bubble(args.text_key, align, args.loc_vars)
end
G.OVERLAY_TUTORIAL.Jimbo:set_alignment(attach)
if args.hard_set then
G.OVERLAY_TUTORIAL.Jimbo:hard_set_VT()
end
G.OVERLAY_TUTORIAL.button_listen = nil
if G.OVERLAY_TUTORIAL.content then
G.OVERLAY_TUTORIAL.content:remove()
end
if args.content then
G.OVERLAY_TUTORIAL.content = UIBox({
definition = args.content(),
config = {
align = args.content_config and args.content_config.align or "cm",
offset = args.content_config and args.content_config.offset or { x = 0, y = 0 },
major = args.content_config and args.content_config.major or G.OVERLAY_TUTORIAL.Jimbo,
bond = "Weak",
},
})
args.highlight[#args.highlight + 1] = G.OVERLAY_TUTORIAL.content
end
if args.button_listen then
G.OVERLAY_TUTORIAL.button_listen = args.button_listen
end
if not args.no_button then
G.OVERLAY_TUTORIAL.Jimbo:add_button(
button.button,
button.func,
button.colour,
button.update_func,
true
)
end
G.OVERLAY_TUTORIAL.Jimbo:say_stuff(2 * #(G.localization.misc.tutorial[args.text_key] or {}) + 1)
if args.snap_to then
G.E_MANAGER:add_event(
Event({
trigger = "immediate",
blocking = false,
blockable = false,
func = function()
if
G.OVERLAY_TUTORIAL
and G.OVERLAY_TUTORIAL.Jimbo
and not G.OVERLAY_TUTORIAL.Jimbo.talking
then
local _snap_to = args.snap_to()
if _snap_to then
G.CONTROLLER.interrupt.focus = false
G.CONTROLLER:snap_to({ node = args.snap_to() })
end
return true
end
end,
}),
"tutorial"
)
end
if args.highlight then
G.OVERLAY_TUTORIAL.highlights = args.highlight
end
G.OVERLAY_TUTORIAL.step_complete = true
end
return not G.OVERLAY_TUTORIAL or G.OVERLAY_TUTORIAL.step > step or G.OVERLAY_TUTORIAL.skip_steps
end,
}),
"tutorial"
)
return step + 1
end
--]]