From 56f8c2bfbc13fa45a7b0b7f3210e16e61227143f Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 10 Jan 2009 12:51:04 +0000 Subject: Code cleanups again, fix Twist. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8379 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 57 +++++++++++----------- crawl-ref/source/spells3.h | 111 +++---------------------------------------- crawl-ref/source/spells4.cc | 11 ++++- crawl-ref/source/spl-cast.cc | 3 +- 4 files changed, 48 insertions(+), 134 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 4af107569f..93cee741c4 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -184,43 +184,44 @@ bool detect_curse(bool suppress_msg) return (success); } -int cast_smiting(int power, dist &beam) +bool cast_smiting(int power, const coord_def& where) { - bool success = false; - - if (mgrd(beam.target) == NON_MONSTER || beam.isMe) - canned_msg(MSG_SPELL_FIZZLES); - else + if (invalid_monster_index(mgrd(where))) { - monsters *monster = &menv[mgrd(beam.target)]; + mpr("There's nothing there!"); + // Counts as a real cast, due to victory-dancing and + // invisible/submerged monsters. + return (true); + } - god_conduct_trigger conducts[3]; - disable_attack_conducts(conducts); + monsters& m = menv[mgrd(where)]; - success = !stop_attack_prompt(monster, false, false); + god_conduct_trigger conducts[3]; + disable_attack_conducts(conducts); - if (success) - { - set_attack_conducts(conducts, monster); + const bool success = !stop_attack_prompt(&m, false, false); - mprf("You smite %s!", monster->name(DESC_NOCAP_THE).c_str()); + if (success) + { + set_attack_conducts(conducts, &m); - behaviour_event(monster, ME_ANNOY, MHITYOU); - if (mons_is_mimic(monster->type)) - mimic_alert(monster); - } + mprf("You smite %s!", m.name(DESC_NOCAP_THE).c_str()); - enable_attack_conducts(conducts); + behaviour_event(&m, ME_ANNOY, MHITYOU); + if (mons_is_mimic(m.type)) + mimic_alert(&m); + } - 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). - monster->hurt(&you, 7 + (random2(power) * 33 / 191)); - if (monster->alive()) - print_wounds(monster); - } + enable_attack_conducts(conducts); + + 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). + m.hurt(&you, 7 + (random2(power) * 33 / 191)); + if (m.alive()) + print_wounds(&m); } return (success); diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h index 0b0ec2bb02..c4e33d720d 100644 --- a/crawl-ref/source/spells3.h +++ b/crawl-ref/source/spells3.h @@ -15,98 +15,24 @@ struct dist; struct bolt; -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spells1 - spells3 - * *********************************************************************** */ bool allow_control_teleport(bool quiet = false); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ int airstrike(int power, dist &beam); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ bool cast_bone_shards(int power, bolt &); - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ -void cast_poison_ammo(void); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - spell - * *********************************************************************** */ +void cast_poison_ammo(); bool cast_selective_amnesia(bool force); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - spell - * *********************************************************************** */ -int cast_smiting(int power, dist &); +bool cast_smiting(int power, const coord_def& where); bool remove_sanctuary(bool did_attack = false); -void decrease_sanctuary_radius(void); +void decrease_sanctuary_radius(); bool cast_sanctuary(const int power); -int halo_radius(void); +int halo_radius(); bool inside_halo(const coord_def& where); - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ -bool project_noise(void); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: item_use - spell - * *********************************************************************** */ +bool project_noise(); bool detect_curse(bool suppress_msg); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: decks - spell - * *********************************************************************** */ bool entomb(int powc); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ -int portal(void); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - spell - * *********************************************************************** */ +int portal(); bool recall(char type_recalled); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: item_use - spell - * *********************************************************************** */ bool remove_curse(bool suppress_msg); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ bool cast_sublimation_of_blood(int pow); bool cast_call_imp(int pow, god_type god = GOD_NO_GOD); @@ -124,44 +50,21 @@ bool cast_summon_greater_demon(int pow, god_type god = GOD_NO_GOD); bool cast_shadow_creatures(god_type god = GOD_NO_GOD); bool cast_summon_horrible_things(int pow, god_type god = GOD_NO_GOD); -// last updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - spell - * *********************************************************************** */ void equip_undead(const coord_def &a, int corps, int monster, int monnum); bool animate_remains(const coord_def &a, corpse_type class_allowed, beh_type beha, unsigned short hitting, god_type god = GOD_NO_GOD, bool actual = true, bool quiet = false, int* mon_index = NULL); -// last updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - it_use3 - monstuff - mstuff2 - spell - * *********************************************************************** */ int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, god_type god = GOD_NO_GOD, bool actual = true); -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ bool cast_simulacrum(int pow, god_type god = GOD_NO_GOD); bool cast_twisted_resurrection(int pow, god_type god = GOD_NO_GOD); bool cast_summon_wraiths(int pow, god_type god = GOD_NO_GOD); bool cast_death_channel(int pow, god_type god = GOD_NO_GOD); - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - beam - decks - fight - item_use - spell - * *********************************************************************** */ -void you_teleport(void); - - -// updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - acr - decks - effects - fight - misc - spells - * *********************************************************************** */ +void you_teleport(); void you_teleport_now( bool allow_control, bool new_abyss_area = false ); diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 9c57589680..2fe715a0f1 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -2034,11 +2034,17 @@ bool cast_twist(int pow, const coord_def& where) if (invalid_monster_index(mgrd(where))) { mpr("There is no monster there!"); - return (false); + // This counts as a real cast, in order not to leak invisible + // monster locations, and to allow victory-dancing. + return (true); } monsters& m = menv[mgrd(where)]; + // Identify mimics, if necessary. + if (mons_is_mimic(m.type)) + m.flags |= MF_KNOWN_MIMIC; + // Monster can magically save vs attack. if (check_mons_resist_magic(&m, pow * 2)) { @@ -2055,6 +2061,9 @@ bool cast_twist(int pow, const coord_def& where) // Inflict the damage. _player_hurt_monster(m, damage); + if (mons_is_mimic(m.type)) + mimic_alert(&m); + return (true); } diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index dbd3d381cc..2ab2ad34e1 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1444,7 +1444,8 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) // LOS spells case SPELL_SMITING: - cast_smiting(powc, spd); + if (!cast_smiting(powc, beam.target)) + return (SPRET_ABORT); break; case SPELL_TWIST: -- cgit v1.2.3-54-g00ecf