-
Notifications
You must be signed in to change notification settings - Fork 0
/
aotr.lua
180 lines (174 loc) · 7.19 KB
/
aotr.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
function get_code(str)
if str then
local start_pos = 1+str:find(")") -- find the end of the function definition
local i = 0
local end_pos = 0
while i do
end_pos = i-1
i = str:find("end", i+1)
end
return str:sub(start_pos, end_pos)
end
return "" -- no callback
end
--bugs: new york reload no weapon on enemies
register_blueprint "runtime_triple_angel"
{
flags = { EF_NOPICKUP },
data = {
nb_choice = 1,
reload_challenge = false
},
callbacks = {
on_enter_level = [=[
function ( self, entity, reenter )
if not reenter and world.data.current == 1 then
local ch = {"challenge_rocket","challenge_marksmanship","challenge_shotgunnery","challenge_berserk"} --,"challenge_reload"} TODO FIXME
local param = {
title = "Choose your weapon challenge",
fsize = 13,
size = coord( 40, 0 ),
}
for i,id in ipairs( ch ) do
param[i] = { desc = world:get_text(id, "desc"), name = world:get_text( id, "name" ), target = self, id = id, }
end
ui:terminal( entity, self, param )
end
end
]=],
-- hack for new york reload challenge
on_create_entity = [=[
function( self, entity, alive )
nova.log("reload? "..tostring(self.data.reload_challenge))
if self.data.reload_challenge and alive then
local id = world:get_id( entity )
if id == "summoner" or id == "exalted_summoner" then
entity.attributes.gate = 666
elseif id == "boss_damage_gate" then
entity.attributes.gate = 666
else
local w = entity:get_weapon()
if w and w.weapon and w.weapon.natural then
if not entity.inventory then
ecs:add( entity, "inventory" )
end
local ilvl = world:get_level().level_info.ilevel
local item
if math.random(10) == 1 then
item = core.lists.item.weapon:roll( ilvl )
else
item = core.lists.item.base_weapon:roll( ilvl )
end
if item then
entity:stash_item( item )
end
end
end
end
end
]=],
on_activate = [=[
function( self, who, level, param, id )
id = world:resolve_hash( id )
if id == "challenge_reload" then
self.data.reload_challenge = true
nova.log("reload detected!")
end
-- nova.log("cpiod id: "..tostring(id))
-- execute challenge code
local str = "local player = world:get_player()\nlocal level = world:get_level()\n"..get_code(blueprints[id].callbacks["on_create"]).."\n"..get_code(blueprints[id].callbacks["on_create_player"])
str = str:gsub("world:destroy%(","level:drop_item(player,")
local new_str = ""
local i = 0
local prev = 0
while i do
prev = i
i = str:find("\n", i+1)
if i then
local line=str:sub(prev,i)
-- keep runtimes as attached, modify the rest to equip
if line:find("attach%( \"runtime_")==nil then
line = line:gsub("attach","equip")
end
new_str = new_str..line
end
end
loadstring(new_str)()
if self.data.nb_choice < 3 then
local ch = {}
local title = ""
if self.data.nb_choice==1 then
ch = {"challenge_light_travel","challenge_vampirism","challenge_impatience","challenge_doom","challenge_mercy","challenge_exalted"}
title = "Choose your modifier challenge"
else
ch = {"challenge_no_retreat","challenge_real_time","challenge_darkness","challenge_volatility"}
title = "Choose your modded challenge"
end
self.data.nb_choice = self.data.nb_choice + 1
local param = {
title = title,
fsize = 10,
size = coord( 40, 0 ),
}
for i,id in ipairs( ch ) do
param[i] = { desc = world:get_text(id, "desc"), name = world:get_text( id, "name" ), target = self, id = id, }
end
ui:terminal( entity, self, param )
end
return 0
end
]=],
},
}
register_blueprint "challenge_triple_angel"
{
text = {
name = "Angel of Trinity",
desc = "{!MEGA CHALLENGE PACK MOD}\nPlay three challenges at once! You choose them at the start of the run. Some challenges will only start on Callisto L2.\n\nRating : {RHARD}",
rating = "HARD",
abbr = "AoT",
letter = "T",
},
-- hack for new york reload challenge
on_create_entity = [=[
function( self, entity, alive )
local player = world:get_player()
nova.log("reload? "..tostring(self.data.reload_challenge))
if false and alive then
local id = world:get_id( entity )
if id == "summoner" or id == "exalted_summoner" then
entity.attributes.gate = 666
elseif id == "boss_damage_gate" then
entity.attributes.gate = 666
else
local w = entity:get_weapon()
if w and w.weapon and w.weapon.natural then
if not entity.inventory then
ecs:add( entity, "inventory" )
end
local ilvl = world:get_level().level_info.ilevel
local item
if math.random(10) == 1 then
item = core.lists.item.weapon:roll( ilvl )
else
item = core.lists.item.base_weapon:roll( ilvl )
end
if item then
entity:stash_item( item )
end
end
end
end
end
]=],
challenge = {
type = "challenge",
},
callbacks = {
on_create_player = [[
function( self, player )
player:attach( "runtime_triple_angel" )
end
]],
},
}