Commit dbb550c090c25be69f83d0dd1ed19aa226263063

Authored by DarkGod
1 parent 14b50d9c

Caldera/Sludgenest/Conclave vaults (and Scoure Pits in Forbidden Cults) are now …

…mutualy exclusive, only one will exist per game. But one will always exist. In addition the racial 100% chance will only exist until the relevant unlock is gained
... ... @@ -330,6 +330,7 @@ function _M:newGame()
330 330 self.creating_player = false
331 331
332 332 birth_done()
  333 + self.state:selectBonusZone()
333 334 self.player:check("on_birth_done")
334 335 self:setTacticalMode(self.always_target)
335 336 self:triggerHook{"ToME:birthDone"}
... ... @@ -2887,6 +2888,10 @@ function _M:takeScreenshot(for_savefile)
2887 2888 end
2888 2889 end
2889 2890
  2891 +function _M:isAllowedBuild(what)
  2892 + return profile.mod.allow_build[what]
  2893 +end
  2894 +
2890 2895 function _M:setAllowedBuild(what, notify)
2891 2896 -- Do not unlock things in easy mode
2892 2897 --if self.difficulty == self.DIFFICULTY_EASY then return end
... ...
... ... @@ -3820,3 +3820,33 @@ function _M:unlockTalentCheck(tid, who)
3820 3820 end
3821 3821 return false, self.unlocked_talents[tid]
3822 3822 end
  3823 +
  3824 +--- Get a list of possible "bonus zones" and pick at most one of them, to combat zone bloat
  3825 +-- Bonus zones need to be implemented as an event for a zone (usualy "wilderness" but not required)
  3826 +function _M:selectBonusZone()
  3827 + local always_list, list = {}, {}
  3828 +
  3829 + local function add(campaign, zone, event, level_range, always_cond)
  3830 + if not game:getPlayer(true):hasDescriptor("world", campaign) then return end
  3831 + if always_cond and always_cond() then always_list[#always_list+1] = {zone=zone, event=event, level_range=level_range}
  3832 + else list[#list+1] = {zone=zone, event=event, level_range=level_range} end
  3833 + end
  3834 +
  3835 + -- always spawn noxious-caldera for Yeeks until the unlock isn't needed anymore
  3836 + add("Maj'Eyal", "wilderness", "noxious-caldera", nil, function() return not game:isAllowedBuild("psionic_solipsist") and game:getPlayer(true):hasDescriptor("race", "Yeek") end)
  3837 + -- always spawn sludgenest for Thalore until the unlock isn't needed anymore
  3838 + add("Maj'Eyal", "wilderness", "sludgenest", nil, function() return not game:isAllowedBuild("wilder_oozemancer") and game:getPlayer(true):hasDescriptor("subrace", "Thalore") end)
  3839 + -- always spawn conclave-vault event for Shalore until the unlock isn't needed anymore
  3840 + add("Maj'Eyal", "halfling-ruins", "conclave-vault", {3, 3}, function() return not game:isAllowedBuild("race_ogre") and game:getPlayer(true):hasDescriptor("subrace", "Shalore") end)
  3841 +
  3842 + -- list and always_list are provided for weird corner cases, DO NOT USE THEM unless you *reallllllllllllllllllllly* need to
  3843 + self:triggerHook{"GameState:bonusZone", add=add, list=list, always_list=always_list}
  3844 +
  3845 + if #always_list > 0 then
  3846 + self.selected_bonus_zone = rng.table(always_list)
  3847 + print("[GameState] Selected bonus zone for always condition", self.selected_bonus_zone.zone, self.selected_bonus_zone.event, table.serialize(self.selected_bonus_zone.level_range or {}))
  3848 + elseif #list > 0 then
  3849 + self.selected_bonus_zone = rng.table(list)
  3850 + print("[GameState] Selected bonus zone for normal condition", self.selected_bonus_zone.zone, self.selected_bonus_zone.event, table.serialize(self.selected_bonus_zone.level_range or {}))
  3851 + end
  3852 +end
... ...
... ... @@ -67,6 +67,10 @@ function _M:onLoadZoneFile(basedir)
67 67 self:triggerHook{"Zone:loadEvents", zone=self.short_name, events=evts}
68 68 if next(evts) then self.events = evts end
69 69 end
  70 + if game.state.selected_bonus_zone and game.state.selected_bonus_zone.zone == self.short_name then
  71 + if not self.events then self.events = {} end
  72 + table.insert(self.events, {name=game.state.selected_bonus_zone.event, level_range=game.state.selected_bonus_zone.level_range, minor=true, percent=100})
  73 + end
70 74 end
71 75
72 76 --- Make it work for high levels
... ...
... ... @@ -22,8 +22,4 @@ return { one_per_level=true,
22 22 {name="protective-aura", minor=true, percent=50},
23 23 {name="necrotic-air", minor=true, percent=50},
24 24 {name="glowing-chest", minor=true, percent=20},
25   - {name="conclave-vault", level_range={3, 3},
26   - -- always spawn conclave-vault event for Shalore
27   - percent=(table.get(game:getPlayer(true), "descriptor", "subrace") == "Shalore" and 100 or 30)
28   - }
29 25 }
... ...
... ... @@ -17,11 +17,5 @@
17 17 -- Nicolas Casalini "DarkGod"
18 18 -- darkgod@te4.org
19 19
20   -local descriptor = table.get(game:getPlayer(true), "descriptor")
21   -
22 20 return {
23   - -- always spawn noxious-caldera for Yeeks (event file does additional tests)
24   - {name="noxious-caldera", percent=(table.get(descriptor, "race") == "Yeek" and 100 or 30)},
25   - -- always spawn sludgenest for Thalore (event file does additional tests)
26   - {name="sludgenest", percent=(table.get(descriptor, "subrace") == "Thalore" and 100 or 30)},
27 21 }
... ...