-
Notifications
You must be signed in to change notification settings - Fork 0
/
aohe.lua
88 lines (80 loc) · 2.76 KB
/
aohe.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
original_generator_run = generator.run
function generator.run( self, linfo, gen_run_func, gen_spawn_func )
local linfo = linfo or world.data.level[ world.data.current ]
local events = nil
if linfo then
events = linfo.event
linfo.event = nil
end
-- we will take care of that
-- run the original generator
original_generator_run ( self, linfo, gen_run_func, gen_spawn_func )
if linfo then
linfo.event = events
end
-- cpiod’s hack, should be backward compatible
local event = nil
if linfo.event then
if type(linfo.event) == "string" then -- legacy behavior
linfo.event = { linfo.event }
end
for _,v in pairs(linfo.event) do
event = world:create_entity( v )
world:attach( self, event )
local uevent = ecs:add( self, "ui_event" )
uevent.event = event
uevent.active = true
end
end
end
function cpiod_pick_event(events)
local val = math.random( #events )
local pick = events[val]
-- at most one timed event
if val >= #events-2 and events[#events] == "event_lockdown" then
table.remove(events, #events)
table.remove(events, #events)
table.remove(events, #events)
else
table.remove(events, val)
end
return pick
end
register_blueprint "challenge_he"
{
text = {
name = "Angel of Randomness",
desc = "{!MEGA CHALLENGE PACK MOD}\nDue to a solar storm, the Jovian moons suffer from many strange events. Each level has a least two random events. And the deeper you go, the worst it gets...\n\nRating : {YMEDIUM}",
rating = "MEDIUM",
abbr = "AoR",
letter = "R",
},
challenge = {
type = "challenge",
},
callbacks = {
on_create = [[
function( self, player )
for i,linfo in ipairs( world.data.level ) do
local events = { "event_low_light",
"event_desolation",
"event_volatile_storage",
"event_infestation",
"event_exalted_curse",
"event_vault",
"event_contamination",
"event_windchill",
"event_hunt",
"event_exalted_summons",
"event_lockdown",
}
local e = {}
for _=1,linfo.episode+1 do
table.insert(e, cpiod_pick_event(events))
end
linfo.event = e
end
end
]],
},
}