From b77d175f750cbcc9cd886718386524640a30b4ce Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 12 Feb 2008 14:48:27 +0000 Subject: Tweak DID_KILL_HOLY handling to allow for killing hostile angels without being put under penance by the good gods. Also add a flag MF_WAS_NEUTRAL, so that previously neutral monsters can be handled differently from always hostile ones. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3432 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/delay.cc | 1 + crawl-ref/source/direct.cc | 21 ++++++++++++++++++--- crawl-ref/source/enum.h | 8 +++++--- crawl-ref/source/fight.cc | 5 +++-- crawl-ref/source/monstuff.cc | 11 +++++++++-- crawl-ref/source/religion.cc | 18 ++++++++++++------ crawl-ref/source/religion.h | 2 +- crawl-ref/source/tags.cc | 2 +- 8 files changed, 50 insertions(+), 18 deletions(-) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 1e0f797446..cc3fc96a8e 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -167,6 +167,7 @@ static int recite_to_monsters(int x, int y, int pow, int unused) default: // permanently neutral, but same message as enchantment mons->attitude = ATT_NEUTRAL; + mons->flags |= MF_WAS_NEUTRAL; simple_monster_message(mons, " seems impressed!"); break; } diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 334793fb33..b365df2de1 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -794,9 +794,24 @@ void direction(dist& moves, targeting_type restricts, { monsters &m = menv[mid]; - m.attitude = (m.attitude == ATT_FRIENDLY? ATT_NEUTRAL : - m.attitude == ATT_HOSTILE ? ATT_FRIENDLY - : ATT_HOSTILE); + switch (m.attitude) + { + case ATT_FRIENDLY: + m.attitude = ATT_NEUTRAL; + m.flags &= ~MF_CREATED_FRIENDLY; + m.flags |= MF_WAS_NEUTRAL; + break; + case ATT_NEUTRAL: + m.attitude = ATT_HOSTILE; + m.flags &= ~MF_WAS_NEUTRAL; + break; + case ATT_HOSTILE: + m.attitude = ATT_FRIENDLY; + m.flags |= MF_CREATED_FRIENDLY; + break; + default: + break; + } // To update visual branding of friendlies. Only // seem capabable of adding bolding, not removing it, diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index b97b771084..7eb992672c 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -641,6 +641,7 @@ enum conduct_type DID_KILL_WIZARD, DID_KILL_PRIEST, DID_KILL_ANGEL, + DID_KILL_NEUTRAL, // unused DID_LIVING_KILLED_BY_UNDEAD_SLAVE, DID_LIVING_KILLED_BY_SERVANT, DID_UNDEAD_KILLED_BY_SERVANT, @@ -1865,12 +1866,13 @@ enum monster_flag_type // or that the player has inspected with ? MF_BANISHED = 0x200, // Monster that has been banished. MF_HARD_RESET = 0x400, // Summoned, should not drop gear on reset - MF_ATT_CHANGE_ATTEMPT = 0x800, // Saw player and attitude changed (or + MF_WAS_NEUTRAL = 0x800, // mirror to CREATED_FRIENDLY for neutrals + MF_ATT_CHANGE_ATTEMPT = 0x1000, // Saw player and attitude changed (or // not); currently used for holy beings // (good god worshippers -> neutral) // and orcs (Beogh worshippers -> friendly) - MF_WAS_IN_VIEW = 0x1000, // Was in view during previous turn - MF_BAND_MEMBER = 0x2000 // Created as a member of a band + MF_WAS_IN_VIEW = 0x2000, // Was in view during previous turn + MF_BAND_MEMBER = 0x4000 // Created as a member of a band }; // Adding slots breaks saves. YHBW. diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 9e8da364e8..5170d50a56 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -970,7 +970,7 @@ bool melee_attack::player_apply_aux_unarmed() poison_monster( def, KC_YOU ); if (mons_holiness(def) == MH_HOLY) - did_god_conduct(DID_ATTACK_HOLY, 1); + did_god_conduct(DID_ATTACK_HOLY, 1, true, def); // normal vampiric biting attack if (damage_brand == SPWPN_VAMPIRICISM @@ -1584,7 +1584,8 @@ void melee_attack::player_check_weapon_effects() bool melee_attack::player_monattk_hit_effects(bool mondied) { if (mons_holiness(def) == MH_HOLY) - did_god_conduct(mondied? DID_KILL_ANGEL : DID_ATTACK_HOLY, 1); + did_god_conduct(mondied? DID_KILL_ANGEL : DID_ATTACK_HOLY, 1, + true, def); player_check_weapon_effects(); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 92a0f8c514..85e7250b04 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -403,9 +403,10 @@ static void give_adjusted_experience(monsters *monster, killer_type killer, const bool created_friendly = testbits(monster->flags, MF_CREATED_FRIENDLY); + const bool was_neutral = testbits(monster->flags, MF_WAS_NEUTRAL); const bool no_xp = monster->has_ench(ENCH_ABJ); - if (created_friendly || no_xp) + if (created_friendly || was_neutral || no_xp) ; // No experience if monster was created friendly or summoned. else if (YOU_KILL(killer)) { @@ -642,6 +643,8 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) { const bool created_friendly = testbits(monster->flags, MF_CREATED_FRIENDLY); + const bool was_neutral = + testbits(monster->flags, MF_WAS_NEUTRAL); if (death_message) { @@ -650,7 +653,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) monster->name(DESC_NOCAP_THE).c_str()); } - if (created_friendly && gives_xp && death_message) + if ((created_friendly || was_neutral) && gives_xp && death_message) mpr("That felt strangely unrewarding."); // killing triggers tutorial lesson @@ -695,6 +698,10 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) if (mons_holiness(monster) == MH_HOLY) did_god_conduct(DID_KILL_ANGEL, monster->hit_dice, true, monster); + + if (created_friendly) + did_god_conduct(DID_KILL_NEUTRAL, monster->hit_dice, + true, monster); } // Divine health and mp restoration doesn't happen when killing diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 7716ffe60f..9ab03c81be 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -762,7 +762,7 @@ static void do_god_gift(bool prayed_for) break; case GOD_ZIN: - //jmf: "good" god will feed you (a la Nethack) + //jmf: this "good" god will feed you (a la Nethack) if (you.hunger_state <= HS_STARVING && you.piety >= 30) { @@ -1147,7 +1147,7 @@ void god_speaks( god_type god, const char *mesg ) // This function is the merger of done_good() and naughty(). // Returns true if god was interested (good or bad) in conduct. bool did_god_conduct( conduct_type thing_done, int level, bool known, - const actor *victim ) + const monsters *victim ) { bool ret = false; int piety_change = 0; @@ -1217,7 +1217,7 @@ bool did_god_conduct( conduct_type thing_done, int level, bool known, break; } piety_change = -level; - if (known) + if (known || DID_ATTACK_HOLY && victim->attitude != ATT_HOSTILE) penance = level * ((you.religion == GOD_SHINING_ONE) ? 2 : 1); ret = true; break; @@ -1431,9 +1431,13 @@ bool did_god_conduct( conduct_type thing_done, int level, bool known, case GOD_ZIN: case GOD_SHINING_ONE: case GOD_ELYVILON: - level *= 3; + if (testbits(victim->flags, MF_CREATED_FRIENDLY) + || testbits(victim->flags, MF_WAS_NEUTRAL)) + { + level *= 3; + penance = level * ((you.religion == GOD_ZIN) ? 2 : 1); + } piety_change = -level; - penance = level * ((you.religion == GOD_ZIN) ? 2 : 1); ret = true; break; @@ -1636,6 +1640,7 @@ bool did_god_conduct( conduct_type thing_done, int level, bool known, } break; + case DID_KILL_NEUTRAL: // unused case DID_STIMULANTS: // unused case DID_EAT_MEAT: // unused case DID_CREATED_LIFE: // unused @@ -2952,7 +2957,7 @@ void beogh_idol_revenge() dummy.attitude = ATT_FRIENDLY; did_god_conduct(DID_ATTACK_FRIEND, 8, true, - static_cast(&dummy)); + static_cast(&dummy)); } } } @@ -3080,6 +3085,7 @@ void good_god_convert_holy(monsters *holy) holy->attitude = ATT_NEUTRAL; holy->flags |= MF_GOD_GIFT; + holy->flags |= MF_WAS_NEUTRAL; // to avoid immobile "followers" behaviour_event(holy, ME_ALERT, MHITNOT); diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h index 76eae4ae65..147022b21b 100644 --- a/crawl-ref/source/religion.h +++ b/crawl-ref/source/religion.h @@ -40,7 +40,7 @@ void dec_penance(int val); void dec_penance(god_type god, int val); bool did_god_conduct(conduct_type thing_done, int pgain, bool known = true, - const actor *victim = NULL); + const monsters *victim = NULL); void excommunication(void); void gain_piety(int pgn); diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index ab03c40274..7e54a35bef 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -2128,7 +2128,7 @@ void tag_missing_level_attitude() break; } - menv[i].attitude = (isFriendly)?ATT_FRIENDLY : ATT_HOSTILE; + menv[i].attitude = (isFriendly)? ATT_FRIENDLY : ATT_HOSTILE; menv[i].behaviour = static_cast(new_beh); menv[i].foe_memory = 0; } -- cgit v1.2.3-54-g00ecf