diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-29 00:57:24 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-29 00:57:24 +0000 |
commit | da87d971f22b1c4c504910a7f57edf214bdb25f2 (patch) | |
tree | 4a1d02e3bb3fb395315b0f9386427656466602b3 | |
parent | 86bae0c1a3a28bc81c0fb66576e63c0a965c292c (diff) | |
download | crawl-ref-da87d971f22b1c4c504910a7f57edf214bdb25f2.tar.gz crawl-ref-da87d971f22b1c4c504910a7f57edf214bdb25f2.zip |
Consolidate and clean up some of the blessing code.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3928 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/monstuff.cc | 31 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 59 | ||||
-rw-r--r-- | crawl-ref/source/religion.h | 7 |
3 files changed, 56 insertions, 41 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 45581f88b0..7a6dd3ea75 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -400,31 +400,24 @@ static void _give_monster_experience( monsters *victim, if (invalid_monster_index(killer_index)) return; - monsters *mons = &menv[killer_index]; - if (!mons->alive()) + monsters *mon = &menv[killer_index]; + if (!mon->alive()) return; - if ((!victim_was_born_friendly || !mons_friendly(mons)) + if ((!victim_was_born_friendly || !mons_friendly(mon)) && !mons_aligned(killer_index, monster_index(victim))) { - if (mons->gain_exp(experience)) + if (mon->gain_exp(experience)) { // Randomly bless the follower who gained experience. - if (you.religion == GOD_SHINING_ONE + if (((you.religion == GOD_SHINING_ONE + && random2(you.piety) >= piety_breakpoint(0)) + || (you.religion == GOD_BEOGH + && random2(you.piety) >= piety_breakpoint(2))) && !player_under_penance() - && random2(you.piety) >= piety_breakpoint(0) && !one_chance_in(3)) { - bless_follower(GOD_SHINING_ONE, is_tso_follower, mons); - } - - // Randomly bless the follower who gained experience. - if (you.religion == GOD_BEOGH - && !player_under_penance() - && random2(you.piety) >= piety_breakpoint(2) - && !one_chance_in(3)) - { - bless_follower(GOD_BEOGH, is_orcish_follower, mons); + bless_follower(mon); } } } @@ -894,7 +887,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) && (!player_under_penance() && random2(you.piety) >= piety_breakpoint(2))) { - bless_follower(GOD_BEOGH, is_orcish_follower); + bless_follower(); } if (you.duration[DUR_DEATH_CHANNEL] @@ -1024,7 +1017,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) false ); } else - bless_follower(GOD_SHINING_ONE, is_tso_follower, mon); + bless_follower(mon); } // Randomly bless the follower who killed. @@ -1036,7 +1029,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) && !invalid_monster_index(i)) { monsters *mon = &menv[i]; - bless_follower(GOD_BEOGH, is_orcish_follower, mon); + bless_follower(mon); } } diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index f08e9fcec3..94c7160d61 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -759,6 +759,43 @@ static void give_nemelex_gift() } } +bool is_tso_follower(const monsters* mon) +{ + // Don't check for evil or unholy allies here, as that's done + // elsewhere. + return (mon->alive() + && (mon->attitude == ATT_FRIENDLY + || mon->has_ench(ENCH_CHARM))); +} + +bool is_orcish_follower(const monsters* mon) +{ + return (mon->alive() && mons_species(mon->type) == MONS_ORC + && mon->attitude == ATT_FRIENDLY + && (mon->flags & MF_GOD_GIFT)); +} + +bool is_follower(const monsters* mon) +{ + bool result = false; + + switch (you.religion) + { + case GOD_SHINING_ONE: + result = is_tso_follower(mon); + break; + + case GOD_BEOGH: + result = is_orcish_follower(mon); + break; + + default: + break; + } + + return result; +} + static bool blessing_wpn(monsters *mon) { // Pick a monster's weapon. @@ -942,9 +979,9 @@ static bool beogh_blessing_priesthood(monsters* mon) // Bless the follower indicated in follower, if any. If there isn't // one, bless a random follower within sight of the player. -void bless_follower(god_type god, - bool (*suitable)(const monsters* mon), - monsters* follower) +void bless_follower(monsters* follower, + god_type god, + bool (*suitable)(const monsters* mon)) { monsters *mon; @@ -3799,22 +3836,6 @@ void beogh_convert_orc(monsters *orc, bool emergency, behaviour_event(orc, ME_ALERT, MHITNOT); } -bool is_tso_follower(const monsters* mon) -{ - // Don't check for evil or unholy allies here, as that's done - // elsewhere. - return (mon->alive() - && (mon->attitude == ATT_FRIENDLY - || mon->has_ench(ENCH_CHARM))); -} - -bool is_orcish_follower(const monsters* mon) -{ - return (mon->alive() && mons_species(mon->type) == MONS_ORC - && mon->attitude == ATT_FRIENDLY - && (mon->flags & MF_GOD_GIFT)); -} - void excommunication(god_type new_god) { const god_type old_god = you.religion; diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h index 6c99a2ec3b..df053ac3f0 100644 --- a/crawl-ref/source/religion.h +++ b/crawl-ref/source/religion.h @@ -71,11 +71,12 @@ bool ely_destroy_weapons(); bool trog_burn_books(); bool tso_stab_safe_monster(const actor *act); -void bless_follower(god_type god, - bool (*suitable)(const monsters* mon), - monsters* follower = NULL); bool is_tso_follower(const monsters* mon); bool is_orcish_follower(const monsters* mon); +bool is_follower(const monsters* mon); +void bless_follower(monsters* follower = NULL, + god_type god = you.religion, + bool (*suitable)(const monsters* mon) = is_follower); bool god_hates_attacking_friend(god_type god, const actor *fr); |