diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-06 21:01:46 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-06 21:01:46 +0000 |
commit | e76fa04ee8cfd52c224e3ec72ff0b23796eb6029 (patch) | |
tree | 73fa8ac4235a5c609027c62b5534d9c575c3e467 | |
parent | 703ecf2d592818a7bbffc70bc49a943ab7f24a33 (diff) | |
download | crawl-ref-e76fa04ee8cfd52c224e3ec72ff0b23796eb6029.tar.gz crawl-ref-e76fa04ee8cfd52c224e3ec72ff0b23796eb6029.zip |
Allow creation of non-friendly god gifts. The BEH_GOD_GIFT behavior has
been removed, and the MF_GOD_GIFT flag is set directly instead.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5503 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/abl-show.cc | 34 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 147 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 209 | ||||
-rw-r--r-- | crawl-ref/source/spells2.h | 7 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 39 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 18 |
9 files changed, 257 insertions, 224 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 5e6e547816..e3a7b576fb 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1277,13 +1277,15 @@ static bool _do_ability(const ability_def& abil) // DEMONIC POWERS: case ABIL_SUMMON_MINOR_DEMON: - summon_ice_beast_etc( you.experience_level * 4, - summon_any_demon(DEMON_LESSER) ); + summon_ice_beast_etc(you.experience_level * 4, + summon_any_demon(DEMON_LESSER), + BEH_FRIENDLY, false); break; case ABIL_SUMMON_DEMONS: - summon_ice_beast_etc( you.experience_level * 4, - summon_any_demon(DEMON_COMMON) ); + summon_ice_beast_etc(you.experience_level * 4, + summon_any_demon(DEMON_COMMON), + BEH_FRIENDLY, false); break; case ABIL_HELLFIRE: @@ -1436,7 +1438,8 @@ static bool _do_ability(const ability_def& abil) break; case ABIL_TSO_SUMMON_DAEVA: - summon_ice_beast_etc(you.skills[SK_INVOCATIONS] * 4, MONS_DAEVA, true); + summon_ice_beast_etc(you.skills[SK_INVOCATIONS] * 4, MONS_DAEVA, + BEH_FRIENDLY, true); exercise(SK_INVOCATIONS, 8 + random2(10)); break; @@ -1459,7 +1462,8 @@ static bool _do_ability(const ability_def& abil) case ABIL_KIKU_INVOKE_DEATH: summon_ice_beast_etc( - 20 + you.skills[SK_INVOCATIONS] * 3, MONS_REAPER, true); + 20 + you.skills[SK_INVOCATIONS] * 3, MONS_REAPER, + BEH_FRIENDLY, true); exercise(SK_INVOCATIONS, 10 + random2(14)); break; @@ -1539,10 +1543,10 @@ static bool _do_ability(const ability_def& abil) break; case ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB: - summon_ice_beast_etc( 20 + you.skills[SK_INVOCATIONS] * 3, - static_cast<monster_type>( - MONS_NEQOXEC + random2(5)), - true ); + summon_ice_beast_etc(20 + you.skills[SK_INVOCATIONS] * 3, + static_cast<monster_type>( + MONS_NEQOXEC + random2(5)), + BEH_FRIENDLY, true); exercise(SK_INVOCATIONS, 2 + random2(3)); break; @@ -1601,10 +1605,10 @@ static bool _do_ability(const ability_def& abil) break; case ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB: - summon_ice_beast_etc( 20 + you.skills[SK_INVOCATIONS] * 3, - static_cast<monster_type>( - MONS_EXECUTIONER + random2(5)), - true ); + summon_ice_beast_etc(20 + you.skills[SK_INVOCATIONS] * 3, + static_cast<monster_type>( + MONS_EXECUTIONER + random2(5)), + BEH_FRIENDLY, true); exercise(SK_INVOCATIONS, 6 + random2(6)); break; @@ -1634,7 +1638,7 @@ static bool _do_ability(const ability_def& abil) // Trog abilities don't use or train invocations. summon_berserker(you.piety + random2(you.piety/4) - random2(you.piety/4), - true); + BEH_FRIENDLY, true); break; case ABIL_SIF_MUNA_FORGET_SPELL: diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 9a1ea32df8..9249559633 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1868,13 +1868,13 @@ enum beh_type BEH_PANIC, // like flee but without running away BEH_INVESTIGATE, // investigating an ME_DISTURB BEH_LURK, // stay still until discovered or - // enemy closeby + // enemy close by NUM_BEHAVIOURS, // max # of legal states - BEH_CHARMED, // hostile-but-charmed; create only + BEH_CHARMED, // hostile-but-charmed; creation only BEH_FRIENDLY, // used during creation only + BEH_GOOD_NEUTRAL, // creation only BEH_NEUTRAL, // creation only BEH_HOSTILE, // creation only - BEH_GOD_GIFT, // creation only BEH_GUARD // creation only - monster is guard }; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 4742f0a1fe..bfb310aab0 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -5028,10 +5028,10 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet) } case ENCH_ABJ: case ENCH_SHORT_LIVED: - add_ench( mon_enchant(ENCH_ABJ) ); + add_ench(mon_enchant(ENCH_ABJ)); // just for flavour - if ((this->flags & MF_GOD_GIFT) && this->has_ench(ENCH_BERSERK)) + if (testbits(this->flags, MF_GOD_GIFT) && this->has_ench(ENCH_BERSERK)) simple_monster_message(this, " is no longer berserk."); monster_die( this, quiet? KILL_DISMISSED : KILL_RESET, 0 ); diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 5780548926..f0f56b6fa0 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -907,9 +907,12 @@ static int _place_monster_aux( const mgen_data &mg, // attitude is hostile. if (mg.behaviour > NUM_BEHAVIOURS) { - if (mg.behaviour == BEH_FRIENDLY || mg.behaviour == BEH_GOD_GIFT) + if (mg.behaviour == BEH_FRIENDLY) menv[id].attitude = ATT_FRIENDLY; + if (mg.behaviour == BEH_GOOD_NEUTRAL) + menv[id].attitude = ATT_GOOD_NEUTRAL; + if (mg.behaviour == BEH_NEUTRAL) menv[id].attitude = ATT_NEUTRAL; @@ -1754,7 +1757,7 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour) if ( mons_is_unique(monster->type) ) interesting = true; // If it's never going to attack us, then not interesting - else if (behaviour == BEH_FRIENDLY || behaviour == BEH_GOD_GIFT) + else if (behaviour == BEH_FRIENDLY) interesting = false; // Don't waste time on moname() if user isn't using this option else if (Options.note_monsters.size() > 0) @@ -1861,15 +1864,15 @@ int mons_place( mgen_data mg ) monsters *creation = &menv[mid]; - // Look at special cases: CHARMED, FRIENDLY, HOSTILE, GOD_GIFT. - // Alert summoned being to player's presence. + // Look at special cases: CHARMED, FRIENDLY, NEUTRAL, GOOD_NEUTRAL, + // HOSTILE. if (mg.behaviour > NUM_BEHAVIOURS) { - if (mg.behaviour == BEH_FRIENDLY || mg.behaviour == BEH_GOD_GIFT) + if (mg.behaviour == BEH_FRIENDLY) creation->flags |= MF_CREATED_FRIENDLY; - if (mg.behaviour == BEH_GOD_GIFT) - creation->flags |= MF_GOD_GIFT; + if (mg.behaviour == BEH_NEUTRAL || mg.behaviour == BEH_GOOD_NEUTRAL) + creation->flags |= MF_WAS_NEUTRAL; if (mg.behaviour == BEH_CHARMED) { diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 05511e8693..7d62b5ac1d 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -829,7 +829,7 @@ 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)); + && testbits(mon->flags, MF_GOD_GIFT)); } bool is_follower(const monsters* mon) @@ -1106,8 +1106,9 @@ static bool _beogh_blessing_reinforcement() int monster = create_monster( - mgen_data(follower_type, BEH_GOD_GIFT, 0, - you.pos(), you.pet_target)); + mgen_data(follower_type, BEH_FRIENDLY, 0, + you.pos(), you.pet_target, MF_GOD_GIFT)); + if (monster != -1) { monsters *mon = &menv[monster]; @@ -1536,12 +1537,12 @@ static void _do_god_gift(bool prayed_for) case GOD_YREDELEMNUL: if (random2(you.piety) > 80 && one_chance_in(5)) { - monster_type thing_called = - _random_servant(GOD_YREDELEMNUL); + monster_type mon = _random_servant(GOD_YREDELEMNUL); if (create_monster( - mgen_data(thing_called, BEH_FRIENDLY, 0, - you.pos(), you.pet_target)) != -1) + mgen_data(mon, BEH_FRIENDLY, 0, + you.pos(), you.pet_target, + MF_GOD_GIFT)) != -1) { simple_god_message(" grants you an undead servant!"); more(); @@ -3010,19 +3011,21 @@ static bool _tso_retribution() bool success = false; int how_many = 1 + random2(you.experience_level / 5) + random2(3); - for (int i = 0; i < how_many; i++) + for (int i = 0; i < how_many; ++i) + { if (create_monster( - mgen_data(MONS_DAEVA, BEH_HOSTILE, 0, - you.pos(), MHITYOU )) != -1) + mgen_data::alert_hostile_at(MONS_DAEVA, + you.pos(), MF_GOD_GIFT)) != -1) { success = true; } + } - simple_god_message( success ? - " sends the divine host to punish you " - "for your evil ways!" : - "'s divine host fails to appear.", - god ); + simple_god_message(success ? + " sends the divine host to punish you " + "for your evil ways!" : + "'s divine host fails to appear.", + god ); break; } @@ -3109,25 +3112,26 @@ static bool _zin_retribution() const int how_many = 1 + (you.experience_level / 10) + random2(3); bool success = false; - for (int i = 0; i < how_many; i++) + for (int i = 0; i < how_many; ++i) + { if (create_monster( - mgen_data(MONS_ANGEL, BEH_HOSTILE, 0, - you.pos(), MHITYOU)) != -1) + mgen_data::alert_hostile_at(MONS_ANGEL, + you.pos(), MF_GOD_GIFT)) != -1) { success = true; } + } - simple_god_message( success ? - " sends the divine host to punish you " - "for your evil ways!" : - "'s divine host fails to appear.", - god); + simple_god_message(success ? + " sends the divine host to punish you " + "for your evil ways!" : + "'s divine host fails to appear.", + god); } else { - // god_gift == false gives unfriendly - bool success = summon_swarm( you.experience_level * 20, true, - false ); + bool success = summon_swarm(you.experience_level * 20, + BEH_HOSTILE, true); simple_god_message(success ? " sends a plague down upon you!" : "'s plague fails to arrive.", @@ -3272,36 +3276,42 @@ static bool _makhleb_retribution() if (random2(you.experience_level) > 7 && !one_chance_in(5)) { - const bool success = - create_monster( - mgen_data( + bool success = false; + + if (create_monster( + mgen_data::alert_hostile_at( static_cast<monster_type>( MONS_EXECUTIONER + random2(5)), - BEH_HOSTILE, 0, - you.pos(), MHITYOU)) != -1; - simple_god_message(success ? - " sends a greater servant after you!" : - "'s greater servant is unavoidably detained.", - god); + you.pos(), MF_GOD_GIFT)) != -1) + { + success = true; + + simple_god_message(success ? + " sends a greater servant after you!" : + "'s greater servant is unavoidably detained.", + god); + } } else { - bool success = false; int how_many = 1 + (you.experience_level / 7); + int count = 0; - for (int i = 0; i < how_many; i++) + for (int i = 0; i < how_many; ++i) + { if (create_monster( - mgen_data( + mgen_data::alert_hostile_at( static_cast<monster_type>( MONS_NEQOXEC + random2(5)), - BEH_HOSTILE, 0, - you.pos(), MHITYOU)) != -1) - success = true; + you.pos(), MF_GOD_GIFT)) != -1) + { + count++; + } + } - simple_god_message(success ? - " sends minions to punish you." : - "'s minions fail to arrive.", - god); + simple_god_message(count > 1 ? " sends minions to punish you." : + count > 0 ? " sends a minion to punish you." : + "'s minions fail to arrive.", god); } return true; @@ -3317,11 +3327,15 @@ static bool _kikubaaqudgha_retribution() bool success = false; int how_many = 1 + (you.experience_level / 5) + random2(3); - for (int i = 0; i < how_many; i++) + for (int i = 0; i < how_many; ++i) + { if (create_monster( - mgen_data(MONS_REAPER, BEH_HOSTILE, 0, you.pos(), - MHITYOU)) != -1) + mgen_data::alert_hostile_at(MONS_REAPER, + you.pos(), MF_GOD_GIFT)) != -1) + { success = true; + } + } if (success) simple_god_message(" unleashes Death upon you!", god); @@ -3355,14 +3369,16 @@ static bool _yredelemnul_retribution() monster_type punisher = _random_servant(GOD_YREDELEMNUL); if (create_monster( - mgen_data(punisher, BEH_HOSTILE, 0, - you.pos(), MHITYOU)) != -1) + mgen_data::alert_hostile_at(punisher, + you.pos(), MF_GOD_GIFT)) != -1) + { count++; + } } - simple_god_message(count > 1? " sends servants to punish you." : - count > 0? " sends a servant to punish you." : - "'s servants fail to arrive.", god); + simple_god_message(count > 1 ? " sends servants to punish you." : + count > 0 ? " sends a servant to punish you." : + "'s servants fail to arrive.", god); } else { @@ -3403,7 +3419,7 @@ static bool _trog_retribution() points -= cost; - if (summon_berserker(cost * 20, false)) + if (summon_berserker(cost * 20, BEH_HOSTILE, true)) count++; } } @@ -3518,9 +3534,8 @@ static bool _beogh_retribution() // Now create monster. int mons = create_monster( - mgen_data::alert_hostile_at( - MONS_DANCING_WEAPON, - you.pos() )); + mgen_data::alert_hostile_at(MONS_DANCING_WEAPON, + you.pos(), MF_GOD_GIFT)); // Hand item information over to monster. if (mons != -1) @@ -3574,8 +3589,8 @@ static bool _beogh_retribution() punisher = MONS_ORC; int mons = create_monster( - mgen_data::alert_hostile_at( punisher, you.pos(), 0, - MG_PERMIT_BANDS) ); + mgen_data::alert_hostile_at(punisher, + you.pos(), MF_GOD_GIFT, MG_PERMIT_BANDS)); // sometimes name band leader if (mons != -1 && one_chance_in(3)) @@ -3604,8 +3619,8 @@ static bool _okawaru_retribution() monster_type punisher = _random_servant(GOD_OKAWARU); if (create_monster( - mgen_data::alert_hostile_at( - punisher, you.pos())) != -1) + mgen_data::alert_hostile_at(punisher, + you.pos(), MF_GOD_GIFT)) != -1) { success = true; } @@ -3698,7 +3713,7 @@ static bool _lugonu_retribution() if (create_monster( mgen_data::alert_hostile_at( static_cast<monster_type>(MONS_GREEN_DEATH + random2(3)), - you.pos())) != -1) + you.pos(), MF_GOD_GIFT)) != -1) { success = true; } @@ -3718,7 +3733,7 @@ static bool _lugonu_retribution() if (create_monster( mgen_data::alert_hostile_at( static_cast<monster_type>(MONS_NEQOXEC + random2(5)), - you.pos())) != -1) + you.pos(), MF_GOD_GIFT)) != -1) { success = true; } @@ -3973,7 +3988,7 @@ static bool _make_god_gifts_on_level_disappear(bool seen = false) if (monster->type != -1 && monster->attitude == ATT_FRIENDLY && monster->has_ench(ENCH_ABJ) - && (monster->flags & MF_GOD_GIFT)) + && testbits(monster->flags, MF_GOD_GIFT)) { if (!seen || simple_monster_message(monster, " abandons you!")) count++; @@ -4014,7 +4029,7 @@ static bool _make_holy_god_gifts_on_level_good_neutral(bool seen = false) if (monster->type != -1 && mons_is_holy(monster) && monster->attitude == ATT_FRIENDLY - && (monster->flags & MF_GOD_GIFT)) + && testbits(monster->flags, MF_GOD_GIFT)) { // monster changes attitude monster->attitude = ATT_GOOD_NEUTRAL; @@ -4054,7 +4069,7 @@ static bool _make_god_gifts_on_level_hostile(bool seen = false) monsters *monster = &menv[i]; if (monster->type != -1 && monster->attitude == ATT_FRIENDLY - && (monster->flags & MF_GOD_GIFT)) + && testbits(monster->flags, MF_GOD_GIFT)) { // monster changes attitude and behaviour monster->attitude = ATT_HOSTILE; diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index fdb1a68457..655f588dc4 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -570,7 +570,7 @@ void cast_twisted(int power, beh_type corps_beh, int corps_hit) else { // This was probably intended, but it's really boring. (jpeg) - // Use menv[mon].number instead (set in create_monster) + // Use menv[mon].number instead (set in create_monster()). // menv[mon].colour = colour; mpr("The heap of corpses melds into an agglomeration of writhing flesh!"); if (type_resurr == MONS_ABOMINATION_LARGE) @@ -1266,7 +1266,7 @@ char burn_freeze(int pow, beam_type flavour) bool summon_elemental(int pow, int restricted_type, unsigned char unfriendly) { - monster_type type_summoned = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; struct dist smove; int dir_x; @@ -1295,7 +1295,7 @@ bool summon_elemental(int pow, int restricted_type, if (mgrd[ targ_x ][ targ_y ] != NON_MONSTER) { - if ( player_monster_visible(&menv[mgrd[targ_x][targ_y]]) ) + if (player_monster_visible(&menv[mgrd[targ_x][targ_y]])) mpr("There's something there already!"); else { @@ -1313,7 +1313,7 @@ bool summon_elemental(int pow, int restricted_type, || grd[ targ_x ][ targ_y ] == DNGN_CLEAR_ROCK_WALL) && (restricted_type == 0 || restricted_type == MONS_EARTH_ELEMENTAL)) { - type_summoned = MONS_EARTH_ELEMENTAL; + mon = MONS_EARTH_ELEMENTAL; if (targ_x > 6 && targ_x < 74 && targ_y > 6 && targ_y < 64) grd[ targ_x ][ targ_y ] = DNGN_FLOOR; @@ -1322,30 +1322,30 @@ bool summon_elemental(int pow, int restricted_type, && env.cloud[env.cgrid[ targ_x ][ targ_y ]].type == CLOUD_FIRE) && (restricted_type == 0 || restricted_type == MONS_FIRE_ELEMENTAL)) { - type_summoned = MONS_FIRE_ELEMENTAL; + mon = MONS_FIRE_ELEMENTAL; delete_cloud( env.cgrid[ targ_x ][ targ_y ] ); } else if ((grd[ targ_x ][ targ_y ] == DNGN_LAVA) && (restricted_type == 0 || restricted_type == MONS_FIRE_ELEMENTAL)) { - type_summoned = MONS_FIRE_ELEMENTAL; + mon = MONS_FIRE_ELEMENTAL; } else if ((grd[ targ_x ][ targ_y ] == DNGN_DEEP_WATER || grd[ targ_x ][ targ_y ] == DNGN_SHALLOW_WATER || grd[ targ_x ][ targ_y ] == DNGN_FOUNTAIN_BLUE) && (restricted_type == 0 || restricted_type == MONS_WATER_ELEMENTAL)) { - type_summoned = MONS_WATER_ELEMENTAL; + mon = MONS_WATER_ELEMENTAL; } else if ((grd[ targ_x ][ targ_y ] >= DNGN_FLOOR && env.cgrid[ targ_x ][ targ_y ] == EMPTY_CLOUD) && (restricted_type == 0 || restricted_type == MONS_AIR_ELEMENTAL)) { - type_summoned = MONS_AIR_ELEMENTAL; + mon = MONS_AIR_ELEMENTAL; } // found something to summon - if (type_summoned == MONS_PROGRAM_BUG) + if (mon == MONS_PROGRAM_BUG) { canned_msg(MSG_NOTHING_HAPPENS); return (false); @@ -1358,27 +1358,26 @@ bool summon_elemental(int pow, int restricted_type, // - Air elementals are harder because they're more dynamic/dangerous // - Earth elementals are more static and easy to tame (as before) // - Fire elementals fall in between the two (10 is still fairly easy) - bool friendly = ((type_summoned != MONS_FIRE_ELEMENTAL + bool friendly = ((mon != MONS_FIRE_ELEMENTAL || random2(10) < you.skills[SK_FIRE_MAGIC]) - && (type_summoned != MONS_WATER_ELEMENTAL + && (mon != MONS_WATER_ELEMENTAL || random2((you.species == SP_MERFOLK) ? 5 : 15) < you.skills[SK_ICE_MAGIC]) - && (type_summoned != MONS_AIR_ELEMENTAL + && (mon != MONS_AIR_ELEMENTAL || random2(15) < you.skills[SK_AIR_MAGIC]) - && (type_summoned != MONS_EARTH_ELEMENTAL + && (mon != MONS_EARTH_ELEMENTAL || random2(5) < you.skills[SK_EARTH_MAGIC]) && random2(100) >= unfriendly); if (create_monster( - mgen_data( type_summoned, - friendly ? BEH_FRIENDLY : BEH_HOSTILE, - numsc, - coord_def(targ_x, targ_y), - friendly ? you.pet_target : MHITYOU )) != -1) + mgen_data(mon, + friendly ? BEH_FRIENDLY : BEH_HOSTILE, + numsc, coord_def(targ_x, targ_y), + friendly ? you.pet_target : MHITYOU )) != -1) { return (false); } @@ -1392,7 +1391,7 @@ bool summon_elemental(int pow, int restricted_type, //jmf: beefed up higher-level casting of this (formerly lame) spell void summon_small_mammals(int pow) { - monster_type thing_called = MONS_PROGRAM_BUG; // error trapping{dlb} + monster_type mon = MONS_PROGRAM_BUG; // error trapping{dlb} int pow_spent = 0; int pow_left = pow + 1; @@ -1419,27 +1418,27 @@ void summon_small_mammals(int pow) // player_angers_monster(). if (!is_good_god(you.religion)) { - thing_called = MONS_ORANGE_RAT; + mon = MONS_ORANGE_RAT; break; } case 65: case 64: case 63: case 27: case 26: case 25: - thing_called = MONS_GREEN_RAT; + mon = MONS_GREEN_RAT; break; case 57: case 56: case 55: case 54: case 53: case 52: case 20: case 18: case 16: case 14: case 12: case 10: - thing_called = coinflip() ? MONS_QUOKKA : MONS_GREY_RAT; + mon = coinflip() ? MONS_QUOKKA : MONS_GREY_RAT; break; default: - thing_called = coinflip() ? MONS_GIANT_BAT : MONS_RAT; + mon = coinflip() ? MONS_GIANT_BAT : MONS_RAT; break; } create_monster( - mgen_data( thing_called, BEH_FRIENDLY, 3, - you.pos(), you.pet_target )); + mgen_data(mon, BEH_FRIENDLY, 3, + you.pos(), you.pet_target)); } } @@ -1459,19 +1458,19 @@ void summon_animals(int pow) int power_left = pow + 1; const bool varied = coinflip(); - monster_type mon_chosen = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; - while ( power_left >= 0 && num_so_far < 8 ) + while (power_left >= 0 && num_so_far < 8) { - // pick a random monster and subtract its cost - if ( varied || num_so_far == 0 ) - mon_chosen = RANDOM_ELEMENT(animals); + // Pick a random monster and subtract its cost. + if (varied || num_so_far == 0) + mon = RANDOM_ELEMENT(animals); - const int power_cost = mons_power(mon_chosen) * 3; + const int power_cost = mons_power(mon) * 3; // Allow a certain degree of overuse, but not too much. // Guarantee at least two summons. - if ( power_cost >= power_left * 2 && num_so_far >= 2 ) + if (power_cost >= power_left * 2 && num_so_far >= 2) break; power_left -= power_cost; @@ -1480,10 +1479,10 @@ void summon_animals(int pow) bool friendly = (random2(pow) > 4); create_monster( - mgen_data( mon_chosen, - friendly ? BEH_FRIENDLY : BEH_HOSTILE, 4, - you.pos(), - friendly ? you.pet_target : MHITYOU )); + mgen_data(mon, + friendly ? BEH_FRIENDLY : BEH_HOSTILE, + 4, you.pos(), + friendly ? you.pet_target : MHITYOU)); } } @@ -1493,15 +1492,14 @@ void summon_scorpions(int pow) numsc = stepdown_value(numsc, 2, 2, 6, 8); //see stuff.cc - 12jan2000 {dlb} - for (int scount = 0; scount < numsc; scount++) + for (int scount = 0; scount < numsc; ++scount) { bool friendly = (random2(pow) > 3); if (create_monster( mgen_data(MONS_SCORPION, friendly ? BEH_FRIENDLY : BEH_HOSTILE, - 3, - you.pos(), + 3, you.pos(), friendly ? you.pet_target : MHITYOU)) != -1) { mprf("A scorpion appears.%s", @@ -1524,8 +1522,7 @@ void summon_ugly_thing(int pow) if (create_monster( mgen_data(ugly, friendly ? BEH_FRIENDLY : BEH_HOSTILE, - numsc, - you.pos(), + numsc, you.pos(), friendly ? you.pet_target : MHITYOU)) != -1) { const char *prefix = (ugly == MONS_VERY_UGLY_THING) ? " very" : "n"; @@ -1535,13 +1532,14 @@ void summon_ugly_thing(int pow) } } // end summon_ugly_thing() -void summon_ice_beast_etc(int pow, monster_type ibc, bool divine_gift) +bool summon_ice_beast_etc(int pow, monster_type mon, beh_type beha, + bool god_gift) { int numsc = std::min(2 + (random2(pow) / 4), 6); - beh_type beha = divine_gift ? BEH_GOD_GIFT : BEH_FRIENDLY; - unsigned short hitting = you.pet_target; + unsigned short hitting = (beha == BEH_FRIENDLY) ? you.pet_target : MHITYOU; + bool success = false; - switch (ibc) + switch (mon) { case MONS_ICE_BEAST: mpr("A chill wind blows around you."); @@ -1585,29 +1583,32 @@ void summon_ice_beast_etc(int pow, monster_type ibc, bool divine_gift) int monster = create_monster( - mgen_data(ibc, beha, numsc, - you.pos(), hitting)); + mgen_data(mon, beha, numsc, + you.pos(), hitting, + god_gift ? MF_GOD_GIFT : 0)); + if (monster != -1) { - if (ibc == MONS_DAEVA) - { - monsters *mon = &menv[monster]; + success = true; - mon->flags |= MF_ATT_CHANGE_ATTEMPT; - } + monsters *summon = &menv[monster]; + + if (mon == MONS_DAEVA) + summon->flags |= MF_ATT_CHANGE_ATTEMPT; } -} // end summon_ice_beast_etc() -// Trog sends some fighting buddies for his followers (or enemies if -// god_gift is false). -bool summon_berserker(int pow, bool god_gift) + return (success); +} + +// Trog sends some fighting buddies (or enemies) for his followers. +bool summon_berserker(int pow, beh_type beha, bool god_gift) { - beh_type beha = (god_gift) ? BEH_GOD_GIFT : BEH_HOSTILE; + monster_type mon = MONS_PROGRAM_BUG; + int numsc = std::min(2 + (random2(pow) / 4), 6); + unsigned short hitting = (beha == BEH_FRIENDLY) ? you.pet_target : MHITYOU; bool success = false; - monster_type mon = MONS_TROLL; - if (pow <= 100) { // bears @@ -1654,17 +1655,18 @@ bool summon_berserker(int pow, bool god_gift) mon = MONS_STONE_GIANT; } - int mons = + int monster = create_monster( - mgen_data( mon, beha, numsc, - you.pos(), - god_gift ? you.pet_target : MHITYOU )); + mgen_data(mon, beha, numsc, + you.pos(), hitting, + god_gift ? MF_GOD_GIFT : 0)); - if (mons != -1) + if (monster != -1) { success = true; - monsters *summon = &menv[mons]; + monsters *summon = &menv[monster]; + summon->go_berserk(false); mon_enchant berserk = summon->get_ench(ENCH_BERSERK); mon_enchant abj = summon->get_ench(ENCH_ABJ); @@ -1678,110 +1680,111 @@ bool summon_berserker(int pow, bool god_gift) summon->update_ench(abj); } - return success; + return (success); } // end summon_berserker() -bool summon_swarm( int pow, bool unfriendly, bool god_gift ) +bool summon_swarm(int pow, beh_type beha, bool god_gift) { - monster_type thing_called = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; + int numsc = 2 + random2(pow) / 10 + random2(pow) / 25; - bool summoned = false; + unsigned short hitting = (beha == BEH_FRIENDLY) ? you.pet_target : MHITYOU; + bool success = false; // see stuff.cc - 12jan2000 {dlb} - numsc = stepdown_value( numsc, 2, 2, 6, 8 ); + numsc = stepdown_value(numsc, 2, 2, 6, 8); - for (int scount = 0; scount < numsc; scount++) + for (int scount = 0; scount < numsc; ++scount) { switch (random2(14)) { case 0: case 1: // prototypical swarming creature {dlb} - thing_called = MONS_KILLER_BEE; + mon = MONS_KILLER_BEE; break; case 2: // comment said "larva", code read scorpion {dlb} - thing_called = MONS_SCORPION; + mon = MONS_SCORPION; break; // think: "The Arrival" {dlb} case 3: //jmf: technically not insects but still cool - thing_called = MONS_WORM; + mon = MONS_WORM; break; // but worms kinda "swarm" so s'ok {dlb} case 4: // comment read "larva", code was for scorpion - thing_called = MONS_GIANT_MOSQUITO; + mon = MONS_GIANT_MOSQUITO; break; // changed into giant mosquito 12jan2000 {dlb} case 5: // think: scarabs in "The Mummy" {dlb} - thing_called = MONS_GIANT_BEETLE; + mon = MONS_GIANT_BEETLE; break; case 6: //jmf: blowfly instead of queen bee - thing_called = MONS_GIANT_BLOWFLY; + mon = MONS_GIANT_BLOWFLY; break; // queen bee added if more than x bees in swarm? {dlb} // the above would require code rewrite - worth it? {dlb} case 8: //jmf: changed to red wasp; was wolf spider - thing_called = MONS_WOLF_SPIDER; //jmf: spiders aren't insects + mon = MONS_WOLF_SPIDER; //jmf: spiders aren't insects break; // think: "Kingdom of the Spiders" {dlb} // not just insects!!! - changed back {dlb} case 9: - thing_called = MONS_BUTTERFLY; // comic relief? {dlb} + mon = MONS_BUTTERFLY; // comic relief? {dlb} break; case 10: // change into some kind of snake -- {dlb} - thing_called = MONS_YELLOW_WASP; // do wasps swarm? {dlb} + mon = MONS_YELLOW_WASP; // do wasps swarm? {dlb} break; // think: "Indiana Jones" and snakepit? {dlb} default: // 3 in 14 chance, 12jan2000 {dlb} - thing_called = MONS_GIANT_ANT; + mon = MONS_GIANT_ANT; break; } // end switch - beh_type behaviour = BEH_HOSTILE; // default to unfriendly - - // Note: friendly, non-god_gift means spell. - if (god_gift) - behaviour = BEH_GOD_GIFT; - else if (!unfriendly && random2(pow) > 7) - behaviour = BEH_FRIENDLY; + // If it's not a god gift, it's from a spell. + if (!god_gift && random2(pow) > 7) + { + beha = BEH_FRIENDLY; + hitting = you.pet_target; + } if (create_monster( - mgen_data( thing_called, behaviour, 3, - you.pos(), - !unfriendly ? you.pet_target : MHITYOU )) != -1) + mgen_data(mon, beha, numsc, + you.pos(), hitting, + god_gift ? MF_GOD_GIFT : 0)) != -1) { - summoned = true; + success = true; } } - return (summoned); -} // end summon_swarm() + return (success); +} void summon_undead(int pow) { int temp_rand = 0; - monster_type thing_called = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; int numsc = 1 + random2(pow) / 30 + random2(pow) / 30; numsc = stepdown_value(numsc, 2, 2, 6, 8); //see stuff.cc {dlb} mpr("You call on the undead to aid you!"); - for (int scount = 0; scount < numsc; scount++) + for (int scount = 0; scount < numsc; ++scount) { temp_rand = random2(25); - thing_called = ((temp_rand > 8) ? MONS_WRAITH : // 64% - (temp_rand > 3) ? MONS_FREEZING_WRAITH // 20% - : MONS_SPECTRAL_WARRIOR); // 16% + mon = ((temp_rand > 8) ? MONS_WRAITH : // 64% + (temp_rand > 3) ? MONS_FREEZING_WRAITH // 20% + : MONS_SPECTRAL_WARRIOR); // 16% bool friendly = (random2(pow) > 5); if (create_monster( - mgen_data(thing_called, + mgen_data(mon, friendly ? BEH_FRIENDLY : BEH_HOSTILE, 5, you.pos(), friendly ? you.pet_target : MHITYOU)) != -1) @@ -1791,7 +1794,7 @@ void summon_undead(int pow) else mpr("You sense a hostile presence."); } - } // end for loop + } //jmf: Kiku sometimes deflects this if (!you.is_undead @@ -1845,11 +1848,11 @@ void summon_things( int pow ) { create_monster( mgen_data(MONS_ABOMINATION_LARGE, BEH_FRIENDLY, 6, - you.pos(), you.pet_target )); + you.pos(), you.pet_target)); numsc--; } mprf("Some Thing%s answered your call!", - (numsc + big_things > 1) ? "s" : "" ); + (numsc + big_things > 1) ? "s" : ""); } } diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 8efb768298..8b5e3f5c5c 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -132,7 +132,8 @@ bool restore_stat(unsigned char which_stat, unsigned char stat_gain, /* *********************************************************************** * called from: ability - spell * *********************************************************************** */ -void summon_ice_beast_etc(int pow, monster_type ibc, bool divine_gift = false); +bool summon_ice_beast_etc(int pow, monster_type mon, beh_type beha, + bool god_gift); // last updated 24may2000 {dlb} @@ -152,13 +153,13 @@ void summon_animals(int pow); * *********************************************************************** */ void summon_small_mammals(int pow); -bool summon_berserker(int pow, bool god_gift); +bool summon_berserker(int pow, beh_type beha, bool god_gift); // last updated 24may2000 {dlb} /* *********************************************************************** * called from: ability - religion - spell * *********************************************************************** */ -bool summon_swarm( int pow, bool unfriendly, bool god_gift ); +bool summon_swarm(int pow, beh_type beha, bool god_gift); // last updated 24may2000 {dlb} diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 64b23cfea0..6277a78adb 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1393,7 +1393,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_SUMMON_SWARM: - summon_swarm( powc, false, false ); + summon_swarm(powc, BEH_FRIENDLY, false); break; case SPELL_SUMMON_HORRIBLE_THINGS: @@ -1488,7 +1488,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_SUMMON_ICE_BEAST: - summon_ice_beast_etc(powc, MONS_ICE_BEAST); + summon_ice_beast_etc(powc, MONS_ICE_BEAST, BEH_FRIENDLY, false); break; case SPELL_OZOCUBUS_ARMOUR: @@ -1496,13 +1496,14 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_CALL_IMP: - if (one_chance_in(3)) - summon_ice_beast_etc(powc, MONS_WHITE_IMP); - else if (one_chance_in(7)) - summon_ice_beast_etc(powc, MONS_SHADOW_IMP); - else - summon_ice_beast_etc(powc, MONS_IMP); + { + monster_type mon = (one_chance_in(3)) ? MONS_WHITE_IMP : + (one_chance_in(7)) ? MONS_SHADOW_IMP + : MONS_IMP; + + summon_ice_beast_etc(powc, mon, BEH_FRIENDLY, false); break; + } case SPELL_REPEL_MISSILES: missile_prot(powc); @@ -1518,7 +1519,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_GUARDIAN: - summon_ice_beast_etc(powc, MONS_ANGEL); + summon_ice_beast_etc(powc, MONS_ANGEL, BEH_FRIENDLY, false); break; case SPELL_THUNDERBOLT: @@ -1532,7 +1533,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_SUMMON_DAEVA: - summon_ice_beast_etc(powc, MONS_DAEVA); + summon_ice_beast_etc(powc, MONS_DAEVA, BEH_FRIENDLY, false); break; // Remember that most holy spells above don't yet use powc! @@ -1588,7 +1589,8 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) case SPELL_SUMMON_DEMON: mpr("You open a gate to Pandemonium!"); - summon_ice_beast_etc(powc, summon_any_demon(DEMON_COMMON)); + summon_ice_beast_etc(powc, summon_any_demon(DEMON_COMMON), + BEH_FRIENDLY, false); break; case SPELL_DEMONIC_HORDE: @@ -1596,7 +1598,10 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) { const int num = 7 + random2(5); for (int i = 0; i < num; ++i) - summon_ice_beast_etc(powc, summon_any_demon(DEMON_LESSER)); + { + summon_ice_beast_etc(powc, summon_any_demon(DEMON_LESSER), + BEH_FRIENDLY, false); + } } break; @@ -1604,15 +1609,15 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) mpr("You open a gate to Pandemonium!"); { - const beh_type dem_beh = ((random2(powc) > 5) ? BEH_CHARMED : - BEH_HOSTILE); + const beh_type beha = ((random2(powc) > 5) ? BEH_CHARMED : + BEH_HOSTILE); - if (dem_beh == BEH_CHARMED) + if (beha == BEH_CHARMED) mpr("You don't feel so good about this..."); create_monster( - mgen_data( summon_any_demon(DEMON_GREATER), dem_beh, 5, - you.pos(), MHITYOU )); + mgen_data(summon_any_demon(DEMON_GREATER), beha, 5, + you.pos(), MHITYOU)); } break; diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 4d2701d4b0..ae74c78c94 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -526,8 +526,8 @@ static bool xom_is_good(int sever) summons[i] = create_monster( - mgen_data(mon, BEH_GOD_GIFT, 3, - you.pos(), you.pet_target)); + mgen_data(mon, BEH_FRIENDLY, 3, + you.pos(), you.pet_target, MF_GOD_GIFT)); if (summons[i] != -1) success = true; @@ -605,7 +605,7 @@ static bool xom_is_good(int sever) different = true; // Mark non-demons hostile as appropriate. - beh_type beha = BEH_GOD_GIFT; + beh_type beha = BEH_FRIENDLY; unsigned short hitting = you.pet_target; if (different && hostiletype) @@ -616,7 +616,7 @@ static bool xom_is_good(int sever) if (create_monster( mgen_data(mon, beha, 6, - you.pos(), hitting)) != -1) + you.pos(), hitting, MF_GOD_GIFT)) != -1) { if (different) god_speaks(GOD_XOM, _get_xom_speech("single holy summon")); @@ -700,7 +700,7 @@ static bool xom_is_good(int sever) different = true; // Mark non-demons hostile as appropriate. - beh_type beha = BEH_GOD_GIFT; + beh_type beha = BEH_FRIENDLY; unsigned short hitting = you.pet_target; if (different && hostiletype) @@ -710,8 +710,9 @@ static bool xom_is_good(int sever) } if (create_monster( - mgen_data(xom_random_demon(sever, one_chance_in(8)), beha, 0, - you.pos(), hitting)) != -1) + mgen_data(xom_random_demon(sever, one_chance_in(8)), + beha, 0, + you.pos(), hitting, MF_GOD_GIFT)) != -1) { if (different) god_speaks(GOD_XOM, _get_xom_speech("single major holy summon")); @@ -886,7 +887,8 @@ static bool xom_is_bad(int sever) { if (create_monster( mgen_data(xom_random_punishment_demon(sever), - BEH_HOSTILE, 4, you.pos())) != -1) + BEH_HOSTILE, 4, + you.pos(), MHITYOU, MF_GOD_GIFT)) != -1) { success = true; } |