Skip to content

Commit

Permalink
add option to duplicate entities
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Feb 2, 2025
1 parent 1e8a6d9 commit bfb0808
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
14 changes: 8 additions & 6 deletions noita-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct GameSettings {
world_num: u16,
debug_mode: Option<bool>,
use_constant_seed: bool,
// item_dedup: Option<bool>, TODO
duplicate: Option<bool>,
enemy_hp_mult: Option<f32>,
game_mode: Option<GameMode>,
friendly_fire: Option<bool>,
Expand Down Expand Up @@ -236,15 +236,15 @@ impl GameSettings {
ui.add(DragValue::new(&mut game_settings.seed));
}
});
/*{
let mut temp = game_settings.item_dedup.unwrap_or(def.item_dedup);
{
let mut temp = game_settings.duplicate.unwrap_or(def.duplicate);
if ui
.checkbox(&mut temp, tr("connect_settings_item_dedup"))
.checkbox(&mut temp, "duplicate synced entities")
.changed()
{
game_settings.item_dedup = Some(temp)
game_settings.duplicate = Some(temp)
}
}TODO*/
}
{
let mut temp = game_settings
.nice_terraforming
Expand Down Expand Up @@ -355,6 +355,7 @@ pub struct DefaultSettings {
share_gold: bool,
nice_terraforming: bool,
same_loadout: bool,
duplicate: bool,
}

impl Default for DefaultSettings {
Expand All @@ -378,6 +379,7 @@ impl Default for DefaultSettings {
share_gold: false,
nice_terraforming: true,
same_loadout: false,
duplicate: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions noita-proxy/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ impl NetManager {
);
state.try_ws_write_option("debug", settings.debug_mode.unwrap_or(def.debug_mode));
// state.try_ws_write_option("item_dedup", settings.item_dedup.unwrap_or(def.item_dedup)); TODO
state.try_ws_write_option("duplicate", settings.duplicate.unwrap_or(def.duplicate));
state.try_ws_write_option(
"randomize_perks",
settings.randomize_perks.unwrap_or(def.randomize_perks),
Expand Down
2 changes: 1 addition & 1 deletion quant.ew/files/system/local_health/local_health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -769,4 +769,4 @@ function rpc.switch_effect(x, y, to_normal_player)
end
end

return module
return module
4 changes: 2 additions & 2 deletions quant.ew/files/system/stevari/stevari.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ function rpc.request_flag_slow(x, y)
local flag = "ew_spawn_stevari" .. ":" .. math.floor(x / 512) .. ":" .. math.floor(y / 512)
local res = GameHasFlagRun(flag)
GameAddFlagRun(flag)
rpc.got_flag_slow(ctx.rpc_peer_id, res, x, y)
rpc.got_flag_slow(ctx.rpc_peer_id, not res or ctx.proxy_opt.duplicate, x, y)
end
end

rpc.opts_reliable()
rpc.opts_everywhere()
function rpc.got_flag_slow(peer_id, state, x, y)
if peer_id == ctx.my_id and not state then
if peer_id == ctx.my_id and state then
rpc.spawn_stevari(x, y)
end
end
Expand Down
12 changes: 6 additions & 6 deletions quant.ew/files/system/uniq_flags/uniq_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function rpc.request_flag(flag)
if ctx.is_host then
local res = GameHasFlagRun(flag)
GameAddFlagRun(flag)
rpc.got_flag(flag, ctx.rpc_peer_id, not res)
rpc.got_flag(flag, ctx.rpc_peer_id, not res or ctx.proxy_opt.duplicate)
end
end

Expand Down Expand Up @@ -42,7 +42,7 @@ function rpc.request_flag_slow(flag, ent)
if ctx.is_host then
local res = GameHasFlagRun(flag)
GameAddFlagRun(flag)
rpc.got_flag_slow(ctx.rpc_peer_id, res, ent)
rpc.got_flag_slow(ctx.rpc_peer_id, not res or ctx.proxy_opt.duplicate, ent)
end
end

Expand All @@ -51,9 +51,9 @@ rpc.opts_everywhere()
function rpc.got_flag_slow(peer_id, state, ent)
if peer_id == ctx.my_id then
if state then
EntityKill(ent)
else
ewext.track(ent)
else
EntityKill(ent)
end
end
end
Expand Down Expand Up @@ -114,14 +114,14 @@ function rpc.request_moon_flag_slow(x, y, dark)
local flag = "ew_moon_spawn" .. ":" .. math.floor(x / 512) .. ":" .. math.floor(y / 512)
local res = GameHasFlagRun(flag)
GameAddFlagRun(flag)
rpc.got_flag_moon_slow(ctx.rpc_peer_id, res, x, y, dark)
rpc.got_flag_moon_slow(ctx.rpc_peer_id, not res or ctx.proxy_opt.duplicate, x, y, dark)
end
end

rpc.opts_reliable()
rpc.opts_everywhere()
function rpc.got_flag_moon_slow(peer_id, state, x, y, dark)
if peer_id == ctx.my_id and not state then
if peer_id == ctx.my_id and state then
if dark then
EntityLoad("data/entities/items/pickup/sun/newsun_dark.xml", x, y)
else
Expand Down
3 changes: 2 additions & 1 deletion quant.ew/files/system/wang_hooks/wang_hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ local allow_patching = {
spawn_bones = {},
spawn_barricade = {},
spawn_rock = {},
spawn_scorpions = {},
}

local current_file
Expand Down Expand Up @@ -242,4 +243,4 @@ end

util.add_cross_call("ew_sync_pixel_scene", rpc.sync_pixel_scene)

return module
return module

0 comments on commit bfb0808

Please sign in to comment.