fix player cosmetics options being broken by peers by last patch, make linter happier

This commit is contained in:
bgkillas 2024-08-15 09:16:29 -04:00
parent ec1c006914
commit 5bc707f9b4
47 changed files with 366 additions and 425 deletions

View file

@ -81,7 +81,7 @@ impl ModmanagerSettings {
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
// Noita uses AppData folder instead of %AppData% // Noita uses AppData folder instead of %AppData%
let appdata_path = PathBuf::from( 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"); .join("AppData");
info!("Appdata path: {}", appdata_path.display()); info!("Appdata path: {}", appdata_path.display());

View file

@ -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()) { match self.noita_process.as_mut().map(|child| child.try_wait()) {
Some(Ok(Some(_))) => false, // Already exited Some(Ok(Some(_))) => false, // Already exited
Some(Ok(None)) => true, // Not yet exited Some(Ok(None)) => true, // Not yet exited
@ -90,7 +90,7 @@ impl NoitaLauncher {
} }
pub fn launch_token(&mut self) -> LaunchTokenResult { pub fn launch_token(&mut self) -> LaunchTokenResult {
if self.is_noita_running() { if self.check_if_noita_running() {
return LaunchTokenResult::AlreadyStarted; return LaunchTokenResult::AlreadyStarted;
} }

View file

@ -160,7 +160,7 @@ fn proxy_bin_name() -> &'static str {
} }
fn proxy_downloader_for(download_path: PathBuf) -> Result<Downloader, ReleasesError> { 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) get_latest_release(&client)
.and_then(|release| release.get_release_assets(&client)) .and_then(|release| release.get_release_assets(&client))
.and_then(|asset_list| asset_list.find_by_name(proxy_asset_name()).cloned()) .and_then(|asset_list| asset_list.find_by_name(proxy_asset_name()).cloned())

View file

@ -369,7 +369,7 @@ impl App {
self.change_state_to_netman(netman, player_path(self.modmanager_settings.mod_path())); 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| { egui::CentralPanel::default().show(ctx, |ui| {
if self.app_saved_state.times_started % 20 == 0 { if self.app_saved_state.times_started % 20 == 0 {
let image = egui::Image::new(egui::include_image!("../assets/longleg.png")) 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 { 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)); ctx.request_repaint_after(Duration::from_millis(500));
match &mut self.state { match &mut self.state {
AppState::Connect => { AppState::Connect => {
@ -777,10 +777,8 @@ impl eframe::App for App {
} }
ui.add_space(15.0); ui.add_space(15.0);
if netman.peer.is_host() { if netman.peer.is_host() && ui.button(tr("netman_show_settings")).clicked() {
if ui.button(tr("netman_show_settings")).clicked() { self.show_settings = true;
self.show_settings = true;
}
} }
ui.add_space(15.0); ui.add_space(15.0);

View file

@ -49,7 +49,7 @@ pub fn ws_encode_proxy_bin(key: u8, data: &[u8]) -> tungstenite::Message {
tungstenite::Message::Binary(buf) 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(); let mut buf = Vec::new();
buf.push(1u8); buf.push(1u8);
buf.extend_from_slice(&peer.0.to_le_bytes()); buf.extend_from_slice(&peer.0.to_le_bytes());
@ -137,7 +137,7 @@ impl NetManager {
.into() .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)); let encoded = lz4_flex::compress_prepend_size(&bitcode::encode(msg));
self.peer.send(peer, encoded.clone(), reliability).ok(); // TODO log self.peer.send(peer, encoded.clone(), reliability).ok(); // TODO log
} }
@ -261,7 +261,7 @@ impl NetManager {
&NetMsg::StartGame { &NetMsg::StartGame {
settings: self.settings.lock().unwrap().clone(), settings: self.settings.lock().unwrap().clone(),
}, },
tangled::Reliability::Reliable, Reliability::Reliable,
); );
create_player_png( create_player_png(
&self.init_settings.mod_path, &self.init_settings.mod_path,

View file

@ -18,7 +18,7 @@ use crate::{
releases::Version, releases::Version,
}; };
use super::omni::{self, OmniNetworkEvent}; use super::omni::OmniNetworkEvent;
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ConnectError { pub enum ConnectError {
@ -444,7 +444,7 @@ impl SteamPeer {
} }
SteamEvent::PeerDisconnectedFromLobby(id) => { SteamEvent::PeerDisconnectedFromLobby(id) => {
self.connections.disconnect(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(), SteamEvent::PeerStateChanged => self.update_lobby_list(),
} }
@ -456,14 +456,14 @@ impl SteamPeer {
.identity_peer() .identity_peer()
.steam_id() .steam_id()
.expect("only steam ids are supported"); .expect("only steam ids are supported");
returned_events.push(omni::OmniNetworkEvent::Message { returned_events.push(OmniNetworkEvent::Message {
src: steam_id.into(), src: steam_id.into(),
data: message.data().to_vec(), // TODO eliminate clone here. data: message.data().to_vec(), // TODO eliminate clone here.
}) })
} }
let mut fully_connected = self.connections.connected.lock().unwrap(); let mut fully_connected = self.connections.connected.lock().unwrap();
for steam_id in fully_connected.iter() { 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(); fully_connected.clear();

View file

@ -54,7 +54,7 @@ impl ChunkData {
} }
impl WorldModel { 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_x = x.div_euclid(CHUNK_SIZE as i32);
let chunk_y = y.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; 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) { 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 chunk = self.chunks.entry(chunk_coord).or_default();
let current = chunk.pixel(offset); let current = chunk.pixel(offset);
if current != pixel { if current != pixel {
@ -74,7 +74,7 @@ impl WorldModel {
} }
fn get_pixel(&self, x: i32, y: i32) -> Pixel { 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 self.chunks
.get(&chunk_coord) .get(&chunk_coord)
.map(|chunk| chunk.pixel(offset)) .map(|chunk| chunk.pixel(offset))
@ -94,7 +94,7 @@ impl WorldModel {
} else { } else {
PixelFlags::Normal PixelFlags::Normal
}; };
for _ in 0..(run.length) { for _ in 0..run.length {
self.set_pixel( self.set_pixel(
header.x + x, header.x + x,
header.y + y, header.y + y,
@ -143,7 +143,7 @@ impl WorldModel {
let chunk = self.chunks.entry(delta.chunk_coord).or_default(); let chunk = self.chunks.entry(delta.chunk_coord).or_default();
let mut offset = 0; let mut offset = 0;
for run in delta.runs.iter() { for run in delta.runs.iter() {
for _ in 0..(run.length) { for _ in 0..run.length {
if let Some(pixel) = run.data { if let Some(pixel) = run.data {
chunk.set_compact_pixel(offset, pixel) chunk.set_compact_pixel(offset, pixel)
} }
@ -190,7 +190,7 @@ impl WorldModel {
let chunk = self.chunks.entry(chunk).or_default(); let chunk = self.chunks.entry(chunk).or_default();
let mut offset = 0; let mut offset = 0;
for run in &chunk_data.runs { for run in &chunk_data.runs {
for _ in 0..(run.length) { for _ in 0..run.length {
let pixel = run.data; let pixel = run.data;
chunk.set_compact_pixel(offset, pixel); chunk.set_compact_pixel(offset, pixel);
offset += 1; offset += 1;

View file

@ -11,8 +11,7 @@ use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
pub fn player_path(path: PathBuf) -> PathBuf { pub fn player_path(path: PathBuf) -> PathBuf {
let path = path.join("files/system/player/unmodified.png"); path.join("files/system/player/unmodified.png")
path
} }
pub fn replace_color(image: &mut RgbaImage, main: Rgba<u8>, alt: Rgba<u8>, arm: Rgba<u8>) { 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 { match i {
2 | 4 | 6 if hat && cosmetics.0 => *pixel = Rgba::from([255, 244, 140, 255]), 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]), 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]), 61 if gem && cosmetics.2 => *pixel = Rgba::from([255, 242, 162, 255]),
68 if gem && cosmetics.2 => *pixel = Rgba::from([255, 227, 133, 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]), 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 cosmetics = rgb.1;
let rgb = rgb.2; let rgb = rgb.2;
let tmp_path = player_path.parent().unwrap(); 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( replace_color(
&mut img, &mut img,
Rgba::from(rgb.player_main), Rgba::from(rgb.player_main),
@ -269,15 +268,15 @@ pub fn create_player_png(
&[ &[
( (
"MARKER_HAT2_ENABLED", "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", "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", "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", "MARKER_MAIN_SPRITE",
@ -342,4 +341,4 @@ fn edit_by_replacing(
fn rgb_to_hex(rgb: [u8; 4]) -> String { fn rgb_to_hex(rgb: [u8; 4]) -> String {
format!("{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2]) format!("{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2])
} }

View file

@ -34,15 +34,14 @@ pub(crate) struct Recorder {
impl Default for Recorder { impl Default for Recorder {
// This is a debug feature, so error handling can be lazier than usual. // This is a debug feature, so error handling can be lazier than usual.
fn default() -> Self { 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 exe_dir_path = exe_path.parent().unwrap();
let recordings_base = exe_dir_path.join("crashcatcher_recordings"); let recordings_base = exe_dir_path.join("crashcatcher_recordings");
// Find the earliest free path to put recordings in. // Find the earliest free path to put recordings in.
let recording_dir = (1u64..) let recording_dir = (1u64..)
.map(|num| recordings_base.join(format!("recording_{num:02}"))) .map(|num| recordings_base.join(format!("recording_{num:02}")))
.skip_while(|path| path.try_exists().unwrap_or(true)) .find(|path| !path.try_exists().unwrap_or(true))
.next()
.expect("at least one name should be free"); .expect("at least one name should be free");
fs::create_dir_all(&recording_dir).expect("can create directory"); fs::create_dir_all(&recording_dir).expect("can create directory");

View file

@ -17,9 +17,9 @@ fn main() {
tracing::subscriber::set_global_default(subscriber).unwrap(); tracing::subscriber::set_global_default(subscriber).unwrap();
let mut args = args().skip(1); 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") => { 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, Some(addr) => addr,
None => { None => {
println!("Expected an address:port to host on as a second argument"); println!("Expected an address:port to host on as a second argument");
@ -29,7 +29,7 @@ fn main() {
Peer::host(bind_addr, None) Peer::host(bind_addr, None)
} }
Some("connect") => { 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, Some(addr) => addr,
None => { None => {
println!("Expected an address:port to connect to as a second argument"); println!("Expected an address:port to connect to as a second argument");

View file

@ -163,7 +163,7 @@ function world.encode_area(chunk_map, start_x, start_y, end_x, end_y, encoded_ar
return encoded_area return encoded_area
end 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. --- Load an encoded area back into the world.
-- @param grid_world -- @param grid_world
@ -228,7 +228,7 @@ function world.decode(grid_world, header, pixel_runs)
-- we skip positions like this. -- we skip positions like this.
goto next_pixel goto next_pixel
end end
local cell_type = pixel.vtable.get_cell_type(pixel) local cell_type = pixel.vtable.get_cell_type(pixel)
if cell_type == C.CELL_TYPE_LIQUID then if cell_type == C.CELL_TYPE_LIQUID then
@ -264,4 +264,4 @@ function world.decode(grid_world, header, pixel_runs)
end end
end end
return world return world

View file

@ -185,7 +185,7 @@ function world.encode_area(chunk_map, start_x, start_y, end_x, end_y, encoded_ar
return encoded_area return encoded_area
end 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. ---Load an encoded area back into the world.
---@param grid_world unknown ---@param grid_world unknown
@ -260,4 +260,4 @@ function world.decode(grid_world, header, pixel_runs)
end end
end end
return world return world

View file

@ -7,7 +7,7 @@ local ctx = {
} }
setmetatable(ctx.hook, { setmetatable(ctx.hook, {
__index = function (_, k) __index = function (_, _)
return function() end return function() end
end end
}) })
@ -74,4 +74,4 @@ function ctx.load_system(system_name)
return ctx.dofile_and_add_hooks("mods/quant.ew/files/system/"..system_name.."/"..system_name..".lua", system_name) return ctx.dofile_and_add_hooks("mods/quant.ew/files/system/"..system_name.."/"..system_name..".lua", system_name)
end end
return ctx return ctx

View file

@ -1,6 +1,5 @@
local np = require("noitapatcher") local np = require("noitapatcher")
local EZWand = dofile_once("mods/quant.ew/files/lib/EZWand.lua") 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 util = dofile_once("mods/quant.ew/files/core/util.lua")
local inventory_helper = {} local inventory_helper = {}
@ -28,7 +27,7 @@ function inventory_helper.get_inventory_items(player_data, inventory_name)
if(not player)then if(not player)then
return {} return {}
end end
local inventory = nil local inventory
local player_child_entities = EntityGetAllChildren( player ) local player_child_entities = EntityGetAllChildren( player )
if ( player_child_entities ~= nil ) then if ( player_child_entities ~= nil ) then
@ -96,7 +95,7 @@ function inventory_helper.serialize_single_item(item)
end end
function inventory_helper.deserialize_single_item(item_data) function inventory_helper.deserialize_single_item(item_data)
local item = nil local item
local x, y = item_data[3], item_data[4] local x, y = item_data[3], item_data[4]
if item_data[1] then if item_data[1] then
item = EZWand(item_data[2], x, y, false).entity_id item = EZWand(item_data[2], x, y, false).entity_id
@ -150,7 +149,7 @@ function inventory_helper.deserialize_single_item(item_data)
ComponentSetValue2(item_cost_component, "stealable", true) ComponentSetValue2(item_cost_component, "stealable", true)
end) end)
end end
util.ensure_component_present(item, "SpriteComponent", "shop_cost", { util.ensure_component_present(item, "SpriteComponent", "shop_cost", {
image_file = "data/fonts/font_pixel_white.xml", image_file = "data/fonts/font_pixel_white.xml",
@ -175,7 +174,7 @@ function inventory_helper.get_item_data(player_data, fresh)
if (not inventory2Comp) or inventory2Comp == 0 then if (not inventory2Comp) or inventory2Comp == 0 then
return {}, {} return {}, {}
end end
local mActiveItem = ComponentGetValue2(inventory2Comp, "mActiveItem") local mActiveItem = ComponentGetValue2(inventory2Comp, "mActiveItem")
local wandData = {} local wandData = {}
local spellData = {} local spellData = {}
@ -185,7 +184,7 @@ function inventory_helper.get_item_data(player_data, fresh)
local item_x, item_y = EntityGetTransform(item) local item_x, item_y = EntityGetTransform(item)
SetRandomSeed(item + slot_x + item_x, slot_y + item_y) SetRandomSeed(item + slot_x + item_x, slot_y + item_y)
if(entity_is_wand(item))then if(entity_is_wand(item))then
table.insert(wandData, table.insert(wandData,
{ {
@ -252,16 +251,16 @@ local function pickup_item(entity, item)
EntityAddChild( child, item) EntityAddChild( child, item)
end end
end end
EntitySetComponentsWithTagEnabled( item, "enabled_in_world", false ) EntitySetComponentsWithTagEnabled( item, "enabled_in_world", false )
EntitySetComponentsWithTagEnabled( item, "enabled_in_hand", false ) EntitySetComponentsWithTagEnabled( item, "enabled_in_hand", false )
EntitySetComponentsWithTagEnabled( item, "enabled_in_inventory", true ) EntitySetComponentsWithTagEnabled( item, "enabled_in_inventory", true )
local wand_children = EntityGetAllChildren(item) or {} local wand_children = EntityGetAllChildren(item) or {}
for k, v in ipairs(wand_children)do for k, v in ipairs(wand_children)do
EntitySetComponentsWithTagEnabled( item, "enabled_in_world", false ) EntitySetComponentsWithTagEnabled( item, "enabled_in_world", false )
end end
end end
function inventory_helper.set_item_data(item_data, player_data) function inventory_helper.set_item_data(item_data, player_data)
@ -279,12 +278,12 @@ function inventory_helper.set_item_data(item_data, player_data)
if (item_data ~= nil) then if (item_data ~= nil) then
local active_item_entity = nil local active_item_entity
for k, itemInfo in ipairs(item_data) do for k, itemInfo in ipairs(item_data) do
local x, y = EntityGetTransform(player) --local x, y = EntityGetTransform(player)
local item_entity = nil local item_entity
local item = nil local item
if(itemInfo.is_wand)then if(itemInfo.is_wand)then
item = inventory_helper.deserialize_single_item(itemInfo.data) item = inventory_helper.deserialize_single_item(itemInfo.data)
item = EZWand(item) item = EZWand(item)
@ -351,7 +350,7 @@ end
function inventory_helper.has_inventory_changed(player_data) function inventory_helper.has_inventory_changed(player_data)
local prev_inventory = player_data.prev_inventory_hash local prev_inventory = player_data.prev_inventory_hash
local inventory_hash = 0 local inventory_hash = 0
for _, item in ipairs(GameGetAllInventoryItems(player_data.entity) or {}) do for _, item in ipairs(GameGetAllInventoryItems(player_data.entity) or {}) do
local item_comp = EntityGetFirstComponentIncludingDisabled(item, "ItemComponent") local item_comp = EntityGetFirstComponentIncludingDisabled(item, "ItemComponent")
@ -362,4 +361,4 @@ function inventory_helper.has_inventory_changed(player_data)
return inventory_hash ~= prev_inventory return inventory_hash ~= prev_inventory
end end
return inventory_helper return inventory_helper

View file

@ -80,8 +80,8 @@ function net.init()
reactor:run(function() reactor:run(function()
local sock = net.sock local sock = net.sock
while true do while true do
local msg_decoded = nil local msg_decoded
local msg = sock:await() local msg = sock:await()
if string.byte(msg, 1, 1) == 2 then if string.byte(msg, 1, 1) == 2 then
local msg_l = string.sub(msg, 2) local msg_l = string.sub(msg, 2)
local res = string_split(msg_l, " ") local res = string_split(msg_l, " ")
@ -102,7 +102,7 @@ function net.init()
-- for _, b in ipairs(peer_id_b) do -- for _, b in ipairs(peer_id_b) do
-- peer_id = peer_id + b * mult -- peer_id = peer_id + b * mult
-- mult = mult * 256 -- mult = mult * 256
-- end -- end
local peer_id = "" local peer_id = ""
for _, b in ipairs(peer_id_b) do for _, b in ipairs(peer_id_b) do
peer_id = hex_table[b+1] .. peer_id peer_id = hex_table[b+1] .. peer_id
@ -143,7 +143,7 @@ function net.init()
pollnet.sleep_ms(100) pollnet.sleep_ms(100)
--print("Waiting for connection...") --print("Waiting for connection...")
end end
end end
local DEST_PROXY = 1 local DEST_PROXY = 1
@ -199,4 +199,4 @@ function net.send_fire(fire_info)
net.send("fire", fire_info, true) net.send("fire", fire_info, true)
end end
return net return net

View file

@ -121,7 +121,7 @@ function util.set_ent_firing_blocked(entity, do_block)
local inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component") local inventory2Comp = EntityGetFirstComponentIncludingDisabled(entity, "Inventory2Component")
if(inventory2Comp ~= nil)then if(inventory2Comp ~= nil)then
local items = GameGetAllInventoryItems(entity) local items = GameGetAllInventoryItems(entity)
for i, item in ipairs(items or {}) do for _, item in ipairs(items or {}) do
local ability = EntityGetFirstComponentIncludingDisabled( item, "AbilityComponent" ); local ability = EntityGetFirstComponentIncludingDisabled( item, "AbilityComponent" );
if ability then if ability then
if(do_block)then if(do_block)then
@ -167,7 +167,7 @@ util.load_ents_tags = util.cached_fn(function(path)
local tags_string = string.match(text, [[tags="(.-)">]]) local tags_string = string.match(text, [[tags="(.-)">]])
local tags = util.string_split(tags_string, ",") local tags = util.string_split(tags_string, ",")
return tags return tags
end) end)
@ -198,4 +198,4 @@ function util.get_or_create_component(entity, component_name, tag)
return component return component
end end
return util return util

View file

@ -26,10 +26,10 @@ local setmetatable = setmetatable
local ffi = require("ffi") local ffi = require("ffi")
local buf_pos = 0 local buf_pos = 0
local buf_size = -1 local buf_size = -1
local buf = nil local buf
local buf_is_writable = true local buf_is_writable = true
local writable_buf = nil local writable_buf
local writable_buf_size = nil local writable_buf_size
local includeMetatables = true -- togglable with bitser.includeMetatables(false) local includeMetatables = true -- togglable with bitser.includeMetatables(false)
local SEEN_LEN = {} local SEEN_LEN = {}

View file

@ -64,11 +64,11 @@ do
local maj_req, min_req, pat_req = split_version(API_VERSION) local maj_req, min_req, pat_req = split_version(API_VERSION)
local maj_dll, min_dll, pat_dll = split_version(POLLNET_VERSION) local maj_dll, min_dll, pat_dll = split_version(POLLNET_VERSION)
if maj_dll ~= maj_req then if maj_dll ~= maj_req then
error("Incompatible Pollnet binary: expected " .. API_VERSION error("Incompatible Pollnet binary: expected " .. API_VERSION
.. " got " .. POLLNET_VERSION) .. " got " .. POLLNET_VERSION)
end end
if (min_dll < min_req) or (min_dll == min_req and pat_dll < pat_req) then if (min_dll < min_req) or (min_dll == min_req and pat_dll < pat_req) then
error("Incompatible Pollnet binary: expected " .. API_VERSION error("Incompatible Pollnet binary: expected " .. API_VERSION
.. " got " .. POLLNET_VERSION) .. " got " .. POLLNET_VERSION)
end end
end end
@ -83,7 +83,7 @@ local POLLNET_RESULT_CODES = {
[6] = "newclient" [6] = "newclient"
} }
local _ctx = nil local _ctx
local function init_ctx() local function init_ctx()
if _ctx then return end if _ctx then return end
@ -131,8 +131,8 @@ local function format_headers(headers)
error("HTTP headers must be table|string, got: " .. tostring(headers)) error("HTTP headers must be table|string, got: " .. tostring(headers))
end end
local keys = {} local keys = {}
for name, _ in pairs(headers) do for name, _ in pairs(headers) do
table.insert(keys, name) table.insert(keys, name)
end end
table.sort(keys) table.sort(keys)
local frags = {} local frags = {}
@ -176,7 +176,7 @@ function socket_mt:http_get(url, headers, ret_body_only)
headers = format_headers(headers or "") headers = format_headers(headers or "")
ret_body_only = not not ret_body_only ret_body_only = not not ret_body_only
return self:_open( return self:_open(
pollnet.pollnet_simple_http_get, pollnet.pollnet_simple_http_get,
url, url,
headers, headers,
ret_body_only ret_body_only
@ -190,10 +190,10 @@ function socket_mt:http_post(url, headers, body, ret_body_only)
}) })
ret_body_only = not not ret_body_only ret_body_only = not not ret_body_only
return self:_open( return self:_open(
pollnet.pollnet_simple_http_post, pollnet.pollnet_simple_http_post,
url, url,
headers, headers,
body, body,
#body, #body,
ret_body_only ret_body_only
) )
@ -253,11 +253,11 @@ end
function socket_mt:_get_message() function socket_mt:_get_message()
local msg_size = pollnet.pollnet_get_data_size(_ctx, self._socket) local msg_size = pollnet.pollnet_get_data_size(_ctx, self._socket)
if msg_size > 0 then if msg_size > 0 then
-- Note: unsafe_get_data_ptr requires careful consideration to use safely! -- Note: unsafe_get_data_ptr requires careful consideration to use safely!
-- Here we are OK because ffi.string copies the data to a new Lua string, -- Here we are OK because ffi.string copies the data to a new Lua string,
-- so we only hang on to the pointer long enough for the copy. -- so we only hang on to the pointer long enough for the copy.
local raw_pointer = pollnet.pollnet_unsafe_get_data_ptr(_ctx, self._socket) local raw_pointer = pollnet.pollnet_unsafe_get_data_ptr(_ctx, self._socket)
if raw_pointer == nil then if raw_pointer == nil then
error("Impossible situation: msg_size > 0 but null data pointer") error("Impossible situation: msg_size > 0 but null data pointer")
end end
return ffi.string(raw_pointer, msg_size) return ffi.string(raw_pointer, msg_size)
@ -268,7 +268,7 @@ end
function socket_mt:poll() function socket_mt:poll()
self._last_message = nil self._last_message = nil
if not self._socket then if not self._socket then
self._status = "invalid" self._status = "invalid"
return false, "invalid" return false, "invalid"
end end
@ -317,7 +317,7 @@ function socket_mt:await()
return false, "timeout" return false, "timeout"
end end
local happy, msg = self:poll() local happy, msg = self:poll()
if not happy then if not happy then
self:close() self:close()
return false, "error: " .. tostring(msg) return false, "error: " .. tostring(msg)
end end
@ -429,11 +429,11 @@ end
local function invoke_handler(handler, req, expose_errors) local function invoke_handler(handler, req, expose_errors)
local happy, res = pcall(handler, req) local happy, res = pcall(handler, req)
if happy then if happy then
return res return res
else else
return { return {
status = "500", status = "500",
body = (expose_errors and tostring(res)) or "Internal Error" body = (expose_errors and tostring(res)) or "Internal Error"
} }
end end
@ -467,7 +467,7 @@ local exports = {
VERSION = POLLNET_VERSION, VERSION = POLLNET_VERSION,
init = init_ctx, init = init_ctx,
init_hack_static = init_ctx_hack_static, init_hack_static = init_ctx_hack_static,
shutdown = shutdown_ctx, shutdown = shutdown_ctx,
Socket = Socket, Socket = Socket,
Reactor = Reactor, Reactor = Reactor,
pollnet = pollnet, pollnet = pollnet,

View file

@ -3,43 +3,43 @@ pretty_print.table = function(node)
-- to make output beautiful -- to make output beautiful
local function tab(amt) local function tab(amt)
local str = "" local str = ""
for i=1,amt do for _ =1,amt do
str = str .. "\t" str = str .. "\t"
end end
return str return str
end end
local cache, stack, output = {},{},{} local cache, stack, output = {},{},{}
local depth = 1 local depth = 1
local output_str = "{\n" local output_str = "{\n"
while true do while true do
local size = 0 local size = 0
for k,v in pairs(node) do for _, _ in pairs(node) do
size = size + 1 size = size + 1
end end
local cur_index = 1 local cur_index = 1
for k,v in pairs(node) do for k,v in pairs(node) do
if (cache[node] == nil) or (cur_index >= cache[node]) then if (cache[node] == nil) or (cur_index >= cache[node]) then
if (string.find(output_str,"}",output_str:len())) then if (string.find(output_str,"}",output_str:len())) then
output_str = output_str .. ",\n" output_str = output_str .. ",\n"
elseif not (string.find(output_str,"\n",output_str:len())) then elseif not (string.find(output_str,"\n",output_str:len())) then
output_str = output_str .. "\n" output_str = output_str .. "\n"
end end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output,output_str) table.insert(output,output_str)
output_str = "" output_str = ""
local key local key
if (type(k) == "number" or type(k) == "boolean") then if (type(k) == "number" or type(k) == "boolean") then
key = "["..tostring(k).."]" key = "["..tostring(k).."]"
else else
key = "['"..tostring(k).."']" key = "['"..tostring(k).."']"
end end
if (type(v) == "number" or type(v) == "boolean") then if (type(v) == "number" or type(v) == "boolean") then
output_str = output_str .. tab(depth) .. key .. " = "..tostring(v) output_str = output_str .. tab(depth) .. key .. " = "..tostring(v)
elseif (type(v) == "table") then elseif (type(v) == "table") then
@ -51,7 +51,7 @@ pretty_print.table = function(node)
else else
output_str = output_str .. tab(depth) .. key .. " = '"..tostring(v).."'" output_str = output_str .. tab(depth) .. key .. " = '"..tostring(v).."'"
end end
if (cur_index == size) then if (cur_index == size) then
output_str = output_str .. "\n" .. tab(depth-1) .. "}" output_str = output_str .. "\n" .. tab(depth-1) .. "}"
else else
@ -63,10 +63,10 @@ pretty_print.table = function(node)
output_str = output_str .. "\n" .. tab(depth-1) .. "}" output_str = output_str .. "\n" .. tab(depth-1) .. "}"
end end
end end
cur_index = cur_index + 1 cur_index = cur_index + 1
end end
if (#stack > 0) then if (#stack > 0) then
node = stack[#stack] node = stack[#stack]
stack[#stack] = nil stack[#stack] = nil
@ -75,11 +75,11 @@ pretty_print.table = function(node)
break break
end end
end end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output,output_str) table.insert(output,output_str)
output_str = table.concat(output) output_str = table.concat(output)
return output_str return output_str
end end
return pretty_print return pretty_print

View file

@ -23,7 +23,7 @@ local function damage_received(damage, message, entity_id, add_healing_effect)
if not was_my_player then if not was_my_player then
return return
end end
module.recent_damage = module.recent_damage + damage module.recent_damage = module.recent_damage + damage
if message ~= nil then if message ~= nil then
module.recent_message = message module.recent_message = message
@ -62,7 +62,7 @@ function module.on_local_player_spawn(my_player)
}) })
end end
ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", true) ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", true)
end end
function module.on_world_update_client() function module.on_world_update_client()
@ -75,7 +75,7 @@ function module.on_world_update_client()
end end
end end
local last_health = nil local last_health
local function do_health_diff(hp, max_hp) local function do_health_diff(hp, max_hp)
local current_hp = util.get_ent_health(ctx.my_player.entity) local current_hp = util.get_ent_health(ctx.my_player.entity)
@ -155,21 +155,21 @@ ctx.cap.health = {
rpc.opts_reliable() rpc.opts_reliable()
function rpc.deal_damage(damage, message) function rpc.deal_damage(damage, message)
local message = GameTextGetTranslatedOrNot(message) .. " ("..ctx.rpc_player_data.name..")" local message_n = GameTextGetTranslatedOrNot(message) .. " ("..ctx.rpc_player_data.name..")"
module.last_damage_message = message module.last_damage_message = message_n
if ctx.is_host then if ctx.is_host then
local host_entity_id = ctx.my_player.entity local host_entity_id = ctx.my_player.entity
local protection_component_id = GameGetGameEffect(host_entity_id, "PROTECTION_ALL") local protection_component_id = GameGetGameEffect(host_entity_id, "PROTECTION_ALL")
if protection_component_id ~= 0 then if protection_component_id ~= 0 then
EntitySetComponentIsEnabled(host_entity_id, protection_component_id, false) EntitySetComponentIsEnabled(host_entity_id, protection_component_id, false)
end end
module.inflict_damage(damage) module.inflict_damage(damage)
if protection_component_id ~= 0 then if protection_component_id ~= 0 then
EntitySetComponentIsEnabled(host_entity_id, protection_component_id, true) EntitySetComponentIsEnabled(host_entity_id, protection_component_id, true)
end end
end end
GamePrint(string.format("Got %.2f damage: %s", damage*25, message)) GamePrint(string.format("Got %.2f damage: %s", damage*25, message_n))
end end
function rpc.update_shared_health(hp, max_hp) function rpc.update_shared_health(hp, max_hp)
@ -228,4 +228,4 @@ function rpc.melee_damage_client(target_peer, damage, message)
end end
np.CrossCallAdd("ew_ds_client_damaged", rpc.melee_damage_client) np.CrossCallAdd("ew_ds_client_damaged", rpc.melee_damage_client)
return module return module

View file

@ -1,7 +1,6 @@
local util = dofile_once("mods/quant.ew/files/core/util.lua") local util = dofile_once("mods/quant.ew/files/core/util.lua")
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 np = require("noitapatcher")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()
@ -22,4 +21,4 @@ np.CrossCallAdd("ew_ending_sequence", function()
rpc.gather_and_do_ending(x, y) rpc.gather_and_do_ending(x, y)
end) end)
return module return module

View file

@ -16,7 +16,7 @@ local spawned_by_us = {}
np.CrossCallAdd("ew_es_death_notify", function(enemy_id, responsible_id) 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 player_data = player_fns.get_player_data_by_local_entity_id(responsible_id)
local responsible = nil local responsible
if player_data ~= nil then if player_data ~= nil then
responsible = player_data.peer_id responsible = player_data.peer_id
else else
@ -83,7 +83,7 @@ function enemy_sync.host_upload_entities()
end end
local hp, max_hp, has_hp = util.get_ent_health(enemy_id) 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. -- Some things (like physics object) don't react well to making their entities ephemerial.
local not_ephemerial = false local not_ephemerial = false
@ -106,7 +106,7 @@ function enemy_sync.host_upload_entities()
-- local laser_sight_data = nil -- local laser_sight_data = nil
-- local laser_sight = EntityGetFirstComponentIncludingDisabled(enemy_id, "SpriteComponent", "laser_sight") -- local laser_sight = EntityGetFirstComponentIncludingDisabled(enemy_id, "SpriteComponent", "laser_sight")
-- if laser_sight ~= nil and laser_sight ~= 0 then -- if laser_sight ~= nil and laser_sight ~= 0 then
-- -- local x, y, r = -- -- local x, y, r =
-- end -- end
table.insert(enemy_data_list, {enemy_id, filename, x, y, vx, vy, hp, max_hp, phys_info, not_ephemerial}) table.insert(enemy_data_list, {enemy_id, filename, x, y, vx, vy, hp, max_hp, phys_info, not_ephemerial})
@ -217,7 +217,7 @@ function rpc.handle_enemy_data(enemy_data)
local has_died = filename == nil local has_died = filename == nil
local frame = GameGetFrameNum() local frame = GameGetFrameNum()
if confirmed_kills[remote_enemy_id] then if confirmed_kills[remote_enemy_id] then
goto continue goto continue
end end
@ -225,7 +225,7 @@ function rpc.handle_enemy_data(enemy_data)
if ctx.entity_by_remote_id[remote_enemy_id] ~= nil and not EntityGetIsAlive(ctx.entity_by_remote_id[remote_enemy_id].id) then if ctx.entity_by_remote_id[remote_enemy_id] ~= nil and not EntityGetIsAlive(ctx.entity_by_remote_id[remote_enemy_id].id) then
ctx.entity_by_remote_id[remote_enemy_id] = nil ctx.entity_by_remote_id[remote_enemy_id] = nil
end end
if ctx.entity_by_remote_id[remote_enemy_id] == nil then if ctx.entity_by_remote_id[remote_enemy_id] == nil then
if filename == nil then if filename == nil then
goto continue goto continue
@ -265,9 +265,9 @@ function rpc.handle_enemy_data(enemy_data)
end end
local enemy_data = ctx.entity_by_remote_id[remote_enemy_id] local enemy_data_new = ctx.entity_by_remote_id[remote_enemy_id]
enemy_data.frame = frame enemy_data_new.frame = frame
local enemy_id = enemy_data.id local enemy_id = enemy_data_new.id
local phys_component = EntityGetFirstComponent(enemy_id, "PhysicsBody2Component") local phys_component = EntityGetFirstComponent(enemy_id, "PhysicsBody2Component")
if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then
@ -329,4 +329,4 @@ function rpc.replicate_projectile(seri_ent, position_x, position_y, target_x, ta
end end
return enemy_sync return enemy_sync

View file

@ -11,13 +11,13 @@ end
local content = ModTextFileGetContent("data/genome_relations.csv") local content = ModTextFileGetContent("data/genome_relations.csv")
--The function works like this: genome_name is the name of your new genome/faction, --The function works like this: genome_name is the name of your new genome/faction,
--default_relation_ab is the relation with all the horizontal genomes which relations weren't specified in the table, --default_relation_ab is the relation with all the horizontal genomes which relations weren't specified in the table,
--default_relation_ba is the relation with all the vertical genomes which relations weren't specified in the table, --default_relation_ba is the relation with all the vertical genomes which relations weren't specified in the table,
--self relation is the genome's relation with itself, --self relation is the genome's relation with itself,
--relations is a table which directly specifies the value of the genome relation with. --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 lines = split_string(content, "\r\n")
local output = "" local output = ""
local genome_order = {} local genome_order = {}
@ -32,7 +32,7 @@ local function add_new_genome(content, genome_name, default_relation_ab, default
end end
local line = genome_name 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) line = line .. "," .. (relations[v] or default_relation_ab)
end end
output = output .. line .. "," .. self_relation output = output .. line .. "," .. self_relation
@ -40,11 +40,11 @@ local function add_new_genome(content, genome_name, default_relation_ab, default
return output return output
end end
content = add_new_genome(content, "notplayer", 100, 100, 100, { content = add_new_genome("notplayer", 100, 100, 100, {
player = 0, 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) ModTextFileSetContent("data/genome_relations.csv", content)

View file

@ -59,7 +59,7 @@ function rpc.fungal_shift(conversions, iter, from_material_name)
local add_icon = true local add_icon = true
local children = EntityGetAllChildren(entity) local children = EntityGetAllChildren(entity)
if children ~= nil then 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 if ( EntityGetName(it) == "fungal_shift_ui_icon" ) then
add_icon = false add_icon = false
break break
@ -90,4 +90,4 @@ np.CrossCallAdd("ew_fungal_shift", function(iter, from_material_name)
conversions = {} conversions = {}
end) end)
return module return module

View file

@ -1,7 +1,6 @@
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.lua") local net = dofile_once("mods/quant.ew/files/core/net.lua")
local util = dofile_once("mods/quant.ew/files/core/util.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.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") ModLuaFileAppend("data/scripts/items/heart_better.lua", "mods/quant.ew/files/system/heart_pickups/append/heart_better.lua")
@ -28,9 +27,9 @@ local function heart_pickup(heart)
local max_hp_increase = max_hp_increase_table[heart] local max_hp_increase = max_hp_increase_table[heart]
local hp, max_hp = ctx.cap.health.health(), ctx.cap.health.max_health() 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 player_count = tonumber(GlobalsGetValue("ew_player_count", "1"))
local max_hp_old = max_hp local max_hp_old = max_hp
if max_hp_increase ~= nil then if max_hp_increase ~= nil then
@ -76,4 +75,4 @@ function rpc.heart_pickup(heart)
heart_pickup(heart) heart_pickup(heart)
end end
return module return module

View file

@ -2,7 +2,6 @@
local inventory_helper = dofile_once("mods/quant.ew/files/core/inventory_helper.lua") 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 ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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") dofile_once("data/scripts/lib/coroutines.lua")
@ -92,7 +91,7 @@ function item_sync.host_localize_item(gid, peer_id)
return return
end end
ctx.item_prevent_localize[gid] = true ctx.item_prevent_localize[gid] = true
if table.contains(pending_remove, gid) then if table.contains(pending_remove, gid) then
GamePrint("Item localize prevented, already taken") GamePrint("Item localize prevented, already taken")
return return
@ -130,10 +129,10 @@ function item_sync.make_item_global(item, instant)
value_string = gid, value_string = gid,
}) })
end end
local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent") --local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent")
if vel then --if vel then
local vx, vy = ComponentGetValue2(vel, "mVelocity") -- local vx, vy = ComponentGetValue2(vel, "mVelocity")
end --end
local item_data = inventory_helper.serialize_single_item(item) local item_data = inventory_helper.serialize_single_item(item)
item_data.gid = gid item_data.gid = gid
ctx.item_prevent_localize[gid] = false ctx.item_prevent_localize[gid] = false
@ -186,7 +185,7 @@ function item_sync.on_world_update_client()
if thrown_item ~= nil and not EntityHasTag(thrown_item, "ew_client_item") then if thrown_item ~= nil and not EntityHasTag(thrown_item, "ew_client_item") then
item_sync.make_item_global(thrown_item) item_sync.make_item_global(thrown_item)
end end
local picked_item = get_global_ent("ew_picked") local picked_item = get_global_ent("ew_picked")
if picked_item ~= nil and EntityHasTag(picked_item, "ew_global_item") then if picked_item ~= nil and EntityHasTag(picked_item, "ew_global_item") then
local gid = item_sync.get_global_item_id(picked_item) local gid = item_sync.get_global_item_id(picked_item)
@ -252,8 +251,8 @@ function rpc.initial_items(item_list)
for _, item_data in ipairs(item_list) do for _, item_data in ipairs(item_list) do
local item = item_sync.find_by_gid(item_data.gid) local item = item_sync.find_by_gid(item_data.gid)
if item == nil then if item == nil then
local item = inventory_helper.deserialize_single_item(item_data) local item_new = inventory_helper.deserialize_single_item(item_data)
add_stuff_to_globalized_item(item, item_data.gid) add_stuff_to_globalized_item(item_new, item_data.gid)
end end
end end
end end
@ -295,4 +294,4 @@ ctx.cap.item_sync = {
end end
} }
return item_sync return item_sync

View file

@ -1,7 +1,6 @@
local util = dofile_once("mods/quant.ew/files/core/util.lua") local util = dofile_once("mods/quant.ew/files/core/util.lua")
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 np = require("noitapatcher")
dofile_once("data/scripts/lib/coroutines.lua") dofile_once("data/scripts/lib/coroutines.lua")
@ -67,7 +66,7 @@ function rpc.kolmi_shield(is_on, orbcount)
if kolmi == nil or kolmi == 0 then if kolmi == nil or kolmi == 0 then
return return
end end
if switch_shield(kolmi, is_on) then if switch_shield(kolmi, is_on) then
return return
end end
@ -137,4 +136,4 @@ ctx.cap.item_sync.register_pickup_handler(function(item_id)
end end
end) end)
return module return module

View file

@ -94,18 +94,18 @@ function module.on_world_update()
rpc.send_status(status) rpc.send_status(status)
end 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 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. -- 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() player_died()
end end
end end
if notplayer_active then --if notplayer_active then
local controls = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ControlsComponent") -- local controls = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ControlsComponent")
end --end
end end
function module.on_world_update_client() function module.on_world_update_client()

View file

@ -1,13 +1,12 @@
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 rpc = net.new_rpc_namespace()
local util = dofile_once("mods/quant.ew/files/core/util.lua") local util = dofile_once("mods/quant.ew/files/core/util.lua")
local nickname = {} local nickname = {}
function nickname.parse( font_filename ) function nickname.parse( font_filename )
local id_width = {} local id_width = {}
@ -18,7 +17,7 @@ function nickname.parse( font_filename )
local id = 0 local id = 0
local width = 0 local width = 0
for k, split in ipairs(util.string_split(file, "%s")) do for k, split in ipairs(util.string_split(file, "%s")) do
--print(string.sub(line, 2, 9)) --print(string.sub(line, 2, 9))
@ -49,13 +48,13 @@ function nickname.parse( font_filename )
if (split == "<QuadChar") then if (split == "<QuadChar") then
quad_open = true quad_open = true
end end
if (split == "<WordSpace>") then if (split == "<WordSpace>") then
space_open = true space_open = true
end end
end end
return id_width return id_width
end end
@ -67,7 +66,7 @@ function nickname.calculate_textwidth(text, font)
local l = string.sub( text, i, i) local l = string.sub( text, i, i)
if (l == " ") then if (l == " ") then
textwidth = textwidth + font["space"] textwidth = textwidth + font["space"]
else else
local c_id = string.byte(l) local c_id = string.byte(l)
--GamePrint("Char: ".. l .. ". Id: "..tostring(c_id)) --GamePrint("Char: ".. l .. ". Id: "..tostring(c_id))
textwidth = textwidth + (font[c_id] or 1) textwidth = textwidth + (font[c_id] or 1)
@ -137,4 +136,4 @@ function rpc.send_name(name)
nickname.add_label(ctx.rpc_player_data.entity, name, "data/fonts/font_pixel_white.xml", 0.75) nickname.add_label(ctx.rpc_player_data.entity, name, "data/fonts/font_pixel_white.xml", 0.75)
end end
return nickname return nickname

View file

@ -3,7 +3,7 @@ local wandfinder = dofile_once("mods/quant.ew/files/system/notplayer_ai/wandfind
local MAX_RADIUS = 128*4 local MAX_RADIUS = 128*4
local state = nil local state
local module = {} local module = {}
@ -65,9 +65,9 @@ local function init_state()
} }
end end
local target = nil local target
local last_length = nil local last_length
local last_did_hit = false local last_did_hit = false
@ -307,8 +307,8 @@ local function update()
ComponentSetValue2(state.control_component, "mButtonFrameFly", GameGetFrameNum()+1) ComponentSetValue2(state.control_component, "mButtonFrameFly", GameGetFrameNum()+1)
end end
state.was_w = state.control_w state.was_w = state.control_w
local _, y = EntityGetTransform(ctx.my_player.entity) local _, y_n = EntityGetTransform(ctx.my_player.entity)
ComponentSetValue2(state.control_component, "mFlyingTargetY", y - 10) ComponentSetValue2(state.control_component, "mFlyingTargetY", y_n - 10)
if (GameGetFrameNum() % 300) == 299 then if (GameGetFrameNum() % 300) == 299 then
teleport_to_next_hm() teleport_to_next_hm()

View file

@ -7,7 +7,7 @@ function collision_trigger()
local entity_id = GetUpdatedEntityID() local entity_id = GetUpdatedEntityID()
local pos_x, pos_y = EntityGetTransform( entity_id ) 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 ) EntityLoad( "data/entities/particles/image_emitters/magical_symbol_fast.xml", pos_x, pos_y )
EntityKill( entity_id ) EntityKill( entity_id )

View file

@ -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") 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") ModLuaFileAppend("data/scripts/misc/no_heal_in_meat_biome.lua", "mods/quant.ew/files/system/patch_meat_biome/append/biome_check.lua")

View file

@ -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 function hide_perk(perk_id)
local perk_data = get_perk_with_id(perk_list, perk_id) local perk_data = get_perk_with_id(perk_list, perk_id)
perk_data.not_in_default_perk_pool = true perk_data.not_in_default_perk_pool = true

View file

@ -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 function hide_perk(perk_id)
local perk_data = get_perk_with_id(perk_list, perk_id) local perk_data = get_perk_with_id(perk_list, perk_id)
perk_data.not_in_default_perk_pool = true perk_data.not_in_default_perk_pool = true

View file

@ -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 ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 np = require("noitapatcher")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()
@ -38,4 +36,4 @@ end
np.CrossCallAdd("ew_perks_modify_max_hp", rpc.modify_max_hp) np.CrossCallAdd("ew_perks_modify_max_hp", rpc.modify_max_hp)
return module return module

View file

@ -3,8 +3,8 @@ local net = dofile_once("mods/quant.ew/files/core/net.lua")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()
function player_color(player_entity) function player_color(player_entity)
local cape = nil local cape
local player_arm = nil local player_arm
local player_child_entities = EntityGetAllChildren( player_entity ) local player_child_entities = EntityGetAllChildren( player_entity )
if ( player_child_entities ~= nil ) then if ( player_child_entities ~= nil ) then

View file

@ -1,7 +1,7 @@
<Entity <Entity
name="client" name="client"
tags="mortal,human,hittable,peasant,prey,teleportable,ew_client,ew_peer,polymorphable_NOT" > tags="mortal,human,hittable,peasant,prey,teleportable,ew_client,ew_peer,polymorphable_NOT" >
<HotspotComponent <HotspotComponent
_tags="hand" _tags="hand"
sprite_hotspot_name="hand" sprite_hotspot_name="hand"
@ -18,14 +18,14 @@
offset.x="0" offset.x="0"
offset.y="2" offset.y="2"
></HotspotComponent> ></HotspotComponent>
<HotspotComponent <HotspotComponent
_tags="crouch_sensor" _tags="crouch_sensor"
offset.x="0" offset.x="0"
offset.y="-14" offset.y="-14"
></HotspotComponent> ></HotspotComponent>
<PhysicsPickUpComponent <PhysicsPickUpComponent
original_left_joint_pos.x="-8" original_left_joint_pos.x="-8"
original_left_joint_pos.y="-2" original_left_joint_pos.y="-2"
original_right_joint_pos.x="-2" original_right_joint_pos.x="-2"
@ -44,41 +44,41 @@
eating_area_max.y="6" eating_area_max.y="6"
eating_cells_per_frame="2" eating_cells_per_frame="2"
></PlatformShooterPlayerComponent> ></PlatformShooterPlayerComponent>
<PathFindingGridMarkerComponent <PathFindingGridMarkerComponent
player_marker_radius="100.0" player_marker_radius="100.0"
marker_offset_y="-3" marker_offset_y="-3"
marker_work_flag="8" marker_work_flag="8"
></PathFindingGridMarkerComponent> ></PathFindingGridMarkerComponent>
<PlayerCollisionComponent <PlayerCollisionComponent
getting_crushed_threshold="6" getting_crushed_threshold="6"
moving_up_before_getting_crushed_threshold="6" moving_up_before_getting_crushed_threshold="6"
></PlayerCollisionComponent > ></PlayerCollisionComponent >
<CharacterDataComponent <CharacterDataComponent
platforming_type="2" platforming_type="2"
check_collision_max_size_x="4" check_collision_max_size_x="4"
check_collision_max_size_y="4" check_collision_max_size_y="4"
climb_over_y="4" climb_over_y="4"
collision_aabb_min_x="-2.0" collision_aabb_min_x="-2.0"
collision_aabb_max_x="2.0" collision_aabb_max_x="2.0"
collision_aabb_min_y="-4.5" collision_aabb_min_y="-4.5"
collision_aabb_max_y="2.1" collision_aabb_max_y="2.1"
eff_hg_offset_y="1.28572" eff_hg_offset_y="1.28572"
eff_hg_position_x="0" eff_hg_position_x="0"
eff_hg_position_y="5" eff_hg_position_y="5"
eff_hg_size_x="6.42857" eff_hg_size_x="6.42857"
eff_hg_size_y="5.14286" eff_hg_size_y="5.14286"
eff_hg_velocity_max_x="19.5787896514" eff_hg_velocity_max_x="19.5787896514"
eff_hg_velocity_max_y="-11.5714" eff_hg_velocity_max_y="-11.5714"
eff_hg_velocity_min_x="-19.5714" eff_hg_velocity_min_x="-19.5714"
eff_hg_velocity_min_y="-40" eff_hg_velocity_min_y="-40"
eff_hg_damage_min="10" eff_hg_damage_min="10"
eff_hg_damage_max="95" eff_hg_damage_max="95"
eff_hg_update_box2d="0" eff_hg_update_box2d="0"
eff_hg_b2force_multiplier="0.0015" eff_hg_b2force_multiplier="0.0015"
effect_hit_ground="1" effect_hit_ground="1"
fly_time_max="3.0" fly_time_max="3.0"
fly_recharge_spd="0.4" fly_recharge_spd="0.4"
fly_recharge_spd_ground="6" fly_recharge_spd_ground="6"
@ -90,17 +90,17 @@
send_transform_update_message="1" send_transform_update_message="1"
></CharacterDataComponent> ></CharacterDataComponent>
<GenomeDataComponent <GenomeDataComponent
herd_id="player" herd_id="player"
food_chain_rank="20" food_chain_rank="20"
is_predator="1" is_predator="1"
berserk_dont_attack_friends="1" berserk_dont_attack_friends="1"
></GenomeDataComponent> ></GenomeDataComponent>
<CharacterPlatformingComponent <CharacterPlatformingComponent
animation_to_play="" animation_to_play=""
jump_keydown_buffer="2" jump_keydown_buffer="2"
jump_velocity_y="-95" jump_velocity_y="-95"
jump_velocity_x="56" jump_velocity_x="56"
fly_model_player="0" fly_model_player="0"
fly_smooth_y="0" fly_smooth_y="0"
@ -108,53 +108,53 @@
fly_speed_max_down="85" fly_speed_max_down="85"
fly_speed_mult="20" fly_speed_mult="20"
fly_speed_change_spd="0.25" fly_speed_change_spd="0.25"
mouse_look="1" mouse_look="1"
keyboard_look="1" keyboard_look="1"
mouse_look_buffer="1" mouse_look_buffer="1"
pixel_gravity="350" pixel_gravity="350"
run_velocity="154" run_velocity="154"
fly_velocity_x="52" fly_velocity_x="52"
accel_x="0.15" accel_x="0.15"
turning_buffer="0.5" turning_buffer="0.5"
velocity_min_x="-57" velocity_min_x="-57"
velocity_max_x="57" velocity_max_x="57"
velocity_min_y="-200" velocity_min_y="-200"
velocity_max_y="350" velocity_max_y="350"
></CharacterPlatformingComponent> ></CharacterPlatformingComponent>
<ControlsComponent <ControlsComponent
enabled="0" enabled="0"
gamepad_fire_on_thumbstick_extend="0" gamepad_fire_on_thumbstick_extend="0"
gamepad_fire_on_thumbstick_extend_threshold="0.9" gamepad_fire_on_thumbstick_extend_threshold="0.9"
gamepad_indirect_aiming_enabled="0" gamepad_indirect_aiming_enabled="0"
></ControlsComponent> ></ControlsComponent>
<DamageModelComponent <DamageModelComponent
air_in_lungs="7" air_in_lungs="7"
air_in_lungs_max="7" air_in_lungs_max="7"
air_lack_of_damage="0.6" air_lack_of_damage="0.6"
air_needed="1" air_needed="1"
falling_damage_damage_max="1.2" falling_damage_damage_max="1.2"
falling_damage_damage_min="0.1" falling_damage_damage_min="0.1"
falling_damage_height_max="250" falling_damage_height_max="250"
falling_damage_height_min="70" falling_damage_height_min="70"
falling_damages="0" falling_damages="0"
fire_damage_amount="0.2" fire_damage_amount="0.2"
fire_probability_of_ignition="1" fire_probability_of_ignition="1"
invincibility_frames="60" invincibility_frames="60"
hp="-1" hp="-1"
is_on_fire="0" is_on_fire="0"
materials_damage="1" materials_damage="1"
materials_that_damage="acid,lava,blood_cold_vapour,blood_cold,poison,radioactive_gas,radioactive_gas_static,rock_static_radioactive,rock_static_poison,ice_radioactive_static,ice_radioactive_glass,ice_acid_static,ice_acid_glass,rock_static_cursed,magic_gas_hp_regeneration,gold_radioactive,gold_static_radioactive,rock_static_cursed_green,cursed_liquid,poo_gas" materials_that_damage="acid,lava,blood_cold_vapour,blood_cold,poison,radioactive_gas,radioactive_gas_static,rock_static_radioactive,rock_static_poison,ice_radioactive_static,ice_radioactive_glass,ice_acid_static,ice_acid_glass,rock_static_cursed,magic_gas_hp_regeneration,gold_radioactive,gold_static_radioactive,rock_static_cursed_green,cursed_liquid,poo_gas"
materials_how_much_damage="0.005,0.003,0.0006,0.0009,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.005,-0.005,0.0002,0.0002,0.004,0.0005,0.00001" materials_how_much_damage="0.005,0.003,0.0006,0.0009,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.005,-0.005,0.0002,0.0002,0.004,0.0005,0.00001"
ragdoll_filenames_file="data/ragdolls/player/filenames.txt" ragdoll_filenames_file="data/ragdolls/player/filenames.txt"
ragdoll_offset_y="-5" ragdoll_offset_y="-5"
ragdollify_child_entity_sprites="1" ragdollify_child_entity_sprites="1"
blood_spray_material="blood" blood_spray_material="blood"
physics_objects_damage="0" physics_objects_damage="0"
critical_damage_resistance="1" critical_damage_resistance="1"
><damage_multipliers ><damage_multipliers
explosion="0.35" explosion="0.35"
holy="1.5" holy="1.5"
> >
</damage_multipliers> </damage_multipliers>
@ -165,59 +165,59 @@
suck_health="1" suck_health="1"
></MaterialSuckerComponent> ></MaterialSuckerComponent>
<HitboxComponent <HitboxComponent
aabb_max_x="3" aabb_max_x="3"
aabb_max_y="4" aabb_max_y="4"
aabb_min_x="-3" aabb_min_x="-3"
aabb_min_y="-12" aabb_min_y="-12"
is_enemy="0" is_enemy="0"
is_item="0" is_item="0"
is_player="1" is_player="1"
></HitboxComponent> ></HitboxComponent>
<HitboxComponent <HitboxComponent
_tags="crouched" _tags="crouched"
_enabled="0" _enabled="0"
aabb_max_x="3" aabb_max_x="3"
aabb_max_y="4" aabb_max_y="4"
aabb_min_x="-3" aabb_min_x="-3"
aabb_min_y="-8.5" aabb_min_y="-8.5"
is_enemy="0" is_enemy="0"
is_item="0" is_item="0"
is_player="1" is_player="1"
></HitboxComponent> ></HitboxComponent>
<Inventory2Component <Inventory2Component
_enabled="1" _enabled="1"
full_inventory_slots_x="0" full_inventory_slots_x="0"
full_inventory_slots_y="0" full_inventory_slots_y="0"
mSavedActiveItemIndex="0" mSavedActiveItemIndex="0"
quick_inventory_slots="4" quick_inventory_slots="4"
></Inventory2Component> ></Inventory2Component>
<SpriteAnimatorComponent> <SpriteAnimatorComponent>
</SpriteAnimatorComponent> </SpriteAnimatorComponent>
<SpriteComponent <SpriteComponent
_tags="character,lukki_disable" _tags="character,lukki_disable"
alpha="1" alpha="1"
image_file="MARKER_MAIN_SPRITE" image_file="MARKER_MAIN_SPRITE"
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.6" z_index="0.6"
></SpriteComponent> ></SpriteComponent>
<SpriteComponent <SpriteComponent
_tags="character,lukki_enable" _tags="character,lukki_enable"
_enabled="0" _enabled="0"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_lukky.xml" image_file="data/enemies_gfx/player_lukky.xml"
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.6" z_index="0.6"
></SpriteComponent> ></SpriteComponent>
@ -229,19 +229,19 @@
<Entity name="arm_r" tags="player_arm_r"> <Entity name="arm_r" tags="player_arm_r">
<SpriteComponent <SpriteComponent
_tags="with_item" _tags="with_item"
alpha="1" alpha="1"
image_file="MARKER_ARM_SPRITE" image_file="MARKER_ARM_SPRITE"
next_rect_animation="" next_rect_animation=""
rect_animation="default" rect_animation="default"
z_index="0.59" z_index="0.59"
></SpriteComponent> ></SpriteComponent>
<InheritTransformComponent <InheritTransformComponent
parent_hotspot_tag="right_arm_root" parent_hotspot_tag="right_arm_root"
only_position="1" only_position="1"
></InheritTransformComponent> ></InheritTransformComponent>
<HotspotComponent <HotspotComponent
_tags="hand" _tags="hand"
@ -305,7 +305,7 @@
event_name="player/pick_gold_sand" event_name="player/pick_gold_sand"
volume_autofade_speed="0.05" volume_autofade_speed="0.05"
></AudioLoopComponent> ></AudioLoopComponent>
<GunComponent> <GunComponent>
</GunComponent> </GunComponent>
@ -324,12 +324,12 @@
<ParticleEmitterComponent <ParticleEmitterComponent
offset.x="-2" offset.x="-2"
offset.y="5" offset.y="5"
lifetime_min="0.0" lifetime_min="0.0"
></ParticleEmitterComponent> ></ParticleEmitterComponent>
</Base> </Base>
<LightComponent <LightComponent
r="255" r="255"
g="255" g="255"
b="255" b="255"
@ -340,7 +340,7 @@
<VelocityComponent <VelocityComponent
updates_velocity="0" updates_velocity="0"
></VelocityComponent> ></VelocityComponent>
<!-- cape --> <!-- cape -->
<HotspotComponent <HotspotComponent
@ -348,125 +348,126 @@
sprite_hotspot_name="cape" > sprite_hotspot_name="cape" >
</HotspotComponent> </HotspotComponent>
<Entity name="cape"> <Entity name="cape">
<Base file="MARKER_CAPE"> <Base file="MARKER_CAPE">
</Base> </Base>
</Entity> </Entity>
<!-- belt --> <!-- belt -->
<HotspotComponent <HotspotComponent
_tags="belt_root" _tags="belt_root"
sprite_hotspot_name="belt" sprite_hotspot_name="belt"
></HotspotComponent> ></HotspotComponent>
<!-- ingestion --> <!-- ingestion -->
<MaterialInventoryComponent <MaterialInventoryComponent
_tags="ingestion" _tags="ingestion"
drop_as_item="0" drop_as_item="0"
on_death_spill="0" on_death_spill="0"
kill_when_empty="0" kill_when_empty="0"
></MaterialInventoryComponent> ></MaterialInventoryComponent>
<IngestionComponent <IngestionComponent
ingestion_capacity="7500" ingestion_capacity="7500"
overingestion_damage="0.002" overingestion_damage="0.002"
blood_healing_speed="0.0024" blood_healing_speed="0.0024"
></IngestionComponent> ></IngestionComponent>
<!-- --> <!-- -->
<WalletComponent> <WalletComponent>
</WalletComponent> </WalletComponent>
<StreamingKeepAliveComponent> <StreamingKeepAliveComponent>
</StreamingKeepAliveComponent> </StreamingKeepAliveComponent>
<KickComponent> <KickComponent>
</KickComponent> </KickComponent>
<VariableStorageComponent <VariableStorageComponent
name="ocarina_song" name="ocarina_song"
value_string="" value_string=""
></VariableStorageComponent> ></VariableStorageComponent>
<VariableStorageComponent <VariableStorageComponent
name="kantele_song" name="kantele_song"
value_string="" value_string=""
></VariableStorageComponent> ></VariableStorageComponent>
<VariableStorageComponent <VariableStorageComponent
name="ocarina_song_pos" name="ocarina_song_pos"
value_int="0" value_int="0"
></VariableStorageComponent> ></VariableStorageComponent>
<VariableStorageComponent <VariableStorageComponent
name="kantele_song_pos" name="kantele_song_pos"
value_int="0" value_int="0"
></VariableStorageComponent> ></VariableStorageComponent>
<SpriteComponent <SpriteComponent
_tags="character,player_amulet" _tags="character,player_amulet"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_amulet.xml" MARKER_AMULET_ENABLED
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.59" z_index="0.59"
_enabled="MARKER_AMULET_ENABLED" _enable="0"
></SpriteComponent> ></SpriteComponent>
<SpriteComponent <SpriteComponent
_tags="character,player_amulet_gem" _tags="character,player_amulet_gem"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_amulet_gem.xml" MARKER_AMULET_GEM_ENABLED
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.58" z_index="0.58"
_enabled="MARKER_AMULET_GEM_ENABLED" _enable="0"
></SpriteComponent> ></SpriteComponent>
<SpriteComponent <SpriteComponent
_tags="character,player_hat" _tags="character,player_hat"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_hat.xml" image_file="data/enemies_gfx/player_hat.xml"
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.59" z_index="0.59"
_enabled="0" _enabled="0"
></SpriteComponent> ></SpriteComponent>
<SpriteComponent <SpriteComponent
_tags="character,player_hat2" _tags="character,player_hat2"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_hat2.xml" image_file="data/enemies_gfx/player_hat2.xml"
next_rect_animation="" MARKER_HAT2_ENABLED
offset_x="6" next_rect_animation=""
offset_y="14" offset_x="6"
rect_animation="walk" offset_y="14"
rect_animation="walk"
z_index="0.58" z_index="0.58"
_enabled="MARKER_HAT2_ENABLED" _enable="0"
></SpriteComponent> ></SpriteComponent>
<SpriteComponent <SpriteComponent
_tags="character,player_hat2_shadow" _tags="character,player_hat2_shadow"
alpha="1" alpha="1"
image_file="data/enemies_gfx/player_hat2_shadow.xml" image_file="data/enemies_gfx/player_hat2_shadow.xml"
next_rect_animation="" next_rect_animation=""
offset_x="6" offset_x="6"
offset_y="14" offset_y="14"
rect_animation="walk" rect_animation="walk"
z_index="0.58" z_index="0.58"
_enabled="MARKER_HAT2_ENABLED" _enabled="MARKER_HAT2_ENABLED"
></SpriteComponent> ></SpriteComponent>
<ParticleEmitterComponent <ParticleEmitterComponent
_tags="fast_movement_particles" _tags="fast_movement_particles"
emitted_material_name="spark_white" emitted_material_name="spark_white"
offset.x="0" offset.x="0"
@ -501,7 +502,7 @@
> >
</ParticleEmitterComponent> </ParticleEmitterComponent>
<ParticleEmitterComponent <ParticleEmitterComponent
_tags="fast_movement_particles" _tags="fast_movement_particles"
emitted_material_name="spark_white" emitted_material_name="spark_white"
offset.x="-2" offset.x="-2"
@ -536,7 +537,7 @@
> >
</ParticleEmitterComponent> </ParticleEmitterComponent>
<ParticleEmitterComponent <ParticleEmitterComponent
_tags="fast_movement_particles" _tags="fast_movement_particles"
emitted_material_name="spark_white" emitted_material_name="spark_white"
offset.x="0" offset.x="0"
@ -576,21 +577,21 @@
value_string="" value_string=""
/> />
<Entity name="chunk_loader"> <Entity name="chunk_loader">
<Base file="mods/quant.ew/files/resource/entities/chunk_loader.xml"> <Base file="mods/quant.ew/files/resource/entities/chunk_loader.xml">
</Base> </Base>
</Entity> </Entity>
<Entity name="cursor"> <Entity name="cursor">
<SpriteComponent <SpriteComponent
alpha="1" alpha="1"
image_file="mods/quant.ew/files/resource/sprites/cursor.png" image_file="mods/quant.ew/files/resource/sprites/cursor.png"
next_rect_animation="" next_rect_animation=""
offset_x="6.5" offset_x="6.5"
offset_y="6.5" offset_y="6.5"
emissive="1" emissive="1"
additive="1" additive="1"
rect_animation="" rect_animation=""
z_index="1" z_index="1"
update_transform="1" update_transform="1"
update_transform_rotation="0" update_transform_rotation="0"

View file

@ -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 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() local gui = GuiCreate()
@ -14,10 +9,10 @@ local module = {}
local function world2gui( x, y ) local function world2gui( x, y )
in_camera_ref = in_camera_ref or false in_camera_ref = in_camera_ref or false
local gui = GuiCreate() local gui_n = GuiCreate()
GuiStartFrame(gui) GuiStartFrame(gui_n)
local w, h = GuiGetScreenDimensions( gui ) local w, h = GuiGetScreenDimensions(gui_n)
GuiDestroy(gui) GuiDestroy(gui_n)
local vres_scaling_factor = w/( MagicNumbersGetValue( "VIRTUAL_RESOLUTION_X" ) + MagicNumbersGetValue( "VIRTUAL_RESOLUTION_OFFSET_X" )) local vres_scaling_factor = w/( MagicNumbersGetValue( "VIRTUAL_RESOLUTION_X" ) + MagicNumbersGetValue( "VIRTUAL_RESOLUTION_OFFSET_X" ))
local cam_x, cam_y = GameGetCameraPos() local cam_x, cam_y = GameGetCameraPos()
@ -52,7 +47,7 @@ function module.on_world_update()
-- local dist_sq = player_dir_x * player_dir_x + player_dir_y * player_dir_y -- local dist_sq = player_dir_x * player_dir_x + player_dir_y * player_dir_y
-- player_dir_x = player_dir_x / dist -- player_dir_x = player_dir_x / dist
-- player_dir_y = player_dir_y / dist -- player_dir_y = player_dir_y / dist
local okay_to_display = false local okay_to_display = false
-- Contain the arrow in screen rect. -- Contain the arrow in screen rect.
@ -106,4 +101,4 @@ function module.on_world_update()
end end
end end
return module return module

View file

@ -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 ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
local np = require("noitapatcher")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()
@ -10,7 +8,7 @@ local module = {}
function rpc.player_update(input_data, pos_data, current_slot) function rpc.player_update(input_data, pos_data, current_slot)
local peer_id = ctx.rpc_peer_id local peer_id = ctx.rpc_peer_id
if not player_fns.peer_has_player(peer_id) then if not player_fns.peer_has_player(peer_id) then
player_fns.spawn_player_for(peer_id, pos_data.x, pos_data.y) player_fns.spawn_player_for(peer_id, pos_data.x, pos_data.y)
end end
@ -35,4 +33,4 @@ function module.on_world_update()
end end
end end
return module return module

View file

@ -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 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 player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
local tether_length = ctx.proxy_opt.tether_length local tether_length = ctx.proxy_opt.tether_length
@ -35,4 +33,4 @@ function module.on_world_update_client()
end end
end end
return module return module

View file

@ -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 ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 module = {}
local KEY_WORLD_FRAME = 0
local KEY_WORLD_END = 1
local CHUNK_SIZE = 128
function module.on_world_update() function module.on_world_update()
if GameGetFrameNum() % 30 ~= 6 then if GameGetFrameNum() % 30 ~= 6 then
return return
@ -26,4 +15,4 @@ function module.on_world_update()
end end
end end
return module return module

View file

@ -1,7 +1,5 @@
local util = dofile_once("mods/quant.ew/files/core/util.lua") local util = dofile_once("mods/quant.ew/files/core/util.lua")
local ctx = dofile_once("mods/quant.ew/files/core/ctx.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 np = require("noitapatcher")
local module = {} local module = {}
@ -56,7 +54,7 @@ end)
-- Called after entity was loaded. -- Called after entity was loaded.
-- Might be useless in some cases, as entity was already despawned/serialized due to CameraBoundComponent. -- Might be useless in some cases, as entity was already despawned/serialized due to CameraBoundComponent.
np.CrossCallAdd("ew_spawn_hook_post", function(ent_path, ent) np.CrossCallAdd("ew_spawn_hook_post", function(ent_path, ent)
end) end)
local entity_is_enemy_cache = {} local entity_is_enemy_cache = {}
@ -76,4 +74,4 @@ function module.entity_is_synced(ent_path)
return res return res
end end
return module return module

View file

@ -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 net = dofile_once("mods/quant.ew/files/core/net.lua")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()
@ -38,4 +37,4 @@ function rpc.apply_weather(weather_pattern)
end end
end end
return module return module

View file

@ -49,7 +49,7 @@ function world_sync.on_world_update_host()
local thread_impl = grid_world.mThreadImpl local thread_impl = grid_world.mThreadImpl
local begin = thread_impl.updated_grid_worlds.begin 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 local count = thread_impl.chunk_update_count
-- GamePrint("w update "..count) -- GamePrint("w update "..count)
@ -66,7 +66,7 @@ function world_sync.on_world_update_host()
end_x = end_x + 1 end_x = end_x + 1
end_y = end_y + 2 end_y = end_y + 2
-- if i < 9 then -- if i < 9 then
-- GamePrint(start_x.." "..start_y.." "..end_x.." "..end_y) -- GamePrint(start_x.." "..start_y.." "..end_x.." "..end_y)
-- end -- end
local rectangle = rect.Rectangle(start_x, start_y, end_x, end_y) local rectangle = rect.Rectangle(start_x, start_y, end_x, end_y)
@ -84,9 +84,9 @@ function world_sync.on_world_update_host()
end end
if #pending_send_wd == 0 then if #pending_send_wd == 0 then
rect_optimiser:scan() rect_optimiser:scan()
for crect in rect.parts(rect_optimiser:iterate(), 256) do 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. -- 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 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) 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) function world_sync.handle_world_data(world_data)
local grid_world = world_ffi.get_grid_world() 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) -- GamePrint("Decoding world data "..i)
local header = ffi.cast("struct EncodedAreaHeader const*", ffi.cast('char const*', datum)) 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)) local runs = ffi.cast(PixelRun_const_ptr, ffi.cast("const char*", datum) + ffi.sizeof(world.EncodedAreaHeader))
@ -125,4 +125,4 @@ function rpc.send_world_data(world_data)
end end
end end
return world_sync return world_sync

View file

@ -5,11 +5,10 @@ local ffi = require("ffi")
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.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 rpc = net.new_rpc_namespace()
local rect_optimiser = rect.Optimiser_new() --local rect_optimiser = rect.Optimiser_new()
local encoded_area = world.EncodedArea() local encoded_area = world.EncodedArea()
local world_sync = {} local world_sync = {}
@ -39,7 +38,7 @@ function world_sync.on_world_update()
local grid_world = world_ffi.get_grid_world() local grid_world = world_ffi.get_grid_world()
local chunk_map = grid_world.vtable.get_chunk_map(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 if GameGetFrameNum() % ctx.proxy_opt.world_sync_interval == 0 then
local player_data = ctx.my_player local player_data = ctx.my_player
@ -87,4 +86,4 @@ net.net_handling.proxy[0] = function(_, value)
world_sync.handle_world_data(value) world_sync.handle_world_data(value)
end end
return world_sync return world_sync

View file

@ -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") inventory_helper = dofile_once("mods/quant.ew/files/core/inventory_helper.lua")
constants = dofile_once("mods/quant.ew/files/core/constants.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 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)" 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 if (players[1]) then
np.RegisterPlayerEntityId(players[1]) 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") local controls_component = EntityGetFirstComponentIncludingDisabled(players[1], "ControlsComponent")
if (paused) then if (paused) then
--EntitySetComponentIsEnabled(players[1], inventory_gui, false) --EntitySetComponentIsEnabled(players[1], inventory_gui, false)

View file

@ -28,8 +28,8 @@ function mod_setting_change_callback( mod_id, gui, in_main_menu, setting, old_va
end end
local mod_id = "quant.ew" -- This should match the name of your mod's folder. local mod_id = "quant.ew" -- This should match the name of your mod's folder.
mod_settings_version = 1 -- This is a magic global that can be used to migrate settings to new mod versions. call mod_settings_get_version() before mod_settings_update() to get the old value. mod_settings_version = 1 -- This is a magic global that can be used to migrate settings to new mod versions. call mod_settings_get_version() before mod_settings_update() to get the old value.
mod_settings = mod_settings =
{ {
} }
@ -40,7 +40,7 @@ mod_settings =
-- - when entering the game after a restart (init_scope will be MOD_SETTING_SCOPE_RESTART) -- - 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) -- - 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 ) 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 ) mod_settings_update( mod_id, mod_settings, init_scope )
if ModIsEnabled(mod_id) then if ModIsEnabled(mod_id) then
print("Running early init fn") print("Running early init fn")
@ -61,4 +61,4 @@ end
-- This function is called to display the settings UI for this mod. Your mod's settings wont be visible in the mod settings menu if this function isn't defined correctly. -- This function is called to display the settings UI for this mod. Your mod's settings wont be visible in the mod settings menu if this function isn't defined correctly.
function ModSettingsGui( gui, in_main_menu ) function ModSettingsGui( gui, in_main_menu )
mod_settings_gui( mod_id, mod_settings, gui, in_main_menu ) mod_settings_gui( mod_id, mod_settings, gui, in_main_menu )
end end