From 8990fa3cb87cc28bbd0d7645fcaef773f47f6175 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 5 Sep 2025 10:00:03 -0500 Subject: [PATCH] add if-then node definition for checking monster range alive --- rsrc/strings/specials-text-ifthen.txt | 16 ++++++++++++++++ src/scenario/special-condition.cpp | 8 +++++++- src/scenario/special.hpp | 4 ++-- src/scenedit/scen.keydlgs.cpp | 11 ++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/rsrc/strings/specials-text-ifthen.txt b/rsrc/strings/specials-text-ifthen.txt index 83aeb75ba..ecb7b9694 100644 --- a/rsrc/strings/specials-text-ifthen.txt +++ b/rsrc/strings/specials-text-ifthen.txt @@ -525,3 +525,19 @@ Unused Otherwise call this special Result depends on the status of a quest. -------------------- +If Monster(s) Alive? +Unused +Unused +Unused +Unused +Unused +Unused +Unused +First monster +Last monster +Specific attitude? +If at least this many are alive ... +Call this special ... +Unused +Otherwise call this special +Result depends on how many monsters within the given range of townpeople are alive and present. \ No newline at end of file diff --git a/src/scenario/special-condition.cpp b/src/scenario/special-condition.cpp index 366c39787..68723a0e9 100644 --- a/src/scenario/special-condition.cpp +++ b/src/scenario/special-condition.cpp @@ -9,7 +9,7 @@ #include "special-conditions.hpp" // Note: If adding a new node type below, be sure to adjust the end point here too. -node_category_info_t CAT_COND{eSpecType::IF_SDF, eSpecType::IF_QUEST}; +node_category_info_t CAT_COND{eSpecType::IF_SDF, eSpecType::IF_MONSTERS_ALIVE}; namespace { node_properties_t S_SDF = node_builder_t(eSpecType::IF_SDF) @@ -165,4 +165,10 @@ namespace { .ex1b(STRT_QUEST_STATUS) .ex1c(eSpecPicker::NODE) .no_preview(); + node_properties_t S_MONSTERS_ALIVE = node_builder_t(eSpecType::IF_MONSTERS_ALIVE) + .ex1a(eSpecPicker::TOWNPERSON) + .ex1b(eSpecPicker::TOWNPERSON) + .ex1c(STRT_ATTITUDE_FILTER) + .ex2b(eSpecPicker::NODE) + .no_preview(); } diff --git a/src/scenario/special.hpp b/src/scenario/special.hpp index 7262b70f3..713537469 100644 --- a/src/scenario/special.hpp +++ b/src/scenario/special.hpp @@ -55,7 +55,7 @@ enum class eSpecType { IF_STATUS = 145, IF_LOOKING = 146, IF_DAY_REACHED = 147, IF_FIELDS = 148, IF_PARTY_SIZE = 149, IF_EVENT_OCCURRED = 150, IF_SPECIES = 151, IF_TRAIT = 152, IF_STATISTIC = 153, IF_TEXT_RESPONSE = 154, IF_SDF_EQ = 155, IF_CONTEXT = 156, IF_NUM_RESPONSE = 157, IF_IN_BOAT = 158, IF_ON_HORSE = 159, - IF_QUEST = 160, + IF_QUEST = 160, IF_MONSTERS_ALIVE = 161, MAKE_TOWN_HOSTILE = 170, TOWN_RUN_MISSILE = 171, TOWN_MONST_ATTACK = 172, TOWN_BOOM_SPACE = 173, TOWN_MOVE_PARTY = 174, TOWN_HIT_SPACE = 175, TOWN_EXPLODE_SPACE = 176, TOWN_LOCK_SPACE = 177, TOWN_UNLOCK_SPACE = 178, TOWN_SFX_BURST = 179, @@ -218,7 +218,7 @@ enum eStrType { STRT_DEBUG_PRINT, STRT_TARG_TYPE, STRT_TARG_MODE, STRT_ID_MODE, STRT_CURSE_MODE, STRT_EQUIP_MODE, STRT_CMP_MODE, STRT_PATH, STRT_SPELL_PAT_MODE, - STRT_LABEL_ALIGN, STRT_HORSE, STRT_BOAT, + STRT_LABEL_ALIGN, STRT_HORSE, STRT_BOAT, STRT_ATTITUDE_FILTER }; const char*const stairDlogs[8] = { diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index a46fe33ec..0e8c0fcec 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -642,6 +642,12 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, std } } break; + case STRT_ATTITUDE_FILTER: + strings = {"Any", "Any Friendly", "Any Hostile"}; + for(std::string str : attitude_disp_strs){ + strings.push_back(str); + } + break; } if(cur_choice < 0 || cur_choice >= strings.size()) cur_choice = -1; @@ -1560,6 +1566,7 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& case STRT_BOAT: title = "Which boat?"; break; case STRT_HORSE: title = "Which horse?"; break; case STRT_TALK: title = "Which personality?"; break; + case STRT_ATTITUDE_FILTER: title = "What attitude(s)?"; break; default: title = "Title not set for this string type!!!"; break; } if(fcn.str_type == STRT_SECTOR && fcn.continuation == eSpecField::NONE) { @@ -1591,6 +1598,8 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& store += 79; } else if(fcn.str_type == STRT_ANY_SPELL && store >= nMageSpells) { store += 100 - nMageSpells; + } else if(fcn.str_type == STRT_ATTITUDE_FILTER) { + store -= 3; } } break; case eSpecPicker::PICTURE: { @@ -1727,7 +1736,7 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& case eSpecPicker::POINTER: store = val; break; // TODO: Not implemented... case eSpecPicker::TOWNPERSON: if(town->creatures.empty()){ - showWarning("There are no creatures in this town to change attitude!"); + showWarning("There are no creatures in this town to choose from!"); break; } if(alt_button){