From c7ec0e3a85b57335bf204dfc4ce77e2db5db6d56 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 19 Feb 2025 12:01:27 -0600 Subject: [PATCH] Debug action: fill active PC's inventory --- src/game/boe.actions.cpp | 21 ++++++++++++++++++++- src/game/boe.actions.hpp | 1 + src/game/boe.main.cpp | 3 +++ src/scenario/item.cpp | 6 ++++++ src/scenario/item.hpp | 1 + 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index cd37ed74..28d52928 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -2015,6 +2015,24 @@ void debug_give_item() { put_pc_screen(); // In case the item was food or gold } +void debug_overburden() { + if(recording){ + record_action("debug_overburden", ""); + } + + cPlayer& pc = univ.current_pc(); + cItem item(ITEM_DEBUG_HEAVY); + // Give the PC very heavy objects that do nothing: + while(pc.give_item(item, GIVE_ALLOW_OVERLOAD)){} + if(pc.has_space()){ + // I don't know why this would ever happen, since the weight is 0, but just in case: + ASB("Debug: failed to fill " + pc.name + "'s inventory."); + }else{ + ASB("Debug: filled " + pc.name + "'s inventory."); + } + print_buf(); +} + void debug_print_location() { if(recording){ record_action("debug_print_location", ""); @@ -2390,7 +2408,7 @@ void show_debug_help() { } // Non-comprehensive list of unused keys: -// Y chijklnoqvy @#$-_+[]{},.'"`~/\|;: +// chijklnoqvy @#$-_+[]{},.'"`~/\|;: void init_debug_actions() { add_debug_action({'B'}, "Leave town", debug_leave_town); add_debug_action({'C'}, "Get cleaned up (lose negative status effects)", debug_clean_up); @@ -2401,6 +2419,7 @@ void init_debug_actions() { add_debug_action({'H'}, "Heal", debug_heal); // This one was missing from the old help dialog: add_debug_action({'I'}, "Give item", debug_give_item); + add_debug_action({'Y'}, "Fill PC's inventory", debug_overburden); // TODO this is not recorded or replayed because the rsrc you pick might not even be packaged // in the build add_debug_action({'J'}, "Preview a dialog's layout", preview_dialog_xml); diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index d5aaf3f1..3c74554d 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -86,6 +86,7 @@ void init_debug_actions(); void show_debug_help(); void debug_fight_encounter(bool wandering); void debug_give_item(); +void debug_overburden(); void debug_print_location(); void debug_step_through(); void debug_leave_town(); diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 420ab418..8fadad72 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -784,6 +784,9 @@ static void replay_action(Element& action) { }else if(t == "debug_give_item"){ debug_give_item(); return; + }else if(t == "debug_overburden"){ + debug_overburden(); + return; }else if(t == "debug_print_location"){ debug_print_location(); return; diff --git a/src/scenario/item.cpp b/src/scenario/item.cpp index 4fb037d7..88feddca 100644 --- a/src/scenario/item.cpp +++ b/src/scenario/item.cpp @@ -334,6 +334,12 @@ cItem::cItem(eItemPreset preset) : cItem() { name = "Potion"; magic = true; break; + case ITEM_DEBUG_HEAVY: + variety = eItemType::NON_USE_OBJECT; + full_name = name = "Debug heavy item"; + ident = true; + weight = 300; + break; case ITEM_SPECIAL: item_level = -1; full_name = "Call Special Node"; diff --git a/src/scenario/item.hpp b/src/scenario/item.hpp index 6d3bede8..b4330d76 100644 --- a/src/scenario/item.hpp +++ b/src/scenario/item.hpp @@ -35,6 +35,7 @@ enum eItemPreset { ITEM_FOOD, ITEM_SPELL, ITEM_POTION, + ITEM_DEBUG_HEAVY, ITEM_SPECIAL, ITEM_SHOP, };