From 4c95fb6768b39a2deba3112956a301accb2d58de Mon Sep 17 00:00:00 2001 From: IQuant Date: Thu, 27 Jun 2024 12:26:59 +0300 Subject: [PATCH] Stop gamble perk from being added, add seed selector. --- noita-proxy/assets/lang/en-US/main.ftl | 1 + noita-proxy/assets/lang/ru-RU/main.ftl | 1 + noita-proxy/src/lib.rs | 25 +++++++--------- quant.ew/files/src/perk_fns.lua | 40 +++++++++++++++----------- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/noita-proxy/assets/lang/en-US/main.ftl b/noita-proxy/assets/lang/en-US/main.ftl index a98c9baf..1b2f7fe2 100644 --- a/noita-proxy/assets/lang/en-US/main.ftl +++ b/noita-proxy/assets/lang/en-US/main.ftl @@ -9,6 +9,7 @@ connect_settings = Game settings connect_settings_debug = Debug settings connect_settings_debug_en = Debug/cheat mode connect_settings_debug_fixed_seed = Use fixed seed +connect_settings_seed = Seed: connect_settings_wsv = World sync version to use: lang_picker = Choose a language diff --git a/noita-proxy/assets/lang/ru-RU/main.ftl b/noita-proxy/assets/lang/ru-RU/main.ftl index 49a7b2b9..1008ebc9 100644 --- a/noita-proxy/assets/lang/ru-RU/main.ftl +++ b/noita-proxy/assets/lang/ru-RU/main.ftl @@ -9,6 +9,7 @@ connect_settings = Настройки игры connect_settings_debug = Настройки разработчика connect_settings_debug_en = Подрубить читы connect_settings_debug_fixed_seed = Фиксированный сид мира +connect_settings_seed = Сид: connect_settings_wsv = Версия синхронизатора мира: lang_picker = Выберите язык diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index 5539b32b..741c32ef 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -8,7 +8,7 @@ use std::{ use bitcode::{Decode, Encode}; use clipboard::{ClipboardContext, ClipboardProvider}; use eframe::egui::{ - self, Align2, Button, Color32, InnerResponse, Key, Margin, OpenUrl, Rect, RichText, + self, Align2, Button, Color32, DragValue, InnerResponse, Key, Margin, OpenUrl, Rect, RichText, TextureOptions, Ui, Vec2, }; use egui_plot::{Plot, PlotPoint, PlotUi, Text}; @@ -54,7 +54,7 @@ struct AppSavedState { times_started: u32, world_sync_version: u32, lang_id: Option, - constant_seed: String, + constant_seed: u64, } impl Default for AppSavedState { @@ -67,7 +67,7 @@ impl Default for AppSavedState { times_started: 0, world_sync_version: 1, lang_id: None, - constant_seed: "0".to_string(), + constant_seed: 0, } } } @@ -165,16 +165,9 @@ impl App { settings.world_sync_version = self.saved_state.world_sync_version; if !self.saved_state.use_constant_seed { settings.seed = rand::random(); - } - else { - match self.saved_state.constant_seed.parse::() { - Ok(i) => settings.seed = i, - Err(..) => { - println!("fail {}", self.saved_state.constant_seed); - settings.seed = 0; - self.notify_error("bad seed"); - }, - }; + } else { + settings.seed = self.saved_state.constant_seed; + info!("Using constant seed: {}", settings.seed); } netman.accept_local.store(true, Ordering::SeqCst); } @@ -285,7 +278,11 @@ impl App { &mut self.saved_state.use_constant_seed, tr("connect_settings_debug_fixed_seed"), ); - ui.text_edit_singleline(&mut self.saved_state.constant_seed); + + ui.horizontal(|ui| { + ui.label(tr("connect_settings_seed")); + ui.add(DragValue::new(&mut self.saved_state.constant_seed)); + }); ui.add_space(20.0); diff --git a/quant.ew/files/src/perk_fns.lua b/quant.ew/files/src/perk_fns.lua index e032e742..f52c4006 100644 --- a/quant.ew/files/src/perk_fns.lua +++ b/quant.ew/files/src/perk_fns.lua @@ -3,6 +3,10 @@ local util = dofile_once("mods/quant.ew/files/src/util.lua") local perk_fns = {} +local perks_to_ignore = { + GAMBLE = true, +} + function perk_fns.get_my_perks() local perks = {} for i=1, #perk_list do @@ -16,24 +20,26 @@ function perk_fns.get_my_perks() end local function give_one_perk(entity_who_picked, perk_info, count) - -- add game effect - if perk_info.game_effect ~= nil then - local game_effect_comp = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect, true ) - if game_effect_comp ~= nil then - ComponentSetValue( game_effect_comp, "frames", "-1" ) - end - end + if not perks_to_ignore[perk_info.id] then + -- add game effect + if perk_info.game_effect ~= nil then + local game_effect_comp = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect, true ) + if game_effect_comp ~= nil then + ComponentSetValue( game_effect_comp, "frames", "-1" ) + end + end - if perk_info.game_effect2 ~= nil then - local game_effect_comp = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect2, true ) - if game_effect_comp ~= nil then - ComponentSetValue( game_effect_comp, "frames", "-1" ) - end - end + if perk_info.game_effect2 ~= nil then + local game_effect_comp = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect2, true ) + if game_effect_comp ~= nil then + ComponentSetValue( game_effect_comp, "frames", "-1" ) + end + end - if perk_info.func ~= nil then - perk_info.func( 0, entity_who_picked, "", count ) - end + if perk_info.func ~= nil then + perk_info.func( 0, entity_who_picked, "", count ) + end + end end function perk_fns.update_perks(perk_data, player_data) @@ -43,7 +49,7 @@ function perk_fns.update_perks(perk_data, player_data) local current = (current_counts[perk_id] or 0) local diff = count - current -- TODO handle diff < 0? - if diff ~= 0 then + if diff ~= 0 then local perk_info = get_perk_with_id(perk_list, perk_id) if perk_info == nil then print("Unknown perk id: "..perk_id)