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