mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
spectate self when died in pvp, dont show player arrows of players not in same biome in pvp, fix pvp teleportation effect maybe
This commit is contained in:
parent
a60293e97b
commit
d95d6ec508
8 changed files with 115 additions and 79 deletions
|
@ -722,8 +722,8 @@ impl LocalDiffModel {
|
|||
EntitySpawnInfo::Filename(entity.filename()?)
|
||||
}
|
||||
_ => EntitySpawnInfo::Serialized {
|
||||
serialized_at: game_get_frame_num()?,
|
||||
data: serialize_entity(entity)?,
|
||||
//serialized_at: game_get_frame_num()?,
|
||||
data: serialize_entity(entity)?, //TODO we never update this?
|
||||
},
|
||||
};
|
||||
with_entity_scripts(entity, |scripts| {
|
||||
|
@ -2127,7 +2127,7 @@ fn spawn_entity_by_data(entity_data: &EntitySpawnInfo, x: f32, y: f32) -> eyre::
|
|||
Ok(ent)
|
||||
}
|
||||
EntitySpawnInfo::Serialized {
|
||||
serialized_at: _,
|
||||
//serialized_at: _,
|
||||
data,
|
||||
} => deserialize_entity(data, x, y),
|
||||
}
|
||||
|
|
|
@ -202,67 +202,71 @@ impl GameSettings {
|
|||
game_settings.health_per_player = Some(temp)
|
||||
}
|
||||
}
|
||||
GameMode::LocalHealth(mode) => {
|
||||
ui.label(tr("local_health_desc_1"));
|
||||
match mode {
|
||||
LocalHealthMode::Normal => {
|
||||
ui.add_space(5.0);
|
||||
ui.label(tr("Health-percent-lost-on-reviving"));
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.health_lost_on_revive
|
||||
.unwrap_or(def.health_lost_on_revive);
|
||||
if ui.add(Slider::new(&mut temp, 0..=100)).changed() {
|
||||
game_settings.health_lost_on_revive = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
|
||||
if ui.checkbox(&mut temp, tr("global_hp_loss")).changed() {
|
||||
game_settings.global_hp_loss = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.no_material_damage
|
||||
.unwrap_or(def.no_material_damage);
|
||||
if ui.checkbox(&mut temp, tr("no_material_damage")).changed() {
|
||||
game_settings.no_material_damage = Some(temp)
|
||||
}
|
||||
}
|
||||
ui.add_space(1.0);
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.physics_damage.unwrap_or(def.physics_damage);
|
||||
if ui.checkbox(&mut temp, tr("physics_damage")).changed() {
|
||||
game_settings.physics_damage = Some(temp)
|
||||
}
|
||||
GameMode::LocalHealth(mode) => match mode {
|
||||
LocalHealthMode::Normal => {
|
||||
ui.label(tr("local_health_desc_1"));
|
||||
ui.add_space(5.0);
|
||||
ui.label(tr("Health-percent-lost-on-reviving"));
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.health_lost_on_revive
|
||||
.unwrap_or(def.health_lost_on_revive);
|
||||
if ui.add(Slider::new(&mut temp, 0..=100)).changed() {
|
||||
game_settings.health_lost_on_revive = Some(temp)
|
||||
}
|
||||
}
|
||||
LocalHealthMode::Alternate => {
|
||||
ui.add_space(5.0);
|
||||
ui.label(tr("Health-percent-lost-on-reviving"));
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.health_lost_on_revive
|
||||
.unwrap_or(def.health_lost_on_revive);
|
||||
if ui.add(Slider::new(&mut temp, 0..=100)).changed() {
|
||||
game_settings.health_lost_on_revive = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
|
||||
if ui.checkbox(&mut temp, tr("global_hp_loss")).changed() {
|
||||
game_settings.global_hp_loss = Some(temp)
|
||||
}
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
|
||||
if ui.checkbox(&mut temp, tr("global_hp_loss")).changed() {
|
||||
game_settings.global_hp_loss = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.no_material_damage
|
||||
.unwrap_or(def.no_material_damage);
|
||||
if ui.checkbox(&mut temp, tr("no_material_damage")).changed() {
|
||||
game_settings.no_material_damage = Some(temp)
|
||||
}
|
||||
}
|
||||
ui.add_space(1.0);
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.physics_damage.unwrap_or(def.physics_damage);
|
||||
if ui.checkbox(&mut temp, tr("physics_damage")).changed() {
|
||||
game_settings.physics_damage = Some(temp)
|
||||
}
|
||||
}
|
||||
LocalHealthMode::PermaDeath => {}
|
||||
LocalHealthMode::PvP => {}
|
||||
}
|
||||
}
|
||||
LocalHealthMode::Alternate => {
|
||||
ui.label(tr("local_health_desc_1"));
|
||||
ui.add_space(5.0);
|
||||
ui.label(tr("Health-percent-lost-on-reviving"));
|
||||
{
|
||||
let mut temp = game_settings
|
||||
.health_lost_on_revive
|
||||
.unwrap_or(def.health_lost_on_revive);
|
||||
if ui.add(Slider::new(&mut temp, 0..=100)).changed() {
|
||||
game_settings.health_lost_on_revive = Some(temp)
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut temp =
|
||||
game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
|
||||
if ui.checkbox(&mut temp, tr("global_hp_loss")).changed() {
|
||||
game_settings.global_hp_loss = Some(temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
LocalHealthMode::PermaDeath => {
|
||||
ui.label(tr("local_health_desc_1"));
|
||||
}
|
||||
|
||||
LocalHealthMode::PvP => {
|
||||
ui.label("round based pvp mode");
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
|
|
|
@ -27,6 +27,7 @@ ctx.init = function()
|
|||
ctx.is_paused = false
|
||||
ctx.host_frame_num = 0
|
||||
ctx.is_texting = false
|
||||
ctx.stop_cam = false
|
||||
end
|
||||
|
||||
local function is_measure_perf_enabled()
|
||||
|
|
|
@ -10,6 +10,7 @@ local IGNORE_EFFECTS = {
|
|||
POLYMORPH_CESSATION = true,
|
||||
POLYMORPH_UNSTABLE = true,
|
||||
NO_WAND_EDITING = true,
|
||||
RESPAWN = true,
|
||||
}
|
||||
|
||||
local REMOVE_EFFECTS = {
|
||||
|
|
|
@ -22,6 +22,11 @@ local function world2gui(x, y)
|
|||
return x, y, vres_scaling_factor
|
||||
end
|
||||
|
||||
local pvp
|
||||
if ctx.proxy_opt.pvp then
|
||||
pvp = dofile_once("mods/quant.ew/files/system/pvp/pvp.lua")
|
||||
end
|
||||
|
||||
function module.on_world_update()
|
||||
if EntityHasTag(ctx.my_player.entity, "polymorphed") and not EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||
return
|
||||
|
@ -49,6 +54,7 @@ function module.on_world_update()
|
|||
or EntityHasTag(player_data.entity, "polymorphed_cessation")
|
||||
or (EntityHasTag(player_data.entity, "ew_notplayer") and ctx.proxy_opt.no_notplayer)
|
||||
or player_data.dc
|
||||
or (ctx.proxy_opt.pvp and (pvp.hm_y == nil or pvp.players_by_floor[pvp.floor][peer_id] == nil))
|
||||
then
|
||||
goto continue
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ local player_count = 1
|
|||
|
||||
local my_num = 0
|
||||
|
||||
local my_pw = 0
|
||||
local my_pw = 1
|
||||
|
||||
local floor = 1
|
||||
|
||||
|
@ -37,11 +37,13 @@ local my_wins = 0
|
|||
|
||||
local player_died = {}
|
||||
|
||||
local players_by_floor = {}
|
||||
|
||||
--TODO give tiny platform so you dont fall in lava after tp
|
||||
|
||||
--TODO regenerate final hm
|
||||
|
||||
local hm_x = -677
|
||||
local hm_x = BiomeMapGetSize() * 512 - 677
|
||||
|
||||
local hm_ys = {
|
||||
1336,
|
||||
|
@ -56,8 +58,8 @@ function rpc.recv_player_num(num, peer)
|
|||
player_count = num + 1
|
||||
if ctx.my_id == peer then
|
||||
my_num = num
|
||||
my_pw = math.ceil(my_num / 2)
|
||||
if my_num % 2 == 0 then
|
||||
my_pw = math.ceil((my_num + 1) / 2)
|
||||
if my_num % 2 == 1 then
|
||||
my_pw = -my_pw
|
||||
end
|
||||
hm_x = my_pw * BiomeMapGetSize() * 512 - 677
|
||||
|
@ -89,9 +91,27 @@ function rpc.died(f)
|
|||
table.insert(player_died[f], ctx.rpc_peer_id)
|
||||
end
|
||||
|
||||
rpc.opts_everywhere()
|
||||
rpc.opts_reliable()
|
||||
function rpc.remove_floor(f)
|
||||
if players_by_floor[f] == nil then
|
||||
players_by_floor[f] = {}
|
||||
end
|
||||
players_by_floor[f][ctx.rpc_peer_id] = nil
|
||||
end
|
||||
|
||||
rpc.opts_everywhere()
|
||||
rpc.opts_reliable()
|
||||
function rpc.add_floor(f)
|
||||
if players_by_floor[f] == nil then
|
||||
players_by_floor[f] = {}
|
||||
end
|
||||
players_by_floor[f][ctx.rpc_peer_id] = true
|
||||
end
|
||||
|
||||
local function float()
|
||||
local character_data = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "CharacterDataComponent")
|
||||
ComponentSetValue2(character_data, "mVelocity", 0, -20)
|
||||
ComponentSetValue2(character_data, "mVelocity", 0, -40)
|
||||
end
|
||||
|
||||
local function set_camera_pos(x, y)
|
||||
|
@ -121,12 +141,15 @@ function pvp.move_next_hm(died)
|
|||
tp(hm_x, hm_y)
|
||||
if died then
|
||||
rpc.died(floor)
|
||||
ctx.stop_cam = true
|
||||
end
|
||||
rpc.remove_floor(floor)
|
||||
floor = floor + 1
|
||||
GlobalsSetValue("ew_floor", tostring(floor))
|
||||
end
|
||||
|
||||
function pvp.teleport_into_biome()
|
||||
rpc.add_floor(floor)
|
||||
local n = floor % #chunks_by_floor
|
||||
if n == 0 then
|
||||
n = #chunks_by_floor
|
||||
|
@ -151,6 +174,7 @@ function pvp.teleport_into_biome()
|
|||
wait(8)
|
||||
local com = EntityCreateNew()
|
||||
EntityAddChild(ctx.my_player.entity, com)
|
||||
EntityAddTag(com, "perk_entity")
|
||||
EntityAddComponent2(com, "GameEffectComponent", {
|
||||
effect = "TELEPORTATION",
|
||||
frames = 4,
|
||||
|
@ -160,7 +184,7 @@ function pvp.teleport_into_biome()
|
|||
teleportation_radius_min = 256,
|
||||
})
|
||||
float()
|
||||
wait(4)
|
||||
wait(12)
|
||||
x, y = EntityGetTransform(ctx.my_player.entity)
|
||||
LoadPixelScene("mods/quant.ew/files/system/pvp/tp.png", "", x - 6, y - 13, "", true, true) --ff5e9ab5
|
||||
end)
|
||||
|
@ -171,20 +195,24 @@ local first = true
|
|||
|
||||
function pvp.on_world_update()
|
||||
if first then
|
||||
if ctx.players[ctx.host_id] ~= nil then
|
||||
rpc.get_player_num()
|
||||
elseif not ctx.is_host then
|
||||
if not ctx.is_host and ctx.players[ctx.host_id] == nil then
|
||||
return
|
||||
end
|
||||
first = false
|
||||
pvp.teleport_into_biome()
|
||||
player_count = tonumber(GlobalsGetValue("ew_player_count", "-1")) or 1
|
||||
my_num = tonumber(GlobalsGetValue("ew_num", "-1")) or 0
|
||||
my_pw = tonumber(GlobalsGetValue("ew_pw", "-1")) or 0
|
||||
my_pw = tonumber(GlobalsGetValue("ew_pw", "-1")) or 1
|
||||
floor = tonumber(GlobalsGetValue("ew_floor", "1")) or 1
|
||||
my_wins = tonumber(GlobalsGetValue("ew_wins", "0")) or 0
|
||||
if my_num == -1 then
|
||||
pvp.get_player_num()
|
||||
if ctx.is_host then
|
||||
my_num = 0
|
||||
my_pw = 1
|
||||
player_count = 1
|
||||
else
|
||||
rpc.get_player_num()
|
||||
end
|
||||
pvp.teleport_into_biome()
|
||||
end
|
||||
end
|
||||
local _, y = EntityGetTransform(ctx.my_player.entity)
|
||||
|
|
|
@ -304,19 +304,15 @@ function spectate.on_world_update()
|
|||
if ctx.run_ended then
|
||||
return
|
||||
end
|
||||
if last_ent == nil then
|
||||
if last_ent == nil or last_ent ~= ctx.my_player.entity then
|
||||
last_ent = ctx.my_player.entity
|
||||
camera_player_id, camera_player = get_me()
|
||||
re_cam = true
|
||||
end
|
||||
if last_ent ~= ctx.my_player.entity then
|
||||
last_ent = ctx.my_player.entity
|
||||
camera_player_id, camera_player = get_me()
|
||||
re_cam = true
|
||||
end
|
||||
if camera_player == nil then
|
||||
if camera_player == nil or ctx.stop_cam then
|
||||
camera_player_id, camera_player = get_me()
|
||||
re_cam = true
|
||||
ctx.stop_cam = false
|
||||
end
|
||||
if last_len == nil then
|
||||
last_len = number_of_players()
|
||||
|
|
|
@ -22,7 +22,7 @@ pub struct Lid(pub u32);
|
|||
#[derive(Debug, Encode, Decode, Clone, PartialEq)]
|
||||
pub enum EntitySpawnInfo {
|
||||
Filename(String),
|
||||
Serialized { serialized_at: i32, data: Vec<u8> },
|
||||
Serialized { data: Vec<u8> },
|
||||
}
|
||||
|
||||
impl Default for EntitySpawnInfo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue