mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
add option to disable global perks and disable spells
This commit is contained in:
parent
96a770c65f
commit
abd3c321f6
6 changed files with 111 additions and 8 deletions
|
@ -135,6 +135,8 @@ pub struct GameSettings {
|
|||
no_material_damage: Option<bool>,
|
||||
global_hp_loss: Option<bool>,
|
||||
perk_ban_list: Option<String>,
|
||||
disabled_globals: Option<String>,
|
||||
spell_ban_list: Option<String>,
|
||||
physics_damage: Option<bool>,
|
||||
share_gold: Option<bool>,
|
||||
nice_terraforming: Option<bool>,
|
||||
|
@ -420,6 +422,35 @@ impl GameSettings {
|
|||
game_settings.give_host_sampo = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp = game_settings.enemy_hp_mult.unwrap_or(def.enemy_hp_mult);
|
||||
if ui
|
||||
.add(
|
||||
Slider::new(&mut temp, 1.0..=1000.0)
|
||||
.logarithmic(true)
|
||||
.text(tr("connect_settings_enemy_hp_scale")),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
game_settings.enemy_hp_mult = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.spell_ban_list
|
||||
.clone()
|
||||
.unwrap_or(def.spell_ban_list);
|
||||
ui.label("spell ban list, by internal names, comma seperated");
|
||||
if ui
|
||||
.add_sized(
|
||||
[ui.available_width() - 30.0, 20.0],
|
||||
egui::TextEdit::singleline(&mut temp),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
game_settings.spell_ban_list = Some(temp)
|
||||
}
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
ui.label("Player settings");
|
||||
ui.horizontal(|ui| {
|
||||
|
@ -478,7 +509,7 @@ impl GameSettings {
|
|||
.perk_ban_list
|
||||
.clone()
|
||||
.unwrap_or(def.perk_ban_list);
|
||||
ui.label("perk ban list, comma seperated");
|
||||
ui.label("perk ban list, by internal names, comma seperated");
|
||||
if ui
|
||||
.add_sized(
|
||||
[ui.available_width() - 30.0, 20.0],
|
||||
|
@ -490,16 +521,19 @@ impl GameSettings {
|
|||
}
|
||||
}
|
||||
{
|
||||
let mut temp = game_settings.enemy_hp_mult.unwrap_or(def.enemy_hp_mult);
|
||||
let mut temp = game_settings
|
||||
.disabled_globals
|
||||
.clone()
|
||||
.unwrap_or(def.disabled_globals);
|
||||
ui.label("global perks to ignore, by internal names, comma seperated, will cause undefined behaviour do not report issues, find list in perk_fns.lua");
|
||||
if ui
|
||||
.add(
|
||||
Slider::new(&mut temp, 1.0..=1000.0)
|
||||
.logarithmic(true)
|
||||
.text(tr("connect_settings_enemy_hp_scale")),
|
||||
.add_sized(
|
||||
[ui.available_width() - 30.0, 20.0],
|
||||
egui::TextEdit::singleline(&mut temp),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
game_settings.enemy_hp_mult = Some(temp)
|
||||
game_settings.disabled_globals = Some(temp)
|
||||
}
|
||||
}
|
||||
if ui.button(tr("apply_default_settings")).clicked() {
|
||||
|
@ -521,6 +555,8 @@ pub struct DefaultSettings {
|
|||
no_material_damage: bool,
|
||||
global_hp_loss: bool,
|
||||
perk_ban_list: String,
|
||||
disabled_globals: String,
|
||||
spell_ban_list: String,
|
||||
physics_damage: bool,
|
||||
share_gold: bool,
|
||||
nice_terraforming: bool,
|
||||
|
@ -554,6 +590,8 @@ impl Default for DefaultSettings {
|
|||
no_material_damage: false,
|
||||
global_hp_loss: false,
|
||||
perk_ban_list: String::new(),
|
||||
disabled_globals: String::new(),
|
||||
spell_ban_list: String::new(),
|
||||
physics_damage: true,
|
||||
share_gold: false,
|
||||
nice_terraforming: true,
|
||||
|
|
|
@ -969,6 +969,16 @@ impl NetManager {
|
|||
"perk_ban_list",
|
||||
lst.perk_ban_list.unwrap_or(def.perk_ban_list).as_str(),
|
||||
);
|
||||
state.try_ws_write_option(
|
||||
"spell_ban_list",
|
||||
lst.spell_ban_list.unwrap_or(def.spell_ban_list).as_str(),
|
||||
);
|
||||
state.try_ws_write_option(
|
||||
"disabled_globals",
|
||||
lst.disabled_globals
|
||||
.unwrap_or(def.disabled_globals)
|
||||
.as_str(),
|
||||
);
|
||||
state.try_ws_write_option(
|
||||
"disable_kummitus",
|
||||
settings.disable_kummitus.unwrap_or(def.disable_kummitus),
|
||||
|
|
|
@ -247,6 +247,17 @@ function perk_fns.update_perks_for_entity(perk_data, entity, allow_perk)
|
|||
-- util.set_ent_variable(entity, "ew_current_perks", perk_data)
|
||||
end
|
||||
|
||||
local function string_split(s, splitter)
|
||||
local words = {}
|
||||
if s == nil or splitter == nil or s == "" then
|
||||
return {}
|
||||
end
|
||||
for word in string.gmatch(s, "([^" .. splitter .. "]+)") do
|
||||
table.insert(words, word)
|
||||
end
|
||||
return words
|
||||
end
|
||||
|
||||
local first = true
|
||||
|
||||
function perk_fns.on_world_update()
|
||||
|
@ -268,6 +279,9 @@ function perk_fns.on_world_update()
|
|||
end
|
||||
end
|
||||
end
|
||||
for _, perk in ipairs(string_split(ctx.proxy_opt.disabled_globals, ",")) do
|
||||
global_perks[perk] = nil
|
||||
end
|
||||
first = false
|
||||
end
|
||||
if
|
||||
|
|
|
@ -81,7 +81,7 @@ end)
|
|||
|
||||
local function string_split(s, splitter)
|
||||
local words = {}
|
||||
if s == nil or splitter == nil then
|
||||
if s == nil or splitter == nil or s == "" then
|
||||
return {}
|
||||
end
|
||||
for word in string.gmatch(s, "([^" .. splitter .. "]+)") do
|
||||
|
|
27
quant.ew/files/system/spell_patches/banned_spells.lua
Normal file
27
quant.ew/files/system/spell_patches/banned_spells.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
local function string_split(s, splitter)
|
||||
local words = {}
|
||||
if s == nil or splitter == nil or s == "" then
|
||||
return {}
|
||||
end
|
||||
for word in string.gmatch(s, "([^" .. splitter .. "]+)") do
|
||||
table.insert(words, word)
|
||||
end
|
||||
return words
|
||||
end
|
||||
local t = string_split(CrossCall("ew_banned_spells"), ",")
|
||||
local old = GetRandomActionWithType
|
||||
function GetRandomActionWithType(...)
|
||||
local n = old
|
||||
while table.contains(t, n) do
|
||||
n = old
|
||||
end
|
||||
return n
|
||||
end
|
||||
old = GetRandomAction
|
||||
function GetRandomAction(...)
|
||||
local n = old
|
||||
while table.contains(t, n) do
|
||||
n = old
|
||||
end
|
||||
return n
|
||||
end
|
|
@ -16,4 +16,18 @@ util.copy_file_content(
|
|||
"data/scripts/projectiles/essence_to_power.lua"
|
||||
)
|
||||
|
||||
if ctx.proxy_opt.spell_ban_list ~= nil and ctx.proxy_opt.spell_ban_list ~= "" then
|
||||
util.add_cross_call("ew_banned_spells", function()
|
||||
return ctx.proxy_opt.spell_ban_list
|
||||
end)
|
||||
for _, file in ipairs({
|
||||
"data/scripts/perks/perk_list.lua",
|
||||
"data/scripts/items/generate_shop_item.lua",
|
||||
"data/scripts/gun/procedural/gun_procedural_better.lua",
|
||||
"data/scripts/gun/procedural/gun_procedural.lua",
|
||||
}) do
|
||||
ModLuaFileAppend(file, "mods/quant.ew/files/system/spell_patches/banned_spells.lua")
|
||||
end
|
||||
end
|
||||
|
||||
return {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue