mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
fix notplayer with friendly fire probably, make fish and worm sync nicer
This commit is contained in:
parent
edda7cd5f9
commit
495481e0d3
8 changed files with 96 additions and 34 deletions
16
noita-proxy/Cargo.lock
generated
16
noita-proxy/Cargo.lock
generated
|
@ -295,9 +295,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.18.0"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae"
|
||||
checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
@ -380,9 +380,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.29"
|
||||
version = "1.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58e804ac3194a48bb129643eb1d62fcc20d18c6b8c181704489353d13120bcd1"
|
||||
checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
@ -1469,9 +1469,9 @@ checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946"
|
|||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.4.1"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05"
|
||||
checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
|
@ -2863,9 +2863,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55"
|
||||
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-platform-verifier"
|
||||
|
|
|
@ -1022,7 +1022,7 @@ impl eframe::App for App {
|
|||
|
||||
ui.checkbox(&mut self.app_saved_state.show_extra_debug_stuff, tr("Show-debug-info"));
|
||||
ui.add_space(15.0);
|
||||
if self.app_saved_state.game_settings.friendly_fire {
|
||||
if self.app_saved_state.game_settings.friendly_fire || netman.settings.lock().map(|a| a.friendly_fire).unwrap_or(false) {
|
||||
let last = self.app_saved_state.game_settings.friendly_fire_team;
|
||||
ui.add(Slider::new(&mut self.app_saved_state.game_settings.friendly_fire_team, -1..=16));
|
||||
if last != self.app_saved_state.game_settings.friendly_fire_team {
|
||||
|
|
|
@ -453,10 +453,16 @@ impl NetManager {
|
|||
} else {
|
||||
info!("No nickname chosen");
|
||||
}
|
||||
if let Ok(mut set) = self.settings.lock() {
|
||||
state.try_ws_write_option(
|
||||
"friendly_fire_team",
|
||||
(settings.friendly_fire_team + 1) as u32,
|
||||
(set.friendly_fire_team + 1) as u32,
|
||||
);
|
||||
if settings.friendly_fire {
|
||||
set.friendly_fire = true
|
||||
}
|
||||
}
|
||||
state.try_ws_write_option("friendly_fire", settings.friendly_fire);
|
||||
state.try_ws_write_option("debug", settings.debug_mode);
|
||||
state.try_ws_write_option("world_sync_version", settings.world_sync_version);
|
||||
state.try_ws_write_option("player_tether", settings.player_tether);
|
||||
|
@ -466,7 +472,6 @@ impl NetManager {
|
|||
state.try_ws_write_option("enemy_hp_scale", settings.enemy_hp_mult);
|
||||
state.try_ws_write_option("world_sync_interval", settings.world_sync_interval);
|
||||
state.try_ws_write_option("game_mode", settings.game_mode);
|
||||
state.try_ws_write_option("friendly_fire", settings.friendly_fire);
|
||||
state.try_ws_write_option("chunk_target", settings.chunk_target);
|
||||
state.try_ws_write_option("health_per_player", settings.health_per_player);
|
||||
state.try_ws_write_option("enemy_sync_interval", settings.enemy_sync_interval);
|
||||
|
|
|
@ -266,6 +266,14 @@ function util.make_type(typedata)
|
|||
inner = inner .. "unsigned int "..var..";\n"
|
||||
end
|
||||
|
||||
for _, var in ipairs(typedata.bool or {}) do
|
||||
inner = inner .. "bool "..var..";\n"
|
||||
end
|
||||
|
||||
for _, var in ipairs(typedata.string or {}) do
|
||||
inner = inner .. "const char* "..var..";\n"
|
||||
end
|
||||
|
||||
ffi.cdef([[
|
||||
#pragma pack(push, 1)
|
||||
typedef struct ]] .. name .. [[{
|
||||
|
|
|
@ -11,20 +11,42 @@ local rpc = net.new_rpc_namespace()
|
|||
|
||||
local EnemyData = util.make_type({
|
||||
u32 = {"enemy_id"},
|
||||
f32 = {"x", "y", "vx", "vy", "rot"},
|
||||
f32 = {"x", "y", "vx", "vy"},
|
||||
})
|
||||
|
||||
-- Variant of EnemyData for when we don't have any motion (or no VelocityComponent).
|
||||
local EnemyDataNoMotion = util.make_type({
|
||||
u32 = {"enemy_id"},
|
||||
f32 = {"x", "y", "rot"}
|
||||
f32 = {"x", "y"}
|
||||
})
|
||||
|
||||
local EnemyDataWorm = util.make_type({
|
||||
u32 = {"enemy_id"},
|
||||
f32 = {"x", "y", "vx", "vy", "tx", "ty"},
|
||||
})
|
||||
|
||||
local EnemyDataFish = util.make_type({
|
||||
u32 = {"enemy_id"},
|
||||
f32 = {"x", "y", "vx", "vy"},
|
||||
u8 = {"r"}
|
||||
})
|
||||
|
||||
--local EnemyDataSniper = util.make_type({
|
||||
-- u32 = {"enemy_id"},
|
||||
-- f32 = {"x", "y", "vx", "vy"},
|
||||
-- bool = {"aiming"},
|
||||
--})
|
||||
|
||||
local HpData = util.make_type({
|
||||
u32 = {"enemy_id"},
|
||||
f32 = {"hp", "max_hp"}
|
||||
})
|
||||
|
||||
--local HpDataMom = util.make_type({
|
||||
-- u32 = {"enemy_id"},
|
||||
-- f32 = {"hp", "max_hp", "hp1", "hp2", "hp3", "hp4"}
|
||||
--})
|
||||
|
||||
local FULL_TURN = math.pi * 2
|
||||
|
||||
local PhysData = util.make_type({
|
||||
|
@ -236,21 +258,40 @@ function enemy_sync.host_upload_entities()
|
|||
-- end
|
||||
|
||||
local en_data
|
||||
if math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
||||
en_data= EnemyDataNoMotion {
|
||||
enemy_id = enemy_id,
|
||||
x = x,
|
||||
y = y,
|
||||
rot = rot,
|
||||
}
|
||||
else
|
||||
en_data= EnemyData {
|
||||
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
||||
if worm ~= nil then
|
||||
local tx, ty = ComponentGetValue2(worm, "mRandomTarget")
|
||||
en_data = EnemyDataWorm {
|
||||
enemy_id = enemy_id,
|
||||
x = x,
|
||||
y = y,
|
||||
vx = vx,
|
||||
vy = vy,
|
||||
tx = tx,
|
||||
ty = ty,
|
||||
}
|
||||
elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
||||
en_data = EnemyDataNoMotion {
|
||||
enemy_id = enemy_id,
|
||||
x = x,
|
||||
y = y,
|
||||
}
|
||||
elseif EntityGetFirstComponentIncludingDisabled(enemy_id, "AdvancedFishAIComponent") ~= nil then
|
||||
en_data = EnemyDataFish {
|
||||
enemy_id = enemy_id,
|
||||
x = x,
|
||||
y = y,
|
||||
vx = vx,
|
||||
vy = vy,
|
||||
r = math.floor((rot % FULL_TURN) / FULL_TURN * 255),
|
||||
}
|
||||
else
|
||||
en_data = EnemyData {
|
||||
enemy_id = enemy_id,
|
||||
x = x,
|
||||
y = y,
|
||||
vx = vx,
|
||||
vy = vy,
|
||||
rot = rot,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -383,7 +424,6 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
|||
local dont_cull = enemy_info_raw[9]
|
||||
local remote_enemy_id = en_data.enemy_id
|
||||
local x, y = en_data.x, en_data.y
|
||||
local rot = en_data.rot
|
||||
if not force_no_cull and not dont_cull then
|
||||
local my_x, my_y = EntityGetTransform(ctx.my_player.entity)
|
||||
if my_x == nil then
|
||||
|
@ -407,7 +447,7 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
|||
end
|
||||
local vx = 0
|
||||
local vy = 0
|
||||
if ffi.typeof(en_data) == EnemyData then
|
||||
if ffi.typeof(en_data) ~= EnemyDataNoMotion then
|
||||
vx, vy = en_data.vx, en_data.vy
|
||||
end
|
||||
local not_ephemerial = enemy_info_raw[3]
|
||||
|
@ -527,7 +567,16 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
|||
if velocity_data ~= nil then
|
||||
ComponentSetValue2(velocity_data, "mVelocity", vx, vy)
|
||||
end
|
||||
EntitySetTransform(enemy_id, x, y, rot)
|
||||
if ffi.typeof(en_data) == EnemyDataFish then
|
||||
EntitySetTransform(enemy_id, x, y, en_data.r / 255 * FULL_TURN)
|
||||
else
|
||||
EntitySetTransform(enemy_id, x, y)
|
||||
end
|
||||
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
||||
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
||||
local tx, ty = en_data.tx, en_data.ty
|
||||
ComponentSetValue2(worm, "mRandomTarget", tx, ty)
|
||||
end
|
||||
end
|
||||
|
||||
local inv = EntityGetFirstComponentIncludingDisabled(enemy_id, "Inventory2Component")
|
||||
|
|
|
@ -42,6 +42,7 @@ end
|
|||
|
||||
content = add_new_genome("notplayer", 1000, 1000, 1000, {
|
||||
player = -1000,
|
||||
player_pvp = -1000,
|
||||
})
|
||||
|
||||
content = add_new_genome("player_pvp", 0, 0, 0, {
|
||||
|
|
|
@ -6,8 +6,7 @@ function HasFlagPersistent(flag)
|
|||
end
|
||||
if CrossCall ~= nil then
|
||||
return CrossCall("ew_has_flag", flag)
|
||||
else
|
||||
end
|
||||
print("the flag, " .. flag .. " is not being called in a synced way")
|
||||
return old(flag)
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ function rpc.player_update(input_data, pos_data, current_slot, team)
|
|||
end
|
||||
local player_data = player_fns.peer_get_player_data(peer_id)
|
||||
|
||||
if team ~= nil and not GameHasFlagRun("ending_game_completed") then
|
||||
if team ~= nil and not GameHasFlagRun("ending_game_completed") and not EntityHasTag(player_data.entity, "ew_notplayer") then
|
||||
local my_team = ctx.proxy_opt.friendly_fire_team - 1
|
||||
if my_team ~= -1 and team ~= -1 and (team == 0 or my_team == 0 or team ~= my_team) then
|
||||
GenomeSetHerdId(player_data.entity, "player_pvp")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue