summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-06 04:21:59 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-06 04:21:59 +0000
commitc6f1b8f3258bc3369e3d31ef9d66ae6f6dfcb7a6 (patch)
tree132adc0b87976509867ecfd14f04e05c313fa5bd
parent3905eb1807dab85e62766fd362daf0edb3815cfb (diff)
downloadcrawl-ref-c6f1b8f3258bc3369e3d31ef9d66ae6f6dfcb7a6.tar.gz
crawl-ref-c6f1b8f3258bc3369e3d31ef9d66ae6f6dfcb7a6.zip
Expand mons_itemuse() to work at the individual monster level, as well.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7152 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/debug.cc2
-rw-r--r--crawl-ref/source/mapdef.cc2
-rw-r--r--crawl-ref/source/mon-util.cc88
-rw-r--r--crawl-ref/source/mon-util.h23
-rw-r--r--crawl-ref/source/monplace.cc21
-rw-r--r--crawl-ref/source/monstuff.cc14
-rw-r--r--crawl-ref/source/spells3.cc2
-rw-r--r--crawl-ref/source/spells4.cc2
8 files changed, 78 insertions, 76 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 0af84dd7cf..56042924fc 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -4012,7 +4012,7 @@ void wizard_apply_monster_blessing(monsters* mon)
#ifdef WIZARD
void wizard_give_monster_item(monsters *mon)
{
- mon_itemuse_type item_use = mons_itemuse( mon->type );
+ mon_itemuse_type item_use = mons_itemuse(mon);
if (item_use < MONUSE_STARTING_EQUIPMENT)
{
mpr("That type of monster can't use any items.");
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 4f75be52a8..651f475253 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -2004,7 +2004,7 @@ mons_list::mons_spec_slot mons_list::parse_mons_spec(std::string spec)
error = "Can't give spec items to a random monster.";
return (slot);
}
- else if (mons_itemuse(mid) < MONUSE_STARTING_EQUIPMENT)
+ else if (mons_class_itemuse(mid) < MONUSE_STARTING_EQUIPMENT)
{
error = make_stringf("Monster '%s' can't use items.",
mon_str.c_str());
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index f1bcce35e0..0eaa79646a 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -328,12 +328,12 @@ bool mons_class_flag(int mc, int bf)
return ((me->bitfields & bf) != 0);
}
-static int _scan_mon_inv_randarts( const monsters *mon,
+static int _scan_mon_inv_randarts(const monsters *mon,
randart_prop_type ra_prop)
{
int ret = 0;
- if (mons_itemuse( mon->type ) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
const int weapon = mon->inv[MSLOT_WEAPON];
const int second = mon->inv[MSLOT_MISSILE]; // Two-headed ogres, etc.
@@ -760,15 +760,20 @@ unsigned mons_char(int mc)
return monster_symbols[mc].glyph;
}
-int mons_class_colour(int mc)
+mon_itemuse_type mons_class_itemuse(int mc)
{
- return monster_symbols[mc].colour;
+ ASSERT(smc);
+ return (smc->gmon_use);
}
-mon_itemuse_type mons_itemuse(int mc)
+mon_itemuse_type mons_itemuse(const monsters *mon)
{
- ASSERT(smc);
- return (smc->gmon_use);
+ return (mons_class_itemuse(mon->type));
+}
+
+int mons_class_colour(int mc)
+{
+ return (monster_symbols[mc].colour);
}
int mons_colour(const monsters *mon)
@@ -976,19 +981,17 @@ bool check_mons_resist_magic( const monsters *monster, int pow )
return (mrch2 < mrchance);
}
-int mons_res_elec( const monsters *mon )
+int mons_res_elec(const monsters *mon)
{
- int mc = mon->type;
-
// This is a variable, not a player_xx() function, so can be above 1.
int u = 0;
u += get_mons_resists(mon).elec;
// Don't bother checking equipment if the monster can't use it.
- if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
- u += _scan_mon_inv_randarts( mon, RAP_ELECTRICITY );
+ u += _scan_mon_inv_randarts(mon, RAP_ELECTRICITY);
// No ego armour, but storm dragon.
const int armour = mon->inv[MSLOT_ARMOUR];
@@ -1014,18 +1017,16 @@ bool mons_res_asphyx(const monsters *mon)
|| get_mons_resists(mon).asphyx > 0);
}
-int mons_res_acid( const monsters *mon )
+int mons_res_acid(const monsters *mon)
{
return get_mons_resists(mon).acid;
}
-int mons_res_poison( const monsters *mon )
+int mons_res_poison(const monsters *mon)
{
- int mc = mon->type;
-
int u = get_mons_resists(mon).poison;
- if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
u += _scan_mon_inv_randarts( mon, RAP_POISON );
@@ -1043,14 +1044,14 @@ int mons_res_poison( const monsters *mon )
}
// ego armour resistance
- if (get_armour_ego_type( mitm[armour] ) == SPARM_POISON_RESISTANCE)
+ if (get_armour_ego_type(mitm[armour]) == SPARM_POISON_RESISTANCE)
u += 1;
}
if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
{
// ego armour resistance
- if (get_armour_ego_type( mitm[shield] ) == SPARM_POISON_RESISTANCE)
+ if (get_armour_ego_type(mitm[shield]) == SPARM_POISON_RESISTANCE)
u += 1;
}
}
@@ -1060,13 +1061,13 @@ int mons_res_poison( const monsters *mon )
return (u);
}
-bool mons_res_sticky_flame( const monsters *mon )
+bool mons_res_sticky_flame(const monsters *mon)
{
return (get_mons_resists(mon).sticky_flame
|| mon->has_equipped(EQ_BODY_ARMOUR, ARM_MOTTLED_DRAGON_ARMOUR));
}
-int mons_res_steam( const monsters *mon )
+int mons_res_steam(const monsters *mon)
{
int res = get_mons_resists(mon).steam;
if (mon->has_equipped(EQ_BODY_ARMOUR, ARM_STEAM_DRAGON_ARMOUR))
@@ -1074,17 +1075,15 @@ int mons_res_steam( const monsters *mon )
return (res + mons_res_fire(mon) / 2);
}
-int mons_res_fire( const monsters *mon )
+int mons_res_fire(const monsters *mon)
{
- int mc = mon->type;
-
const mon_resist_def res = get_mons_resists(mon);
int u = std::min(res.fire + res.hellfire * 3, 3);
- if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
- u += _scan_mon_inv_randarts( mon, RAP_FIRE );
+ u += _scan_mon_inv_randarts(mon, RAP_FIRE);
const int armour = mon->inv[MSLOT_ARMOUR];
const int shield = mon->inv[MSLOT_SHIELD];
@@ -1101,7 +1100,7 @@ int mons_res_fire( const monsters *mon )
}
// check ego resistance
- const int ego = get_armour_ego_type( mitm[armour] );
+ const int ego = get_armour_ego_type(mitm[armour]);
if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
u += 1;
}
@@ -1109,7 +1108,7 @@ int mons_res_fire( const monsters *mon )
if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
{
// check ego resistance
- const int ego = get_armour_ego_type( mitm[shield] );
+ const int ego = get_armour_ego_type(mitm[shield]);
if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
u += 1;
}
@@ -1123,15 +1122,13 @@ int mons_res_fire( const monsters *mon )
return (u);
}
-int mons_res_cold( const monsters *mon )
+int mons_res_cold(const monsters *mon)
{
- int mc = mon->type;
-
int u = get_mons_resists(mon).cold;
- if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
- u += _scan_mon_inv_randarts( mon, RAP_COLD );
+ u += _scan_mon_inv_randarts(mon, RAP_COLD);
const int armour = mon->inv[MSLOT_ARMOUR];
const int shield = mon->inv[MSLOT_SHIELD];
@@ -1148,7 +1145,7 @@ int mons_res_cold( const monsters *mon )
}
// check ego resistance
- const int ego = get_armour_ego_type( mitm[armour] );
+ const int ego = get_armour_ego_type(mitm[armour]);
if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
u += 1;
}
@@ -1156,7 +1153,7 @@ int mons_res_cold( const monsters *mon )
if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
{
// check ego resistance
- const int ego = get_armour_ego_type( mitm[shield] );
+ const int ego = get_armour_ego_type(mitm[shield]);
if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
u += 1;
}
@@ -1170,15 +1167,14 @@ int mons_res_cold( const monsters *mon )
return (u);
}
-int mons_res_miasma( const monsters *mon )
+int mons_res_miasma(const monsters *mon)
{
return (mons_holiness(mon) != MH_NATURAL
|| mon->type == MONS_DEATH_DRAKE ? 3 : 0);
}
-int mons_res_negative_energy( const monsters *mon )
+int mons_res_negative_energy(const monsters *mon)
{
- int mc = mon->type;
const mon_holy_type holiness = mons_holiness(mon);
if (mons_is_unholy(mon)
@@ -1194,9 +1190,9 @@ int mons_res_negative_energy( const monsters *mon )
int u = 0;
- if (mons_itemuse(mc) >= MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
{
- u += _scan_mon_inv_randarts( mon, RAP_NEGATIVE_ENERGY );
+ u += _scan_mon_inv_randarts(mon, RAP_NEGATIVE_ENERGY);
const int armour = mon->inv[MSLOT_ARMOUR];
const int shield = mon->inv[MSLOT_SHIELD];
@@ -1204,14 +1200,14 @@ int mons_res_negative_energy( const monsters *mon )
if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
{
// check for ego resistance
- if (get_armour_ego_type( mitm[armour] ) == SPARM_POSITIVE_ENERGY)
+ if (get_armour_ego_type(mitm[armour]) == SPARM_POSITIVE_ENERGY)
u += 1;
}
if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
{
// check for ego resistance
- if (get_armour_ego_type( mitm[shield] ) == SPARM_POSITIVE_ENERGY)
+ if (get_armour_ego_type(mitm[shield]) == SPARM_POSITIVE_ENERGY)
u += 1;
}
}
@@ -1220,7 +1216,7 @@ int mons_res_negative_energy( const monsters *mon )
u = 3;
return (u);
-} // end mons_res_negative_energy()
+}
bool mons_is_holy(const monsters *mon)
{
@@ -1364,10 +1360,10 @@ int exper_value( const struct monsters *monster )
// These are some values we care about.
const int speed = mons_speed(mclass);
const int modifier = _mons_exp_mod(mclass);
- const int item_usage = mons_itemuse(mclass);
+ const int item_usage = mons_itemuse(monster);
// XXX: Shapeshifters can qualify here, even though they can't cast.
- const bool spellcaster = mons_class_flag( mclass, M_SPELLCASTER );
+ const bool spellcaster = mons_class_flag(mclass, M_SPELLCASTER);
// Early out for no XP monsters.
if (mons_class_flag(mclass, M_NO_EXP_GAIN))
@@ -6033,7 +6029,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
}
// Handled in handle_pickup.
- if (mons_itemuse(type) == MONUSE_EATS_ITEMS)
+ if (mons_itemuse(this) == MONUSE_EATS_ITEMS)
break;
// The enchantment doubles as the durability of a net
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index f6ae1c1103..2232cf4b55 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -453,7 +453,8 @@ bool mons_wall_shielded(const monsters *mon);
/* ***********************************************************************
* called from: dungeon - monstuff
* *********************************************************************** */
-mon_itemuse_type mons_itemuse(int mc);
+mon_itemuse_type mons_class_itemuse(int mc);
+mon_itemuse_type mons_itemuse(const monsters *mon);
// last updated 12may2000 {dlb}
@@ -559,16 +560,16 @@ habitat_type mons_secondary_habitat(const monsters *mon);
bool intelligent_ally(const monsters *mon);
-bool mons_res_sticky_flame( const monsters *mon );
-int mons_res_cold( const monsters *mon );
-int mons_res_elec( const monsters *mon );
-int mons_res_fire( const monsters *mon );
-int mons_res_steam( const monsters *mon );
-int mons_res_poison( const monsters *mon );
-int mons_res_acid( const monsters *mon );
-int mons_res_negative_energy( const monsters *mon );
-int mons_res_miasma( const monsters *mon );
-bool mons_res_asphyx( const monsters *mon );
+bool mons_res_sticky_flame(const monsters *mon);
+int mons_res_cold(const monsters *mon);
+int mons_res_elec(const monsters *mon);
+int mons_res_fire(const monsters *mon);
+int mons_res_steam(const monsters *mon);
+int mons_res_poison(const monsters *mon);
+int mons_res_acid(const monsters *mon);
+int mons_res_negative_energy(const monsters *mon);
+int mons_res_miasma(const monsters *mon);
+bool mons_res_asphyx(const monsters *mon);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 8c37ee2931..00bd5c8613 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -899,17 +899,17 @@ static int _place_monster_aux( const mgen_data &mg,
if (mg.cls == MONS_DANCING_WEAPON && mg.number != 1) // ie not from spell
{
- give_item( id, mg.power );
+ give_item(id, mg.power);
if (menv[id].inv[MSLOT_WEAPON] != NON_ITEM)
- menv[id].colour = mitm[ menv[id].inv[MSLOT_WEAPON] ].colour;
+ menv[id].colour = mitm[menv[id].inv[MSLOT_WEAPON]].colour;
}
- else if (mons_itemuse(mg.cls) >= MONUSE_STARTING_EQUIPMENT)
+ else if (mons_class_itemuse(mg.cls) >= MONUSE_STARTING_EQUIPMENT)
{
- give_item( id, mg.power );
+ give_item(id, mg.power);
// Give these monsters a second weapon -- bwr
if (mons_wields_two_weapons(mg.cls))
- give_item( id, mg.power );
+ give_item(id, mg.power);
unwind_var<int> save_speedinc(menv[id].speed_increment);
menv[id].wield_melee_weapon(false);
@@ -2656,10 +2656,15 @@ bool monster_pathfind::traversable(coord_def p)
return (false);
// Monsters that can't open doors won't be able to pass them.
- if ((grd(p) == DNGN_CLOSED_DOOR || grd(p) == DNGN_SECRET_DOOR)
- && mons_itemuse(montype) < MONUSE_OPEN_DOORS)
+ if (grd(p) == DNGN_CLOSED_DOOR || grd(p) == DNGN_SECRET_DOOR)
{
- return (false);
+ if (mons_is_zombified(mons))
+ {
+ if (mons_class_itemuse(montype) < MONUSE_OPEN_DOORS)
+ return (false);
+ }
+ else if (mons_itemuse(mons) < MONUSE_OPEN_DOORS)
+ return (false);
}
// Your friends only know about doors you know about, unless they feel
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 78a0c00866..090b7c4528 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -5294,7 +5294,7 @@ static bool _handle_throw(monsters *monster, bolt & beem)
}
// Zombies are always too stupid to do this.
- if (mons_itemuse(monster->type) < MONUSE_OPEN_DOORS)
+ if (mons_itemuse(monster) < MONUSE_OPEN_DOORS)
return (false);
const bool archer = mons_class_flag(monster->type, M_ARCHER);
@@ -5717,8 +5717,8 @@ static void _handle_monster_move(int i, monsters *monster)
}
if (igrd(monster->pos()) != NON_ITEM
- && (mons_itemuse(monster->type) == MONUSE_WEAPONS_ARMOUR
- || mons_itemuse(monster->type) == MONUSE_EATS_ITEMS))
+ && (mons_itemuse(monster) == MONUSE_WEAPONS_ARMOUR
+ || mons_itemuse(monster) == MONUSE_EATS_ITEMS))
{
// Keep neutral and charmed monsters from picking up stuff.
// Same for friendlies if friendly_pickup is set to "none".
@@ -6105,7 +6105,7 @@ static bool _handle_pickup(monsters *monster)
return (false);
}
- if (mons_itemuse(monster->type) == MONUSE_EATS_ITEMS)
+ if (mons_itemuse(monster) == MONUSE_EATS_ITEMS)
{
// Friendly jellies won't eat.
if (monster->attitude != ATT_HOSTILE)
@@ -6952,13 +6952,13 @@ static bool _monster_move(monsters *monster)
if (mons_is_zombified(monster))
{
// For zombies, monster type is kept in mon->base_monster.
- if (mons_itemuse(monster->base_monster) >= MONUSE_OPEN_DOORS)
+ if (mons_class_itemuse(monster->base_monster) >= MONUSE_OPEN_DOORS)
{
_mons_open_door(monster, newpos);
return (true);
}
}
- else if (mons_itemuse(monster->type) >= MONUSE_OPEN_DOORS)
+ else if (mons_itemuse(monster) >= MONUSE_OPEN_DOORS)
{
_mons_open_door(monster, newpos);
return (true);
@@ -6967,7 +6967,7 @@ static bool _monster_move(monsters *monster)
// Jellies eat doors. Yum!
if ((grd(newpos) == DNGN_CLOSED_DOOR || grd(newpos) == DNGN_OPEN_DOOR)
- && mons_itemuse(monster->type) == MONUSE_EATS_ITEMS)
+ && mons_itemuse(monster) == MONUSE_EATS_ITEMS)
{
grd(newpos) = DNGN_FLOOR;
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 5535607f41..ac9505d13d 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -656,7 +656,7 @@ static void _equip_undead(const coord_def &a, int corps, int monster,
monster_type type = static_cast<monster_type>(monnum);
- if (mons_itemuse(monnum) < MONUSE_STARTING_EQUIPMENT)
+ if (mons_itemuse(mon) < MONUSE_STARTING_EQUIPMENT)
return;
// If the player picked up and dropped the corpse then all its
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 24e3f8edf5..d347b6cc8b 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -1845,7 +1845,7 @@ bool cast_fragmentation(int pow, const dist& spd)
explode = true;
beam.ex_size = petrifying ? 1 : 2;
beam.name = "blast of petrified fragments";
- beam.colour = mon->colour;
+ beam.colour = mons_class_colour(mon->type);
beam.damage.num = petrifying ? 2 : 3;
if (player_hurt_monster(midx, beam.damage.roll()))
beam.damage.num++;