Commit b7ca338050324f0ca042eb9fdfaf4e452b849ad3

Authored by Chris Davidson
1 parent 6b95ddbf

Add a new "Endgamify" debug option

... ... @@ -678,6 +678,7 @@ newEntity{
678 678 unique = true,
679 679 type = "misc", subtype="egg",
680 680 unided_name = "dark egg",
  681 + define_as = "MUMMIFIED_EGGSAC",
681 682 name = "Mummified Egg-sac of Ungolë", image = "object/artifact/mummified_eggsack.png",
682 683 level_range = {20, 35},
683 684 rarity = 190,
... ...
... ... @@ -143,11 +143,210 @@ function _M:use(item)
143 143 game.player:sortInven()
144 144 end
145 145 end
  146 + elseif act == "endgamify" then
  147 + local NPC = require "mod.class.NPC"
  148 + local Chat = require "engine.Chat"
  149 + if game.player.endgamified then return end
  150 + game.player.endgamified = true
  151 + game.player.unused_generics = game.player.unused_generics + 2 -- Derth quest
  152 + game.player:forceLevelup(50)
  153 + game.player.money = 999999
  154 +
  155 + self:makeEndgameItems()
  156 + self:makeEndgameFixed()
  157 +
  158 + game.state:goneEast()
  159 + game.player:grantQuest("lost-merchant")
  160 + game.player:setQuestStatus("lost-merchant", engine.Quest.COMPLETED, "saved")
  161 +
  162 + -- Change the zone name each iteration so the quest id is different
  163 + local old_name = game.zone.short_name
  164 + for i = 1,5 do
  165 + game.zone.short_name = game.zone.short_name..i
  166 + game.player:grantQuest("escort-duty")
  167 + for _, e in pairs(game.level.entities) do
  168 + if e.quest_id then
  169 + -- Make giving the reward their first action so it happens after the dialogs are closed
  170 + e.act = function(self)
  171 + self.on_die = nil
  172 + game.player:setQuestStatus(self.quest_id, engine.Quest.DONE)
  173 + local Chat = require "engine.Chat"
  174 + Chat.new("escort-quest", self, game.player, {npc=self}):invoke()
  175 + self:disappear()
  176 + self:removed()
  177 + game.party:removeMember(self, true)
  178 + end
  179 + end
  180 + end
  181 + game.zone.short_name = old_name
  182 + end
146 183 else
147 184 self:triggerHook{"DebugMain:use", act=act}
148 185 end
149 186 end
150 187
  188 +-- {Rares, Randarts}
  189 +local endgame_items = {
  190 + ["voratun helm"] = {10,3},
  191 + ["voratun gauntlets"] = {5,2},
  192 + ["drakeskin leather gloves"] = {5,2},
  193 + ["voratun ring"] = {10,3},
  194 + ["voratun amulet"] = {5,2},
  195 + ["voratun mail armour"] = {5,4},
  196 + ["voratun plate armour"] = {5,4},
  197 + ["voratun helm"] = {10,3},
  198 + ["elven-silk cloak"] = {10,3},
  199 + ["dragonbone totem"] = {5,2},
  200 + ["voratun torque"] = {5,2},
  201 + ["dragonbone wand"] = {5,2},
  202 + ["voratun helm"] = {10,3},
  203 + ["voratun pickaxe"] = {5,2},
  204 + ["dwarven lantern"] = {5,2},
  205 + ["pair of drakeskin leather boots"] = {10,3},
  206 + ["drakeskin leather belt"] = {10,3},
  207 +}
  208 +
  209 +local endgame_class_items = {
  210 + ["Anorithil"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  211 + ["Sun Paladin"] = { ["voratun longsword"] = {10,3}, ["voratun greatsword"] = {10,3}, ["voratun shield"] = {10,3} },
  212 +
  213 + ["Cursed"] = { ["voratun longsword"] = {10,3}, ["voratun greatsword"] = {10,3}, ["living mindstar"] = {10,3}},
  214 + ["Doomed"] = {["living mindstar"] = {10,3}},
  215 +
  216 + ["Temporal Warden"] = {["voratun longsword"] = {10,3}, ["voratun dagger"] = {10,3}, ["quiver of dragonbone arrows"] = {10,3}, ["dragonbone longbow"] = {10,3},},
  217 + ["Paradox Mage"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  218 +
  219 + ["Corruptor"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  220 + ["Reaver"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4}, ["voratun longsword"] = {10,3},},
  221 +
  222 + ["Alchemist"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  223 + ["Archmage"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  224 + ["Necromancer"] = {["dragonbone staff"] = {10,3}, ["elven-silk robe"] = {5,4},},
  225 +
  226 + ["Mindslayer"] = {["voratun greatsword"] = {10,3}, ["living mindstar"] = {10,3}},
  227 + ["Solipsist"] = {["living mindstar"] = {10,3}},
  228 +
  229 + ["Rogue"] = {["voratun longsword"] = {10,3}, ["voratun dagger"] = {10,3}, ["drakeskin leather armour"] = {5,4},},
  230 + ["Shadowblade"] = {["voratun longsword"] = {10,3}, ["voratun dagger"] = {10,3}, ["drakeskin leather armour"] = {5,4}, },
  231 + ["Skirmisher"] = {["pouch of voratun shots"] = {10,3}, ["drakeskin leather sling"] = {10,3}, ["drakeskin leather armour"] = {5,4},},
  232 + ["Marauder"] = {["voratun longsword"] = {10,3}, ["drakeskin leather armour"] = {5,4}, ["voratun dagger"] = {10,3}},
  233 +
  234 + ["Arcane Blade"] = {["dragonbone staff"] = {10,3}, ["voratun longsword"] = {10,3}, ["voratun greatsword"] = {10,3}, ["voratun shield"] = {10,3}, ["voratun dagger"] = {10,3}},
  235 + ["Brawler"] = {["drakeskin leather armour"] = {5,4}, },
  236 + ["Bulwark"] = {["voratun longsword"] = {10,3}, ["voratun shield"] = {10,3}},
  237 + ["Berserker"] = {["voratun greatsword"] = {10,3}},
  238 + ["Archer"] = {["quiver of dragonbone arrows"] = {10,3}, ["pouch of voratun shots"] = {10,3}, ["dragonbone longbow"] = {10,3}, ["drakeskin leather sling"] = {10,3}, ["drakeskin leather armour"] = {5,4}, },
  239 +
  240 + ["Summoner"] = {["living mindstar"] = {10,3}},
  241 + ["Oozemancer"] = {["living mindstar"] = {10,3}},
  242 + ["Wyrmic"] = {["voratun longsword"] = {10,3}, ["voratun greatsword"] = {10,3}, ["voratun shield"] = {10,3}, ["living mindstar"] = {10,3}},
  243 + ["Stone Warden"] = {["voratun shield"] = {10,3}},
  244 +
  245 + ["Other"] = {
  246 + ["dragonbone staff"] = {10,3}, ["voratun longsword"] = {10,3}, ["dragonbone longbow"] = {10,3}, ["pouch of voratun shots"] = {10,3}, ["drakeskin leather armour"] = {5,4},
  247 + ["drakeskin leather sling"] = {10,3}, ["voratun greatsword"] = {10,3}, ["voratun shield"] = {10,3}, ["living mindstar"] = {10,3}, ["voratun dagger"] = {10,3},
  248 + ["quiver of dragonbone arrows"] = {10,3},
  249 + }, -- We don't know what we want, so create everything
  250 +}
  251 +
  252 +-- Fixedarts from quests or things that we can assume experienced players almost always get
  253 +local endgame_fixed_artifacts= {"ORB_ELEMENTS", "ORB_UNDEATH", "ORB_DESTRUCTION", "ORB_DRAGON", "RUNE_DISSIPATION", "INFUSION_WILD_GROWTH", "TAINT_PURGING", "RING_OF_BLOOD", "ELIXIR_FOUNDATIONS",
  254 + "SANDQUEEN_HEART", "PUTRESCENT_POTION", "ELIXIR_FOCUS", "MUMMIFIED_EGGSAC", "ORB_MANY_WAYS" }
  255 +function _M:makeEndgameItems(class, ilvl, filter)
  256 + local class_name = game.player.descriptor.subclass
  257 + local items = table.merge(table.clone(endgame_items), table.clone(endgame_class_items[class_name] or endgame_class_items["Other"]))
  258 + for base, amounts in pairs(items) do
  259 + table.print(amounts)
  260 + for i = 1, amounts[2] do
  261 + local base_object = game.zone:makeEntity(game.level, "object", {name=base, ignore_material_restriction=true, ego_filter={keep_egos=true, ego_chance=-1000}}, nil, true)
  262 +
  263 + local filter = {base=base_object, material_level = 5, lev=60}
  264 + local item = game.state:generateRandart(filter)
  265 + item.__transmo = true
  266 + item:identify(true)
  267 + game.zone:addEntity(game.level, item, "object")
  268 + game.player:addObject(game.player:getInven("INVEN"), item)
  269 + end
  270 + -- Create rares
  271 + for i = 1, amounts[1] do
  272 + local base_object = game.zone:makeEntity(game.level, "object", {name=base, ignore_material_restriction=true, ego_filter={keep_egos=true, ego_chance=-1000}}, nil, true)
  273 + local filter = {base=base_object, lev=60, egos=1, material_level = 5, greater_egos_bias = 0, power_points_factor = 3, nb_powers_add = 2, }
  274 + local item = game.state:generateRandart(filter)
  275 + item.unique, item.randart, item.rare = nil, nil, true
  276 + item.__transmo = true
  277 + item:identify(true)
  278 + game.zone:addEntity(game.level, item, "object")
  279 + game.player:addObject(game.player:getInven("INVEN"), item)
  280 + end
  281 +
  282 + end
  283 + return
  284 +end
  285 +
  286 +function _M:makeEndgameFixed()
  287 + local Object = require "mod.class.Object"
  288 +
  289 + local old_list = game.zone.object_list
  290 + local obj_list = table.clone(game.zone.object_list, true)
  291 + obj_list.ignore_loaded = true
  292 +
  293 + -- protected load of objects from a file
  294 + local function load_file(file, obj_list)
  295 + local ok, ret = xpcall(function()
  296 + Object:loadList(file, false, obj_list, nil, obj_list.__loaded_files)
  297 + end, debug.traceback)
  298 + if not ok then
  299 + game.log("#ORANGE# Create Object: Unable to load all objects from file %s:#GREY#\n %s", file, ret)
  300 + end
  301 + end
  302 + -- load all objects from a base directory
  303 + local function load_objects(base)
  304 + local file
  305 + file = base.."/general/objects/objects.lua"
  306 + if fs.exists(file) then load_file(file, obj_list) end
  307 +
  308 + file = base.."/general/objects/world-artifacts.lua"
  309 + if fs.exists(file) then load_file(file, obj_list) end
  310 +
  311 + file = base.."/general/objects/boss-artifacts.lua"
  312 + if fs.exists(file) then load_file(file, obj_list) end
  313 +
  314 + file = base.."/general/objects/quest-artifacts.lua"
  315 + if fs.exists(file) then load_file(file, obj_list) end
  316 +
  317 + file = base.."/general/objects/brotherhood-artifacts.lua"
  318 + if fs.exists(file) then load_file(file, obj_list) end
  319 +
  320 + if fs.exists(file) then load_file(file, obj_list) end
  321 + for i, dir in ipairs(fs.list(base.."/zones/")) do
  322 + file = base.."/zones/"..dir.."/objects.lua"
  323 + if dir ~= game.zone.short_name and fs.exists(file) and not dir:find("infinite%-dungeon") and not dir:find("noxious%-caldera") then
  324 + load_file(file, obj_list)
  325 + end
  326 + end
  327 + end
  328 +
  329 + -- load base global and zone objects
  330 + load_objects("/data", "")
  331 +
  332 + -- load all objects defined by addons (in standard directories)
  333 + for i, dir in ipairs(fs.list("/")) do
  334 + local _, _, addon = dir:find("^data%-(.+)$")
  335 + if addon then
  336 + load_objects("/"..dir)
  337 + end
  338 + end
  339 + game.zone.object_list = obj_list
  340 + for _, name in pairs(endgame_fixed_artifacts) do
  341 + local o = game.zone:makeEntityByName(game.level, "object", name)
  342 + if not o then game.log("Failed to generate "..name) break end
  343 + o:identify(true)
  344 + game.zone:addEntity(game.level, o, "object")
  345 + game.player:addObject(game.player:getInven("INVEN"), o)
  346 + end
  347 + game.zone.object_list = old_list
  348 +end
  349 +
151 350 -- Ideas:
152 351 -- force reload all shops
153 352 function _M:generateList()
... ... @@ -168,6 +367,7 @@ function _M:generateList()
168 367 list[#list+1] = {name="Give Sher'tul fortress energy", action="shertul-energy"}
169 368 list[#list+1] = {name="Give all ingredients", action="all-ingredients"}
170 369 list[#list+1] = {name="Weakdamage", action="weakdamage"}
  370 + list[#list+1] = {name="Endgamify", action="endgamify"}
171 371 self:triggerHook{"DebugMain:generate", menu=list}
172 372
173 373 local chars = {}
... ...