From 7a597761898a99d57991d8d09b3d015976c234bd Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Thu, 29 Jan 2015 21:16:44 -0500 Subject: [PATCH] Various special node fixes/tweaks - Fix secret passage nodes (CANT_ENTER with ex1a = 0, ex2a = 1) not working - Set many flags now sets the entire row of 50 flags - Division node now accepts either SDF to be null - New mode for append item to buffer - adds the item's "interesting string" rather than its name - Affect mage/priest spell inverted the meaning of ex1b relative to other affect nodes; this has been fixed - Fix affect party status being confused about which fields mean what (the implementation had one idea, and the porting of old scenarios had a different idea, and the scenario editor had yet a different idea). In addition, it now allows removing the statuses. - Fix some typos in special node information for the editor --- rsrc/strings/special-contexts.txt | 2 +- rsrc/strings/specials-text-affect.txt | 10 +++--- rsrc/strings/specials-text-general.txt | 42 +++++++++++++------------- rsrc/strings/trap-types.txt | 1 + src/boe.specials.cpp | 26 ++++++++++------ src/boe.townspec.cpp | 2 +- src/classes/living.cpp | 17 ++++++++--- src/classes/special.cpp | 15 +++++---- 8 files changed, 67 insertions(+), 48 deletions(-) diff --git a/rsrc/strings/special-contexts.txt b/rsrc/strings/special-contexts.txt index 23ad0e72..bd4e473d 100644 --- a/rsrc/strings/special-contexts.txt +++ b/rsrc/strings/special-contexts.txt @@ -11,7 +11,7 @@ Town event timer triggered Scenario event timer triggered Special node timer triggered Killed a monster -Entetred outdoor combat +Entered outdoor combat Fled outdoor encounter Won outdoor encounter Targetung spell diff --git a/rsrc/strings/specials-text-affect.txt b/rsrc/strings/specials-text-affect.txt index 9e3c9f62..eb49efeb 100644 --- a/rsrc/strings/specials-text-affect.txt +++ b/rsrc/strings/specials-text-affect.txt @@ -297,7 +297,7 @@ Unused Amount (0 .. 10) 0 - increase, 1 - decrease Unused -Statistic to adjust (0..21) +Statistic to adjust (0..20) Unused Unused Special to Jump To @@ -311,7 +311,7 @@ Unused Unused Unused Which Spell (0 .. 61) -0 - remove, 1 - give +1 - remove, 0 - give Unused Unused Unused @@ -327,7 +327,7 @@ Unused Unused Unused Which Spell (0 .. 61) -0 - remove, 1 - give +1 - remove, 0 - give Unused Unused Unused @@ -391,11 +391,11 @@ Unused Unused Unused Amount (0 .. 250) +0 - increase, 1 - decrease +Unused Which effect (0 .. 3) Unused Unused -Unused -Unused Special to Jump To -------------------- Create New PC diff --git a/rsrc/strings/specials-text-general.txt b/rsrc/strings/specials-text-general.txt index 5aa5d63d..14e68182 100644 --- a/rsrc/strings/specials-text-general.txt +++ b/rsrc/strings/specials-text-general.txt @@ -383,19 +383,19 @@ Unused Special to Jump To -------------------- Display Picture -sdf1 -sdf2 +Unused +Unused Picture title string -msg2 -msg3 -pic -pt +Unused +Unused +Unused +Unused Number of large (full-sheet) pic to display -ex1b -ex1c -ex2a -ex2b -ex2c +Unused +Unused +Unused +Unused +Unused Special to Jump To -------------------- Have a Rest @@ -472,26 +472,26 @@ Unused Unused Campaign Flag Part A (0..24) Campaign Flag Part B (0..24) -ex1c +Unused 0 - Set Campaign Flag, 1 - Retrieve Flag -ex2b -ex2c +Unused +Unused Special to Jump To -------------------- Debug Print Numbers Stuff Done Flag Part A Stuff Done Flag Part B -msg1 -msg2 -msg3 +Unused +Unused +Unused 0 - SDF, 1 - extra1 values, 2 - monster hp/mp -pt +Unused Number of monster, or value to print Value to print (could be a pointer) Value to print (could be a pointer) -ex2a -ex2b -ex2c +Unused +Unused +Unused Special to Jump To -------------------- Multiplication diff --git a/rsrc/strings/trap-types.txt b/rsrc/strings/trap-types.txt index 1350496a..398b4c5f 100644 --- a/rsrc/strings/trap-types.txt +++ b/rsrc/strings/trap-types.txt @@ -1,3 +1,4 @@ +Random Trap (out of next 4) Knife Trap Poison Dart Poison Gas (affects whole party) diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 38f63b44..4b66fc2d 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -199,6 +199,8 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, if(!is_blocked(where_check)) runSpecial = true; if(ter_special == eTerSpec::CHANGE_WHEN_STEP_ON) runSpecial = true; if(ter_special == eTerSpec::CALL_SPECIAL) runSpecial = true; + if(univ.town->specials[*spec_num].type == eSpecType::CANT_ENTER) + runSpecial = true; if(!PSD[SDF_NO_BOAT_SPECIALS] && univ.party.in_boat >= 0 && univ.scenario.ter_types[ter].boat_over) runSpecial = true; if(runSpecial) { @@ -2202,7 +2204,7 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::SET_SDF_ROW: if(spec.sd1 != minmax(0,299,spec.sd1)) giveError("Stuff Done flag out of range."); - else for(i = 0; i < 10; i++) PSD[spec.sd1][i] = spec.ex1a; + else for(i = 0; i < 50; i++) PSD[spec.sd1][i] = spec.ex1a; break; case eSpecType::COPY_SDF: if(!univ.party.sd_legit(spec.sd1,spec.sd2) || !univ.party.sd_legit(spec.ex1a,spec.ex1b)) @@ -2286,8 +2288,10 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::SDF_DIFF: setsd(spec.sd1, spec.sd2, i - j); break; case eSpecType::SDF_TIMES: setsd(spec.sd1, spec.sd2, i * j); break; case eSpecType::SDF_DIVIDE: - setsd(spec.sd1, spec.sd2, i / j); - setsd(spec.ex1c, spec.ex2c, i % j); + if(univ.party.sd_legit(spec.sd1, spec.sd2)) + setsd(spec.sd1, spec.sd2, i / j); + if(univ.party.sd_legit(spec.ex1c, spec.ex2c)) + setsd(spec.ex1c, spec.ex2c, i % j); break; case eSpecType::SDF_POWER: if(i == 2) setsd(spec.sd1, spec.sd2, 1 << j); @@ -2374,8 +2378,10 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } else univ.scenario.get_buf() += univ.scenario.scen_monsters[spec.ex1a].m_name; break; case eSpecType::APPEND_ITEM: - if(spec.ex1b) + if(spec.ex1b == 1) univ.scenario.get_buf() += univ.scenario.scen_items[spec.ex1a].full_name; + else if(spec.ex1b == 2) + univ.scenario.get_buf() += get_item_interesting_string(univ.scenario.scen_items[spec.ex1a]); else univ.scenario.get_buf() += univ.scenario.scen_items[spec.ex1a].name; break; case eSpecType::APPEND_TER: @@ -2922,7 +2928,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } for(i = 0; i < 6; i++) if(pc_num == 6 || pc_num == i) - univ.party[i].mage_spells[spec.ex1a] = spec.ex1b; + univ.party[i].mage_spells[spec.ex1a] = !spec.ex1b; break; case eSpecType::AFFECT_PRIEST_SPELL: if(pc_num >= 100) break; @@ -2932,7 +2938,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } for(i = 0; i < 6; i++) if(pc_num == 6 || pc_num == i) - univ.party[i].priest_spells[spec.ex1a] = spec.ex1b; + univ.party[i].priest_spells[spec.ex1a] = !spec.ex1b; break; case eSpecType::AFFECT_GOLD: if(spec.ex1b == 0) @@ -2957,12 +2963,14 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, break; case eSpecType::AFFECT_PARTY_STATUS: if(spec.ex2a < 0 || spec.ex2a > 3) break; - if(spec.ex2a == 1 && univ.party.in_boat >= 0) + if(spec.ex1b == 0 && spec.ex2a == 1 && univ.party.in_boat >= 0) add_string_to_buf(" Can't fly when on a boat."); - else if(spec.ex2a == 1 && univ.party.in_horse >= 0) + else if(spec.ex1b == 0 && spec.ex2a == 1 && univ.party.in_horse >= 0) add_string_to_buf(" Can't fly when on a horse."); r1 = univ.party.status[ePartyStatus(spec.ex2a)]; - r1 = minmax(0,250,r1 + spec.ex1a); + if(spec.ex1b == 0) + r1 = minmax(0,250,r1 + spec.ex1a); + else r1 = minmax(0,250,r1 - spec.ex1a); univ.party.status[ePartyStatus::STEALTH] = r1; break; case eSpecType::AFFECT_TRAITS: diff --git a/src/boe.townspec.cpp b/src/boe.townspec.cpp index 67826715..bb888fd2 100644 --- a/src/boe.townspec.cpp +++ b/src/boe.townspec.cpp @@ -45,7 +45,7 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) { num_hits += trap_level; if(trap_type == TRAP_RANDOM) - trap_type = (eTrapType) get_ran(1,0,4); + trap_type = (eTrapType) get_ran(1,1,4); if(trap_type == TRAP_FALSE_ALARM) return true; diff --git a/src/classes/living.cpp b/src/classes/living.cpp index bd8fe001..a2e79eac 100644 --- a/src/classes/living.cpp +++ b/src/classes/living.cpp @@ -12,6 +12,8 @@ #include "mathutil.hpp" void iLiving::apply_status(eStatus which, int how_much) { + if(!is_alive()) return; + static const std::set allow_negative = { // The obvious ones: eStatus::BLESS_CURSE, eStatus::HASTE_SLOW, @@ -22,12 +24,17 @@ void iLiving::apply_status(eStatus which, int how_much) { eStatus::MAGIC_RESISTANCE, eStatus::DUMB, }; - // TODO: Martyr's Shield range seems to be 0..10; Paralyzed seems to range something like 0..1000 + int lo = 0, hi = 8; - if(!is_alive()) return; - status[which] = minmax(-8,8,status[which] + how_much); - if(!allow_negative.count(which)) - status[which] = max(status[which],0); + if(which == eStatus::MARTYRS_SHIELD) + hi = 10; + else if(which == eStatus::PARALYZED) + hi = 5000; + + if(allow_negative.count(which)) + lo = -hi; + + status[which] = minmax(lo,hi,status[which] + how_much); } void iLiving::clear_bad_status() { diff --git a/src/classes/special.cpp b/src/classes/special.cpp index d73a3374..1f4c6511 100644 --- a/src/classes/special.cpp +++ b/src/classes/special.cpp @@ -104,7 +104,7 @@ void cSpecial::append(legacy::special_node_type& old){ break; case 99: case 100: // Add mage/priest spell TODO: Merge these by adding 100 if it's a priest spell ex1a += 30; - ex1b = 1; // Meaning give spell, not take + ex1b = 0; // Meaning give spell, not take break; case 148: case 149: // if barrels or crates type = eSpecType::IF_FIELDS; @@ -201,15 +201,18 @@ void cSpecial::append(legacy::special_node_type& old){ // Party statuses (three nodes collapsed into one) case 104: type = eSpecType::AFFECT_STATUS; - ex1c = int(ePartyStatus::STEALTH); + ex1b = 0; + ex2a = int(ePartyStatus::STEALTH); break; case 105: type = eSpecType::AFFECT_STATUS; - ex1c = int(ePartyStatus::FIREWALK); + ex1b = 0; + ex2a = int(ePartyStatus::FIREWALK); break; case 106: type = eSpecType::AFFECT_STATUS; - ex1c = int(ePartyStatus::FLIGHT); + ex1b = 0; + ex2a = int(ePartyStatus::FLIGHT); break; // Place fields (twelve individual node types were collapsed into one) case 200: @@ -422,9 +425,9 @@ static const char*const button_dict[7][11] = { " 5", // pic " s", // pictype " w q AP a ", // ex1a - " E ", // ex1b + " ", // ex1b " e Q", // ex1c - " K ", // ex2a + " K E ", // ex2a " D ", // ex2b " x ", // ex2c }, { // if-then nodes