Stop gamble perk from being added, add seed selector.

This commit is contained in:
IQuant 2024-06-27 12:26:59 +03:00
parent 8a649b3abe
commit 4c95fb6768
4 changed files with 36 additions and 31 deletions

View file

@ -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

View file

@ -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 = Выберите язык

View file

@ -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<LanguageIdentifier>,
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::<u64>() {
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);

View file

@ -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)