From 63e4083df060b3cdd0ce18d04949dd7831cc10d4 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sun, 25 May 2008 17:33:38 +0000 Subject: Consolidate the attack warning prompts for both melee and beams, and use the prompts properly with Burn/Freeze, Smite, and Airstrike. Also, move the now-single function for this into misc.cc, since I can't think of a better location right now. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5235 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 97 ++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 58 deletions(-) (limited to 'crawl-ref/source/spells3.cc') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index aa9063d5e7..dd11b43503 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -31,7 +31,6 @@ #include "debug.h" #include "delay.h" #include "effects.h" // holy word -#include "fight.h" #include "food.h" #include "itemname.h" #include "itemprop.h" @@ -200,45 +199,38 @@ int cast_smiting(int power, dist &beam) { bool success = false; - if (mgrd[beam.tx][beam.ty] == NON_MONSTER - || beam.isMe) - { + if (mgrd[beam.tx][beam.ty] == NON_MONSTER || beam.isMe) canned_msg(MSG_SPELL_FIZZLES); - } else { monsters *monster = &menv[mgrd[beam.tx][beam.ty]]; - mprf("You smite %s!", monster->name(DESC_NOCAP_THE).c_str()); - god_conduct_trigger conduct; conduct.enabled = false; - if (mons_friendly(monster)) - conduct.set(DID_ATTACK_FRIEND, 5, true, monster); - else if (mons_neutral(monster)) - conduct.set(DID_ATTACK_NEUTRAL, 5, true, monster); + success = !stop_attack_prompt(monster, false, false, &conduct); - if (is_unchivalric_attack(&you, monster, monster)) - conduct.set(DID_UNCHIVALRIC_ATTACK, 4, true, monster); - - if (mons_is_holy(monster)) - conduct.set(DID_ATTACK_HOLY, monster->hit_dice, true, monster); + if (success) + { + mprf("You smite %s!", monster->name(DESC_NOCAP_THE).c_str()); - behaviour_event(monster, ME_ANNOY, MHITYOU); + behaviour_event(monster, ME_ANNOY, MHITYOU); + } conduct.enabled = true; - // Maxes out at around 40 damage at 27 Invocations, which is plenty - // in my book (the old max damage was around 70, which seems excessive) - hurt_monster(monster, 7 + (random2(power) * 33 / 191)); - - if (monster->hit_points < 1) - monster_die(monster, KILL_YOU, 0); - else - print_wounds(monster); + if (success) + { + // Maxes out at around 40 damage at 27 Invocations, which is + // plenty in my book (the old max damage was around 70, + // which seems excessive). + hurt_monster(monster, 7 + (random2(power) * 33 / 191)); - success = true; + if (monster->hit_points < 1) + monster_die(monster, KILL_YOU, 0); + else + print_wounds(monster); + } } return (success); @@ -248,51 +240,42 @@ int airstrike(int power, dist &beam) { bool success = false; - if (mgrd[beam.tx][beam.ty] == NON_MONSTER - || beam.isMe) - { + if (mgrd[beam.tx][beam.ty] == NON_MONSTER || beam.isMe) canned_msg(MSG_SPELL_FIZZLES); - } else { monsters *monster = &menv[mgrd[beam.tx][beam.ty]]; - mprf("The air twists around and strikes %s!", - monster->name(DESC_NOCAP_THE).c_str()); + god_conduct_trigger conduct; + conduct.enabled = false; - int hurted = 8 + random2( random2(4) + (random2(power) / 6) - + (random2(power) / 7) ); + success = !stop_attack_prompt(monster, false, false, &conduct); - if ( mons_flies(monster) ) + if (success) { - hurted *= 3; - hurted /= 2; - } + mprf("The air twists around and strikes %s!", + monster->name(DESC_NOCAP_THE).c_str()); - hurted -= random2(1 + monster->ac); + behaviour_event(monster, ME_ANNOY, MHITYOU); + } - if (hurted < 0) - hurted = 0; + conduct.enabled = true; - if (hurted) + if (success) { - god_conduct_trigger conduct; - conduct.enabled = false; - - if (mons_friendly(monster)) - conduct.set(DID_ATTACK_FRIEND, 5, true, monster); - else if (mons_neutral(monster)) - conduct.set(DID_ATTACK_NEUTRAL, 5, true, monster); + int hurted = 8 + random2(random2(4) + (random2(power) / 6) + + (random2(power) / 7)); - if (is_unchivalric_attack(&you, monster, monster)) - conduct.set(DID_UNCHIVALRIC_ATTACK, 5, true, monster); - - if (mons_is_holy(monster)) - conduct.set(DID_ATTACK_HOLY, monster->hit_dice, true, monster); + if (mons_flies(monster)) + { + hurted *= 3; + hurted /= 2; + } - behaviour_event(monster, ME_ANNOY, MHITYOU); + hurted -= random2(1 + monster->ac); - conduct.enabled = true; + if (hurted < 0) + hurted = 0; hurt_monster(monster, hurted); @@ -301,8 +284,6 @@ int airstrike(int power, dist &beam) else print_wounds(monster); } - - success = true; } return (success); -- cgit v1.2.3-54-g00ecf