Mutators: little style changes
This commit is contained in:
parent
a79d879de0
commit
f6c62a949a
3 changed files with 41 additions and 40 deletions
|
@ -4,40 +4,40 @@
|
|||
local vmf = get_mod("VMF")
|
||||
|
||||
-- List of all die types
|
||||
local missions = {
|
||||
local MISSIONS = {
|
||||
"bonus_dice_hidden_mission",
|
||||
"tome_bonus_mission",
|
||||
"grimoire_hidden_mission"
|
||||
}
|
||||
|
||||
-- Amounts of additional dice to be added at level completion
|
||||
local num_dice_per_mission = {
|
||||
local _num_dice_per_mission = {
|
||||
bonus_dice_hidden_mission = 0,
|
||||
tome_bonus_mission = 0,
|
||||
grimoire_hidden_mission = 0
|
||||
}
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Local functions ##############################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Local functions ###############################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
-- Adds/remove dice
|
||||
local function adjustDice(grims, tomes, bonus, multiplier)
|
||||
if grims then
|
||||
num_dice_per_mission.grimoire_hidden_mission = num_dice_per_mission.grimoire_hidden_mission + grims * multiplier
|
||||
_num_dice_per_mission.grimoire_hidden_mission = _num_dice_per_mission.grimoire_hidden_mission + grims * multiplier
|
||||
end
|
||||
if tomes then
|
||||
num_dice_per_mission.tome_bonus_mission = num_dice_per_mission.tome_bonus_mission + tomes * multiplier
|
||||
_num_dice_per_mission.tome_bonus_mission = _num_dice_per_mission.tome_bonus_mission + tomes * multiplier
|
||||
end
|
||||
if bonus then
|
||||
num_dice_per_mission.bonus_dice_hidden_mission = num_dice_per_mission.bonus_dice_hidden_mission + bonus *
|
||||
multiplier
|
||||
_num_dice_per_mission.bonus_dice_hidden_mission = _num_dice_per_mission.bonus_dice_hidden_mission + bonus *
|
||||
multiplier
|
||||
end
|
||||
end
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Hooks ########################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Hooks #########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
vmf:hook("GameModeManager.complete_level", function(func, ...)
|
||||
local num_dice = 0
|
||||
|
@ -46,8 +46,8 @@ vmf:hook("GameModeManager.complete_level", function(func, ...)
|
|||
local active_mission = mission_system.active_missions
|
||||
|
||||
-- Add additional dice
|
||||
for _, mission in ipairs(missions) do
|
||||
for _ = 1, num_dice_per_mission[mission] do
|
||||
for _, mission in ipairs(MISSIONS) do
|
||||
for _ = 1, _num_dice_per_mission[mission] do
|
||||
mission_system:request_mission(mission, nil, Network.peer_id())
|
||||
mission_system:update_mission(mission, true, nil, Network.peer_id(), nil, true)
|
||||
end
|
||||
|
@ -55,13 +55,13 @@ vmf:hook("GameModeManager.complete_level", function(func, ...)
|
|||
|
||||
-- Get total number of dice
|
||||
for name, obj in pairs(active_mission) do
|
||||
if table.contains(missions, name) then
|
||||
if table.contains(MISSIONS, name) then
|
||||
num_dice = num_dice + obj.current_amount
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove excess dice
|
||||
for _, mission in ipairs(missions) do
|
||||
for _, mission in ipairs(MISSIONS) do
|
||||
if active_mission[mission] then
|
||||
for _ = 1, active_mission[mission].current_amount do
|
||||
if num_dice > max_dice then
|
||||
|
@ -77,9 +77,9 @@ vmf:hook("GameModeManager.complete_level", function(func, ...)
|
|||
func(...)
|
||||
end)
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Return #######################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Return ########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
return {
|
||||
addDice = function(dice)
|
||||
|
|
|
@ -5,9 +5,9 @@ local vmf = get_mod("VMF")
|
|||
|
||||
local _were_enabled_before = false
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Local functions ##############################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Local functions ###############################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
-- Assembles a list of enabled mutators
|
||||
local function add_enabled_mutators_titles_to_string(separator, is_short)
|
||||
|
@ -52,9 +52,9 @@ local function get_peer_id_from_cookie(client_cookie)
|
|||
return string.match(client_cookie, "%[(.-)%]")
|
||||
end
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Hooks ########################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Hooks #########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
-- Append difficulty name with enabled mutators' titles
|
||||
vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self)
|
||||
|
@ -100,8 +100,8 @@ vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func,
|
|||
func(self, sender, client_cookie, ...)
|
||||
end)
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Return #######################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Return ########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
return set_lobby_data
|
|
@ -32,9 +32,9 @@ local _default_config = vmf:dofile("scripts/mods/vmf/modules/core/mutators/mutat
|
|||
-- List of enabled mutators in case VMF is reloaded in the middle of the game
|
||||
local _enabled_mutators = vmf:persistent_table("enabled_mutators")
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Local functions ##############################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Local functions ###############################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
local function get_index(tbl, o)
|
||||
for i, v in ipairs(tbl) do
|
||||
|
@ -357,9 +357,9 @@ local function initialize_mutator_config(mutator, _raw_config)
|
|||
update_mutators_sequence(mutator)
|
||||
end
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### VMF internal functions and variables #########################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### VMF internal functions and variables ##########################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
vmf.mutators = _mutators
|
||||
|
||||
|
@ -481,6 +481,7 @@ function vmf.is_mutator_enabled(mutator_name)
|
|||
return _enabled_mutators[mutator_name]
|
||||
end
|
||||
|
||||
|
||||
-- Removes all raw_configs which won't be used anymore
|
||||
function vmf.mutators_delete_raw_config()
|
||||
for _, mutator in ipairs(_mutators) do
|
||||
|
@ -488,18 +489,18 @@ function vmf.mutators_delete_raw_config()
|
|||
end
|
||||
end
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Hooks ########################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Hooks #########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
vmf:hook("DifficultyManager.set_difficulty", function(func, ...)
|
||||
func(...)
|
||||
disable_impossible_mutators(true, "disabled_reason_difficulty_change")
|
||||
end)
|
||||
|
||||
-- ####################################################################################################################
|
||||
-- ##### Script #######################################################################################################
|
||||
-- ####################################################################################################################
|
||||
-- #####################################################################################################################
|
||||
-- ##### Script ########################################################################################################
|
||||
-- #####################################################################################################################
|
||||
|
||||
-- Testing
|
||||
--vmf:dofile("scripts/mods/vmf/modules/core/mutators/test/mutators_test")
|
Loading…
Add table
Reference in a new issue