summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/fight.cc24
-rw-r--r--crawl-ref/source/fight.h5
-rw-r--r--crawl-ref/source/it_use3.cc8
-rw-r--r--crawl-ref/source/mon-util.h4
-rw-r--r--crawl-ref/source/monstuff.cc6
5 files changed, 29 insertions, 18 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 40de539dd2..08b2c65d9f 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -581,13 +581,17 @@ bool melee_attack::attack()
if (!mons_near(def))
simple_monster_message(atk, " hits something");
else if (!you.can_see(atk))
+ {
mprf("%s hits the %s.", def->name(DESC_CAP_THE).c_str(),
feat_name.c_str());
+ }
else
+ {
mprf("%s tries to hit the %s, but is blocked by the %s.",
atk->name(DESC_CAP_THE).c_str(),
def->name(DESC_NOCAP_THE).c_str(),
feat_name.c_str());
+ }
}
return (true);
}
@@ -3757,7 +3761,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
void melee_attack::mons_perform_attack_rounds()
{
- const int nrounds = atk->has_hydra_multi_attack()? atk->number : 4;
+ const int nrounds = atk->has_hydra_multi_attack()? atk->number : 4;
const coord_def pos = defender->pos();
// Melee combat, tell attacker to wield its melee weapon.
@@ -3784,6 +3788,9 @@ void melee_attack::mons_perform_attack_rounds()
break;
}
+ if (attk.type != AT_HIT && !unarmed_ok)
+ continue;
+
if (attk.type == AT_SHOOT)
continue;
@@ -4045,7 +4052,8 @@ static void mons_lose_attack_energy(monsters *attacker, int wpn_speed,
}
}
-bool monster_attack(int monster_attacking)
+// A monster attacking the player.
+bool monster_attack(int monster_attacking, bool allow_unarmed)
{
monsters *attacker = &menv[monster_attacking];
@@ -4056,20 +4064,22 @@ bool monster_attack(int monster_attacking)
// In case the monster hasn't noticed you, bumping into it will
// change that.
behaviour_event( attacker, ME_ALERT, MHITYOU );
- melee_attack attk(attacker, &you);
+ melee_attack attk(attacker, &you, allow_unarmed);
attk.attack();
return (true);
-} // end monster_attack()
+}
-bool monsters_fight(int monster_attacking, int monster_attacked)
+// Two monsters fighting each other.
+bool monsters_fight(int monster_attacking, int monster_attacked,
+ bool allow_unarmed)
{
monsters *attacker = &menv[monster_attacking];
monsters *defender = &menv[monster_attacked];
- melee_attack attk(attacker, defender);
+ melee_attack attk(attacker, defender, allow_unarmed);
return attk.attack();
-} // end monsters_fight()
+}
/*
diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h
index 02d01c618c..7ad6255645 100644
--- a/crawl-ref/source/fight.h
+++ b/crawl-ref/source/fight.h
@@ -69,14 +69,15 @@ bool you_attack(int monster_attacked, bool unarmed_attacks);
/* ***********************************************************************
* called from: monstuff
* *********************************************************************** */
-bool monster_attack(int monster_attacking);
+bool monster_attack(int monster_attacking, bool allow_unarmed = true);
// last updated: 08jun2000 {dlb}
/* ***********************************************************************
* called from: monstuff
* *********************************************************************** */
-bool monsters_fight(int monster_attacking, int monster_attacked);
+bool monsters_fight(int monster_attacking, int monster_attacked,
+ bool allow_unarmed = true);
int calc_your_to_hit( bool random_factor );
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 28598708e0..367ef11f85 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -251,7 +251,7 @@ void special_wielded()
return;
} // end special_wielded()
-static bool reaching_weapon_attack(const item_def& wpn)
+static bool _reaching_weapon_attack(const item_def& wpn)
{
dist beam;
@@ -340,7 +340,7 @@ static bool reaching_weapon_attack(const item_def& wpn)
you_attack(mgrd[beam.tx][beam.ty], false);
return (true);
-} // end reaching_weapon_attack()
+}
static bool evoke_horn_of_geryon()
{
@@ -460,13 +460,13 @@ bool evoke_wielded()
case OBJ_WEAPONS:
if (get_weapon_brand(wpn) == SPWPN_REACHING)
{
- if ( reaching_weapon_attack(wpn) )
+ if (_reaching_weapon_attack(wpn))
{
pract = 0;
did_work = true;
}
else
- return false;
+ return (false);
}
else if (is_fixed_artefact( wpn ))
{
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index 47acf9a3c6..e20fa68c02 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -41,7 +41,7 @@ enum gender_type
enum mon_attack_type
{
AT_NONE,
- AT_HIT, // including weapon attacks
+ AT_HIT, // Including weapon attacks.
AT_BITE,
AT_STING,
AT_SPORE,
@@ -51,7 +51,7 @@ enum mon_attack_type
AT_TAIL_SLAP,
AT_BUTT,
- AT_SHOOT // attack representing missile damage for M_ARCHER
+ AT_SHOOT // Attack representing missile damage for M_ARCHER.
};
enum mon_attack_flavour
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 9bb733e6f3..f900bd7b5c 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2086,7 +2086,7 @@ void behaviour_event( monsters *mon, int event, int src,
break;
case ME_ALERT:
- if (mon->is_patrolling())
+ if (mons_friendly(mon) && mon->is_patrolling())
break;
// Will alert monster to <src> and turn them
@@ -3864,7 +3864,7 @@ static bool _handle_reaching(monsters *monster)
if (dx == 2 && dy <= 2 || dy == 2 && dx <= 2)
{
ret = true;
- monster_attack( monster_index(monster) );
+ monster_attack( monster_index(monster), false );
}
}
}
@@ -3882,7 +3882,7 @@ static bool _handle_reaching(monsters *monster)
if (dx == 2 && dy <= 2 || dy == 2 && dx <= 2)
{
ret = true;
- monsters_fight( monster_index(monster), monster->foe );
+ monsters_fight(monster_index(monster), monster->foe, false);
}
}
}