From 4bb83e6f59b45c0ed55268ee26ed228e8d5a5de8 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 17 Mar 2025 19:37:49 -0400 Subject: [PATCH] Update labels for If Context node and add a picker for the spell when context is "targeting" --- rsrc/strings/specials-text-ifthen.txt | 2 +- src/scenario/special-condition.cpp | 9 +++++++-- src/scenario/special.hpp | 2 +- src/scenedit/scen.keydlgs.cpp | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/rsrc/strings/specials-text-ifthen.txt b/rsrc/strings/specials-text-ifthen.txt index bf0525db..c900149c 100644 --- a/rsrc/strings/specials-text-ifthen.txt +++ b/rsrc/strings/specials-text-ifthen.txt @@ -449,7 +449,7 @@ Unused Unused Unused Which context -Prevent entry? +Unused|Prevent entry?|Spell being cast (-1 = any spell) If context matches, call this special ... Unused Unused diff --git a/src/scenario/special-condition.cpp b/src/scenario/special-condition.cpp index 69be8186..0338e20c 100644 --- a/src/scenario/special-condition.cpp +++ b/src/scenario/special-condition.cpp @@ -107,8 +107,13 @@ namespace { .ex1b(eSpecPicker::NODE); node_properties_t S_CONTEXT = node_builder_t(eSpecType::IF_CONTEXT) .ex1a(STRT_CONTEXT) - .ex1b(eSpecPicker::TOGGLE) - .ex1c(eSpecPicker::NODE); + .ex1c(eSpecPicker::NODE) + .when(eSpecField::EX1A < 3, 1) + .ex1b(eSpecPicker::TOGGLE) + .end() + .when(eSpecField::EX1A == 16, 2) + .ex1b(STRT_ANY_SPELL) + .end(); node_properties_t S_NUM = node_builder_t(eSpecType::IF_NUM_RESPONSE) .msg1(+eSpecPicker::MSG_SINGLE) .pict(STRT_CMP_MODE) diff --git a/src/scenario/special.hpp b/src/scenario/special.hpp index f94db548..f087bc58 100644 --- a/src/scenario/special.hpp +++ b/src/scenario/special.hpp @@ -137,7 +137,7 @@ enum eStrType { STRT_MONST, STRT_ITEM, STRT_TER, STRT_BUTTON, STRT_SPEC_ITEM, STRT_MAGE, STRT_PRIEST, STRT_ALCHEMY, STRT_TOWN, STRT_SECTOR, STRT_SKILL, STRT_SKILL_CHECK, - STRT_TRAIT, STRT_RACE, + STRT_TRAIT, STRT_RACE, STRT_ANY_SPELL, STRT_PICT, STRT_CMP, STRT_ACCUM, STRT_TRAP, STRT_ATTITUDE, STRT_STAIR, STRT_LIGHT, STRT_CONTEXT, STRT_SHOP, STRT_COST_ADJ, STRT_STAIR_MODE, STRT_TALK_NODE, diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index 90f5a10b..2a7e6f30 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -461,6 +461,14 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, std strings.push_back((*cSpell::fromNum(eSkill::PRIEST_SPELLS, i)).name()); } break; + case STRT_ANY_SPELL: + for(int i = 0; i < 255; i++) { + eSpell spell = cSpell::fromNum(i); + if(spell != eSpell::NONE) { + strings.push_back((*spell).name()); + } + } + break; case STRT_ALCHEMY: for(int i = 0; i < 20; i++) { strings.push_back(get_str("magic-names", i + 200)); @@ -1131,6 +1139,7 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& case STRT_ALCHEMY: title = "Which recipe?"; break; case STRT_MAGE: title = "Which spell?"; break; case STRT_PRIEST: title = "Which spell?"; break; + case STRT_ANY_SPELL: title = "Which spell?"; break; case STRT_SKILL: title = "Which statistic?"; break; case STRT_SKILL_CHECK: title = "Which statistic?"; break; case STRT_TRAIT: title = "Which trait?"; break; @@ -1175,10 +1184,21 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& break; } auto otherField = get_control_for_field(fcn.continuation); + static int nMageSpells; if(fcn.str_type == STRT_SECTOR) { val = val * scenario.outdoors.height() + me[otherField].getTextAsNum(); } else if(fcn.str_type == STRT_SKILL_CHECK && val >= 100) { val -= 79; + } else if(fcn.str_type == STRT_ANY_SPELL && val >= 100) { + if(nMageSpells == 0) { + for(int i = 0; i < 100; i++) { + if(cSpell::fromNum(i) == eSpell::NONE) { + nMageSpells = i; + break; + } + } + } + val -= 100 - nMageSpells; } store = choose_text(fcn.str_type, val + fcn.adjust, &me, title) - fcn.adjust; if(fcn.str_type == STRT_SECTOR) { @@ -1186,6 +1206,8 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& store /= scenario.outdoors.height(); } else if(fcn.str_type == STRT_SKILL_CHECK && store > 20) { store += 79; + } else if(fcn.str_type == STRT_ANY_SPELL && store >= nMageSpells) { + store += 100 - nMageSpells; } } break; case eSpecPicker::PICTURE: {