From 76295e2f25d00fac3b902bea69fb2874248eb029 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 28 Jan 2015 17:43:22 -0500 Subject: [PATCH] Separate summoned monster duration from whether it was summoned by the party --- src/boe.actions.cpp | 4 +-- src/boe.combat.cpp | 51 +++++++++++++++++---------------------- src/boe.items.cpp | 2 +- src/boe.monster.cpp | 11 +++++---- src/boe.monster.h | 2 +- src/boe.party.cpp | 22 ++++++++--------- src/boe.specials.cpp | 10 ++++---- src/boe.town.cpp | 2 +- src/classes/creatlist.cpp | 2 +- src/classes/creature.cpp | 12 ++++++--- src/classes/creature.hpp | 3 ++- 11 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index 2b937c15..a7f4a731 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -531,9 +531,9 @@ static void handle_talk(location destination, bool& did_something, bool& need_re need_redraw = true; if(univ.town.monst[i].attitude % 2 == 1) { add_string_to_buf(" Creature is hostile."); - } else if(univ.town.monst[i].summoned > 0 || univ.town.monst[i].personality < 0) { + } else if(univ.town.monst[i].summon_time > 0 || univ.town.monst[i].personality < 0) { short small_talk = 1; - if(!univ.town.monst[i].summoned) + if(univ.town.monst[i].summon_time == 0) small_talk = -univ.town.monst[i].personality; std::string str = "No response."; if(small_talk > 1000) str = univ.scenario.spec_strs[small_talk - 1000]; diff --git a/src/boe.combat.cpp b/src/boe.combat.cpp index 2ba9d725..9d8506e9 100644 --- a/src/boe.combat.cpp +++ b/src/boe.combat.cpp @@ -1199,59 +1199,59 @@ void do_combat_cast(location target) { switch(spell_being_cast) { case eSpell::SIMULACRUM: r2 = get_ran(3,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster(store_sum_monst,target,r2,2)) + if(!summon_monster(store_sum_monst,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_BEAST: r2 = get_ran(3,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if((summon == 0) || (!summon_monster(summon,target,r2,2))) + if((summon == 0) || (!summon_monster(summon,target,r2,2,true))) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_WEAK: r2 = get_ran(4,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if((summon == 0) || (!summon_monster(summon,target,r2,2))) + if((summon == 0) || (!summon_monster(summon,target,r2,2,true))) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON: r2 = get_ran(5,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if((summon == 0) || (!summon_monster(summon,target,r2,2))) + if((summon == 0) || (!summon_monster(summon,target,r2,2,true))) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_MAJOR: r2 = get_ran(7,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if((summon == 0) || (!summon_monster(summon,target,r2,2))) + if((summon == 0) || (!summon_monster(summon,target,r2,2,true))) add_string_to_buf(" Summon failed."); break; case eSpell::DEMON: r2 = get_ran(5,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster(85,target,r2,2)) + if(!summon_monster(85,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_RAT: r1 = get_ran(3,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster(80,target,r1,2)) + if(!summon_monster(80,target,r1,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_SPIRIT: r2 = get_ran(2,1,5) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster(125,target,r2,2)) + if(!summon_monster(125,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::STICKS_TO_SNAKES: r1 = get_ran(1,0,7); r2 = get_ran(2,1,5) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster((r1 == 1) ? 100 : 99,target,r2,2)) + if(!summon_monster((r1 == 1) ? 100 : 99,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_HOST: // host r2 = get_ran(2,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster((i == 0) ? 126 : 125,target,r2,2)) + if(!summon_monster((i == 0) ? 126 : 125,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_GUARDIAN: // guardian r2 = get_ran(6,1,4) + caster.stat_adj(eSkill::INTELLIGENCE); - if(!summon_monster(122,target,r2,2)) + if(!summon_monster(122,target,r2,2,true)) add_string_to_buf(" Summon failed."); break; default: @@ -2124,12 +2124,12 @@ void do_monster_turn() { // Now take care of summoned monsters if(cur_monst->active > 0) { - if((cur_monst->summoned % 100) == 1) { + if(cur_monst->summon_time == 1) { cur_monst->active = 0; cur_monst->ap = 0; cur_monst->spell_note(17); } - move_to_zero(cur_monst->summoned); + move_to_zero(cur_monst->summon_time); } } @@ -2473,12 +2473,12 @@ void do_monster_turn() { } if(what_summon) r1 = get_ran(1, abil.summon.min, abil.summon.max); else r1 = 0; - if(r1 && summon_monster(what_summon, cur_monst->cur_loc,abil.summon.len,cur_monst->attitude)) { + if(r1 && summon_monster(what_summon, cur_monst->cur_loc,abil.summon.len,cur_monst->attitude,cur_monst->is_friendly())) { cur_monst->spell_note(33); play_sound(61); bool failed = false; while(--r1 && !failed) { - failed = summon_monster(what_summon, cur_monst->cur_loc,abil.summon.len,cur_monst->attitude); + failed = summon_monster(what_summon,cur_monst->cur_loc,abil.summon.len,cur_monst->attitude,cur_monst->is_friendly()); } } } @@ -3361,8 +3361,7 @@ bool monst_cast_mage(cCreature *caster,short targ) { x = get_ran(3,1,4); play_sound(25); play_sound(-61); - summon_monster(r1,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude); + summon_monster(r1,caster->cur_loc,x,caster->attitude,caster->is_friendly()); break; case eSpell::CONFLAGRATION: run_a_missile(l,target,13,1,25,0,0,80); @@ -3400,8 +3399,7 @@ bool monst_cast_mage(cCreature *caster,short targ) { x = get_ran(4,1,4); for(i = 0; i < j; i++){ play_sound(-61); - if(!summon_monster(r1,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude)) { + if(!summon_monster(r1,caster->cur_loc,x,caster->attitude,caster->is_friendly())) { add_string_to_buf(" Summon failed."); i = j;} } break; @@ -3473,8 +3471,7 @@ bool monst_cast_mage(cCreature *caster,short targ) { play_sound(25); play_sound(-61); sf::sleep(time_in_ticks(12)); // gives sound time to end - summon_monster(85,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude); + summon_monster(85,caster->cur_loc,x,caster->attitude,caster->is_friendly()); break; case eSpell::BLESS_MAJOR: play_sound(25); @@ -3664,8 +3661,7 @@ bool monst_cast_priest(cCreature *caster,short targ) { play_sound(-61); x = get_ran(3,1,4); - summon_monster(spell == eSpell::SUMMON_SPIRIT ? 125 : 122,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude); + summon_monster(spell == eSpell::SUMMON_SPIRIT ? 125 : 122,caster->cur_loc,x,caster->attitude,caster->is_friendly()); break; case eSpell::DISEASE: run_a_missile(l,vict_loc,11,0,24,0,0,80); @@ -3701,8 +3697,7 @@ bool monst_cast_priest(cCreature *caster,short targ) { play_sound(-61); r2 = get_ran(1,0,7); x = get_ran(3,1,4); - summon_monster((r2 == 1) ? 100 : 99,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude); + summon_monster((r2 == 1) ? 100 : 99,caster->cur_loc,x,caster->attitude,caster->is_friendly()); } break; case eSpell::MARTYRS_SHIELD: // martyr's shield @@ -3713,12 +3708,10 @@ bool monst_cast_priest(cCreature *caster,short targ) { play_sound(24); x = get_ran(3,1,4) + 1; play_sound(-61); - summon_monster(126,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude); + summon_monster(126,caster->cur_loc,x,caster->attitude,caster->is_friendly()); for(i = 0; i < 4; i++) { play_sound(-61); - if(!summon_monster(125,caster->cur_loc, - ((caster->attitude % 2 != 1) ? 0 : 100) + x,caster->attitude)) + if(!summon_monster(125,caster->cur_loc,x,caster->attitude,caster->is_friendly())) i = 4; } break; diff --git a/src/boe.items.cpp b/src/boe.items.cpp index 7263e42a..859948be 100644 --- a/src/boe.items.cpp +++ b/src/boe.items.cpp @@ -381,7 +381,7 @@ void set_town_attitude(short lo,short hi,short att) { std::swap(lo, hi); for(i = lo; i <= hi; i++) { - if((univ.town.monst[i].active > 0) && (univ.town.monst[i].summoned == 0)){ + if(univ.town.monst[i].active > 0 && univ.town.monst[i].summon_time == 0){ univ.town.monst[i].attitude = att; num = univ.town.monst[i].number; // If made hostile, make mobile diff --git a/src/boe.monster.cpp b/src/boe.monster.cpp index 2f490aaf..17b04c4c 100644 --- a/src/boe.monster.cpp +++ b/src/boe.monster.cpp @@ -169,7 +169,7 @@ void set_up_monst(short mode,mon_num_t m_num) { cMonster& monst = m_num >= 10000 ? univ.party.summons[m_num - 10000] : univ.scenario.scen_monsters[m_num]; univ.town.monst.assign(which, cCreature(m_num), monst, PSD[SDF_EASY_MODE], univ.difficulty_adjust()); univ.town.monst[which].active = 2; - univ.town.monst[which].summoned = 0; + univ.town.monst[which].summon_time = 0; univ.town.monst[which].attitude = mode + 1; univ.town.monst[which].mobility = 1; } @@ -1250,7 +1250,7 @@ short place_monster(mon_num_t which,location where) { univ.town.monst[i].mobility = 1; univ.town.monst[i].active = 2; univ.town.monst[i].cur_loc = where; - univ.town.monst[i].summoned = 0; + univ.town.monst[i].summon_time = 0; univ.town.monst[i].target = 6; univ.town.set_crate(where.x,where.y,false); @@ -1263,7 +1263,7 @@ short place_monster(mon_num_t which,location where) { // returns true if placement was successful //which; // if in town, this is caster loc., if in combat, this is where to try // to put monster -bool summon_monster(mon_num_t which,location where,short duration,short given_attitude) { +bool summon_monster(mon_num_t which,location where,short duration,short given_attitude,bool by_party) { location loc; short spot; @@ -1296,7 +1296,8 @@ bool summon_monster(mon_num_t which,location where,short duration,short given_at univ.town.monst[spot].attitude = given_attitude; - univ.town.monst[spot].summoned = duration; + univ.town.monst[spot].summon_time = duration; + univ.town.monst[spot].party_summoned = by_party; univ.town.monst[spot].spell_note(21); return true; @@ -1314,7 +1315,7 @@ void activate_monsters(short code,short /*attitude*/) { univ.town.monst[i].spec_enc_code = 0; univ.town.monst[i].active = 2; - univ.town.monst[i].summoned = 0; + univ.town.monst[i].summon_time = 0; univ.town.monst[i].target = 6; univ.town.set_crate(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y,false); diff --git a/src/boe.monster.h b/src/boe.monster.h index eb70108d..8b78c726 100644 --- a/src/boe.monster.h +++ b/src/boe.monster.h @@ -33,7 +33,7 @@ void monst_inflict_fields(short which_monst); bool monst_check_special_terrain(location where_check,short mode,short which_monst); void record_monst(cCreature *which_m); short place_monster(mon_num_t which,location where); -bool summon_monster(mon_num_t which,location where,short duration,short given_attitude); +bool summon_monster(mon_num_t which,location where,short duration,short given_attitude,bool by_party); void activate_monsters(short code,short attitude); short get_encumberance(short pc_num); mon_num_t get_summon_monster(short summon_class); diff --git a/src/boe.party.cpp b/src/boe.party.cpp index dffe4038..6f61bc94 100644 --- a/src/boe.party.cpp +++ b/src/boe.party.cpp @@ -864,7 +864,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; store = get_ran(3,1,4) + adj; - if(!summon_monster(r1,where,store,2)) + if(!summon_monster(r1,where,store,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_WEAK: @@ -876,7 +876,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { univ.party[pc_num].cur_sp -= (*spell_num).cost; store = get_ran(4,1,4) + adj; for(i = 0; i < j; i++) - if(!summon_monster(r1,where,store,2)) + if(!summon_monster(r1,where,store,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON: @@ -888,7 +888,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { univ.party[pc_num].cur_sp -= (*spell_num).cost; store = get_ran(5,1,4) + adj; for(i = 0; i < j; i++) - if(!summon_monster(r1,where,store,2)) + if(!summon_monster(r1,where,store,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::SUMMON_MAJOR: @@ -900,19 +900,19 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { univ.party[pc_num].cur_sp -= (*spell_num).cost; store = get_ran(7,1,4) + adj; for(i = 0; i < j; i++) - if(!summon_monster(r1,where,store,2)) + if(!summon_monster(r1,where,store,2,true)) add_string_to_buf(" Summon failed."); break; case eSpell::DEMON: store = get_ran(5,1,4) + 2 * adj; - if(!summon_monster(85,where,store,2)) + if(!summon_monster(85,where,store,2,true)) add_string_to_buf(" Summon failed."); else if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; break; case eSpell::SUMMON_RAT: store = get_ran(5,1,4) + 2 * adj; - if(!summon_monster(80,where,store,2)) + if(!summon_monster(80,where,store,2,true)) add_string_to_buf(" Summon failed."); break; @@ -1063,7 +1063,7 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { break; case eSpell::SUMMON_SPIRIT: - if(!summon_monster(125,where,get_ran(2,1,4) + adj,2)) + if(!summon_monster(125,where,get_ran(2,1,4) + adj,2,true)) add_string_to_buf(" Summon failed."); else if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; @@ -1075,7 +1075,7 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { for(i = 0; i < r1; i++) { r2 = get_ran(1,0,7); store = get_ran(2,1,5) + adj; - if(!summon_monster((r2 == 1) ? 100 : 99,where,store,2 )) + if(!summon_monster((r2 == 1) ? 100 : 99,where,store,2,true)) add_string_to_buf(" Summon failed."); } break; @@ -1083,17 +1083,17 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; store = get_ran(2,1,4) + adj; - if(!summon_monster(126,where,store,2)) + if(!summon_monster(126,where,store,2,true)) add_string_to_buf(" Summon failed."); for(i = 0; i < 4; i++) { store = get_ran(2,1,4) + adj; - if(!summon_monster(125,where,store,2)) + if(!summon_monster(125,where,store,2,true)) add_string_to_buf(" Summon failed."); } break; case eSpell::SUMMON_GUARDIAN: store = get_ran(6,1,4) + adj; - if(!summon_monster(122,where,store,2)) + if(!summon_monster(122,where,store,2,true)) add_string_to_buf(" Summon failed."); else if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 00dd4c30..6ced576b 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -1128,14 +1128,14 @@ void use_item(short pc,short item) { else do_mage_spell(current_pc, spell, true); break; case eItemAbil::SUMMONING: - if(!summon_monster(univ.party[pc].items[item].abil_data[1],user_loc,str,2)) + if(!summon_monster(univ.party[pc].items[item].abil_data[1],user_loc,str,2,true)) add_string_to_buf(" Summon failed."); break; case eItemAbil::MASS_SUMMONING: r1 = get_ran(str,1,4); j = get_ran(1,3,5); for(i = 0; i < j; i++) - if(!summon_monster(univ.party[pc].items[item].abil_data[1],user_loc,r1,2)) + if(!summon_monster(univ.party[pc].items[item].abil_data[1],user_loc,r1,2,true)) add_string_to_buf(" Summon failed."); break; case eItemAbil::QUICKFIRE: @@ -1625,7 +1625,7 @@ void kill_monst(cCreature *which_m,short who_killed,eMainStatus type) { if(which_m->abil[eMonstAbil::DEATH_TRIGGER].active) run_special(eSpecCtx::KILL_MONST,0,which_m->abil[eMonstAbil::DEATH_TRIGGER].special.extra1,which_m->cur_loc,&s1,&s2,&s3); - if((!in_scen_debug) && ((which_m->summoned >= 100) || (which_m->summoned == 0))) { // no xp for party-summoned monsters + if(!in_scen_debug && (which_m->summon_time == 0 || !which_m->party_summoned)) { // no xp for party-summoned monsters xp = which_m->level * 2; if(who_killed < 6) award_xp(who_killed,xp); @@ -1640,7 +1640,7 @@ void kill_monst(cCreature *which_m,short who_killed,eMainStatus type) { place_glands(l,which_m->number); } - if((!in_scen_debug) && (which_m->summoned == 0)) + if(!in_scen_debug && which_m->summon_time == 0) place_treasure(which_m->cur_loc, which_m->level / 2, which_m->treasure, 0); i = which_m->cur_loc.x; @@ -1668,7 +1668,7 @@ void kill_monst(cCreature *which_m,short who_killed,eMainStatus type) { break; } - if(((is_town()) || (which_combat_type == 1)) && (which_m->summoned == 0)) { + if((is_town() || which_combat_type == 1) && which_m->summon_time == 0) { univ.party.m_killed[univ.town.num]++; } diff --git a/src/boe.town.cpp b/src/boe.town.cpp index ff657e0a..2d922f0d 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -196,7 +196,7 @@ void start_town_mode(short which_town, short entry_dir) { univ.town.monst[j].mp = univ.town.monst[j].max_mp; univ.town.monst[j].morale = univ.town.monst[j].m_morale; univ.town.monst[j].status.clear(); - if(univ.town.monst[j].summoned > 0) + if(univ.town.monst[j].summon_time > 0) univ.town.monst[j].active = 0; univ.town.monst[j].target = 6; } diff --git a/src/classes/creatlist.cpp b/src/classes/creatlist.cpp index ecef8dae..5303bbfd 100644 --- a/src/classes/creatlist.cpp +++ b/src/classes/creatlist.cpp @@ -59,7 +59,7 @@ void cPopulation::assign(size_t n, const cTownperson& other, const cMonster& bas dudes[n].attitude = dudes[n].start_attitude; dudes[n].cur_loc = dudes[n].start_loc; dudes[n].target = 6; // No target - dudes[n].summoned = 0; + dudes[n].summon_time = 0; } void cPopulation::readFrom(std::istream& in, size_t n) { diff --git a/src/classes/creature.cpp b/src/classes/creature.cpp index 630812ee..b06bf6b4 100644 --- a/src/classes/creature.cpp +++ b/src/classes/creature.cpp @@ -19,7 +19,7 @@ cCreature::cCreature(){ number = active = attitude = start_attitude = 0; start_loc.x = start_loc.y = cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80; mobility = 1; - summoned = 0; + summon_time = 0; time_flag = eMonstTime::ALWAYS; spec1 = spec2 = spec_enc_code = time_code = monster_time = 0; personality = special_on_kill = facial_pic = -1; @@ -38,7 +38,11 @@ void cCreature::append(legacy::creature_data_type old){ cur_loc.y = old.m_loc.y; cMonster::append(old.m_d); mobility = old.mobile; - summoned = old.summoned; + summon_time = old.summoned; + if(summon_time >= 100) { + party_summoned = false; + summon_time -= 100; + } else party_summoned = true; number = old.monst_start.number; start_attitude = old.monst_start.start_attitude; start_loc.x = old.monst_start.start_loc.x; @@ -192,7 +196,7 @@ void cCreature::writeTo(std::ostream& file) const { file << "LOCATION " << cur_loc.x << ' ' << cur_loc.y << '\n'; file << "MOBILITY " << mobility << '\n'; file << "TIMEFLAG " << time_flag << '\n'; - file << "SUMMONED " << summoned << '\n'; + file << "SUMMONED " << summon_time << ' ' << party_summoned << '\n'; file << "SPEC " << spec1 << ' ' << spec2 << '\n'; file << "SPECCODE " << spec_enc_code << '\n'; file << "TIMECODE " << time_code << '\n'; @@ -239,7 +243,7 @@ void cCreature::readFrom(std::istream& file) { } else if(cur == "TIMEFLAG") { line >> time_flag; } else if(cur == "SUMMONED") - line >> summoned; + line >> summon_time >> party_summoned; else if(cur == "SPEC") line >> spec1 >> spec2; else if(cur == "SPECCODE") { diff --git a/src/classes/creature.hpp b/src/classes/creature.hpp index 2f1d50cc..39e6a5cd 100644 --- a/src/classes/creature.hpp +++ b/src/classes/creature.hpp @@ -20,7 +20,8 @@ public: static const short charm_odds[20]; short active, attitude; location cur_loc; - short summoned; + short summon_time; + bool party_summoned; short target; location targ_loc; short health;