From f47f37ffd81a1e8dde825ca57ef9faef9eacd2fc Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 9 Jul 2024 21:30:19 +0200 Subject: [PATCH] custom land list mode now can configure PTM runs/multipliers --- landlock.cpp | 17 +++++++++++++++++ yendor.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/landlock.cpp b/landlock.cpp index 94bbcfe3..0810cbee 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -781,6 +781,7 @@ EX array custom_land_list; EX array custom_land_treasure; EX array custom_land_difficulty; EX array custom_land_wandering; +EX array custom_land_ptm_runs, custom_land_ptm_mult; EX bool isLandIngame(eLand l) { if(isElemental(l)) l = laElementalWall; @@ -915,6 +916,20 @@ EX void customize_land_in_list(eLand l) { dialog::get_ne().reaction = mark_tamper; }); + dialog::addSelItem(XLAT("PTM runs"), its(custom_land_ptm_runs[l]), 'r'); + dialog::add_action([l] { + dialog::editNumber(custom_land_ptm_runs[l], 0, 10, 3, 1, XLAT("%the1: number of PTM runs", linf[l].name), ""); + dialog::get_ne().reaction = mark_tamper; + dialog::bound_up(10); + dialog::bound_low(0); + }); + + dialog::addSelItem(XLAT("PTM multiplier"), its(custom_land_ptm_mult[l]), 'm'); + dialog::add_action([l] { + dialog::editNumber(custom_land_ptm_mult[l], 0, 100, 1, 1, XLAT("%the1: PTM multiplier", linf[l].name), ""); + dialog::get_ne().reaction = mark_tamper; + }); + gen_landvisited(); if(landvisited[l]) { dialog::addItem(XLAT("test"), 'T'); @@ -938,6 +953,8 @@ EX void customize_land_list() { custom_land_treasure[l] = 100; custom_land_difficulty[l] = 100; custom_land_wandering[l] = 100; + custom_land_ptm_runs[l] = tactic::default_runs(l); + custom_land_ptm_mult[l] = tactic::default_mult(l); } if(dialog::infix != "" && !dialog::hasInfix(linf[l].name)) return false; if(l == laCanvas) return true; diff --git a/yendor.cpp b/yendor.cpp index 4a6dc78d..aa7b9eb2 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -734,8 +734,18 @@ EX namespace tactic { }; map> scoreboard; + EX int default_runs(eLand l) { + return l == laCamelot ? 1 : 3; + } + + EX int default_mult(eLand l) { + return l == laCamelot ? 3 : 1; + } + + /** also called 'runs' */ EX int chances(eLand l, modecode_t xc IS(modecode())) { - if(xc != 0 && l != laCamelot) return 3; + if(use_custom_land_list) return max(min(custom_land_ptm_runs[l], 10), 1); + if(xc != 0) return default_runs(l); for(auto& ti: land_tac) if(ti.l == l) return ti.tries; @@ -743,8 +753,8 @@ EX namespace tactic { } int tacmultiplier(eLand l) { - if(modecode() != 0 && l != laCamelot) return 1; - if(modecode() != 0 && l == laCamelot) return 3; + if(use_custom_land_list) return custom_land_ptm_mult[l]; + if(modecode() != 0) return default_mult(l); for(auto& ti: land_tac) if(ti.l == l) return ti.multiplier; @@ -832,6 +842,7 @@ EX namespace tactic { dynamicval t(tactic::on, true); generateLandList([] (eLand l) { if(dialog::infix != "" && !dialog::hasInfix(linf[l].name)) return false; + if(use_custom_land_list) return custom_land_list[l] && custom_land_ptm_runs[l] > 0; return !!(land_validity(l).flags & lv::appears_in_ptm); }); } @@ -1026,6 +1037,21 @@ EX void save_mode_data(hstream& f) { f.write(7); f.write(vid.creature_scale); } + if(use_custom_land_list) { + bool ptm_modified = false; + for(int i=0; i(8); + f.write(landtypes); + for(int i=0; i(custom_land_ptm_runs[i]); + f.write(custom_land_ptm_mult[i]); + } + } + } } EX eLandStructure get_default_land_structure() { @@ -1101,6 +1127,8 @@ EX void load_mode_data_with_zero(hstream& f) { custom_land_treasure[i] = f.get(); custom_land_difficulty[i] = f.get(); custom_land_wandering[i] = f.get(); + custom_land_ptm_runs[i] = tactic::default_runs(eLand(i)); + custom_land_ptm_mult[i] = tactic::default_mult(eLand(i)); } break; } @@ -1120,6 +1148,15 @@ EX void load_mode_data_with_zero(hstream& f) { case 7: vid.creature_scale = f.get(); + case 8: { + if(!use_custom_land_list) throw hstream_exception("PTM defined in a non-custom mode"); + int lt = f.get(); + for(int i=0; i();; + } + break; + } + default: throw hstream_exception("wrong option"); }