diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 01:00:51 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 01:00:51 +0000 |
commit | b49b73d9b3736c7dad367e7f61c78ca35787f428 (patch) | |
tree | 90b20c0aa3aef6ca3f37a367c6009221b0b14e25 /crawl-ref | |
parent | 7fd9d9a617f65db7695d4858deed6f2cc01fd72c (diff) | |
download | crawl-ref-b49b73d9b3736c7dad367e7f61c78ca35787f428.tar.gz crawl-ref-b49b73d9b3736c7dad367e7f61c78ca35787f428.zip |
Lots and lots of type safety.
Caught a bug in the definition of shadows (isn't it lucky that
BLACK == MST_NO_SPELLS?)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1788 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/abl-show.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/decks.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/direct.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/direct.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 11 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/mon-data.h | 72 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 64 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.h | 81 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/spells4.cc | 50 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 402 | ||||
-rw-r--r-- | crawl-ref/source/view.h | 2 |
19 files changed, 360 insertions, 419 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 606a6ca084..05a75e815c 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -890,7 +890,7 @@ static bool do_ability(const ability_def& abil) case ABIL_DELAYED_FIREBALL: { - if (spell_direction(spd, beam, DIR_NONE, TARG_ENEMY) == -1) + if ( !spell_direction(spd, beam, DIR_NONE, TARG_ENEMY) ) return (false); // Note: power level of ball calculated at release -- bwr @@ -922,7 +922,7 @@ static bool do_ability(const ability_def& abil) canned_msg(MSG_CANNOT_DO_YET); return (false); } - else if (spell_direction(abild, beam) == -1) + else if ( !spell_direction(abild, beam) ) { return (false); } @@ -982,7 +982,7 @@ static bool do_ability(const ability_def& abil) canned_msg(MSG_CANNOT_DO_YET); return (false); } - else if (spell_direction( abild, beam ) == -1) + else if ( !spell_direction( abild, beam ) ) { return (false); } @@ -1133,7 +1133,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_CONTROL_DEMON: - if (spell_direction(abild, beam) == -1) + if ( !spell_direction(abild, beam) ) { return (false); } @@ -1158,7 +1158,7 @@ static bool do_ability(const ability_def& abil) case ABIL_THROW_FLAME: case ABIL_THROW_FROST: - if (spell_direction(abild, beam) == -1) + if ( !spell_direction(abild, beam) ) { return (false); } @@ -1169,7 +1169,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_BOLT_OF_DRAINING: - if (spell_direction(abild, beam) == -1) + if ( !spell_direction(abild, beam) ) { return (false); } @@ -1260,7 +1260,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_TSO_ANNIHILATE_UNDEAD: - if (spell_direction(spd, beam) == -1) + if ( !spell_direction(spd, beam) ) { return (false); } @@ -1270,7 +1270,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_TSO_CLEANSING_FLAME: - if (spell_direction(spd, beam) == -1) + if ( !spell_direction(spd, beam) ) { return (false); } @@ -1290,7 +1290,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_KIKU_ENSLAVE_UNDEAD: - if (spell_direction(spd, beam) == -1) + if ( !spell_direction(spd, beam) ) { return (false); } @@ -1363,7 +1363,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_MAKHLEB_MINOR_DESTRUCTION: - if (spell_direction(spd, beam) == -1) + if ( !spell_direction(spd, beam) ) { return (false); } @@ -1392,7 +1392,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_MAKHLEB_MAJOR_DESTRUCTION: - if (spell_direction(spd, beam) == -1) + if ( !spell_direction(spd, beam) ) { return (false); } diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index b9a0c48ecd..e603029bb2 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -664,7 +664,7 @@ static void damaging_card( card_type card, int power, deck_rarity_type rarity ) // For now, just throw a bolt in that direction. // Make this more interesting later! XXX - if ( spell_direction( target, beam ) != -1 ) + if ( spell_direction( target, beam ) ) zapping(ztype, random2(power/4), beam); } @@ -678,7 +678,7 @@ static void elixir_card(int power, deck_rarity_type rarity) if ( power_level == 0 ) { if ( coinflip() ) - potion_effect( POT_HEAL_WOUNDS, 40 ); // doesn't matter + potion_effect( POT_HEAL_WOUNDS, 40 ); // power doesn't matter else cast_regen( random2(power / 4) ); } diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 9f65fcd112..3b314f4fbe 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -3699,7 +3699,7 @@ void describe_monsters(monsters& mons) } description << " " << i << ": " - << mons_spell_name(hspell_pass[i]) + << spell_title(hspell_pass[i]) << " (" << static_cast<int>(hspell_pass[i]) << ")$"; } diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index f8cef123fe..49ac7db165 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -308,7 +308,7 @@ static void draw_ray_glyph(const coord_def &pos, int colour, // //--------------------------------------------------------------- void direction(dist& moves, targeting_type restricts, - int mode, bool just_looking, const char *prompt) + targ_mode_type mode, bool just_looking, const char *prompt) { // NOTE: Even if just_looking is set, moves is still interesting, // because we can travel there! @@ -524,7 +524,7 @@ void direction(dist& moves, targeting_type restricts, break; case CMD_TARGET_CYCLE_TARGET_MODE: - mode = (mode + 1) % TARG_NUM_MODES; + mode = static_cast<targ_mode_type>((mode + 1) % TARG_NUM_MODES); mprf( "Targeting mode is now: %s", (mode == TARG_ANY) ? "any" : (mode == TARG_ENEMY) ? "enemies" : @@ -657,6 +657,7 @@ void direction(dist& moves, targeting_type restricts, // A bunch of confirmation tests; if we survive them all, // then break out. + // Confirm self-targeting on TARG_ENEMY. // Conceivably we might want to confirm on TARG_ANY too. if ( moves.isTarget && moves.tx == you.x_pos && moves.ty == you.y_pos && @@ -672,7 +673,7 @@ void direction(dist& moves, targeting_type restricts, } // Ask for confirmation if we're quitting for some odd reason else if ( moves.isValid || moves.isCancel || - yesno("Are you sure you want to fizzle?") ) + yesno("Are you sure you want to fizzle?") ) { // Finalize whatever is inside the loop // (moves-internal finalizations can be done later) diff --git a/crawl-ref/source/direct.h b/crawl-ref/source/direct.h index 7b14bb3e00..f8be4357a7 100644 --- a/crawl-ref/source/direct.h +++ b/crawl-ref/source/direct.h @@ -23,8 +23,8 @@ * spells2 - spells3 - spells4 * *********************************************************************** */ -void direction( struct dist &moves, targeting_type restricts = DIR_NONE, - int mode = TARG_ANY, bool just_looking = false, +void direction( dist &moves, targeting_type restricts = DIR_NONE, + targ_mode_type mode = TARG_ANY, bool just_looking = false, const char *prompt = NULL ); bool in_los_bounds(int x, int y); diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index e62edb2b48..7797a83c4c 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2492,6 +2492,15 @@ enum mon_holy_type // matches (char) H_foo in mon-util.h, see: monster_holiness( MH_PLANT // plants }; +enum mon_intel_type // Must be in increasing intelligence order +{ + I_PLANT = 0, + I_INSECT, + I_ANIMAL, + I_NORMAL, + I_HIGH +}; + // Adding slots breaks saves. YHBW. enum mon_inv_type // (int) menv[].inv[] { @@ -3037,7 +3046,7 @@ enum shout_type S_SILENT, // silent S_SHOUT, // shout S_BARK, // bark - S_SHOUT2, // shout twice + S_SHOUT2, // shout twice (e.g. two-headed ogres) S_ROAR, // roar S_SCREAM, // scream S_BELLOW, // bellow (?) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index d0d9e70ce9..af1681dab9 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1042,7 +1042,7 @@ public: void pandemon_init(); void destroy_inventory(); void reset(); - void load_spells(int spellbook); + void load_spells(mon_spellbook_type spellbook); actor *get_foe() const; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index d57bf9ded2..6c803040e6 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -2582,13 +2582,13 @@ bool remove_ring(int slot, bool announce) void zap_wand(void) { - struct bolt beam; - struct dist zap_wand; + bolt beam; + dist zap_wand; int item_slot; // Unless the character knows the type of the wand, the targeting // system will default to enemies. -- [ds] - int targ_mode = TARG_ENEMY; + targ_mode_type targ_mode = TARG_ENEMY; beam.obvious_effect = false; diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h index 907db57e20..bab7d4fc4e 100644 --- a/crawl-ref/source/mon-data.h +++ b/crawl-ref/source/mon-data.h @@ -79,17 +79,6 @@ shouts - various things monsters can do upon seeing you - #define S_RANDOM -1 - #define S_SILENT 0 - #define S_SHOUT 1 //1=shout - #define S_BARK 2 //2=bark - #define S_SHOUT2 3 //3=shout twice - eg 2-headed ogres - #define S_ROAR 4 //4=roar - #define S_SCREAM 5 //5=scream - #define S_BELLOW 6 //6=bellow (?) - #define S_SCREECH 7 //7=screech - #define S_BUZZ 8 //8=buzz - #define S_MOAN 9 //9=moan intel explanation: - How smart it is. So far, differences here have little effects except @@ -363,7 +352,7 @@ 0, 10, 19, MH_NATURAL, MAG_IMMUNE, { 50, 0, 0, 0 }, { 10, 5, 5, 0 }, - 3, 3, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_REPTILE, + 3, 3, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_HUGE } , @@ -548,7 +537,7 @@ 0, 12, MONS_ICE_BEAST, MONS_ICE_BEAST, MH_NATURAL, -3, { {AT_HIT, AF_COLD, 5}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 5, 3, 5, 0 }, - 5, 10, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL_LIKE, + 5, 10, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_LARGE } , @@ -668,7 +657,7 @@ 200, 10, MONS_SNAKE, MONS_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_POISON, 5}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 2, 3, 5, 0 }, - 1, 15, 13, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_REPTILE, + 1, 15, 13, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_SMALL } , @@ -692,7 +681,7 @@ 0, 12, MONS_UNSEEN_HORROR, MONS_UNSEEN_HORROR, MH_NATURAL, -3, { {AT_HIT, AF_PLAIN, 12}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 7, 3, 5, 0 }, - 5, 10, 30, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL_LIKE, + 5, 10, 30, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -902,7 +891,7 @@ 0, 10, MONS_WRAITH, MONS_SHADOW, MH_UNDEAD, -5, { {AT_HIT, AF_DRAIN_STR, 5}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 3, 3, 5, 0 }, - 12, 10, 10, 7, BLACK, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL, + 12, 10, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_NOZOMBIE, S_SILENT, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_SMALL } , @@ -974,7 +963,7 @@ 150, 10, MONS_WORM, MONS_BRAIN_WORM, MH_NATURAL, -3, { {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 5, 3, 3, 0 }, - 1, 5, 10, 7, MST_BRAIN_WORM, CE_POISONOUS, Z_SMALL, S_SILENT, I_REPTILE, + 1, 5, 10, 7, MST_BRAIN_WORM, CE_POISONOUS, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_SMALL } , @@ -1264,7 +1253,7 @@ 1000, 10, MONS_DRAGON, MONS_STEAM_DRAGON, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 12}, {AT_CLAW, AF_PLAIN, 6}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 4, 5, 5, 0 }, - 5, 10, 10, 7, MST_STEAM_DRAGON, CE_CLEAN, Z_BIG, S_SILENT, I_ANIMAL_LIKE, + 5, 10, 10, 7, MST_STEAM_DRAGON, CE_CLEAN, Z_BIG, S_SILENT, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_GIANT, } , @@ -1324,7 +1313,7 @@ 1800, 11, MONS_HYDRA, MONS_HYDRA, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 18}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 13, 3, 5, 0 }, - 0, 5, 10, 7, MST_NO_SPELLS, CE_POISONOUS, Z_NOZOMBIE, S_ROAR, I_REPTILE, + 0, 5, 10, 7, MST_NO_SPELLS, CE_POISONOUS, Z_NOZOMBIE, S_ROAR, I_INSECT, MONUSE_OPEN_DOORS, SIZE_BIG } , @@ -1524,7 +1513,7 @@ 1100, 10, MONS_DRAGON, MONS_MOTTLED_DRAGON, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 15}, {AT_CLAW, AF_PLAIN, 6}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 5, 3, 5, 0 }, - 5, 10, 10, 7, MST_MOTTLED_DRAGON, CE_POISONOUS, Z_BIG, S_SILENT, I_ANIMAL_LIKE, + 5, 10, 10, 7, MST_MOTTLED_DRAGON, CE_POISONOUS, Z_BIG, S_SILENT, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_GIANT, } , @@ -1598,7 +1587,7 @@ 300, 10, MONS_SNAKE, MONS_BROWN_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_POISON_MEDIUM, 10}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 4, 3, 5, 0 }, - 2, 15, 14, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_REPTILE, + 2, 15, 14, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -1610,7 +1599,7 @@ 600, 10, MONS_GIANT_LIZARD, MONS_GIANT_LIZARD, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 20}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 5, 3, 5, 0 }, - 4, 10, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_REPTILE, + 4, 10, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -1846,7 +1835,7 @@ 1000, 11, MONS_DRAGON, MONS_LINDWURM, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 20}, {AT_CLAW, AF_PLAIN, 10}, {AT_CLAW, AF_PLAIN, 10}, {AT_NONE, AF_PLAIN, 0} }, { 9, 3, 5, 0 }, - 8, 6, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_BIG, S_ROAR, I_REPTILE, + 8, 6, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_BIG, S_ROAR, I_INSECT, MONUSE_NOTHING, SIZE_GIANT, } , @@ -1918,7 +1907,7 @@ 500, 12, MONS_SNAKE, MONS_BLACK_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_POISON_MEDIUM, 20}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 7, 3, 5, 0 }, - 4, 15, 18, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_REPTILE, + 4, 15, 18, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -2061,7 +2050,7 @@ 400, 10, MONS_SNAKE, MONS_YELLOW_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_POISON_MEDIUM, 15}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 6, 3, 5, 0 }, - 4, 14, 13, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_REPTILE, + 4, 14, 13, 7, MST_NO_SPELLS, CE_POISONOUS, Z_SMALL, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -2073,7 +2062,7 @@ 600, 10, MONS_SNAKE, MONS_GREY_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 30}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 11, 3, 5, 0 }, - 4, 16, 18, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_HISS, I_REPTILE, + 4, 16, 18, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_LARGE } , @@ -2121,7 +2110,7 @@ 1900, 11, MONS_DRAGON, MONS_SWAMP_DRAGON, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 18}, {AT_CLAW, AF_PLAIN, 9}, {AT_CLAW, AF_PLAIN, 9}, {AT_NONE, AF_PLAIN, 0} }, { 9, 5, 5, 0 }, - 7, 7, 10, 7, MST_SWAMP_DRAGON, CE_CONTAMINATED, Z_BIG, S_ROAR, I_ANIMAL_LIKE, + 7, 7, 10, 7, MST_SWAMP_DRAGON, CE_CONTAMINATED, Z_BIG, S_ROAR, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_GIANT, } , @@ -2133,7 +2122,7 @@ 900, 11, MONS_DRAGON, MONS_SWAMP_DRAKE, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 14}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 4, 5, 5, 0 }, - 3, 11, 11, 7, MST_SWAMP_DRAKE, CE_CONTAMINATED, Z_SMALL, S_ROAR, I_ANIMAL_LIKE, + 3, 11, 11, 7, MST_SWAMP_DRAKE, CE_CONTAMINATED, Z_SMALL, S_ROAR, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_BIG } , @@ -2145,7 +2134,7 @@ 900, 11, MONS_DRAGON, MONS_DEATH_DRAKE, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 12}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 9, 5, 7, 0 }, - 6, 14, 13, 10, MST_DEATH_DRAKE, CE_HCL, Z_BIG, S_ROAR, I_ANIMAL_LIKE, + 6, 14, 13, 10, MST_DEATH_DRAKE, CE_HCL, Z_BIG, S_ROAR, I_ANIMAL, MONUSE_OPEN_DOORS, SIZE_BIG } , @@ -2264,7 +2253,7 @@ 100, 13, MONS_SNAKE, MONS_SMALL_SNAKE, MH_NATURAL, -1, { {AT_BITE, AF_POISON, 2}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 1, 2, 3, 0 }, - 0, 11, 12, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_REPTILE, + 0, 11, 12, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -4117,7 +4106,7 @@ 0, 10, MONS_LAVA_WORM, MONS_LAVA_WORM, MH_NATURAL, -3, { {AT_BITE, AF_FIRE, 15}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 6, 3, 5, 0 }, - 1, 10, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL_LIKE, + 1, 10, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_LARGE } , @@ -4129,7 +4118,7 @@ 0, 10, MONS_BIG_FISH, MONS_LAVA_FISH, MH_NATURAL, -3, { {AT_BITE, AF_FIRE, 10}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 4, 3, 5, 0 }, - 4, 15, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL_LIKE, + 4, 15, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -4141,7 +4130,7 @@ 0, 10, MONS_SNAKE, MONS_LAVA_SNAKE, MH_NATURAL, -3, { {AT_BITE, AF_FIRE, 7}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 3, 3, 5, 0 }, - 2, 17, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_HISS, I_ANIMAL_LIKE, + 2, 17, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_HISS, I_ANIMAL, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -4168,7 +4157,7 @@ 0, 10, MONS_BIG_FISH, MONS_BIG_FISH, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 8}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 4, 3, 5, 0 }, - 1, 12, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL_LIKE, + 1, 12, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_SMALL } , @@ -4180,7 +4169,7 @@ 0, 10, MONS_BIG_FISH, MONS_GIANT_GOLDFISH, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 15}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 7, 3, 5, 0 }, - 5, 7, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL_LIKE, + 5, 7, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -4192,7 +4181,7 @@ 0, 10, MONS_ELECTRICAL_EEL, MONS_ELECTRICAL_EEL, MH_NATURAL, -3, { {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 3, 3, 5, 0 }, - 1, 15, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL_LIKE, + 1, 15, 10, 7, MST_NO_SPELLS, CE_NOCORPSE, Z_SMALL, S_SILENT, I_ANIMAL, MONUSE_NOTHING, SIZE_SMALL } , @@ -4338,7 +4327,7 @@ 150, 10, MONS_GIANT_LIZARD, MONS_GIANT_NEWT, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 3}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 1, 1, 2, 0 }, - 0, 15, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_REPTILE, + 0, 15, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_TINY } , @@ -4350,7 +4339,7 @@ 250, 10, MONS_GIANT_LIZARD, MONS_GIANT_GECKO, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 5}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 1, 3, 5, 0 }, - 1, 14, 12, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_REPTILE, + 1, 14, 12, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_SILENT, I_INSECT, MONUSE_NOTHING, SIZE_TINY } , @@ -4362,7 +4351,7 @@ 400, 10, MONS_GIANT_LIZARD, MONS_GIANT_IGUANA, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 15}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 3, 3, 5, 0 }, - 5, 9, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_HISS, I_REPTILE, + 5, 9, 10, 7, MST_NO_SPELLS, CE_CLEAN, Z_SMALL, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -4375,7 +4364,7 @@ 500, 10, MONS_GIANT_LIZARD, MONS_GILA_MONSTER, MH_NATURAL, -3, { {AT_BITE, AF_PLAIN, 20}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 5, 4, 4, 0 }, - 3, 12, 10, 7, MST_NO_SPELLS, CE_POISONOUS, Z_BIG, S_HISS, I_REPTILE, + 3, 12, 10, 7, MST_NO_SPELLS, CE_POISONOUS, Z_BIG, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_LITTLE, } , @@ -4387,7 +4376,7 @@ 800, 10, MONS_GIANT_LIZARD, MONS_KOMODO_DRAGON, MH_NATURAL, -3, { {AT_BITE, AF_DISEASE, 30}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, { 8, 3, 5, 0 }, - 7, 8, 10, 7, MST_NO_SPELLS, CE_CONTAMINATED, Z_BIG, S_HISS, I_REPTILE, + 7, 8, 10, 7, MST_NO_SPELLS, CE_CONTAMINATED, Z_BIG, S_HISS, I_INSECT, MONUSE_NOTHING, SIZE_MEDIUM } , @@ -4462,5 +4451,4 @@ 7, 3, 8, 8, MST_NO_SPELLS, CE_CLEAN, Z_BIG, S_SHOUT, I_HIGH, MONUSE_STARTING_EQUIPMENT, SIZE_GIANT, }, - #endif diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 7cbeed364f..df006f7cb1 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -66,11 +66,11 @@ enum habitat_type static bool initialized_randmons = false; static std::vector<monster_type> monsters_by_habitat[NUM_HABITATS]; -static struct monsterentry mondata[] = { +static monsterentry mondata[] = { #include "mon-data.h" }; -#define MONDATASIZE (sizeof(mondata)/sizeof(monsterentry)) +#define MONDATASIZE ARRAYSIZE(mondata) static int mspell_list[][7] = { #include "mon-spll.h" @@ -203,7 +203,6 @@ void init_monsters(FixedVector < unsigned short, 1000 > &colour) if (mon_entry[x] == -1) mon_entry[x] = mon_entry[MONS_PROGRAM_BUG]; } - //return (monsterentry *) 0; // return value should not matter here {dlb} } // end mons_init() unsigned long get_mons_class_resists(int mc) @@ -448,12 +447,12 @@ monster_type draco_subspecies( const monsters *mon ) return (ret); } -int mons_shouts(int mc) +shout_type mons_shouts(int mc) { - int u = smc->shouts; + shout_type u = smc->shouts; - if (u == -1) - u = random2(12); + if (u == S_RANDOM) + u = static_cast<shout_type>(random2(NUM_SHOUTS)); return (u); } // end mons_shouts() @@ -517,7 +516,7 @@ unsigned char mons_char(int mc) return static_cast<unsigned char>(smc->showchar); } // end mons_char() -char mons_itemuse(int mc) +mon_itemuse_type mons_itemuse(int mc) { return (smc->gmon_use); } // end mons_itemuse() @@ -1160,20 +1159,11 @@ int exper_value( const struct monsters *monster ) return (x_val); } // end exper_value() -void mons_load_spells( monsters *mon, int book ) +void mons_load_spells( monsters *mon, mon_spellbook_type book ) { mon->load_spells(book); } -#ifdef DEBUG_DIAGNOSTICS - -const char *mons_spell_name( spell_type spell ) -{ - return (spell_title(spell)); -} - -#endif - // generate a shiny new and unscarred monster void define_monster(int index) { @@ -1185,7 +1175,7 @@ void define_monster(int index) int monnumber = mons.number; const monsterentry *m = seekmonster(mcls); int col = mons_class_colour(mons.type); - int spells = MST_NO_SPELLS; + mon_spellbook_type spells = MST_NO_SPELLS; hd = m->hpdice[0]; @@ -1239,12 +1229,12 @@ void define_monster(int index) case MONS_DEEP_ELF_KNIGHT: case MONS_DEEP_ELF_SOLDIER: case MONS_ORC_WIZARD: - spells = MST_ORC_WIZARD_I + random2(3); + spells = static_cast<mon_spellbook_type>(MST_ORC_WIZARD_I+random2(3)); break; case MONS_LICH: case MONS_ANCIENT_LICH: - spells = MST_LICH_I + random2(4); + spells = static_cast<mon_spellbook_type>(MST_LICH_I + random2(4)); break; case MONS_HELL_KNIGHT: @@ -1259,7 +1249,7 @@ void define_monster(int index) case MONS_OGRE_MAGE: case MONS_EROLCHA: case MONS_DEEP_ELF_MAGE: - spells = MST_WIZARD_I + random2(5); + spells = static_cast<mon_spellbook_type>(MST_WIZARD_I + random2(5)); break; case MONS_DEEP_ELF_CONJURER: @@ -1540,32 +1530,10 @@ int mons_speed(int mc) } // end mons_speed() -int mons_intel(int mc) //jmf: "fixed" to work with new I_ types -{ - switch (smc->intel) - { - case I_PLANT: - return (I_PLANT); - case I_INSECT: - case I_REPTILE: - return (I_INSECT); - case I_ANIMAL: - case I_ANIMAL_LIKE: - return (I_ANIMAL); - case I_NORMAL: - return (I_NORMAL); - case I_HIGH: - return (I_HIGH); - default: - return (I_NORMAL); - } -} // ens mons_intel() - - -int mons_intel_type(int mc) //jmf: new, used by my spells +mon_intel_type mons_intel(int mc) { return (smc->intel); -} // end mons_intel_type() +} int mons_power(int mc) { @@ -3344,7 +3312,7 @@ void monsters::set_transit(const level_id &dest) add_monster_to_transit(dest, *this); } -void monsters::load_spells(int book) +void monsters::load_spells(mon_spellbook_type book) { spells.init(SPELL_NO_SPELL); if (book == MST_NO_SPELLS || (book == MST_GHOST && !ghost.get())) @@ -3352,7 +3320,7 @@ void monsters::load_spells(int book) #if DEBUG_DIAGNOSTICS mprf( MSGCH_DIAGNOSTICS, "%s: loading spellbook #%d", - name(DESC_PLAIN).c_str(), book ); + name(DESC_PLAIN).c_str(), static_cast<int>(book) ); #endif if (book == MST_GHOST) diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index e5252b3ba3..ad080d8fda 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -19,41 +19,6 @@ // ($pellbinder) (c) D.G.S.E. 1998 -// zombie size -#define Z_NOZOMBIE 0 // no zombie (and no skeleton) -#define Z_SMALL 1 -#define Z_BIG 2 -// Note - this should be set to 0 for classed monsters, eg orc wizard - -// shout -#define S_RANDOM -1 -#define S_SILENT 0 -#define S_SHOUT 1 //1=shout -#define S_BARK 2 //2=bark -#define S_SHOUT2 3 //3=shout twice -#define S_ROAR 4 //4=roar -#define S_SCREAM 5 //5=scream -#define S_BELLOW 6 //6=bellow (?) -#define S_SCREECH 7 //7=screech -#define S_BUZZ 8 //8=buzz -#define S_MOAN 9 //9=moan -#define S_WHINE 10 //10=irritating whine (mosquito) -#define S_CROAK 11 //11=frog croak -#define S_GROWL 12 //jmf: for bears -#define S_HISS 13 //bwr: for snakes and lizards - -// ai -// So far this only affects a) chance to see stealthy player and b) chance to -// walk through damaging clouds (LRH) -//jmf: now has relevence to mind-affecting spells, maybe soon behaviour -#define I_PLANT 0 -#define I_INSECT 1 -#define I_ANIMAL 2 -#define I_NORMAL 3 -#define I_HIGH 4 -#define I_ANIMAL_LIKE 5 -#define I_REPTILE 6 - struct monsterentry { short mc; // monster number @@ -74,7 +39,7 @@ struct monsterentry monster_type genus, // "team" the monster plays for species; // corpse type of the monster - mon_holy_type holiness; // -1=holy,0=normal,1=undead,2=very very evil + mon_holy_type holiness; short resist_magic; // (positive is ??) // max damage in a turn is total of these four? @@ -95,21 +60,14 @@ struct monsterentry char speed, speed_inc; // duh! - short sec; // not used (250) most o/t time - - // eating the corpse: 1=clean,2=might be contaminated,3=poison,4=very bad + mon_spellbook_type sec; corpse_effect_type corpse_thingy; - // 0=no zombie, 1=small zombie (z) 107, 2=_BIG_ zombie (Z) 108 - char zombie_size; - // 0-12: see above, -1=random one of (0-7) - char shouts; - // AI things? - char intel; // 0=none, 1=worst...4=best - - char gmon_use; - + zombie_size_type zombie_size; + shout_type shouts; + mon_intel_type intel; + mon_itemuse_type gmon_use; size_type size; -}; // mondata[] - again, no idea why this was externed {dlb} +}; // wow. this struct is only about 48 bytes, (excluding the name) @@ -136,7 +94,7 @@ int mons_flies( const monsters *mon ); /* *********************************************************************** * called from: dungeon - monstuff * *********************************************************************** */ -char mons_itemuse(int mc); +mon_itemuse_type mons_itemuse(int mc); // last updated 12may2000 {dlb} @@ -153,7 +111,7 @@ bool mons_player_visible( struct monsters *mon ); /* *********************************************************************** * called from: view * *********************************************************************** */ -int mons_shouts(int mclass); +shout_type mons_shouts(int mclass); bool mons_is_unique(int mclass); @@ -224,15 +182,7 @@ bool mons_is_summoned(const monsters *m); /* *********************************************************************** * called from: monstuff - spells4 - view * *********************************************************************** */ -int mons_intel(int mclass); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: spells4 - * *********************************************************************** */ -int mons_intel_type(int mclass); //jmf: added 20mar2000 - +mon_intel_type mons_intel(int mclass); // last updated 12may2000 {dlb} /* *********************************************************************** @@ -323,7 +273,7 @@ unsigned char mons_char(int mc); int mons_class_colour(int mc); int mons_colour(const monsters *m); -void mons_load_spells( monsters *mon, int book ); +void mons_load_spells( monsters *mon, mon_spellbook_type book ); // last updated 12may2000 {dlb} /* *********************************************************************** @@ -331,15 +281,6 @@ void mons_load_spells( monsters *mon, int book ); * *********************************************************************** */ void define_monster(int mid); - -#ifdef DEBUG_DIAGNOSTICS -// last updated 25sep2001 {dlb} -/* *********************************************************************** - * called from: describe - * *********************************************************************** */ -extern const char *mons_spell_name(spell_type); -#endif - // last updated 4jan2001 (gdl) /* *********************************************************************** * called from: monstuff diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index b8f55d54f4..c0fe8a6480 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1682,7 +1682,7 @@ static void handle_behaviour(monsters *mon) { if (mon->foe == MHITYOU) { - if (check_awaken(monster_index(mon))) + if (check_awaken(mon)) { mon->target_x = you.x_pos; mon->target_y = you.y_pos; @@ -1717,19 +1717,19 @@ static void handle_behaviour(monsters *mon) int memory; switch(mons_intel(monster_index(mon))) { - case I_HIGH: - memory = 100 + random2(200); - break; - case I_NORMAL: - memory = 50 + random2(100); - break; - case I_ANIMAL: - default: - memory = 25 + random2(75); - break; - case I_INSECT: - memory = 10 + random2(50); - break; + case I_HIGH: + memory = 100 + random2(200); + break; + case I_NORMAL: + memory = 50 + random2(100); + break; + case I_ANIMAL: + case I_PLANT: + memory = 25 + random2(75); + break; + case I_INSECT: + memory = 10 + random2(50); + break; } mon->foe_memory = memory; diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 74445a69d8..bab6d51e8f 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -40,6 +40,7 @@ #include "spells2.h" #include "spells4.h" #include "spl-cast.h" +#include "spl-util.h" #include "stuff.h" #include "view.h" @@ -406,7 +407,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) #if DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Mon #%d casts %s (#%d)", - monster_index(monster), mons_spell_name( spell_cast ), spell_cast); + monster_index(monster), spell_title(spell_cast), spell_cast); #endif if (spell_cast == SPELL_HELLFIRE_BURST || spell_cast == SPELL_BRAIN_FEED diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 96530f662e..1c8d0e34bf 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -878,25 +878,42 @@ void cast_mass_sleep(int pow) apply_area_visible(sleep_monsters, pow); } // end cast_mass_sleep() +// This is a hack until we set an is_beast flag in the monster data +// (which we might never do, this is sort of minor.) +// It's a list of monster types which can be affected by beast taming. +static bool is_domesticated_animal(int type) +{ + const monster_type types[] = { + MONS_GIANT_BAT, MONS_HOUND, MONS_JACKAL, MONS_RAT, + MONS_YAK, MONS_WYVERN, MONS_HIPPOGRIFF, MONS_GRIFFON, + MONS_DEATH_YAK, MONS_WAR_DOG, MONS_GREY_RAT, + MONS_GREEN_RAT, MONS_ORANGE_RAT, MONS_SHEEP, + MONS_HOG, MONS_GIANT_FROG, MONS_GIANT_BROWN_FROG, + MONS_SPINY_FROG, MONS_BLINK_FROG, MONS_WOLF, MONS_WARG, + MONS_BEAR, MONS_GRIZZLY_BEAR, MONS_POLAR_BEAR, MONS_BLACK_BEAR + }; + for ( unsigned int i = 0; i < ARRAYSIZE(types); ++i ) + if ( types[i] == type ) + return true; + return false; +} + static int tame_beast_monsters(int x, int y, int pow, int garbage) { UNUSED( garbage ); - int which_mons = mgrd[x][y]; + const int which_mons = mgrd[x][y]; - if (which_mons == NON_MONSTER) return 0; + if (which_mons == NON_MONSTER) + return 0; - struct monsters *monster = &menv[which_mons]; + monsters *monster = &menv[which_mons]; - if (mons_holiness(monster) != MH_NATURAL) return 0; - if (mons_intel_type(monster->type) != I_ANIMAL) return 0; - if (mons_friendly(monster)) return 0; + if (!is_domesticated_animal(monster->type) || mons_friendly(monster)) + return 0; - // 50% bonus for dogs, add cats if they get implemented - if (monster->type == MONS_HOUND || monster->type == MONS_WAR_DOG - || monster->type == MONS_BLACK_BEAR) - { + // 50% bonus for dogs + if (monster->type == MONS_HOUND || monster->type == MONS_WAR_DOG ) pow += (pow / 2); - } if (you.species == SP_HILL_ORC && monster->type == MONS_WARG) pow += (pow / 2); @@ -904,15 +921,12 @@ static int tame_beast_monsters(int x, int y, int pow, int garbage) if (check_mons_resist_magic(monster, pow)) return 0; - // I'd like to make the monsters affected permanently, but that's - // pretty powerful. Maybe a small (pow/10) chance of being permanently - // tamed, large chance of just being enslaved. simple_monster_message(monster, " is tamed!"); if (random2(100) < random2(pow / 10)) - monster->attitude = ATT_FRIENDLY; // permanent, right? + monster->attitude = ATT_FRIENDLY; // permanent else - monster->add_ench(ENCH_CHARM); + monster->add_ench(ENCH_CHARM); // temporary return 1; } // end tame_beast_monsters() @@ -2678,7 +2692,7 @@ void cast_twist(int pow) // Get target, using DIR_TARGET for targetting only, // since we don't use fire_beam() for this spell. - if (spell_direction(targ, tmp, DIR_TARGET) == -1) + if ( !spell_direction(targ, tmp, DIR_TARGET) ) return; const int mons = mgrd[ targ.tx ][ targ.ty ]; @@ -2753,7 +2767,7 @@ void cast_far_strike(int pow) // Get target, using DIR_TARGET for targetting only, // since we don't use fire_beam() for this spell. - if (spell_direction(targ, tmp, DIR_TARGET) == -1) + if ( !spell_direction(targ, tmp, DIR_TARGET) ) return; // Get the target monster... diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 61a9e1aaa1..b5821cb120 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -841,7 +841,8 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) // Hopefully, those will eventually be fixed. -- bwr if (flags & SPFLAG_TARGETING_MASK) { - int targ = (testbits(flags, SPFLAG_HELPFUL) ? TARG_FRIEND : TARG_ENEMY); + targ_mode_type targ = + (testbits(flags, SPFLAG_HELPFUL) ? TARG_FRIEND : TARG_ENEMY); targeting_type dir = (testbits( flags, SPFLAG_TARGET ) ? DIR_TARGET : @@ -852,7 +853,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) if (dir == DIR_DIR) mpr(prompt? prompt : "Which direction? ", MSGCH_PROMPT); - if (spell_direction( spd, beam, dir, targ, prompt ) == -1) + if ( !spell_direction( spd, beam, dir, targ, prompt ) ) return (SPRET_ABORT); if (testbits( flags, SPFLAG_NOT_SELF ) && spd.isMe) diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index ed62c89478..6cd0a5cad2 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -674,8 +674,10 @@ void apply_area_cloud( int (*func) (int, int, int, cloud_type, kill_category), } } // end apply_area_cloud() -char spell_direction( struct dist &spelld, struct bolt &pbolt, - targeting_type restrict, int mode, +// Select a spell direction and fill dist and pbolt appropriately. +// Return false if the user canceled, true otherwise. +bool spell_direction( dist &spelld, bolt &pbolt, + targeting_type restrict, targ_mode_type mode, const char *prompt ) { if (restrict != DIR_DIR) @@ -687,14 +689,14 @@ char spell_direction( struct dist &spelld, struct bolt &pbolt, { // check for user cancel canned_msg(MSG_OK); - return -1; + return false; } pbolt.set_target(spelld); pbolt.source_x = you.x_pos; pbolt.source_y = you.y_pos; - return 1; + return true; } // end spell_direction() const char* spelltype_short_name( int which_spelltype ) diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index 3c480d8668..e64095654a 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -95,9 +95,9 @@ int apply_one_neighbouring_square(int (*func) (int, int, int, int), int apply_area_within_radius(int (*func) (int, int, int, int), int x, int y, int pow, int radius, int ctype); -char spell_direction( struct dist &spelld, struct bolt &pbolt, +bool spell_direction( dist &spelld, bolt &pbolt, targeting_type restrict = DIR_NONE, - int mode = TARG_ENEMY, + targ_mode_type mode = TARG_ENEMY, const char *prompt = NULL ); void apply_area_cloud(int (*func) (int, int, int, cloud_type, kill_category), diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index f37c8c05b6..21f32f3259 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -610,9 +610,209 @@ static bool mons_was_seen_this_turn(const monsters *mons) monsters_seen_this_turn.end()); } +static void beogh_follower_convert(monsters *monster) +{ + // for followers of Beogh, decide whether orcs will join you + if (mons_species(monster->type) == MONS_ORC + && you.religion == GOD_BEOGH + && !(monster->flags & MF_CONVERT_ATTEMPT) + // && !mons_is_unique(monster->type) // does not work on Blork + && monster->foe == MHITYOU + && mons_player_visible(monster) && !mons_is_sleeping(monster) + && !mons_is_confused(monster) && !mons_is_paralysed(monster)) + { + monster->flags |= MF_CONVERT_ATTEMPT; + + const int hd = monster->hit_dice; + + if (you.piety >= 75 && !you.penance[GOD_BEOGH] && + random2(you.piety/9) > random2(hd) + hd + random2(5)) + { + int wpn = you.equip[EQ_WEAPON]; + if (wpn != -1 + && you.inv[wpn].base_type == OBJ_WEAPONS + && get_weapon_brand( you.inv[wpn] ) == SPWPN_ORC_SLAYING + && coinflip()) // 50% chance of conversion failing + { + msg::stream << monster->name(DESC_CAP_THE) + << " flinches from your weapon." + << std::endl; + return; + } + + if (player_monster_visible(monster)) // show reaction + { + std::ostream& chan = msg::streams(MSGCH_MONSTER_ENCHANT); + chan << monster->name(DESC_CAP_THE); + + // FIXME what about female monsters? + switch (random2(3)) + { + case 0: + chan << " stares at you in amazement and kneels."; + break; + case 1: + chan << " relaxes his fighting stance and smiles at you."; + break; + case 2: + chan << " falls on his knees before you."; + break; + } + chan << std::endl; + + if (!one_chance_in(3)) + { + std::ostream& tchan = msg::streams(MSGCH_TALK); + tchan << "He "; + switch (random2(4)) + { + case 0: + tchan << "shouts, \"I'll follow thee gladly!\""; + break; + case 1: + tchan << "shouts, \"Surely Beogh must have " + "sent you!\""; + break; + case 2: + tchan << "asks, \"Are you our saviour?\""; + break; + case 3: + tchan << "says, \"I'm so glad you are here now.\""; + break; + } + tchan << std::endl; + } + } + + monster->attitude = ATT_FRIENDLY; + monster->behaviour = BEH_GOD_GIFT; // alternative to BEH_FRIENDLY + // not really "created" friendly, but should it become + // hostile later on, it won't count as a good kill + monster->flags |= MF_CREATED_FRIENDLY; + monster->flags |= MF_GOD_GIFT; + + // to avoid immobile "followers" + behaviour_event(monster, ME_ALERT, MHITYOU); + } + } + else if (mons_species(monster->type) == MONS_ORC + && you.species == SP_HILL_ORC + && !(you.religion == GOD_BEOGH) +// && monster->foe == MHITYOU + && monster->attitude == ATT_FRIENDLY + && (monster->flags & MF_CONVERT_ATTEMPT) + && (monster->flags & MF_GOD_GIFT) + && mons_player_visible(monster) && !mons_is_sleeping(monster) + && !mons_is_confused(monster) && !mons_is_paralysed(monster)) + { // reconversion if no longer Beogh + + monster->attitude = ATT_HOSTILE; + monster->behaviour = BEH_HOSTILE; + // CREATED_FRIENDLY stays -> no piety bonus on killing these + + // give message only sometimes + if (player_monster_visible(monster) && random2(4)) + { + msg::streams(MSGCH_MONSTER_ENCHANT) + << monster->name(DESC_CAP_THE) + << " deserts you." + << std::endl; + } + } +} + +static void handle_monster_shouts(monsters* monster) +{ + if (you.turn_is_over + && mons_shouts(monster->type) != S_SILENT + && random2(30) >= you.skills[SK_STEALTH]) + { + int noise_level = 8; + + if (!mons_friendly(monster) + && (!silenced(you.x_pos, you.y_pos) + && !silenced(monster->x, monster->y))) + { + if (mons_is_demon( monster->type ) && coinflip()) + { + if (monster->type == MONS_IMP + || monster->type == MONS_WHITE_IMP + || monster->type == MONS_SHADOW_IMP) + { + imp_taunt( monster ); + } + else + { + demon_taunt( monster ); + } + } + else + { + std::string msg = "You hear "; + switch (mons_shouts(monster->type)) + { + case S_SILENT: + case NUM_SHOUTS: + case S_RANDOM: + msg += "buggy behaviour!"; + break; + case S_SHOUT: + msg += "a shout!"; + break; + case S_BARK: + msg += "a bark!"; + break; + case S_SHOUT2: + msg += "two shouts!"; + noise_level = 12; + break; + case S_ROAR: + msg += "a roar!"; + noise_level = 12; + break; + case S_SCREAM: + msg += "a hideous shriek!"; + break; + case S_BELLOW: + msg += "a bellow!"; + break; + case S_SCREECH: + msg += "a screech!"; + break; + case S_BUZZ: + msg += "an angry buzzing noise."; + break; + case S_MOAN: + msg += "a chilling moan."; + break; + case S_WHINE: + msg += "an irritating high-pitched whine."; + break; + case S_CROAK: + if (coinflip()) + msg += "a loud, deep croak!"; + else + msg += "a croak."; + break; + case S_GROWL: + msg += "an angry growl!"; + break; + case S_HISS: + msg += "an angry hiss!"; + noise_level = 4; // not very loud -- bwr + break; + } + msg::streams(MSGCH_SOUND) << msg << std::endl; + } + } + + noisy( noise_level, monster->x, monster->y ); + } +} + void monster_grid(bool do_updates) { - struct monsters *monster = 0; // NULL {dlb} + monsters *monster = NULL; for (int s = 0; s < MAX_MONSTERS; s++) { @@ -623,95 +823,10 @@ void monster_grid(bool do_updates) if (do_updates && (monster->behaviour == BEH_SLEEP || monster->behaviour == BEH_WANDER) - && check_awaken(s)) + && check_awaken(monster)) { behaviour_event( monster, ME_ALERT, MHITYOU ); - - if (you.turn_is_over - && mons_shouts(monster->type) > 0 - && random2(30) >= you.skills[SK_STEALTH]) - { - int noise_level = 8; - - if (!mons_friendly(monster) - && (!silenced(you.x_pos, you.y_pos) - && !silenced(monster->x, monster->y))) - { - if (mons_is_demon( monster->type ) && coinflip()) - { - if (monster->type == MONS_IMP - || monster->type == MONS_WHITE_IMP - || monster->type == MONS_SHADOW_IMP) - { - imp_taunt( monster ); - } - else - { - demon_taunt( monster ); - } - } - else - { - std::string msg = "You hear "; - switch (mons_shouts(monster->type)) - { - case S_SILENT: - default: - msg += "buggy behaviour!"; - break; - case S_SHOUT: - msg += "a shout!"; - break; - case S_BARK: - msg += "a bark!"; - break; - case S_SHOUT2: - msg += "two shouts!"; - noise_level = 12; - break; - case S_ROAR: - msg += "a roar!"; - noise_level = 12; - break; - case S_SCREAM: - msg += "a hideous shriek!"; - break; - case S_BELLOW: - msg += "a bellow!"; - break; - case S_SCREECH: - msg += "a screech!"; - break; - case S_BUZZ: - msg += "an angry buzzing noise."; - break; - case S_MOAN: - msg += "a chilling moan."; - break; - case S_WHINE: - msg += "an irritating high-pitched whine."; - break; - case S_CROAK: - if (coinflip()) - msg += "a loud, deep croak!"; - else - msg += "a croak."; - break; - case S_GROWL: - msg += "an angry growl!"; - break; - case S_HISS: - msg += "an angry hiss!"; - noise_level = 4; // not very loud -- bwr - break; - } - - mpr(msg.c_str(), MSGCH_SOUND); - } - } - - noisy( noise_level, monster->x, monster->y ); - } + handle_monster_shouts(monster); } const int ex = monster->x - you.x_pos + 9; @@ -747,108 +862,10 @@ void monster_grid(bool do_updates) env.show[ex][ey] = monster->type + DNGN_START_OF_MONSTERS; env.show_col[ex][ey] = get_mons_colour( monster ); - // for followers of Beogh, decide whether orcs will join you - if (mons_species(monster->type) == MONS_ORC - && you.religion == GOD_BEOGH - && !(monster->flags & MF_CONVERT_ATTEMPT) - // && !mons_is_unique(monster->type) // does not work on Blork - && monster->foe == MHITYOU - && mons_player_visible(monster) && !mons_is_sleeping(monster) - && !mons_is_confused(monster) && !mons_is_paralysed(monster)) - { - monster->flags |= MF_CONVERT_ATTEMPT; - - int hd = monster->hit_dice; - - if (you.piety >= 75 && !you.penance[GOD_BEOGH] && - random2(you.piety/9) > random2(hd) + hd + random2(5)) - { - int wpn = you.equip[EQ_WEAPON]; - if (wpn != -1 - && you.inv[wpn].base_type == OBJ_WEAPONS - && get_weapon_brand( you.inv[wpn] ) == SPWPN_ORC_SLAYING - && coinflip()) // 50% chance of conversion failing - { - snprintf(info, INFO_SIZE, "%s flinches from your weapon.", - monster->name(DESC_CAP_THE).c_str()); - mpr(info); - continue; - } - - if (player_monster_visible(monster)) // show reaction - { - std::string reaction; - - switch (random2(3)) - { - case 1: reaction = " stares at you in amazement and kneels."; - break; - case 2: reaction = " relaxes his fighting stance and smiles at you."; - break; - default: reaction = " falls on his knees before you."; - } - - snprintf(info, INFO_SIZE, "%s%s", - monster->name(DESC_CAP_THE).c_str(),reaction.c_str()); - mpr(info, MSGCH_MONSTER_ENCHANT); - - if (random2(3)) - { - switch (random2(4)) - { - case 0: reaction = "shouts, \"I'll follow thee gladly!\""; - break; - case 1: reaction = "shouts, \"Surely Beogh must have sent you!\""; - break; - case 2: reaction = "asks, \"Are you our saviour?\""; - break; - default: reaction = "says, \"I'm so glad you are here now.\""; - } - - snprintf(info, INFO_SIZE, "He %s", reaction.c_str()); - mpr(info, MSGCH_TALK); - } - - } - - monster->attitude = ATT_FRIENDLY; - monster->behaviour = BEH_GOD_GIFT; // alternative to BEH_FRIENDLY - // not really "created" friendly, but should it become - // hostile later on, it won't count as a good kill - monster->flags |= MF_CREATED_FRIENDLY; - monster->flags |= MF_GOD_GIFT; - - // to avoid immobile "followers" - behaviour_event(monster, ME_ALERT, MHITYOU); - } - } - else if (mons_species(monster->type) == MONS_ORC - && you.species == SP_HILL_ORC - && !(you.religion == GOD_BEOGH) -// && monster->foe == MHITYOU - && monster->attitude == ATT_FRIENDLY - && (monster->flags & MF_CONVERT_ATTEMPT) - && (monster->flags & MF_GOD_GIFT) - && mons_player_visible(monster) && !mons_is_sleeping(monster) - && !mons_is_confused(monster) && !mons_is_paralysed(monster)) - { // reconversion if no longer Beogh - - monster->attitude = ATT_HOSTILE; - monster->behaviour = BEH_HOSTILE; - // CREATED_FRIENDLY stays -> no piety bonus on killing these - - // give message only sometimes - if (player_monster_visible(monster) && random2(4)) - { - snprintf(info, INFO_SIZE, "%s deserts you.", - monster->name(DESC_CAP_THE).c_str()); - mpr(info, MSGCH_MONSTER_ENCHANT); - } - } // end of Beogh routine - - } // end "if (monster->type != -1 && mons_ner)" - } // end "for s" -} // end monster_grid() + beogh_follower_convert(monster); + } + } +} void fire_monster_alerts() { @@ -876,11 +893,10 @@ void fire_monster_alerts() monsters_seen_this_turn.clear(); } -bool check_awaken(int mons_aw) +bool check_awaken(monsters* monster) { int mons_perc = 0; - struct monsters *monster = &menv[mons_aw]; - const int mon_holy = mons_holiness(monster); + const mon_holy_type mon_holy = mons_holiness(monster); // Monsters put to sleep by ensorcelled hibernation will sleep // at least one turn. diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index e031388b35..b48cef660b 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -106,7 +106,7 @@ void setLOSRadius(int newLR); /* *********************************************************************** * called from: view monstuff * *********************************************************************** */ -bool check_awaken(int mons_aw); +bool check_awaken(monsters* monster); void clear_map(bool clear_items = true, bool clear_mons = true); |