summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-25 22:36:55 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-25 22:36:55 +0000
commita81f929851dd78e52d4748835ac33e082e945992 (patch)
tree6e10da17c848082f2904b46553f96cb23692052d /crawl-ref/source/fight.cc
parentf07d0af2207210a792aa3681b1c98ccb0b513baa (diff)
downloadcrawl-ref-a81f929851dd78e52d4748835ac33e082e945992.tar.gz
crawl-ref-a81f929851dd78e52d4748835ac33e082e945992.zip
Fix aborting unchivalric attacks costing a turn.
Implement ordering your friends to stay where they are. To do this, I've added a new variable to the monster struct: patrol_point, that is set by the new t sub-command "Wait here!" Once this is set, monsters will spend their time wandering around within the LOS radius centred on the patrol point. If they are attacked, or the player or other friends are attacked, they'll stop wandering to fight, but once the foe is gone, they continue doing so. Currently, the only way to make them stop again is to issue another command, "Follow me!" that is basically the already existing "Come here!" command. I've also added a "Stop fighting!" command that for non-patrolling monsters has the same effect as "Follow me!" - patrolling monsters are supposed to take up their wanderings again. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5247 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc62
1 files changed, 36 insertions, 26 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 9fea017008..8a26e078f8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -357,13 +357,12 @@ melee_attack::melee_attack(actor *attk, actor *defn,
void melee_attack::check_hand_half_bonus_eligible()
{
- hand_half_bonus =
- unarmed_ok
- && !can_do_unarmed
- && !shield
- && weapon
- && !item_cursed( *weapon )
- && hands == HANDS_HALF;
+ hand_half_bonus = (unarmed_ok
+ && !can_do_unarmed
+ && !shield
+ && weapon
+ && !item_cursed( *weapon )
+ && hands == HANDS_HALF);
}
void melee_attack::init_attack()
@@ -396,11 +395,11 @@ void melee_attack::init_attack()
water_attack = is_water_attack(attacker, defender);
attacker_visible = attacker->visible();
- attacker_invisible = !attacker_visible && see_grid(attacker->pos());
- defender_visible = defender && defender->visible();
- defender_invisible = !defender_visible && defender
- && see_grid(defender->pos());
- needs_message = attacker_visible || defender_visible;
+ attacker_invisible = (!attacker_visible && see_grid(attacker->pos()));
+ defender_visible = (defender && defender->visible());
+ defender_invisible = (!defender_visible && defender
+ && see_grid(defender->pos()));
+ needs_message = (attacker_visible || defender_visible);
if (defender && defender->submerged())
unarmed_ok = false;
@@ -607,10 +606,13 @@ bool melee_attack::attack()
if (attacker->atype() == ACT_PLAYER)
{
- if (!stop_attack_prompt(def, false, false))
- set_attack_conducts(def, conduct);
- else
+ if (stop_attack_prompt(def, false, false))
+ {
cancel_attack = true;
+ return (false);
+ }
+ else
+ set_attack_conducts(def, conduct);
}
// Trying to stay general beyond this point is a recipe for insanity.
@@ -782,8 +784,8 @@ bool melee_attack::player_attack()
if (damage_done > 0)
{
- int blood =
- _modify_blood_amount(damage_done, attacker->damage_type());
+ int blood = _modify_blood_amount(damage_done,
+ attacker->damage_type());
if (blood > defender->stat_hp())
blood = defender->stat_hp();
@@ -3080,8 +3082,8 @@ bool melee_attack::mons_attack_mons()
behaviour_event(def, ME_WHACK, monster_index(atk));
}
- // if an enemy attacked a friend, set the pet target if it isn't
- // set already
+ // If an enemy attacked a friend, set the pet target if it isn't
+ // set already.
if (perceived_attack && atk->alive() && mons_friendly(def)
&& !mons_wont_attack(atk) && you.pet_target == MHITNOT)
{
@@ -3837,8 +3839,8 @@ void melee_attack::mons_perform_attack_rounds()
if (defender->atype() == ACT_MONSTER)
type = defender->id();
- int blood
- = _modify_blood_amount(damage_done, attacker->damage_type());
+ int blood = _modify_blood_amount(damage_done,
+ attacker->damage_type());
if (blood > defender->stat_hp())
blood = defender->stat_hp();
@@ -3983,12 +3985,20 @@ bool you_attack(int monster_attacked, bool unarmed_attacks)
wielded_weapon_check(attk.weapon);
bool attack = attk.attack();
- if (attack && (is_sanctuary(you.x_pos, you.y_pos)
- || is_sanctuary(defender->x, defender->y)))
+ if (!attack)
+ {
+ // Attack was cancelled or unsuccessful...
+ if (attk.cancel_attack)
+ you.turn_is_over = false;
+ return (false);
+ }
+
+ if (is_sanctuary(you.x_pos, you.y_pos)
+ || is_sanctuary(defender->x, defender->y))
{
remove_sanctuary(true);
}
- return attack;
+ return (true);
}
// Lose attack energy for attacking with a weapon. The monster has already lost
@@ -4026,7 +4036,7 @@ bool monster_attack(int monster_attacking)
// Friendly and good neutral monsters won't attack unless confused.
if (mons_wont_attack(attacker) && !mons_is_confused(attacker))
- return false;
+ return (false);
// In case the monster hasn't noticed you, bumping into it will
// change that.
@@ -4034,7 +4044,7 @@ bool monster_attack(int monster_attacking)
melee_attack attk(attacker, &you);
attk.attack();
- return true;
+ return (true);
} // end monster_attack()
bool monsters_fight(int monster_attacking, int monster_attacked)