mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
fix player cosmetics options being broken by peers by last patch, make linter happier
This commit is contained in:
parent
ec1c006914
commit
5bc707f9b4
47 changed files with 366 additions and 425 deletions
|
@ -81,7 +81,7 @@ impl ModmanagerSettings {
|
|||
if cfg!(target_os = "windows") {
|
||||
// Noita uses AppData folder instead of %AppData%
|
||||
let appdata_path = PathBuf::from(
|
||||
std::env::var_os("USERPROFILE").expect("homepath to be defined on windows"),
|
||||
env::var_os("USERPROFILE").expect("homepath to be defined on windows"),
|
||||
)
|
||||
.join("AppData");
|
||||
info!("Appdata path: {}", appdata_path.display());
|
||||
|
|
|
@ -80,7 +80,7 @@ impl NoitaLauncher {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_noita_running(&mut self) -> bool {
|
||||
fn check_if_noita_running(&mut self) -> bool {
|
||||
match self.noita_process.as_mut().map(|child| child.try_wait()) {
|
||||
Some(Ok(Some(_))) => false, // Already exited
|
||||
Some(Ok(None)) => true, // Not yet exited
|
||||
|
@ -90,7 +90,7 @@ impl NoitaLauncher {
|
|||
}
|
||||
|
||||
pub fn launch_token(&mut self) -> LaunchTokenResult {
|
||||
if self.is_noita_running() {
|
||||
if self.check_if_noita_running() {
|
||||
return LaunchTokenResult::AlreadyStarted;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ fn proxy_bin_name() -> &'static str {
|
|||
}
|
||||
|
||||
fn proxy_downloader_for(download_path: PathBuf) -> Result<Downloader, ReleasesError> {
|
||||
let client = reqwest::blocking::Client::builder().timeout(None).build()?;
|
||||
let client = Client::builder().timeout(None).build()?;
|
||||
get_latest_release(&client)
|
||||
.and_then(|release| release.get_release_assets(&client))
|
||||
.and_then(|asset_list| asset_list.find_by_name(proxy_asset_name()).cloned())
|
||||
|
|
|
@ -369,7 +369,7 @@ impl App {
|
|||
self.change_state_to_netman(netman, player_path(self.modmanager_settings.mod_path()));
|
||||
}
|
||||
|
||||
fn connect_screen(&mut self, ctx: &egui::Context) {
|
||||
fn connect_screen(&mut self, ctx: &Context) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
if self.app_saved_state.times_started % 20 == 0 {
|
||||
let image = egui::Image::new(egui::include_image!("../assets/longleg.png"))
|
||||
|
@ -670,7 +670,7 @@ fn draw_bg(ui: &mut Ui) {
|
|||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
|
||||
ctx.request_repaint_after(Duration::from_millis(500));
|
||||
match &mut self.state {
|
||||
AppState::Connect => {
|
||||
|
@ -777,11 +777,9 @@ impl eframe::App for App {
|
|||
}
|
||||
ui.add_space(15.0);
|
||||
|
||||
if netman.peer.is_host() {
|
||||
if ui.button(tr("netman_show_settings")).clicked() {
|
||||
if netman.peer.is_host() && ui.button(tr("netman_show_settings")).clicked() {
|
||||
self.show_settings = true;
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_space(15.0);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn ws_encode_proxy_bin(key: u8, data: &[u8]) -> tungstenite::Message {
|
|||
tungstenite::Message::Binary(buf)
|
||||
}
|
||||
|
||||
pub(crate) fn ws_encode_mod(peer: omni::OmniPeerId, data: &[u8]) -> tungstenite::Message {
|
||||
pub(crate) fn ws_encode_mod(peer: OmniPeerId, data: &[u8]) -> tungstenite::Message {
|
||||
let mut buf = Vec::new();
|
||||
buf.push(1u8);
|
||||
buf.extend_from_slice(&peer.0.to_le_bytes());
|
||||
|
@ -137,7 +137,7 @@ impl NetManager {
|
|||
.into()
|
||||
}
|
||||
|
||||
pub(crate) fn send(&self, peer: omni::OmniPeerId, msg: &NetMsg, reliability: Reliability) {
|
||||
pub(crate) fn send(&self, peer: OmniPeerId, msg: &NetMsg, reliability: Reliability) {
|
||||
let encoded = lz4_flex::compress_prepend_size(&bitcode::encode(msg));
|
||||
self.peer.send(peer, encoded.clone(), reliability).ok(); // TODO log
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ impl NetManager {
|
|||
&NetMsg::StartGame {
|
||||
settings: self.settings.lock().unwrap().clone(),
|
||||
},
|
||||
tangled::Reliability::Reliable,
|
||||
Reliability::Reliable,
|
||||
);
|
||||
create_player_png(
|
||||
&self.init_settings.mod_path,
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
releases::Version,
|
||||
};
|
||||
|
||||
use super::omni::{self, OmniNetworkEvent};
|
||||
use super::omni::OmniNetworkEvent;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum ConnectError {
|
||||
|
@ -444,7 +444,7 @@ impl SteamPeer {
|
|||
}
|
||||
SteamEvent::PeerDisconnectedFromLobby(id) => {
|
||||
self.connections.disconnect(id);
|
||||
returned_events.push(omni::OmniNetworkEvent::PeerDisconnected(id.into()))
|
||||
returned_events.push(OmniNetworkEvent::PeerDisconnected(id.into()))
|
||||
}
|
||||
SteamEvent::PeerStateChanged => self.update_lobby_list(),
|
||||
}
|
||||
|
@ -456,14 +456,14 @@ impl SteamPeer {
|
|||
.identity_peer()
|
||||
.steam_id()
|
||||
.expect("only steam ids are supported");
|
||||
returned_events.push(omni::OmniNetworkEvent::Message {
|
||||
returned_events.push(OmniNetworkEvent::Message {
|
||||
src: steam_id.into(),
|
||||
data: message.data().to_vec(), // TODO eliminate clone here.
|
||||
})
|
||||
}
|
||||
let mut fully_connected = self.connections.connected.lock().unwrap();
|
||||
for steam_id in fully_connected.iter() {
|
||||
returned_events.push(omni::OmniNetworkEvent::PeerConnected((*steam_id).into()))
|
||||
returned_events.push(OmniNetworkEvent::PeerConnected((*steam_id).into()))
|
||||
}
|
||||
fully_connected.clear();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl ChunkData {
|
|||
}
|
||||
|
||||
impl WorldModel {
|
||||
fn to_chunk_coords(x: i32, y: i32) -> (ChunkCoord, usize) {
|
||||
fn get_chunk_coords(x: i32, y: i32) -> (ChunkCoord, usize) {
|
||||
let chunk_x = x.div_euclid(CHUNK_SIZE as i32);
|
||||
let chunk_y = y.div_euclid(CHUNK_SIZE as i32);
|
||||
let x = x.rem_euclid(CHUNK_SIZE as i32) as usize;
|
||||
|
@ -64,7 +64,7 @@ impl WorldModel {
|
|||
}
|
||||
|
||||
fn set_pixel(&mut self, x: i32, y: i32, pixel: Pixel) {
|
||||
let (chunk_coord, offset) = Self::to_chunk_coords(x, y);
|
||||
let (chunk_coord, offset) = Self::get_chunk_coords(x, y);
|
||||
let chunk = self.chunks.entry(chunk_coord).or_default();
|
||||
let current = chunk.pixel(offset);
|
||||
if current != pixel {
|
||||
|
@ -74,7 +74,7 @@ impl WorldModel {
|
|||
}
|
||||
|
||||
fn get_pixel(&self, x: i32, y: i32) -> Pixel {
|
||||
let (chunk_coord, offset) = Self::to_chunk_coords(x, y);
|
||||
let (chunk_coord, offset) = Self::get_chunk_coords(x, y);
|
||||
self.chunks
|
||||
.get(&chunk_coord)
|
||||
.map(|chunk| chunk.pixel(offset))
|
||||
|
@ -94,7 +94,7 @@ impl WorldModel {
|
|||
} else {
|
||||
PixelFlags::Normal
|
||||
};
|
||||
for _ in 0..(run.length) {
|
||||
for _ in 0..run.length {
|
||||
self.set_pixel(
|
||||
header.x + x,
|
||||
header.y + y,
|
||||
|
@ -143,7 +143,7 @@ impl WorldModel {
|
|||
let chunk = self.chunks.entry(delta.chunk_coord).or_default();
|
||||
let mut offset = 0;
|
||||
for run in delta.runs.iter() {
|
||||
for _ in 0..(run.length) {
|
||||
for _ in 0..run.length {
|
||||
if let Some(pixel) = run.data {
|
||||
chunk.set_compact_pixel(offset, pixel)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ impl WorldModel {
|
|||
let chunk = self.chunks.entry(chunk).or_default();
|
||||
let mut offset = 0;
|
||||
for run in &chunk_data.runs {
|
||||
for _ in 0..(run.length) {
|
||||
for _ in 0..run.length {
|
||||
let pixel = run.data;
|
||||
chunk.set_compact_pixel(offset, pixel);
|
||||
offset += 1;
|
||||
|
|
|
@ -11,8 +11,7 @@ use std::io::{BufRead, BufReader};
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn player_path(path: PathBuf) -> PathBuf {
|
||||
let path = path.join("files/system/player/unmodified.png");
|
||||
path
|
||||
path.join("files/system/player/unmodified.png")
|
||||
}
|
||||
|
||||
pub fn replace_color(image: &mut RgbaImage, main: Rgba<u8>, alt: Rgba<u8>, arm: Rgba<u8>) {
|
||||
|
@ -75,7 +74,7 @@ pub fn add_cosmetics(
|
|||
match i {
|
||||
2 | 4 | 6 if hat && cosmetics.0 => *pixel = Rgba::from([255, 244, 140, 255]),
|
||||
10 | 14 if hat && cosmetics.0 => *pixel = Rgba::from([191, 141, 65, 255]),
|
||||
11 | 12 | 13 if hat && cosmetics.0 => *pixel = Rgba::from([255, 206, 98, 255]),
|
||||
11..=13 if hat && cosmetics.0 => *pixel = Rgba::from([255, 206, 98, 255]),
|
||||
61 if gem && cosmetics.2 => *pixel = Rgba::from([255, 242, 162, 255]),
|
||||
68 if gem && cosmetics.2 => *pixel = Rgba::from([255, 227, 133, 255]),
|
||||
69 if gem && cosmetics.2 => *pixel = Rgba::from([255, 94, 38, 255]),
|
||||
|
@ -228,7 +227,7 @@ pub fn create_player_png(
|
|||
let cosmetics = rgb.1;
|
||||
let rgb = rgb.2;
|
||||
let tmp_path = player_path.parent().unwrap();
|
||||
let mut img = image::open(&player_path).unwrap().into_rgba8();
|
||||
let mut img = image::open(player_path).unwrap().into_rgba8();
|
||||
replace_color(
|
||||
&mut img,
|
||||
Rgba::from(rgb.player_main),
|
||||
|
@ -269,15 +268,15 @@ pub fn create_player_png(
|
|||
&[
|
||||
(
|
||||
"MARKER_HAT2_ENABLED",
|
||||
(if cosmetics.0 { "1" } else { "0" }).into(),
|
||||
(if cosmetics.0 { "image_file=\"data/enemies_gfx/player_hat2.xml\"" } else { "0" }).into(),
|
||||
),
|
||||
(
|
||||
"MARKER_AMULET_ENABLED",
|
||||
(if cosmetics.1 { "1" } else { "0" }).into(),
|
||||
(if cosmetics.1 { "image_file=\"data/enemies_gfx/player_amulet.xml\"" } else { "0" }).into(),
|
||||
),
|
||||
(
|
||||
"MARKER_AMULET_GEM_ENABLED",
|
||||
(if cosmetics.2 { "1" } else { "0" }).into(),
|
||||
(if cosmetics.2 { "image_file=\"data/enemies_gfx/player_amulet_gem.xml\"" } else { "0" }).into(),
|
||||
),
|
||||
(
|
||||
"MARKER_MAIN_SPRITE",
|
||||
|
|
|
@ -34,15 +34,14 @@ pub(crate) struct Recorder {
|
|||
impl Default for Recorder {
|
||||
// This is a debug feature, so error handling can be lazier than usual.
|
||||
fn default() -> Self {
|
||||
let exe_path = std::env::current_exe().expect("path to exist");
|
||||
let exe_path = env::current_exe().expect("path to exist");
|
||||
let exe_dir_path = exe_path.parent().unwrap();
|
||||
let recordings_base = exe_dir_path.join("crashcatcher_recordings");
|
||||
|
||||
// Find the earliest free path to put recordings in.
|
||||
let recording_dir = (1u64..)
|
||||
.map(|num| recordings_base.join(format!("recording_{num:02}")))
|
||||
.skip_while(|path| path.try_exists().unwrap_or(true))
|
||||
.next()
|
||||
.find(|path| !path.try_exists().unwrap_or(true))
|
||||
.expect("at least one name should be free");
|
||||
|
||||
fs::create_dir_all(&recording_dir).expect("can create directory");
|
||||
|
|
|
@ -17,9 +17,9 @@ fn main() {
|
|||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||
|
||||
let mut args = args().skip(1);
|
||||
let peer = match args.next().as_ref().map(|s| s.as_str()) {
|
||||
let peer = match args.next().as_deref() {
|
||||
Some("host") => {
|
||||
let bind_addr = match args.next().map_or(None, |arg| arg.parse().ok()) {
|
||||
let bind_addr = match args.next().and_then(|arg| arg.parse().ok()) {
|
||||
Some(addr) => addr,
|
||||
None => {
|
||||
println!("Expected an address:port to host on as a second argument");
|
||||
|
@ -29,7 +29,7 @@ fn main() {
|
|||
Peer::host(bind_addr, None)
|
||||
}
|
||||
Some("connect") => {
|
||||
let connect_addr = match args.next().map_or(None, |arg| arg.parse().ok()) {
|
||||
let connect_addr = match args.next().and_then(|arg| arg.parse().ok()) {
|
||||
Some(addr) => addr,
|
||||
None => {
|
||||
println!("Expected an address:port to connect to as a second argument");
|
||||
|
|
|
@ -163,7 +163,7 @@ function world.encode_area(chunk_map, start_x, start_y, end_x, end_y, encoded_ar
|
|||
return encoded_area
|
||||
end
|
||||
|
||||
local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
||||
--local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
||||
|
||||
--- Load an encoded area back into the world.
|
||||
-- @param grid_world
|
||||
|
|
|
@ -185,7 +185,7 @@ function world.encode_area(chunk_map, start_x, start_y, end_x, end_y, encoded_ar
|
|||
return encoded_area
|
||||
end
|
||||
|
||||
local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
||||
--local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
||||
|
||||
---Load an encoded area back into the world.
|
||||
---@param grid_world unknown
|
||||
|
|
|
@ -7,7 +7,7 @@ local ctx = {
|
|||
}
|
||||
|
||||
setmetatable(ctx.hook, {
|
||||
__index = function (_, k)
|
||||
__index = function (_, _)
|
||||
return function() end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
local np = require("noitapatcher")
|
||||
local EZWand = dofile_once("mods/quant.ew/files/lib/EZWand.lua")
|
||||
local pretty = dofile_once("mods/quant.ew/files/lib/pretty_print.lua")
|
||||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
|
||||
local inventory_helper = {}
|
||||
|
@ -28,7 +27,7 @@ function inventory_helper.get_inventory_items(player_data, inventory_name)
|
|||
if(not player)then
|
||||
return {}
|
||||
end
|
||||
local inventory = nil
|
||||
local inventory
|
||||
|
||||
local player_child_entities = EntityGetAllChildren( player )
|
||||
if ( player_child_entities ~= nil ) then
|
||||
|
@ -96,7 +95,7 @@ function inventory_helper.serialize_single_item(item)
|
|||
end
|
||||
|
||||
function inventory_helper.deserialize_single_item(item_data)
|
||||
local item = nil
|
||||
local item
|
||||
local x, y = item_data[3], item_data[4]
|
||||
if item_data[1] then
|
||||
item = EZWand(item_data[2], x, y, false).entity_id
|
||||
|
@ -279,12 +278,12 @@ function inventory_helper.set_item_data(item_data, player_data)
|
|||
|
||||
|
||||
if (item_data ~= nil) then
|
||||
local active_item_entity = nil
|
||||
local active_item_entity
|
||||
|
||||
for k, itemInfo in ipairs(item_data) do
|
||||
local x, y = EntityGetTransform(player)
|
||||
local item_entity = nil
|
||||
local item = nil
|
||||
--local x, y = EntityGetTransform(player)
|
||||
local item_entity
|
||||
local item
|
||||
if(itemInfo.is_wand)then
|
||||
item = inventory_helper.deserialize_single_item(itemInfo.data)
|
||||
item = EZWand(item)
|
||||
|
|
|
@ -80,7 +80,7 @@ function net.init()
|
|||
reactor:run(function()
|
||||
local sock = net.sock
|
||||
while true do
|
||||
local msg_decoded = nil
|
||||
local msg_decoded
|
||||
local msg = sock:await()
|
||||
if string.byte(msg, 1, 1) == 2 then
|
||||
local msg_l = string.sub(msg, 2)
|
||||
|
|
|
@ -121,7 +121,7 @@ function util.set_ent_firing_blocked(entity, do_block)
|
|||
local inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component")
|
||||
if(inventory2Comp ~= nil)then
|
||||
local items = GameGetAllInventoryItems(entity)
|
||||
for i, item in ipairs(items or {}) do
|
||||
for _, item in ipairs(items or {}) do
|
||||
local ability = EntityGetFirstComponentIncludingDisabled( item, "AbilityComponent" );
|
||||
if ability then
|
||||
if(do_block)then
|
||||
|
|
|
@ -26,10 +26,10 @@ local setmetatable = setmetatable
|
|||
local ffi = require("ffi")
|
||||
local buf_pos = 0
|
||||
local buf_size = -1
|
||||
local buf = nil
|
||||
local buf
|
||||
local buf_is_writable = true
|
||||
local writable_buf = nil
|
||||
local writable_buf_size = nil
|
||||
local writable_buf
|
||||
local writable_buf_size
|
||||
local includeMetatables = true -- togglable with bitser.includeMetatables(false)
|
||||
local SEEN_LEN = {}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ local POLLNET_RESULT_CODES = {
|
|||
[6] = "newclient"
|
||||
}
|
||||
|
||||
local _ctx = nil
|
||||
local _ctx
|
||||
|
||||
local function init_ctx()
|
||||
if _ctx then return end
|
||||
|
|
|
@ -3,7 +3,7 @@ pretty_print.table = function(node)
|
|||
-- to make output beautiful
|
||||
local function tab(amt)
|
||||
local str = ""
|
||||
for i=1,amt do
|
||||
for _ =1,amt do
|
||||
str = str .. "\t"
|
||||
end
|
||||
return str
|
||||
|
@ -15,7 +15,7 @@ pretty_print.table = function(node)
|
|||
|
||||
while true do
|
||||
local size = 0
|
||||
for k,v in pairs(node) do
|
||||
for _, _ in pairs(node) do
|
||||
size = size + 1
|
||||
end
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ function module.on_world_update_client()
|
|||
end
|
||||
end
|
||||
|
||||
local last_health = nil
|
||||
local last_health
|
||||
|
||||
local function do_health_diff(hp, max_hp)
|
||||
local current_hp = util.get_ent_health(ctx.my_player.entity)
|
||||
|
@ -155,8 +155,8 @@ ctx.cap.health = {
|
|||
|
||||
rpc.opts_reliable()
|
||||
function rpc.deal_damage(damage, message)
|
||||
local message = GameTextGetTranslatedOrNot(message) .. " ("..ctx.rpc_player_data.name..")"
|
||||
module.last_damage_message = message
|
||||
local message_n = GameTextGetTranslatedOrNot(message) .. " ("..ctx.rpc_player_data.name..")"
|
||||
module.last_damage_message = message_n
|
||||
if ctx.is_host then
|
||||
local host_entity_id = ctx.my_player.entity
|
||||
local protection_component_id = GameGetGameEffect(host_entity_id, "PROTECTION_ALL")
|
||||
|
@ -169,7 +169,7 @@ function rpc.deal_damage(damage, message)
|
|||
EntitySetComponentIsEnabled(host_entity_id, protection_component_id, true)
|
||||
end
|
||||
end
|
||||
GamePrint(string.format("Got %.2f damage: %s", damage*25, message))
|
||||
GamePrint(string.format("Got %.2f damage: %s", damage*25, message_n))
|
||||
end
|
||||
|
||||
function rpc.update_shared_health(hp, max_hp)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
local np = require("noitapatcher")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
|
|
@ -16,7 +16,7 @@ local spawned_by_us = {}
|
|||
|
||||
np.CrossCallAdd("ew_es_death_notify", function(enemy_id, responsible_id)
|
||||
local player_data = player_fns.get_player_data_by_local_entity_id(responsible_id)
|
||||
local responsible = nil
|
||||
local responsible
|
||||
if player_data ~= nil then
|
||||
responsible = player_data.peer_id
|
||||
else
|
||||
|
@ -83,7 +83,7 @@ function enemy_sync.host_upload_entities()
|
|||
end
|
||||
local hp, max_hp, has_hp = util.get_ent_health(enemy_id)
|
||||
|
||||
local phys_info = nil
|
||||
local phys_info
|
||||
-- Some things (like physics object) don't react well to making their entities ephemerial.
|
||||
local not_ephemerial = false
|
||||
|
||||
|
@ -265,9 +265,9 @@ function rpc.handle_enemy_data(enemy_data)
|
|||
|
||||
end
|
||||
|
||||
local enemy_data = ctx.entity_by_remote_id[remote_enemy_id]
|
||||
enemy_data.frame = frame
|
||||
local enemy_id = enemy_data.id
|
||||
local enemy_data_new = ctx.entity_by_remote_id[remote_enemy_id]
|
||||
enemy_data_new.frame = frame
|
||||
local enemy_id = enemy_data_new.id
|
||||
|
||||
local phys_component = EntityGetFirstComponent(enemy_id, "PhysicsBody2Component")
|
||||
if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then
|
||||
|
|
|
@ -17,7 +17,7 @@ local content = ModTextFileGetContent("data/genome_relations.csv")
|
|||
--self relation is the genome's relation with itself,
|
||||
--relations is a table which directly specifies the value of the genome relation with.
|
||||
|
||||
local function add_new_genome(content, genome_name, default_relation_ab, default_relation_ba, self_relation, relations)
|
||||
local function add_new_genome(genome_name, default_relation_ab, default_relation_ba, self_relation, relations)
|
||||
local lines = split_string(content, "\r\n")
|
||||
local output = ""
|
||||
local genome_order = {}
|
||||
|
@ -32,7 +32,7 @@ local function add_new_genome(content, genome_name, default_relation_ab, default
|
|||
end
|
||||
|
||||
local line = genome_name
|
||||
for i, v in ipairs(genome_order) do
|
||||
for _, v in ipairs(genome_order) do
|
||||
line = line .. "," .. (relations[v] or default_relation_ab)
|
||||
end
|
||||
output = output .. line .. "," .. self_relation
|
||||
|
@ -40,11 +40,11 @@ local function add_new_genome(content, genome_name, default_relation_ab, default
|
|||
return output
|
||||
end
|
||||
|
||||
content = add_new_genome(content, "notplayer", 100, 100, 100, {
|
||||
content = add_new_genome("notplayer", 100, 100, 100, {
|
||||
player = 0,
|
||||
})
|
||||
|
||||
content = add_new_genome(content, "player_pvp", 0, 0, 0, {})
|
||||
content = add_new_genome("player_pvp", 0, 0, 0, {})
|
||||
|
||||
ModTextFileSetContent("data/genome_relations.csv", content)
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ function rpc.fungal_shift(conversions, iter, from_material_name)
|
|||
local add_icon = true
|
||||
local children = EntityGetAllChildren(entity)
|
||||
if children ~= nil then
|
||||
for i,it in ipairs(children) do
|
||||
for _,it in ipairs(children) do
|
||||
if ( EntityGetName(it) == "fungal_shift_ui_icon" ) then
|
||||
add_icon = false
|
||||
break
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
ModLuaFileAppend("data/scripts/items/heart.lua", "mods/quant.ew/files/system/heart_pickups/append/heart.lua")
|
||||
ModLuaFileAppend("data/scripts/items/heart_better.lua", "mods/quant.ew/files/system/heart_pickups/append/heart_better.lua")
|
||||
|
@ -28,7 +27,7 @@ local function heart_pickup(heart)
|
|||
local max_hp_increase = max_hp_increase_table[heart]
|
||||
|
||||
local hp, max_hp = ctx.cap.health.health(), ctx.cap.health.max_health()
|
||||
local cap = util.get_ent_health_cap(ctx.my_player.entity)
|
||||
--local cap = util.get_ent_health_cap(ctx.my_player.entity)
|
||||
local player_count = tonumber(GlobalsGetValue("ew_player_count", "1"))
|
||||
|
||||
local max_hp_old = max_hp
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
local inventory_helper = dofile_once("mods/quant.ew/files/core/inventory_helper.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
|
||||
dofile_once("data/scripts/lib/coroutines.lua")
|
||||
|
||||
|
@ -130,10 +129,10 @@ function item_sync.make_item_global(item, instant)
|
|||
value_string = gid,
|
||||
})
|
||||
end
|
||||
local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent")
|
||||
if vel then
|
||||
local vx, vy = ComponentGetValue2(vel, "mVelocity")
|
||||
end
|
||||
--local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent")
|
||||
--if vel then
|
||||
-- local vx, vy = ComponentGetValue2(vel, "mVelocity")
|
||||
--end
|
||||
local item_data = inventory_helper.serialize_single_item(item)
|
||||
item_data.gid = gid
|
||||
ctx.item_prevent_localize[gid] = false
|
||||
|
@ -252,8 +251,8 @@ function rpc.initial_items(item_list)
|
|||
for _, item_data in ipairs(item_list) do
|
||||
local item = item_sync.find_by_gid(item_data.gid)
|
||||
if item == nil then
|
||||
local item = inventory_helper.deserialize_single_item(item_data)
|
||||
add_stuff_to_globalized_item(item, item_data.gid)
|
||||
local item_new = inventory_helper.deserialize_single_item(item_data)
|
||||
add_stuff_to_globalized_item(item_new, item_data.gid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
local np = require("noitapatcher")
|
||||
|
||||
dofile_once("data/scripts/lib/coroutines.lua")
|
||||
|
|
|
@ -94,18 +94,18 @@ function module.on_world_update()
|
|||
rpc.send_status(status)
|
||||
end
|
||||
|
||||
local hp, max_hp, has_hp = util.get_ent_health(ctx.my_player.entity)
|
||||
local hp_new, max_hp_new, has_hp = util.get_ent_health(ctx.my_player.entity)
|
||||
if not ctx.my_player.currently_polymorphed and has_hp then
|
||||
if hp <= 0 then
|
||||
if hp_new <= 0 then
|
||||
-- Restore the player back to small amount of hp.
|
||||
util.set_ent_health(ctx.my_player.entity, {5/25, max_hp})
|
||||
util.set_ent_health(ctx.my_player.entity, {5/25, max_hp_new})
|
||||
player_died()
|
||||
end
|
||||
end
|
||||
|
||||
if notplayer_active then
|
||||
local controls = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ControlsComponent")
|
||||
end
|
||||
--if notplayer_active then
|
||||
-- local controls = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ControlsComponent")
|
||||
--end
|
||||
end
|
||||
|
||||
function module.on_world_update_client()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ local wandfinder = dofile_once("mods/quant.ew/files/system/notplayer_ai/wandfind
|
|||
|
||||
local MAX_RADIUS = 128*4
|
||||
|
||||
local state = nil
|
||||
local state
|
||||
|
||||
local module = {}
|
||||
|
||||
|
@ -65,9 +65,9 @@ local function init_state()
|
|||
}
|
||||
end
|
||||
|
||||
local target = nil
|
||||
local target
|
||||
|
||||
local last_length = nil
|
||||
local last_length
|
||||
|
||||
local last_did_hit = false
|
||||
|
||||
|
@ -307,8 +307,8 @@ local function update()
|
|||
ComponentSetValue2(state.control_component, "mButtonFrameFly", GameGetFrameNum()+1)
|
||||
end
|
||||
state.was_w = state.control_w
|
||||
local _, y = EntityGetTransform(ctx.my_player.entity)
|
||||
ComponentSetValue2(state.control_component, "mFlyingTargetY", y - 10)
|
||||
local _, y_n = EntityGetTransform(ctx.my_player.entity)
|
||||
ComponentSetValue2(state.control_component, "mFlyingTargetY", y_n - 10)
|
||||
|
||||
if (GameGetFrameNum() % 300) == 299 then
|
||||
teleport_to_next_hm()
|
||||
|
|
|
@ -7,7 +7,7 @@ function collision_trigger()
|
|||
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local pos_x, pos_y = EntityGetTransform( entity_id )
|
||||
local eid = EntityLoad( "mods/quant.ew/files/system/patch_dragon_boss/dragon_boss_extra.xml", pos_x, pos_y )
|
||||
EntityLoad( "mods/quant.ew/files/system/patch_dragon_boss/dragon_boss_extra.xml", pos_x, pos_y )
|
||||
EntityLoad( "data/entities/particles/image_emitters/magical_symbol_fast.xml", pos_x, pos_y )
|
||||
|
||||
EntityKill( entity_id )
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
|
||||
ModLuaFileAppend("data/scripts/misc/no_heal_in_meat_biome.lua", "mods/quant.ew/files/system/patch_meat_biome/append/biome_check.lua")
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
local function patch_perk(perk_id, ignore_original_func, fn)
|
||||
local perk_data = get_perk_with_id(perk_list, perk_id)
|
||||
local old_func = perk_data.func
|
||||
perk_data.func = function(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
if not ignore_original_func then
|
||||
old_func(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
end
|
||||
fn(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
end
|
||||
end
|
||||
|
||||
local function hide_perk(perk_id)
|
||||
local perk_data = get_perk_with_id(perk_list, perk_id)
|
||||
perk_data.not_in_default_perk_pool = true
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
local function patch_perk(perk_id, ignore_original_func, fn)
|
||||
local perk_data = get_perk_with_id(perk_list, perk_id)
|
||||
local old_func = perk_data.func
|
||||
perk_data.func = function(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
if not ignore_original_func then
|
||||
old_func(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
end
|
||||
fn(entity_perk_item, entity_who_picked, item_name, pickup_count)
|
||||
end
|
||||
end
|
||||
|
||||
local function hide_perk(perk_id)
|
||||
local perk_data = get_perk_with_id(perk_list, perk_id)
|
||||
perk_data.not_in_default_perk_pool = true
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
local np = require("noitapatcher")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
|
|
@ -3,8 +3,8 @@ local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
|||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
function player_color(player_entity)
|
||||
local cape = nil
|
||||
local player_arm = nil
|
||||
local cape
|
||||
local player_arm
|
||||
|
||||
local player_child_entities = EntityGetAllChildren( player_entity )
|
||||
if ( player_child_entities ~= nil ) then
|
||||
|
|
|
@ -409,25 +409,25 @@
|
|||
<SpriteComponent
|
||||
_tags="character,player_amulet"
|
||||
alpha="1"
|
||||
image_file="data/enemies_gfx/player_amulet.xml"
|
||||
MARKER_AMULET_ENABLED
|
||||
next_rect_animation=""
|
||||
offset_x="6"
|
||||
offset_y="14"
|
||||
rect_animation="walk"
|
||||
z_index="0.59"
|
||||
_enabled="MARKER_AMULET_ENABLED"
|
||||
_enable="0"
|
||||
></SpriteComponent>
|
||||
|
||||
<SpriteComponent
|
||||
_tags="character,player_amulet_gem"
|
||||
alpha="1"
|
||||
image_file="data/enemies_gfx/player_amulet_gem.xml"
|
||||
MARKER_AMULET_GEM_ENABLED
|
||||
next_rect_animation=""
|
||||
offset_x="6"
|
||||
offset_y="14"
|
||||
rect_animation="walk"
|
||||
z_index="0.58"
|
||||
_enabled="MARKER_AMULET_GEM_ENABLED"
|
||||
_enable="0"
|
||||
></SpriteComponent>
|
||||
|
||||
<SpriteComponent
|
||||
|
@ -446,12 +446,13 @@
|
|||
_tags="character,player_hat2"
|
||||
alpha="1"
|
||||
image_file="data/enemies_gfx/player_hat2.xml"
|
||||
MARKER_HAT2_ENABLED
|
||||
next_rect_animation=""
|
||||
offset_x="6"
|
||||
offset_y="14"
|
||||
rect_animation="walk"
|
||||
z_index="0.58"
|
||||
_enabled="MARKER_HAT2_ENABLED"
|
||||
_enable="0"
|
||||
></SpriteComponent>
|
||||
|
||||
<SpriteComponent
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
local gui = GuiCreate()
|
||||
|
||||
|
@ -14,10 +9,10 @@ local module = {}
|
|||
local function world2gui( x, y )
|
||||
in_camera_ref = in_camera_ref or false
|
||||
|
||||
local gui = GuiCreate()
|
||||
GuiStartFrame(gui)
|
||||
local w, h = GuiGetScreenDimensions( gui )
|
||||
GuiDestroy(gui)
|
||||
local gui_n = GuiCreate()
|
||||
GuiStartFrame(gui_n)
|
||||
local w, h = GuiGetScreenDimensions(gui_n)
|
||||
GuiDestroy(gui_n)
|
||||
|
||||
local vres_scaling_factor = w/( MagicNumbersGetValue( "VIRTUAL_RESOLUTION_X" ) + MagicNumbersGetValue( "VIRTUAL_RESOLUTION_OFFSET_X" ))
|
||||
local cam_x, cam_y = GameGetCameraPos()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
local np = require("noitapatcher")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
local tether_length = ctx.proxy_opt.tether_length
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
local world_ffi = require("noitapatcher.nsew.world_ffi")
|
||||
local world = require("noitapatcher.nsew.world")
|
||||
local rect = require("noitapatcher.nsew.rect")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
local module = {}
|
||||
|
||||
local KEY_WORLD_FRAME = 0
|
||||
local KEY_WORLD_END = 1
|
||||
|
||||
local CHUNK_SIZE = 128
|
||||
|
||||
function module.on_world_update()
|
||||
if GameGetFrameNum() % 30 ~= 6 then
|
||||
return
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
local np = require("noitapatcher")
|
||||
|
||||
local module = {}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
|
|
@ -49,7 +49,7 @@ function world_sync.on_world_update_host()
|
|||
local thread_impl = grid_world.mThreadImpl
|
||||
|
||||
local begin = thread_impl.updated_grid_worlds.begin
|
||||
local end_ = begin + thread_impl.chunk_update_count
|
||||
--local end_ = begin + thread_impl.chunk_update_count
|
||||
|
||||
local count = thread_impl.chunk_update_count
|
||||
-- GamePrint("w update "..count)
|
||||
|
@ -86,7 +86,7 @@ function world_sync.on_world_update_host()
|
|||
rect_optimiser:scan()
|
||||
|
||||
for crect in rect.parts(rect_optimiser:iterate(), 256) do
|
||||
local area = nil
|
||||
local area
|
||||
-- Make sure we don't send chunks that aren't loaded yet, like holy mountains before host got there.
|
||||
if DoesWorldExistAt(crect.left, crect.top, crect.right, crect.bottom) then
|
||||
area = world.encode_area(chunk_map, crect.left, crect.top, crect.right, crect.bottom, encoded_area)
|
||||
|
@ -111,7 +111,7 @@ local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
|||
|
||||
function world_sync.handle_world_data(world_data)
|
||||
local grid_world = world_ffi.get_grid_world()
|
||||
for i, datum in ipairs(world_data) do
|
||||
for _, datum in ipairs(world_data) do
|
||||
-- GamePrint("Decoding world data "..i)
|
||||
local header = ffi.cast("struct EncodedAreaHeader const*", ffi.cast('char const*', datum))
|
||||
local runs = ffi.cast(PixelRun_const_ptr, ffi.cast("const char*", datum) + ffi.sizeof(world.EncodedAreaHeader))
|
||||
|
|
|
@ -5,11 +5,10 @@ local ffi = require("ffi")
|
|||
|
||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||
|
||||
-- local rpc = net.new_rpc_namespace()
|
||||
|
||||
local rect_optimiser = rect.Optimiser_new()
|
||||
--local rect_optimiser = rect.Optimiser_new()
|
||||
local encoded_area = world.EncodedArea()
|
||||
|
||||
local world_sync = {}
|
||||
|
@ -39,7 +38,7 @@ function world_sync.on_world_update()
|
|||
|
||||
local grid_world = world_ffi.get_grid_world()
|
||||
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
||||
local thread_impl = grid_world.mThreadImpl
|
||||
--local thread_impl = grid_world.mThreadImpl
|
||||
|
||||
if GameGetFrameNum() % ctx.proxy_opt.world_sync_interval == 0 then
|
||||
local player_data = ctx.my_player
|
||||
|
|
|
@ -18,7 +18,6 @@ util = dofile_once("mods/quant.ew/files/core/util.lua")
|
|||
inventory_helper = dofile_once("mods/quant.ew/files/core/inventory_helper.lua")
|
||||
constants = dofile_once("mods/quant.ew/files/core/constants.lua")
|
||||
|
||||
local pretty = dofile_once("mods/quant.ew/files/lib/pretty_print.lua")
|
||||
local perk_fns = dofile_once("mods/quant.ew/files/core/perk_fns.lua")
|
||||
|
||||
local version = dofile_once("mods/quant.ew/files/version.lua") or "unknown (dev build)"
|
||||
|
@ -136,7 +135,7 @@ function OnPausedChanged(paused, is_wand_pickup)
|
|||
|
||||
if (players[1]) then
|
||||
np.RegisterPlayerEntityId(players[1])
|
||||
local inventory_gui = EntityGetFirstComponentIncludingDisabled(players[1], "InventoryGuiComponent")
|
||||
--local inventory_gui = EntityGetFirstComponentIncludingDisabled(players[1], "InventoryGuiComponent")
|
||||
local controls_component = EntityGetFirstComponentIncludingDisabled(players[1], "ControlsComponent")
|
||||
if (paused) then
|
||||
--EntitySetComponentIsEnabled(players[1], inventory_gui, false)
|
||||
|
|
|
@ -40,7 +40,7 @@ mod_settings =
|
|||
-- - when entering the game after a restart (init_scope will be MOD_SETTING_SCOPE_RESTART)
|
||||
-- - at the end of an update when mod settings have been changed via ModSettingsSetNextValue() and the game is unpaused (init_scope will be MOD_SETTINGS_SCOPE_RUNTIME)
|
||||
function ModSettingsUpdate( init_scope )
|
||||
local old_version = mod_settings_get_version( mod_id ) -- This can be used to migrate some settings between mod versions.
|
||||
--local old_version = mod_settings_get_version( mod_id ) -- This can be used to migrate some settings between mod versions.
|
||||
mod_settings_update( mod_id, mod_settings, init_scope )
|
||||
if ModIsEnabled(mod_id) then
|
||||
print("Running early init fn")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue