From 443761e4649390291d5e06bb9dba2540ac5e9fd9 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 27 Mar 2016 15:46:59 +0200 Subject: Fix occasional overflow when monster speaks --- src/melee2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index b3aa5c61..5a643132 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -6330,7 +6330,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (player_has_los_bold(oy, ox) && (r_ptr->flags2 & RF2_CAN_SPEAK)) { char m_name[80]; - char monmessage[80]; + char monmessage[1024]; /* Acquire the monster name/poss */ if (m_ptr->ml) -- cgit v1.2.3 From 899041ce6b7cbc33e8cb3124aaa54b518c4a4b72 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 29 Mar 2016 20:32:55 +0200 Subject: Convert dungeon_info_type to use new flag_set --- src/melee2.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 5a643132..e4f0802a 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -16,6 +16,7 @@ #include "cave.hpp" #include "cave_type.hpp" #include "cmd1.hpp" +#include "dungeon_flag.hpp" #include "feature_type.hpp" #include "files.hpp" #include "hook_mon_speak_in.hpp" @@ -2259,7 +2260,7 @@ static bool_ monst_spell_monst(int m_idx) /* RF6_TPORT */ case 160 + 5: { - if (dungeon_flags2 & DF2_NO_TELEPORT) break; /* No teleport on special levels */ + if (dungeon_flags & DF_NO_TELEPORT) break; /* No teleport on special levels */ else { if (disturb_other) disturb(1); @@ -2279,7 +2280,7 @@ static bool_ monst_spell_monst(int m_idx) /* RF6_TELE_AWAY */ case 160 + 7: { - if (dungeon_flags2 & DF2_NO_TELEPORT) break; + if (dungeon_flags & DF_NO_TELEPORT) break; if (!direct) break; else -- cgit v1.2.3 From 7137a17f77fd3b6c3bbcefa2d621b3a11f161679 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Remove monster memory Instead of having monster memory, the player automatically knows everything about all monsters from the start. --- src/melee2.cc | 268 ---------------------------------------------------------- 1 file changed, 268 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index e4f0802a..080208f1 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -1712,12 +1712,6 @@ static bool_ monst_spell_monst(int m_idx) (tr_ptr->flags3 & (RF3_NO_CONF)) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { - /* Memorize a flag */ - if (tr_ptr->flags3 & (RF3_NO_CONF)) - { - if (seen) tr_ptr->r_flags3 |= (RF3_NO_CONF); - } - /* No obvious effect */ if (see_t) { @@ -1756,11 +1750,6 @@ static bool_ monst_spell_monst(int m_idx) (tr_ptr->flags3 & (RF3_NO_CONF)) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { - /* Memorize a flag */ - if (tr_ptr->flags3 & (RF3_NO_CONF)) - { - if (seen) tr_ptr->r_flags3 |= (RF3_NO_CONF); - } /* No obvious effect */ if (see_t) { @@ -2296,7 +2285,6 @@ static bool_ monst_spell_monst(int m_idx) { if (see_t) { - tr_ptr->r_flags3 |= RF3_RES_TELE; monster_msg("%^s is unaffected!", t_name); } resists_tele = TRUE; @@ -2305,7 +2293,6 @@ static bool_ monst_spell_monst(int m_idx) { if (see_t) { - tr_ptr->r_flags3 |= RF3_RES_TELE; monster_msg("%^s resists!", t_name); } resists_tele = TRUE; @@ -2713,39 +2700,6 @@ static bool_ monst_spell_monst(int m_idx) t_ptr->csleep = 0; } - - /* Remember what the monster did, if we saw it */ - if (seen) - { - /* Inate spell */ - if (thrown_spell < 32*4) - { - r_ptr->r_flags4 |= (1L << (thrown_spell - 32 * 3)); - if (r_ptr->r_cast_inate < MAX_UCHAR) r_ptr->r_cast_inate++; - } - - /* Bolt or Ball */ - else if (thrown_spell < 32*5) - { - r_ptr->r_flags5 |= (1L << (thrown_spell - 32 * 4)); - if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++; - } - - /* Special spell */ - else if (thrown_spell < 32*6) - { - r_ptr->r_flags6 |= (1L << (thrown_spell - 32 * 5)); - if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++; - } - } - - /* Always take note of monsters that kill you --- - * even accidentally */ - if (death && (r_ptr->r_deaths < MAX_SHORT)) - { - r_ptr->r_deaths++; - } - /* A spell was cast */ return (TRUE); } @@ -4554,38 +4508,6 @@ static bool_ make_attack_spell(int m_idx) } } - /* Remember what the monster did to us */ - if (seen) - { - /* Inate spell */ - if (thrown_spell < 32*4) - { - r_ptr->r_flags4 |= (1L << (thrown_spell - 32 * 3)); - if (r_ptr->r_cast_inate < MAX_UCHAR) r_ptr->r_cast_inate++; - } - - /* Bolt or Ball */ - else if (thrown_spell < 32*5) - { - r_ptr->r_flags5 |= (1L << (thrown_spell - 32 * 4)); - if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++; - } - - /* Special spell */ - else if (thrown_spell < 32*6) - { - r_ptr->r_flags6 |= (1L << (thrown_spell - 32 * 5)); - if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++; - } - } - - - /* Always take note of monsters that kill you */ - if (death && (r_ptr->r_deaths < MAX_SHORT)) - { - r_ptr->r_deaths++; - } - /* A spell was cast */ return (TRUE); } @@ -5449,9 +5371,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) /* Scan through all four blows */ for (int ap_cnt = 0; ap_cnt < 4; ap_cnt++) { - bool_ visible = FALSE; - bool_ obvious = FALSE; - int power = 0; int damage = 0; @@ -5482,9 +5401,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) /* break; */ } - /* Extract visibility (before blink) */ - if (m_ptr->ml) visible = TRUE; - /* Extract the attack "power" */ power = get_attack_power(effect); @@ -5680,9 +5596,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) } - /* Hack -- assume all attacks are obvious */ - obvious = TRUE; - /* Roll out the damage */ damage = damroll(d_dice, d_side); @@ -5846,8 +5759,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) { blinked = FALSE; monster_msg("%^s is suddenly very hot!", m_name); - if (t_ptr->ml) - tr_ptr->r_flags2 |= RF2_AURA_FIRE; } project(t_idx, 0, m_ptr->fy, m_ptr->fx, damroll (1 + ((t_ptr->level) / 26), @@ -5862,8 +5773,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) { blinked = FALSE; monster_msg("%^s gets zapped!", m_name); - if (t_ptr->ml) - tr_ptr->r_flags2 |= RF2_AURA_ELEC; } project(t_idx, 0, m_ptr->fy, m_ptr->fx, damroll (1 + ((t_ptr->level) / 26), @@ -5908,21 +5817,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) } } } - - - /* Analyze "visible" monsters only */ - if (visible) - { - /* Count "obvious" attacks (and ones that cause damage) */ - if (obvious || damage || (r_ptr->r_blows[ap_cnt] > 10)) - { - /* Count attacks of this type */ - if (r_ptr->r_blows[ap_cnt] < MAX_UCHAR) - { - r_ptr->r_blows[ap_cnt]++; - } - } - } } if (explode) @@ -6137,18 +6031,7 @@ static void process_monster(int m_idx, bool_ is_frien) { /* Monster wakes up "a little bit" */ m_ptr->csleep -= d; - - /* Notice the "not waking up" */ - if (m_ptr->ml) - { - /* Hack -- Count the ignores */ - if (r_ptr->r_ignore < MAX_UCHAR) - { - r_ptr->r_ignore++; - } - } } - /* Just woke up */ else { @@ -6165,12 +6048,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Dump a message */ msg_format("%^s wakes up.", m_name); - - /* Hack -- Count the wakings */ - if (r_ptr->r_wake < MAX_UCHAR) - { - r_ptr->r_wake++; - } } } } @@ -6399,10 +6276,6 @@ static void process_monster(int m_idx, bool_ is_frien) (r_ptr->flags1 & (RF1_RAND_25)) && (rand_int(100) < 75)) { - /* Memorize flags */ - if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_50); - if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_25); - /* Try four "random" directions */ mm[0] = mm[1] = mm[2] = mm[3] = 5; } @@ -6411,9 +6284,6 @@ static void process_monster(int m_idx, bool_ is_frien) else if ((r_ptr->flags1 & (RF1_RAND_50)) && (rand_int(100) < 50)) { - /* Memorize flags */ - if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_50); - /* Try four "random" directions */ mm[0] = mm[1] = mm[2] = mm[3] = 5; } @@ -6422,9 +6292,6 @@ static void process_monster(int m_idx, bool_ is_frien) else if ((r_ptr->flags1 & (RF1_RAND_25)) && (rand_int(100) < 25)) { - /* Memorize flags */ - if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_25); - /* Try four "random" directions */ mm[0] = mm[1] = mm[2] = mm[3] = 5; } @@ -6448,12 +6315,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Assume nothing */ bool_ did_open_door = FALSE; bool_ did_bash_door = FALSE; - bool_ did_take_item = FALSE; - bool_ did_kill_item = FALSE; - bool_ did_move_body = FALSE; - bool_ did_kill_body = FALSE; - bool_ did_pass_wall = FALSE; - bool_ did_kill_wall = FALSE; /* Take a zero-terminated array of "directions" */ for (i = 0; mm[i]; i++) @@ -6566,9 +6427,6 @@ static void process_monster(int m_idx, bool_ is_frien) { /* Pass through walls/doors/rubble */ do_move = TRUE; - - /* Monster went through a wall */ - did_pass_wall = TRUE; } /* Monster destroys walls (and doors) */ @@ -6577,9 +6435,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Eat through walls/doors/rubble */ do_move = TRUE; - /* Monster destroyed a wall */ - did_kill_wall = TRUE; - if (randint(GRINDNOISE) == 1) { msg_print("There is a grinding sound."); @@ -6600,9 +6455,6 @@ static void process_monster(int m_idx, bool_ is_frien) { /* Pass through walls/doors/rubble */ do_move = TRUE; - - /* Monster went through a wall */ - did_pass_wall = TRUE; } /* Monster moves through webs */ @@ -6843,11 +6695,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Allow movement */ do_move = TRUE; - /* Monster ate another monster */ - did_kill_body = TRUE; - - /* XXX XXX XXX Message */ - /* Kill the monster */ delete_monster(ny, nx); @@ -6879,11 +6726,6 @@ static void process_monster(int m_idx, bool_ is_frien) { /* Allow movement */ do_move = TRUE; - - /* Monster pushed past another monster */ - did_move_body = TRUE; - - /* XXX XXX XXX Message */ } } @@ -7044,9 +6886,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Only give a message for "take_item" */ if (r_ptr->flags2 & (RF2_TAKE_ITEM)) { - /* Take note */ - did_take_item = TRUE; - /* Describe observable situations */ if (m_ptr->ml && player_has_los_bold(ny, nx)) { @@ -7060,9 +6899,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Pick up the item */ else if (r_ptr->flags2 & (RF2_TAKE_ITEM)) { - /* Take note */ - did_take_item = TRUE; - /* Describe observable situations */ if (player_has_los_bold(ny, nx)) { @@ -7092,9 +6928,6 @@ static void process_monster(int m_idx, bool_ is_frien) /* Destroy the item */ else { - /* Take note */ - did_kill_item = TRUE; - /* Describe observable situations */ if (player_has_los_bold(ny, nx)) { @@ -7135,35 +6968,6 @@ static void process_monster(int m_idx, bool_ is_frien) } - /* Learn things from observable monster */ - if (m_ptr->ml) - { - /* Monster opened a door */ - if (did_open_door) r_ptr->r_flags2 |= (RF2_OPEN_DOOR); - - /* Monster bashed a door */ - if (did_bash_door) r_ptr->r_flags2 |= (RF2_BASH_DOOR); - - /* Monster tried to pick something up */ - if (did_take_item) r_ptr->r_flags2 |= (RF2_TAKE_ITEM); - - /* Monster tried to crush something */ - if (did_kill_item) r_ptr->r_flags2 |= (RF2_KILL_ITEM); - - /* Monster pushed past another monster */ - if (did_move_body) r_ptr->r_flags2 |= (RF2_MOVE_BODY); - - /* Monster ate another monster */ - if (did_kill_body) r_ptr->r_flags2 |= (RF2_KILL_BODY); - - /* Monster passed through a wall */ - if (did_pass_wall) r_ptr->r_flags2 |= (RF2_PASS_WALL); - - /* Monster destroyed a wall */ - if (did_kill_wall) r_ptr->r_flags2 |= (RF2_KILL_WALL); - } - - /* Hack -- get "bold" if out of options */ if (!do_turn && !do_move && m_ptr->monfear) { @@ -7270,56 +7074,10 @@ void process_monsters(void) monster_type *m_ptr; - int old_monster_race_idx; - - u32b old_r_flags1 = 0L; - u32b old_r_flags2 = 0L; - u32b old_r_flags3 = 0L; - u32b old_r_flags4 = 0L; - u32b old_r_flags5 = 0L; - u32b old_r_flags6 = 0L; - - byte old_r_blows0 = 0; - byte old_r_blows1 = 0; - byte old_r_blows2 = 0; - byte old_r_blows3 = 0; - - byte old_r_cast_inate = 0; - byte old_r_cast_spell = 0; - /* Check the doppleganger */ if (doppleganger && !(r_info[m_list[doppleganger].r_idx].flags9 & RF9_DOPPLEGANGER)) doppleganger = 0; - /* Memorize old race */ - old_monster_race_idx = monster_race_idx; - - /* Acquire knowledge */ - if (monster_race_idx) - { - /* Acquire current monster */ - monster_race *r_ptr = &r_info[monster_race_idx]; - - /* Memorize flags */ - old_r_flags1 = r_ptr->r_flags1; - old_r_flags2 = r_ptr->r_flags2; - old_r_flags3 = r_ptr->r_flags3; - old_r_flags4 = r_ptr->r_flags4; - old_r_flags5 = r_ptr->r_flags5; - old_r_flags6 = r_ptr->r_flags6; - - /* Memorize blows */ - old_r_blows0 = r_ptr->r_blows[0]; - old_r_blows1 = r_ptr->r_blows[1]; - old_r_blows2 = r_ptr->r_blows[2]; - old_r_blows3 = r_ptr->r_blows[3]; - - /* Memorize castings */ - old_r_cast_inate = r_ptr->r_cast_inate; - old_r_cast_spell = r_ptr->r_cast_spell; - } - - /* Hack -- calculate the "player noise" */ noise = (1L << (30 - p_ptr->skill_stl)); @@ -7447,30 +7205,4 @@ void process_monsters(void) /* Reset global index */ hack_m_idx = 0; - - - /* Tracking a monster race (the same one we were before) */ - if (monster_race_idx && (monster_race_idx == old_monster_race_idx)) - { - /* Acquire monster race */ - monster_race *r_ptr = &r_info[monster_race_idx]; - - /* Check for knowledge change */ - if ((old_r_flags1 != r_ptr->r_flags1) || - (old_r_flags2 != r_ptr->r_flags2) || - (old_r_flags3 != r_ptr->r_flags3) || - (old_r_flags4 != r_ptr->r_flags4) || - (old_r_flags5 != r_ptr->r_flags5) || - (old_r_flags6 != r_ptr->r_flags6) || - (old_r_blows0 != r_ptr->r_blows[0]) || - (old_r_blows1 != r_ptr->r_blows[1]) || - (old_r_blows2 != r_ptr->r_blows[2]) || - (old_r_blows3 != r_ptr->r_blows[3]) || - (old_r_cast_inate != r_ptr->r_cast_inate) || - (old_r_cast_spell != r_ptr->r_cast_spell)) - { - /* Window stuff */ - p_ptr->window |= (PW_MONSTER); - } - } } -- cgit v1.2.3 From 0cb03efd7c438ee8fc5d9444e0c8e60a8eeb7f16 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Remove redundant parens from RFn_* in expressions --- src/melee2.cc | 286 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 143 insertions(+), 143 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 080208f1..522b2f47 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -118,10 +118,10 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) /* Do nothing */ } /* Death by Physical attack -- non-living monster */ - else if ((r_ptr->flags3 & (RF3_DEMON)) || - (r_ptr->flags3 & (RF3_UNDEAD)) || - (r_ptr->flags2 & (RF2_STUPID)) || - (r_ptr->flags3 & (RF3_NONLIVING)) || + else if ((r_ptr->flags3 & RF3_DEMON) || + (r_ptr->flags3 & RF3_UNDEAD) || + (r_ptr->flags2 & RF2_STUPID) || + (r_ptr->flags3 & RF3_NONLIVING) || (strchr("Evg", r_ptr->d_char))) { cmonster_msg(TERM_L_RED, "%^s is destroyed.", m_name); @@ -172,7 +172,7 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) } /* When an Unique dies, it stays dead */ - if (r_ptr->flags1 & (RF1_UNIQUE)) + if (r_ptr->flags1 & RF1_UNIQUE) { r_ptr->max_num = 0; } @@ -229,7 +229,7 @@ void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear) /* Sometimes a monster gets scared by damage */ auto const r_ptr = m_ptr->race(); - if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR))) + if (!m_ptr->monfear && !(r_ptr->flags3 & RF3_NO_FEAR)) { int percentage; @@ -290,7 +290,7 @@ void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear) static bool_ int_outof(std::shared_ptr r_ptr, int prob) { /* Non-Smart monsters are half as "smart" */ - if (!(r_ptr->flags2 & (RF2_SMART))) prob = prob / 2; + if (!(r_ptr->flags2 & RF2_SMART)) prob = prob / 2; /* Roll the dice */ return (rand_int(100) < prob); @@ -314,7 +314,7 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p) /* Too stupid to know anything? */ auto const r_ptr = m_ptr->race(); - if (r_ptr->flags2 & (RF2_STUPID)) return; + if (r_ptr->flags2 & RF2_STUPID) return; /* Must be cheating or learning */ @@ -338,178 +338,178 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p) if (smart & (SM_IMM_ACID)) { - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_BR_ACID); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BA_ACID); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ACID); + if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_ACID; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_ACID; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ACID; } else if ((smart & (SM_OPP_ACID)) && (smart & (SM_RES_ACID))) { - if (int_outof(r_ptr, 80)) f4 &= ~(RF4_BR_ACID); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BA_ACID); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BO_ACID); + if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_ACID; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_ACID; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ACID; } else if ((smart & (SM_OPP_ACID)) || (smart & (SM_RES_ACID))) { - if (int_outof(r_ptr, 30)) f4 &= ~(RF4_BR_ACID); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BA_ACID); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BO_ACID); + if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_ACID; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_ACID; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ACID; } if (smart & (SM_IMM_ELEC)) { - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_BR_ELEC); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BA_ELEC); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ELEC); + if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_ELEC; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_ELEC; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ELEC; } else if ((smart & (SM_OPP_ELEC)) && (smart & (SM_RES_ELEC))) { - if (int_outof(r_ptr, 80)) f4 &= ~(RF4_BR_ELEC); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BA_ELEC); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BO_ELEC); + if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_ELEC; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_ELEC; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ELEC; } else if ((smart & (SM_OPP_ELEC)) || (smart & (SM_RES_ELEC))) { - if (int_outof(r_ptr, 30)) f4 &= ~(RF4_BR_ELEC); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BA_ELEC); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BO_ELEC); + if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_ELEC; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_ELEC; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ELEC; } if (smart & (SM_IMM_FIRE)) { - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_BR_FIRE); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BA_FIRE); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_FIRE); + if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_FIRE; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_FIRE; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_FIRE; } else if ((smart & (SM_OPP_FIRE)) && (smart & (SM_RES_FIRE))) { - if (int_outof(r_ptr, 80)) f4 &= ~(RF4_BR_FIRE); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BA_FIRE); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BO_FIRE); + if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_FIRE; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_FIRE; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_FIRE; } else if ((smart & (SM_OPP_FIRE)) || (smart & (SM_RES_FIRE))) { - if (int_outof(r_ptr, 30)) f4 &= ~(RF4_BR_FIRE); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BA_FIRE); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BO_FIRE); + if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_FIRE; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_FIRE; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_FIRE; } if (smart & (SM_IMM_COLD)) { - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_BR_COLD); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BA_COLD); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_COLD); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ICEE); + if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_COLD; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_COLD; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_COLD; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ICEE; } else if ((smart & (SM_OPP_COLD)) && (smart & (SM_RES_COLD))) { - if (int_outof(r_ptr, 80)) f4 &= ~(RF4_BR_COLD); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BA_COLD); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BO_COLD); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BO_ICEE); + if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_COLD; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_COLD; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_COLD; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ICEE; } else if ((smart & (SM_OPP_COLD)) || (smart & (SM_RES_COLD))) { - if (int_outof(r_ptr, 30)) f4 &= ~(RF4_BR_COLD); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BA_COLD); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BO_COLD); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BO_ICEE); + if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_COLD; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_COLD; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_COLD; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ICEE; } if ((smart & (SM_OPP_POIS)) && (smart & (SM_RES_POIS))) { - if (int_outof(r_ptr, 80)) f4 &= ~(RF4_BR_POIS); - if (int_outof(r_ptr, 80)) f5 &= ~(RF5_BA_POIS); - if (int_outof(r_ptr, 40)) f4 &= ~(RF4_BA_NUKE); - if (int_outof(r_ptr, 40)) f4 &= ~(RF4_BR_NUKE); + if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_POIS; + if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_POIS; + if (int_outof(r_ptr, 40)) f4 &= ~RF4_BA_NUKE; + if (int_outof(r_ptr, 40)) f4 &= ~RF4_BR_NUKE; } else if ((smart & (SM_OPP_POIS)) || (smart & (SM_RES_POIS))) { - if (int_outof(r_ptr, 30)) f4 &= ~(RF4_BR_POIS); - if (int_outof(r_ptr, 30)) f5 &= ~(RF5_BA_POIS); + if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_POIS; + if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_POIS; } if (smart & (SM_RES_NETH)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_NETH); - if (int_outof(r_ptr, 50)) f5 &= ~(RF5_BA_NETH); - if (int_outof(r_ptr, 50)) f5 &= ~(RF5_BO_NETH); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_NETH; + if (int_outof(r_ptr, 50)) f5 &= ~RF5_BA_NETH; + if (int_outof(r_ptr, 50)) f5 &= ~RF5_BO_NETH; } if (smart & (SM_RES_LITE)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_LITE); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_LITE; } if (smart & (SM_RES_DARK)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_DARK); - if (int_outof(r_ptr, 50)) f5 &= ~(RF5_BA_DARK); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_DARK; + if (int_outof(r_ptr, 50)) f5 &= ~RF5_BA_DARK; } if (smart & (SM_RES_FEAR)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_SCARE); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_SCARE; } if (smart & (SM_RES_CONF)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_CONF); - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_CONF); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_CONF; + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CONF; } if (smart & (SM_RES_CHAOS)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_CONF); - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_CONF); - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_CHAO); - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BA_CHAO); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_CONF; + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CONF; + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CHAO; + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BA_CHAO; } if (smart & (SM_RES_DISEN)) { - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_BR_DISE); + if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_DISE; } if (smart & (SM_RES_BLIND)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BLIND); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BLIND; } if (smart & (SM_RES_NEXUS)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_NEXU); - if (int_outof(r_ptr, 50)) f6 &= ~(RF6_TELE_LEVEL); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_NEXU; + if (int_outof(r_ptr, 50)) f6 &= ~RF6_TELE_LEVEL; } if (smart & (SM_RES_SOUND)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_SOUN); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_SOUN; } if (smart & (SM_RES_SHARD)) { - if (int_outof(r_ptr, 50)) f4 &= ~(RF4_BR_SHAR); - if (int_outof(r_ptr, 20)) f4 &= ~(RF4_ROCKET); + if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_SHAR; + if (int_outof(r_ptr, 20)) f4 &= ~RF4_ROCKET; } if (smart & (SM_IMM_REFLECT)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_COLD); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_FIRE); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ACID); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ELEC); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_POIS); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_NETH); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_WATE); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_MANA); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_PLAS); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_BO_ICEE); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_MISSILE); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_COLD; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_FIRE; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ACID; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ELEC; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_POIS; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_NETH; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_WATE; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_MANA; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_PLAS; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ICEE; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_MISSILE; if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_1); if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_2); if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_3); @@ -518,13 +518,13 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p) if (smart & (SM_IMM_FREE)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_HOLD); - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_SLOW); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_HOLD; + if (int_outof(r_ptr, 100)) f5 &= ~RF5_SLOW; } if (smart & (SM_IMM_MANA)) { - if (int_outof(r_ptr, 100)) f5 &= ~(RF5_DRAIN_MANA); + if (int_outof(r_ptr, 100)) f5 &= ~RF5_DRAIN_MANA; } /* XXX XXX XXX No spells left? */ @@ -770,7 +770,7 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num) /* Stupid monsters choose randomly */ auto const r_ptr = m_ptr->race(); - if (r_ptr->flags2 & (RF2_STUPID)) + if (r_ptr->flags2 & RF2_STUPID) { /* Pick at random */ return (spells[rand_int(num)]); @@ -884,7 +884,7 @@ static void breath(int m_idx, int typ, int dam_hp, int rad) auto const r_ptr = m_ptr->race(); /* Determine the radius of the blast */ - if (rad < 1) rad = (r_ptr->flags2 & (RF2_POWERFUL)) ? 3 : 2; + if (rad < 1) rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; /* Target the player with a ball attack */ (void)project(m_idx, rad, p_ptr->py, p_ptr->px, dam_hp, typ, flg); @@ -904,7 +904,7 @@ static void monst_breath_monst(int m_idx, int y, int x, int typ, int dam_hp, int auto const r_ptr = m_ptr->race(); /* Determine the radius of the blast */ - if (rad < 1) rad = (r_ptr->flags2 & (RF2_POWERFUL)) ? 3 : 2; + if (rad < 1) rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; (void)project(m_idx, rad, y, x, dam_hp, typ, flg); } @@ -1065,14 +1065,14 @@ static bool_ monst_spell_monst(int m_idx) f6 = r_ptr->flags6; /* Hack -- allow "desperate" spells */ - if ((r_ptr->flags2 & (RF2_SMART)) && + if ((r_ptr->flags2 & RF2_SMART) && (m_ptr->hp < m_ptr->maxhp / 10) && (rand_int(100) < 50)) { /* Require intelligent spells */ - f4 &= (RF4_INT_MASK); - f5 &= (RF5_INT_MASK); - f6 &= (RF6_INT_MASK); + f4 &= RF4_INT_MASK; + f5 &= RF5_INT_MASK; + f6 &= RF6_INT_MASK; /* No spells left */ if ((!f4 && !f5 && !f6) && (monst_spell_monst_spell == -1)) return (FALSE); @@ -1708,8 +1708,8 @@ static bool_ monst_spell_monst(int m_idx) } /* Attempt a saving throw */ - if ((tr_ptr->flags1 & (RF1_UNIQUE)) || - (tr_ptr->flags3 & (RF3_NO_CONF)) || + if ((tr_ptr->flags1 & RF1_UNIQUE) || + (tr_ptr->flags3 & RF3_NO_CONF) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { /* No obvious effect */ @@ -1746,8 +1746,8 @@ static bool_ monst_spell_monst(int m_idx) } /* Attempt a saving throw */ - if ((tr_ptr->flags1 & (RF1_UNIQUE)) || - (tr_ptr->flags3 & (RF3_NO_CONF)) || + if ((tr_ptr->flags1 & RF1_UNIQUE) || + (tr_ptr->flags3 & RF3_NO_CONF) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { /* No obvious effect */ @@ -2279,9 +2279,9 @@ static bool_ monst_spell_monst(int m_idx) monster_msg("%^s teleports %s away.", m_name, t_name); - if (tr_ptr->flags3 & (RF3_RES_TELE)) + if (tr_ptr->flags3 & RF3_RES_TELE) { - if (tr_ptr->flags1 & (RF1_UNIQUE)) + if (tr_ptr->flags1 & RF1_UNIQUE) { if (see_t) { @@ -2948,14 +2948,14 @@ static bool_ make_attack_spell(int m_idx) if (no_inate) f4 = 0L; /* Hack -- allow "desperate" spells */ - if ((r_ptr->flags2 & (RF2_SMART)) && + if ((r_ptr->flags2 & RF2_SMART) && (m_ptr->hp < m_ptr->maxhp / 10) && (rand_int(100) < 50)) { /* Require intelligent spells */ - f4 &= (RF4_INT_MASK); - f5 &= (RF5_INT_MASK); - f6 &= (RF6_INT_MASK); + f4 &= RF4_INT_MASK; + f5 &= RF5_INT_MASK; + f6 &= RF6_INT_MASK; /* No spells left */ if (!f4 && !f5 && !f6) return (FALSE); @@ -2968,27 +2968,27 @@ static bool_ make_attack_spell(int m_idx) if (!f4 && !f5 && !f6) return (FALSE); /* Check for a clean bolt shot */ - if ((f4&(RF4_BOLT_MASK) || f5 & (RF5_BOLT_MASK) || - f6&(RF6_BOLT_MASK)) && - !(r_ptr->flags2 & (RF2_STUPID)) && + if ((f4&RF4_BOLT_MASK || f5 & RF5_BOLT_MASK || + f6&RF6_BOLT_MASK) && + !(r_ptr->flags2 & RF2_STUPID) && !clean_shot(m_ptr->fy, m_ptr->fx, y, x)) { /* Remove spells that will only hurt friends */ - f4 &= ~(RF4_BOLT_MASK); - f5 &= ~(RF5_BOLT_MASK); - f6 &= ~(RF6_BOLT_MASK); + f4 &= ~RF4_BOLT_MASK; + f5 &= ~RF5_BOLT_MASK; + f6 &= ~RF6_BOLT_MASK; } /* Check for a possible summon */ - if ((f4 & (RF4_SUMMON_MASK) || f5 & (RF5_SUMMON_MASK) || - f6 & (RF6_SUMMON_MASK)) && - !(r_ptr->flags2 & (RF2_STUPID)) && + if ((f4 & RF4_SUMMON_MASK || f5 & RF5_SUMMON_MASK || + f6 & RF6_SUMMON_MASK) && + !(r_ptr->flags2 & RF2_STUPID) && !(summon_possible(y, x))) { /* Remove summoning spells */ - f4 &= ~(RF4_SUMMON_MASK); - f5 &= ~(RF5_SUMMON_MASK); - f6 &= ~(RF6_SUMMON_MASK); + f4 &= ~RF4_SUMMON_MASK; + f5 &= ~RF5_SUMMON_MASK; + f6 &= ~RF6_SUMMON_MASK; } /* No spells left */ @@ -3034,7 +3034,7 @@ static bool_ make_attack_spell(int m_idx) failrate = 25 - (rlev + 3) / 4; /* Hack -- Stupid monsters will never fail (for jellies and such) */ - if (r_ptr->flags2 & (RF2_STUPID)) failrate = 0; + if (r_ptr->flags2 & RF2_STUPID) failrate = 0; /* Check for spell failure (inate attacks never fail) */ if ((thrown_spell >= 128) && (rand_int(100) < failrate)) @@ -5032,8 +5032,8 @@ static bool_ get_moves(int m_idx, int *mm) */ if ((r_ptr->flags1 & RF1_FRIENDS) && (r_ptr->flags3 & RF3_ANIMAL) && - !((r_ptr->flags2 & (RF2_PASS_WALL)) || - (r_ptr->flags2 & (RF2_KILL_WALL)))) + !((r_ptr->flags2 & RF2_PASS_WALL) || + (r_ptr->flags2 & RF2_KILL_WALL))) { int i, room = 0; @@ -5767,7 +5767,7 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) } /* Aura elec */ - if ((tr_ptr->flags2 & (RF2_AURA_ELEC)) && !(r_ptr->flags3 & (RF3_IM_ELEC))) + if ((tr_ptr->flags2 & RF2_AURA_ELEC) && !(r_ptr->flags3 & RF3_IM_ELEC)) { if (m_ptr->ml || t_ptr->ml) { @@ -6142,7 +6142,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Paranoia... no friendly uniques outside wizard mode -- TY */ if ((m_ptr->status > MSTATUS_NEUTRAL) && (m_ptr->status < MSTATUS_COMPANION) && !(wizard) && - (r_ptr->flags1 & (RF1_UNIQUE)) && !(r_ptr->flags7 & RF7_PET)) + (r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_PET)) gets_angry = TRUE; if (gets_angry) @@ -6198,7 +6198,7 @@ static void process_monster(int m_idx, bool_ is_frien) ox = m_ptr->fx; /* Attempt to "multiply" if able and allowed */ - if ((r_ptr->flags4 & (RF4_MULTIPLY)) && (num_repro < MAX_REPRO)) + if ((r_ptr->flags4 & RF4_MULTIPLY) && (num_repro < MAX_REPRO)) { if (ai_multiply(m_idx)) return; } @@ -6409,28 +6409,28 @@ static void process_monster(int m_idx, bool_ is_frien) /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_LEVITATE) && (r_ptr->flags7 & (RF7_CAN_FLY))) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_LEVITATE) && (r_ptr->flags7 & RF7_CAN_FLY)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_FLY) && (r_ptr->flags7 & (RF7_CAN_FLY))) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_FLY) && (r_ptr->flags7 & RF7_CAN_FLY)) { /* Pass through trees/... */ do_move = TRUE; } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & (RF2_PASS_WALL))) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Monster destroys walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & (RF2_KILL_WALL))) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_KILL_WALL)) { /* Eat through walls/doors/rubble */ do_move = TRUE; @@ -6451,7 +6451,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & (RF2_PASS_WALL))) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; @@ -6475,7 +6475,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Take a turn */ do_turn = TRUE; - if ((r_ptr->flags2 & (RF2_OPEN_DOOR)) && + if ((r_ptr->flags2 & RF2_OPEN_DOOR) && ((is_friend(m_ptr) <= 0) || p_ptr->pet_open_doors)) { /* Closed doors and secret doors */ @@ -6745,7 +6745,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (do_move && (r_ptr->flags1 & RF1_NEVER_MOVE)) { /* Hack -- memorize lack of attacks */ - /* if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_NEVER_MOVE); */ + /* if (m_ptr->ml) r_ptr->r_flags1 |= RF1_NEVER_MOVE; */ /* Do not move */ do_move = FALSE; @@ -6846,9 +6846,9 @@ static void process_monster(int m_idx, bool_ is_frien) /* Take or Kill objects on the floor */ /* rr9: Pets will no longer pick up/destroy items */ - if ((((r_ptr->flags2 & (RF2_TAKE_ITEM)) && + if ((((r_ptr->flags2 & RF2_TAKE_ITEM) && ((is_friend(m_ptr) <= 0) || p_ptr->pet_pickup_items)) || - (r_ptr->flags2 & (RF2_KILL_ITEM))) && + (r_ptr->flags2 & RF2_KILL_ITEM)) && (is_friend(m_ptr) <= 0)) { u32b f1, f2, f3, f4, f5, esp; @@ -6868,23 +6868,23 @@ static void process_monster(int m_idx, bool_ is_frien) monster_desc(m_name, m_ptr, 0x04); /* React to objects that hurt the monster */ - if (f5 & (TR5_KILL_DEMON)) flg3 |= (RF3_DEMON); - if (f5 & (TR5_KILL_UNDEAD)) flg3 |= (RF3_UNDEAD); - if (f1 & (TR1_SLAY_DRAGON)) flg3 |= (RF3_DRAGON); - if (f1 & (TR1_SLAY_TROLL)) flg3 |= (RF3_TROLL); - if (f1 & (TR1_SLAY_GIANT)) flg3 |= (RF3_GIANT); - if (f1 & (TR1_SLAY_ORC)) flg3 |= (RF3_ORC); - if (f1 & (TR1_SLAY_DEMON)) flg3 |= (RF3_DEMON); - if (f1 & (TR1_SLAY_UNDEAD)) flg3 |= (RF3_UNDEAD); - if (f1 & (TR1_SLAY_ANIMAL)) flg3 |= (RF3_ANIMAL); - if (f1 & (TR1_SLAY_EVIL)) flg3 |= (RF3_EVIL); + if (f5 & (TR5_KILL_DEMON)) flg3 |= RF3_DEMON; + if (f5 & (TR5_KILL_UNDEAD)) flg3 |= RF3_UNDEAD; + if (f1 & (TR1_SLAY_DRAGON)) flg3 |= RF3_DRAGON; + if (f1 & (TR1_SLAY_TROLL)) flg3 |= RF3_TROLL; + if (f1 & (TR1_SLAY_GIANT)) flg3 |= RF3_GIANT; + if (f1 & (TR1_SLAY_ORC)) flg3 |= RF3_ORC; + if (f1 & (TR1_SLAY_DEMON)) flg3 |= RF3_DEMON; + if (f1 & (TR1_SLAY_UNDEAD)) flg3 |= RF3_UNDEAD; + if (f1 & (TR1_SLAY_ANIMAL)) flg3 |= RF3_ANIMAL; + if (f1 & (TR1_SLAY_EVIL)) flg3 |= RF3_EVIL; /* The object cannot be picked up by the monster */ if (artifact_p(o_ptr) || (r_ptr->flags3 & flg3) || (o_ptr->art_name)) { /* Only give a message for "take_item" */ - if (r_ptr->flags2 & (RF2_TAKE_ITEM)) + if (r_ptr->flags2 & RF2_TAKE_ITEM) { /* Describe observable situations */ if (m_ptr->ml && player_has_los_bold(ny, nx)) @@ -6897,7 +6897,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Pick up the item */ - else if (r_ptr->flags2 & (RF2_TAKE_ITEM)) + else if (r_ptr->flags2 & RF2_TAKE_ITEM) { /* Describe observable situations */ if (player_has_los_bold(ny, nx)) -- cgit v1.2.3 From fa5083020d4cc4d6d7471b461c430d40ed36c02e Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Remove ANIM_DEAD monster spell It doesn't seem like it was ever implemented fully in the first place, i.e. it was only available to Possessors and Symbiants, not monsters. --- src/melee2.cc | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 522b2f47..83827dcf 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2344,12 +2344,6 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_ANIM_DEAD */ - case 160 + 12: - { - break; - } - /* RF6_S_BUG */ case 160 + 13: { @@ -4214,10 +4208,6 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_ANIM_DEAD */ - case 160 + 12: - break; - /* RF6_S_BUG */ case 160 + 13: { -- cgit v1.2.3 From 59b5314b6b7880cfda73f34aed03a700fd523017 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Rework RF{4,5,6}_* monster spell flags to flag_set<> --- src/melee2.cc | 1135 ++++++++++++++++++++++----------------------------------- 1 file changed, 440 insertions(+), 695 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 83827dcf..3e03c8f6 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -28,6 +28,8 @@ #include "monster2.hpp" #include "monster3.hpp" #include "monster_race.hpp" +#include "monster_spell.hpp" +#include "monster_spell_flag.hpp" #include "monster_type.hpp" #include "object1.hpp" #include "object2.hpp" @@ -301,16 +303,13 @@ static bool_ int_outof(std::shared_ptr r_ptr, int prob) /* * Remove the "bad" spells from a spell list */ -static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p) +static void remove_bad_spells(int m_idx, monster_spell_flag_set *spells_p) { monster_type *m_ptr = &m_list[m_idx]; - - u32b f4 = (*f4p); - u32b f5 = (*f5p); - u32b f6 = (*f6p); - u32b smart = 0L; + // Shorthand + auto spells(*spells_p); /* Too stupid to know anything? */ auto const r_ptr = m_ptr->race(); @@ -338,201 +337,199 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p) if (smart & (SM_IMM_ACID)) { - if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_ACID; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_ACID; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ACID; + if (int_outof(r_ptr, 100)) spells &= ~SF_BR_ACID; + if (int_outof(r_ptr, 100)) spells &= ~SF_BA_ACID; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ACID; } else if ((smart & (SM_OPP_ACID)) && (smart & (SM_RES_ACID))) { - if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_ACID; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_ACID; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ACID; + if (int_outof(r_ptr, 80)) spells &= ~SF_BR_ACID; + if (int_outof(r_ptr, 80)) spells &= ~SF_BA_ACID; + if (int_outof(r_ptr, 80)) spells &= ~SF_BO_ACID; } else if ((smart & (SM_OPP_ACID)) || (smart & (SM_RES_ACID))) { - if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_ACID; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_ACID; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ACID; + if (int_outof(r_ptr, 30)) spells &= ~SF_BR_ACID; + if (int_outof(r_ptr, 30)) spells &= ~SF_BA_ACID; + if (int_outof(r_ptr, 30)) spells &= ~SF_BO_ACID; } if (smart & (SM_IMM_ELEC)) { - if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_ELEC; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_ELEC; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ELEC; + if (int_outof(r_ptr, 100)) spells &= ~SF_BR_ELEC; + if (int_outof(r_ptr, 100)) spells &= ~SF_BA_ELEC; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ELEC; } else if ((smart & (SM_OPP_ELEC)) && (smart & (SM_RES_ELEC))) { - if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_ELEC; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_ELEC; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ELEC; + if (int_outof(r_ptr, 80)) spells &= ~SF_BR_ELEC; + if (int_outof(r_ptr, 80)) spells &= ~SF_BA_ELEC; + if (int_outof(r_ptr, 80)) spells &= ~SF_BO_ELEC; } else if ((smart & (SM_OPP_ELEC)) || (smart & (SM_RES_ELEC))) { - if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_ELEC; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_ELEC; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ELEC; + if (int_outof(r_ptr, 30)) spells &= ~SF_BR_ELEC; + if (int_outof(r_ptr, 30)) spells &= ~SF_BA_ELEC; + if (int_outof(r_ptr, 30)) spells &= ~SF_BO_ELEC; } if (smart & (SM_IMM_FIRE)) { - if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_FIRE; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_FIRE; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_FIRE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BR_FIRE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BA_FIRE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_FIRE; } else if ((smart & (SM_OPP_FIRE)) && (smart & (SM_RES_FIRE))) { - if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_FIRE; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_FIRE; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_FIRE; + if (int_outof(r_ptr, 80)) spells &= ~SF_BR_FIRE; + if (int_outof(r_ptr, 80)) spells &= ~SF_BA_FIRE; + if (int_outof(r_ptr, 80)) spells &= ~SF_BO_FIRE; } else if ((smart & (SM_OPP_FIRE)) || (smart & (SM_RES_FIRE))) { - if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_FIRE; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_FIRE; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_FIRE; + if (int_outof(r_ptr, 30)) spells &= ~SF_BR_FIRE; + if (int_outof(r_ptr, 30)) spells &= ~SF_BA_FIRE; + if (int_outof(r_ptr, 30)) spells &= ~SF_BO_FIRE; } if (smart & (SM_IMM_COLD)) { - if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_COLD; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BA_COLD; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_COLD; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ICEE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BR_COLD; + if (int_outof(r_ptr, 100)) spells &= ~SF_BA_COLD; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_COLD; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ICEE; } else if ((smart & (SM_OPP_COLD)) && (smart & (SM_RES_COLD))) { - if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_COLD; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_COLD; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_COLD; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BO_ICEE; + if (int_outof(r_ptr, 80)) spells &= ~SF_BR_COLD; + if (int_outof(r_ptr, 80)) spells &= ~SF_BA_COLD; + if (int_outof(r_ptr, 80)) spells &= ~SF_BO_COLD; + if (int_outof(r_ptr, 80)) spells &= ~SF_BO_ICEE; } else if ((smart & (SM_OPP_COLD)) || (smart & (SM_RES_COLD))) { - if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_COLD; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_COLD; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_COLD; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BO_ICEE; + if (int_outof(r_ptr, 30)) spells &= ~SF_BR_COLD; + if (int_outof(r_ptr, 30)) spells &= ~SF_BA_COLD; + if (int_outof(r_ptr, 30)) spells &= ~SF_BO_COLD; + if (int_outof(r_ptr, 30)) spells &= ~SF_BO_ICEE; } if ((smart & (SM_OPP_POIS)) && (smart & (SM_RES_POIS))) { - if (int_outof(r_ptr, 80)) f4 &= ~RF4_BR_POIS; - if (int_outof(r_ptr, 80)) f5 &= ~RF5_BA_POIS; - if (int_outof(r_ptr, 40)) f4 &= ~RF4_BA_NUKE; - if (int_outof(r_ptr, 40)) f4 &= ~RF4_BR_NUKE; + if (int_outof(r_ptr, 80)) spells &= ~SF_BR_POIS; + if (int_outof(r_ptr, 80)) spells &= ~SF_BA_POIS; + if (int_outof(r_ptr, 40)) spells &= ~SF_BA_NUKE; + if (int_outof(r_ptr, 40)) spells &= ~SF_BR_NUKE; } else if ((smart & (SM_OPP_POIS)) || (smart & (SM_RES_POIS))) { - if (int_outof(r_ptr, 30)) f4 &= ~RF4_BR_POIS; - if (int_outof(r_ptr, 30)) f5 &= ~RF5_BA_POIS; + if (int_outof(r_ptr, 30)) spells &= ~SF_BR_POIS; + if (int_outof(r_ptr, 30)) spells &= ~SF_BA_POIS; } if (smart & (SM_RES_NETH)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_NETH; - if (int_outof(r_ptr, 50)) f5 &= ~RF5_BA_NETH; - if (int_outof(r_ptr, 50)) f5 &= ~RF5_BO_NETH; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_NETH; + if (int_outof(r_ptr, 50)) spells &= ~SF_BA_NETH; + if (int_outof(r_ptr, 50)) spells &= ~SF_BO_NETH; } if (smart & (SM_RES_LITE)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_LITE; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_LITE; } if (smart & (SM_RES_DARK)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_DARK; - if (int_outof(r_ptr, 50)) f5 &= ~RF5_BA_DARK; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_DARK; + if (int_outof(r_ptr, 50)) spells &= ~SF_BA_DARK; } if (smart & (SM_RES_FEAR)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_SCARE; + if (int_outof(r_ptr, 100)) spells &= ~SF_SCARE; } if (smart & (SM_RES_CONF)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_CONF; - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CONF; + if (int_outof(r_ptr, 100)) spells &= ~SF_CONF; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_CONF; } if (smart & (SM_RES_CHAOS)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_CONF; - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CONF; - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_CHAO; - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BA_CHAO; + if (int_outof(r_ptr, 100)) spells &= ~SF_CONF; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_CONF; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_CHAO; + if (int_outof(r_ptr, 50)) spells &= ~SF_BA_CHAO; } if (smart & (SM_RES_DISEN)) { - if (int_outof(r_ptr, 100)) f4 &= ~RF4_BR_DISE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BR_DISE; } if (smart & (SM_RES_BLIND)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BLIND; + if (int_outof(r_ptr, 100)) spells &= ~SF_BLIND; } if (smart & (SM_RES_NEXUS)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_NEXU; - if (int_outof(r_ptr, 50)) f6 &= ~RF6_TELE_LEVEL; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_NEXU; + if (int_outof(r_ptr, 50)) spells &= ~SF_TELE_LEVEL; } if (smart & (SM_RES_SOUND)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_SOUN; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_SOUN; } if (smart & (SM_RES_SHARD)) { - if (int_outof(r_ptr, 50)) f4 &= ~RF4_BR_SHAR; - if (int_outof(r_ptr, 20)) f4 &= ~RF4_ROCKET; + if (int_outof(r_ptr, 50)) spells &= ~SF_BR_SHAR; + if (int_outof(r_ptr, 20)) spells &= ~SF_ROCKET; } if (smart & (SM_IMM_REFLECT)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_COLD; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_FIRE; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ACID; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ELEC; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_POIS; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_NETH; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_WATE; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_MANA; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_PLAS; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_BO_ICEE; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_MISSILE; - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_1); - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_2); - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_3); - if (int_outof(r_ptr, 100)) f4 &= ~(RF4_ARROW_4); + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_COLD; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_FIRE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ACID; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ELEC; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_POIS; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_NETH; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_WATE; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_MANA; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_PLAS; + if (int_outof(r_ptr, 100)) spells &= ~SF_BO_ICEE; + if (int_outof(r_ptr, 100)) spells &= ~SF_MISSILE; + if (int_outof(r_ptr, 100)) spells &= ~(SF_ARROW_1); + if (int_outof(r_ptr, 100)) spells &= ~(SF_ARROW_2); + if (int_outof(r_ptr, 100)) spells &= ~(SF_ARROW_3); + if (int_outof(r_ptr, 100)) spells &= ~(SF_ARROW_4); } if (smart & (SM_IMM_FREE)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_HOLD; - if (int_outof(r_ptr, 100)) f5 &= ~RF5_SLOW; + if (int_outof(r_ptr, 100)) spells &= ~SF_HOLD; + if (int_outof(r_ptr, 100)) spells &= ~SF_SLOW; } if (smart & (SM_IMM_MANA)) { - if (int_outof(r_ptr, 100)) f5 &= ~RF5_DRAIN_MANA; + if (int_outof(r_ptr, 100)) spells &= ~SF_DRAIN_MANA; } /* XXX XXX XXX No spells left? */ /* if (!f4 && !f5 && !f6) ... */ - (*f4p) = f4; - (*f5p) = f5; - (*f6p) = f6; + *spells_p = spells; } @@ -628,117 +625,70 @@ static void bolt(int m_idx, int typ, int dam_hp) /* - * Return TRUE if a spell is good for hurting the player (directly). - */ -static bool_ spell_attack(byte spell) -{ - /* All RF4 spells hurt (except for shriek, multiply, summon animal) */ - if (spell >= 96 + 3 && spell <= 96 + 31) return (TRUE); - - /* Various "ball" spells */ - if (spell >= 128 && spell <= 128 + 8) return (TRUE); - - /* "Cause wounds" and "bolt" spells */ - if (spell >= 128 + 12 && spell <= 128 + 26) return (TRUE); - - /* Hand of Doom */ - if (spell == 160 + 1) return (TRUE); - - /* Doesn't hurt */ - return (FALSE); -} - - -/* - * Return TRUE if a spell is good for escaping. - */ -static bool_ spell_escape(byte spell) -{ - /* Blink or Teleport */ - if (spell == 160 + 4 || spell == 160 + 5) return (TRUE); - - /* Teleport the player away */ - if (spell == 160 + 7 || spell == 160 + 8) return (TRUE); - - /* Isn't good for escaping */ - return (FALSE); -} - -/* - * Return TRUE if a spell is good for annoying the player. - */ -static bool_ spell_annoy(byte spell) -{ - /* Shriek */ - if (spell == 96 + 0) return (TRUE); - - /* Brain smash, et al (added curses) */ - if (spell >= 128 + 9 && spell <= 128 + 14) return (TRUE); - - /* Scare, confuse, blind, slow, paralyze */ - if (spell >= 128 + 27 && spell <= 128 + 31) return (TRUE); - - /* Teleport to */ - if (spell == 160 + 6) return (TRUE); - - /* Darkness, make traps, cause amnesia */ - if (spell >= 160 + 9 && spell <= 160 + 11) return (TRUE); - - /* Doesn't annoy */ - return (FALSE); -} - -/* - * Return TRUE if a spell summons help. + * Calculate the mask for "bolt" spells */ -static bool_ spell_summon(byte spell) +static monster_spell_flag_set compute_bolt_mask() { - /* RF4_S_ANIMAL, RF6_S_ANIMALS */ - if (spell == 96 + 2 || spell == 160 + 3) return (TRUE); - /* All other summon spells */ - if (spell >= 160 + 13 && spell <= 160 + 31) return (TRUE); - - /* Doesn't summon */ - return (FALSE); + monster_spell_flag_set flags; + for (auto const &monster_spell: monster_spells()) + { + if (monster_spell->is_bolt) + { + flags |= monster_spell->flag_set; + } + } + return flags; } /* - * Return TRUE if a spell is good in a tactical situation. + * Calculate mask for summoning spells */ -static bool_ spell_tactic(byte spell) +static monster_spell_flag_set compute_summoning_mask() { - /* Blink */ - if (spell == 160 + 4) return (TRUE); - - /* Not good */ - return (FALSE); + monster_spell_flag_set flags; + for (auto const &monster_spell: monster_spells()) + { + if (monster_spell->is_summon) + { + flags |= monster_spell->flag_set; + } + } + return flags; } /* - * Return TRUE if a spell hastes. + * Calculate mask for spells requiring SMART flag */ -static bool_ spell_haste(byte spell) +static monster_spell_flag_set compute_smart_mask() { - /* Haste self */ - if (spell == 160 + 0) return (TRUE); - - /* Not a haste spell */ - return (FALSE); + monster_spell_flag_set flags; + for (auto const &monster_spell: monster_spells()) + { + if (monster_spell->is_smart) + { + flags |= monster_spell->flag_set; + } + } + return flags; } /* - * Return TRUE if a spell is good for healing. + * Calculate mask for spells requiring SMART flag */ -static bool_ spell_heal(byte spell) +static monster_spell_flag_set compute_innate_mask() { - /* Heal */ - if (spell == 160 + 2) return (TRUE); - - /* No healing */ - return (FALSE); + monster_spell_flag_set flags; + for (auto const &monster_spell: monster_spells()) + { + if (monster_spell->is_innate) + { + flags |= monster_spell->flag_set; + } + } + return flags; } @@ -756,49 +706,71 @@ static bool_ spell_heal(byte spell) * * This function may well be an efficiency bottleneck. */ -static int choose_attack_spell(int m_idx, byte spells[], byte num) +static monster_spell const *choose_attack_spell(int m_idx, std::vector const &spells) { monster_type *m_ptr = &m_list[m_idx]; - byte escape[96], escape_num = 0; - byte attack[96], attack_num = 0; - byte summon[96], summon_num = 0; - byte tactic[96], tactic_num = 0; - byte annoy[96], annoy_num = 0; - byte haste[96], haste_num = 0; - byte heal[96], heal_num = 0; - /* Stupid monsters choose randomly */ auto const r_ptr = m_ptr->race(); if (r_ptr->flags2 & RF2_STUPID) { /* Pick at random */ - return (spells[rand_int(num)]); + return spells[rand_int(spells.size())]; } + /* Spells by category */ + std::vector escape; escape.reserve(spells.size()); + std::vector attack; attack.reserve(spells.size()); + std::vector summon; summon.reserve(spells.size()); + std::vector tactic; tactic.reserve(spells.size()); + std::vector annoy ; annoy.reserve(spells.size()); + std::vector haste ; haste.reserve(spells.size()); + std::vector heal ; heal.reserve(spells.size()); + /* Categorize spells */ - for (int i = 0; i < num; i++) + for (std::size_t i = 0; i < spells.size(); i++) { /* Escape spell? */ - if (spell_escape(spells[i])) escape[escape_num++] = spells[i]; + if (spells[i]->is_escape) + { + escape.push_back(spells[i]); + } /* Attack spell? */ - if (spell_attack(spells[i])) attack[attack_num++] = spells[i]; + if (spells[i]->is_damage) + { + attack.push_back(spells[i]); + } /* Summon spell? */ - if (spell_summon(spells[i])) summon[summon_num++] = spells[i]; + if (spells[i]->is_summon) + { + summon.push_back(spells[i]); + } /* Tactical spell? */ - if (spell_tactic(spells[i])) tactic[tactic_num++] = spells[i]; + if (spells[i]->is_tactic) + { + tactic.push_back(spells[i]); + } /* Annoyance spell? */ - if (spell_annoy(spells[i])) annoy[annoy_num++] = spells[i]; + if (spells[i]->is_annoy) + { + annoy.push_back(spells[i]); + } /* Haste spell? */ - if (spell_haste(spells[i])) haste[haste_num++] = spells[i]; + if (spells[i]->is_haste) + { + haste.push_back(spells[i]); + } /* Heal spell? */ - if (spell_heal(spells[i])) heal[heal_num++] = spells[i]; + if (spells[i]->is_heal) + { + heal.push_back(spells[i]); + } } /*** Try to pick an appropriate spell type ***/ @@ -806,68 +778,59 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num) /* Hurt badly or afraid, attempt to flee */ if ((m_ptr->hp < m_ptr->maxhp / 3) || m_ptr->monfear) { - /* Choose escape spell if possible */ - if (escape_num) return (escape[rand_int(escape_num)]); + if (!escape.empty()) return escape[rand_int(escape.size())]; } /* Still hurt badly, couldn't flee, attempt to heal */ if (m_ptr->hp < m_ptr->maxhp / 3) { - /* Choose heal spell if possible */ - if (heal_num) return (heal[rand_int(heal_num)]); + if (!heal.empty()) return heal[rand_int(heal.size())]; } /* Player is close and we have attack spells, blink away */ - if ((distance(p_ptr->py, p_ptr->px, m_ptr->fy, m_ptr->fx) < 4) && attack_num && (rand_int(100) < 75)) + if ((distance(p_ptr->py, p_ptr->px, m_ptr->fy, m_ptr->fx) < 4) && !attack.empty() && (rand_int(100) < 75)) { - /* Choose tactical spell */ - if (tactic_num) return (tactic[rand_int(tactic_num)]); + if (!tactic.empty()) return tactic[rand_int(tactic.size())]; } /* We're hurt (not badly), try to heal */ if ((m_ptr->hp < m_ptr->maxhp * 3 / 4) && (rand_int(100) < 75)) { - /* Choose heal spell if possible */ - if (heal_num) return (heal[rand_int(heal_num)]); + if (!heal.empty()) return heal[rand_int(heal.size())]; } /* Summon if possible (sometimes) */ - if (summon_num && (rand_int(100) < 50)) + if (!summon.empty() && (rand_int(100) < 50)) { - /* Choose summon spell */ - return (summon[rand_int(summon_num)]); + return summon[rand_int(summon.size())]; } /* Attack spell (most of the time) */ - if (attack_num && (rand_int(100) < 85)) + if (!attack.empty() && (rand_int(100) < 85)) { - /* Choose attack spell */ - return (attack[rand_int(attack_num)]); + return attack[rand_int(attack.size())]; } /* Try another tactical spell (sometimes) */ - if (tactic_num && (rand_int(100) < 50)) + if (!tactic.empty() && (rand_int(100) < 50)) { - /* Choose tactic spell */ - return (tactic[rand_int(tactic_num)]); + return tactic[rand_int(tactic.size())]; } /* Haste self if we aren't already somewhat hasted (rarely) */ - if (haste_num && (rand_int(100) < (20 + m_ptr->speed - m_ptr->mspeed))) + if (!haste.empty() && (rand_int(100) < (20 + m_ptr->speed - m_ptr->mspeed))) { - /* Choose haste spell */ - return (haste[rand_int(haste_num)]); + return haste[rand_int(haste.size())]; } /* Annoy player (most of the time) */ - if (annoy_num && (rand_int(100) < 85)) + if (!annoy.empty() && (rand_int(100) < 85)) { - /* Choose annoyance spell */ - return (annoy[rand_int(annoy_num)]); + return annoy[rand_int(annoy.size())]; } /* Choose no spell */ - return (0); + return nullptr; } @@ -981,6 +944,24 @@ void cmonster_msg(char a, cptr fmt, ...) } } +/** + * Extract list of spell indexes from a flag set. + */ +static std::vector extract_spells(monster_spell_flag_set const &spell_flag_set) +{ + auto result = std::vector(); + result.reserve(spell_flag_set.nbits); + + for (std::size_t k = 0; k < monster_spell_flag_set::nbits; k++) + { + if (spell_flag_set.bit(k)) + { + result.push_back(monster_spells()[k]); + } + } + + return result; +} /* * Monster tries to 'cast a spell' (or breath, etc) @@ -989,15 +970,14 @@ void cmonster_msg(char a, cptr fmt, ...) int monst_spell_monst_spell = -1; static bool_ monst_spell_monst(int m_idx) { + static const monster_spell_flag_set SF_INT_MASK = compute_smart_mask(); + int y = 0, x = 0; int i = 1; - int thrown_spell; - byte spell[96], num = 0; char m_name[80], t_name[80]; char m_poss[80]; char ddesc[80]; monster_type *m_ptr = &m_list[m_idx]; /* Attacker */ - u32b f4, f5, f6; /* racial spell flags */ bool_ direct = TRUE; bool_ wake_up = FALSE; @@ -1059,10 +1039,8 @@ static bool_ monst_spell_monst(int m_idx) /* Extract the monster level */ const int rlev = ((m_ptr->level >= 1) ? m_ptr->level : 1); - /* Extract the racial spell flags */ - f4 = r_ptr->flags4; - f5 = r_ptr->flags5; - f6 = r_ptr->flags6; + /* Which spells are allowed? */ + monster_spell_flag_set allowed_spells = r_ptr->spells; /* Hack -- allow "desperate" spells */ if ((r_ptr->flags2 & RF2_SMART) && @@ -1070,34 +1048,17 @@ static bool_ monst_spell_monst(int m_idx) (rand_int(100) < 50)) { /* Require intelligent spells */ - f4 &= RF4_INT_MASK; - f5 &= RF5_INT_MASK; - f6 &= RF6_INT_MASK; - - /* No spells left */ - if ((!f4 && !f5 && !f6) && (monst_spell_monst_spell == -1)) return (FALSE); - } + allowed_spells &= SF_INT_MASK; - /* Extract the "inate" spells */ - for (int k = 0; k < 32; k++) - { - if (f4 & (1L << k)) spell[num++] = k + 32 * 3; - } - - /* Extract the "normal" spells */ - for (int k = 0; k < 32; k++) - { - if (f5 & (1L << k)) spell[num++] = k + 32 * 4; + /* No spells left? */ + if ((!allowed_spells) && (monst_spell_monst_spell == -1)) return (FALSE); } - /* Extract the "bizarre" spells */ - for (int k = 0; k < 32; k++) - { - if (f6 & (1L << k)) spell[num++] = k + 32 * 5; - } + /* Extract spells */ + auto spell = extract_spells(allowed_spells); - /* No spells left */ - if (!num) return (FALSE); + /* No spells left? */ + if (spell.empty()) return (FALSE); /* Stop if player is dead or gone */ if (!alive || death) return (FALSE); @@ -1118,12 +1079,12 @@ static bool_ monst_spell_monst(int m_idx) monster_desc(ddesc, m_ptr, 0x88); /* Choose a spell to cast */ - thrown_spell = spell[rand_int(num)]; + auto thrown_spell = spell[rand_int(spell.size())]; /* Force a spell ? */ if (monst_spell_monst_spell > -1) { - thrown_spell = monst_spell_monst_spell; + thrown_spell = spell[monst_spell_monst_spell]; monst_spell_monst_spell = -1; } @@ -1133,10 +1094,9 @@ static bool_ monst_spell_monst(int m_idx) see_both = (see_m && see_t); int count = 0; - switch (thrown_spell) + switch (thrown_spell->spell_idx) { - /* RF4_SHRIEK */ - case 96 + 0: + case SF_SHRIEK_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1146,14 +1106,12 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_MULTIPLY */ - case 96 + 1: + case SF_MULTIPLY_IDX: { break; } - /* RF4_S_ANIMAL */ - case 96 + 2: + case SF_S_ANIMAL_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1169,8 +1127,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_ROCKET */ - case 96 + 3: + case SF_ROCKET_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear an explosion!"); @@ -1181,8 +1138,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_ARROW_1 */ - case 96 + 4: + case SF_ARROW_1_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear a strange noise."); @@ -1193,8 +1149,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_ARROW_2 */ - case 96 + 5: + case SF_ARROW_2_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear a strange noise."); @@ -1205,8 +1160,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_ARROW_3 */ - case 96 + 6: + case SF_ARROW_3_IDX: { if (disturb_other) disturb(1); @@ -1218,8 +1172,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_ARROW_4 */ - case 96 + 7: + case SF_ARROW_4_IDX: { if (!see_either) monster_msg("You hear a strange noise."); else if (disturb_other) disturb(1); @@ -1230,8 +1183,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_ACID */ - case 96 + 8: + case SF_BR_ACID_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1243,8 +1195,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_ELEC */ - case 96 + 9: + case SF_BR_ELEC_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1256,8 +1207,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_FIRE */ - case 96 + 10: + case SF_BR_FIRE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1269,8 +1219,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_COLD */ - case 96 + 11: + case SF_BR_COLD_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1282,8 +1231,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_POIS */ - case 96 + 12: + case SF_BR_POIS_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1295,8 +1243,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_NETH */ - case 96 + 13: + case SF_BR_NETH_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1308,8 +1255,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_LITE */ - case 96 + 14: + case SF_BR_LITE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1321,8 +1267,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_DARK */ - case 96 + 15: + case SF_BR_DARK_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1334,8 +1279,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_CONF */ - case 96 + 16: + case SF_BR_CONF_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1347,8 +1291,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_SOUN */ - case 96 + 17: + case SF_BR_SOUN_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1360,8 +1303,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_CHAO */ - case 96 + 18: + case SF_BR_CHAO_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1373,8 +1315,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_DISE */ - case 96 + 19: + case SF_BR_DISE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1386,8 +1327,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_NEXU */ - case 96 + 20: + case SF_BR_NEXU_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1399,8 +1339,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_TIME */ - case 96 + 21: + case SF_BR_TIME_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1412,8 +1351,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_INER */ - case 96 + 22: + case SF_BR_INER_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1425,8 +1363,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_GRAV */ - case 96 + 23: + case SF_BR_GRAV_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1438,8 +1375,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_SHAR */ - case 96 + 24: + case SF_BR_SHAR_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1451,8 +1387,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_PLAS */ - case 96 + 25: + case SF_BR_PLAS_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1464,8 +1399,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_WALL */ - case 96 + 26: + case SF_BR_WALL_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1477,8 +1411,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_MANA */ - case 96 + 27: + case SF_BR_MANA_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1490,8 +1423,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BA_NUKE */ - case 96 + 28: + case SF_BA_NUKE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear someone mumble."); @@ -1503,8 +1435,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_NUKE */ - case 96 + 29: + case SF_BR_NUKE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1516,8 +1447,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BA_CHAO */ - case 96 + 30: + case SF_BA_CHAO_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear someone mumble frighteningly."); @@ -1529,8 +1459,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF4_BR_DISI -> Breathe Disintegration */ - case 96 + 31: + case SF_BR_DISI_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear breathing noise."); @@ -1542,8 +1471,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_ACID */ - case 128 + 0: + case SF_BA_ACID_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1553,8 +1481,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_ELEC */ - case 128 + 1: + case SF_BA_ELEC_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1565,8 +1492,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_FIRE */ - case 128 + 2: + case SF_BA_FIRE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1577,8 +1503,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_COLD */ - case 128 + 3: + case SF_BA_COLD_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1589,8 +1514,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_POIS */ - case 128 + 4: + case SF_BA_POIS_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1601,8 +1525,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_NETH */ - case 128 + 5: + case SF_BA_NETH_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1613,8 +1536,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_WATE */ - case 128 + 6: + case SF_BA_WATE_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble."); @@ -1626,8 +1548,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_MANA */ - case 128 + 7: + case SF_BA_MANA_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble powerfully."); @@ -1638,8 +1559,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BA_DARK */ - case 128 + 8: + case SF_BA_DARK_IDX: { if (disturb_other) disturb(1); if (!see_either) monster_msg ("You hear someone mumble powerfully."); @@ -1650,8 +1570,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_DRAIN_MANA */ - case 128 + 9: + case SF_DRAIN_MANA_IDX: { /* Attack power */ int r1 = (randint(rlev) / 2) + 1; @@ -1665,7 +1584,7 @@ static bool_ monst_spell_monst(int m_idx) /* Heal the monster */ if (m_ptr->hp < m_ptr->maxhp) { - if (!(tr_ptr->flags4 || tr_ptr->flags5 || tr_ptr->flags6)) + if (!tr_ptr->spells) { if (see_both) monster_msg("%^s is unaffected!", t_name); @@ -1691,8 +1610,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_MIND_BLAST */ - case 128 + 10: + case SF_MIND_BLAST_IDX: { if (!direct) break; @@ -1731,8 +1649,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BRAIN_SMASH */ - case 128 + 11: + case SF_BRAIN_SMASH_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1772,8 +1689,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_CAUSE_1 */ - case 128 + 12: + case SF_CAUSE_1_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1793,8 +1709,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_CAUSE_2 */ - case 128 + 13: + case SF_CAUSE_2_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1813,8 +1728,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_CAUSE_3 */ - case 128 + 14: + case SF_CAUSE_3_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1833,8 +1747,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_CAUSE_4 */ - case 128 + 15: + case SF_CAUSE_4_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1853,8 +1766,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_ACID */ - case 128 + 16: + case SF_BO_ACID_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1864,8 +1776,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_ELEC */ - case 128 + 17: + case SF_BO_ELEC_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1875,8 +1786,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_FIRE */ - case 128 + 18: + case SF_BO_FIRE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1886,8 +1796,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_COLD */ - case 128 + 19: + case SF_BO_COLD_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1897,15 +1806,13 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_POIS */ - case 128 + 20: + case SF_BO_POIS_IDX: { /* XXX XXX XXX */ break; } - /* RF5_BO_NETH */ - case 128 + 21: + case SF_BO_NETH_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1915,8 +1822,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_WATE */ - case 128 + 22: + case SF_BO_WATE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1926,8 +1832,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_MANA */ - case 128 + 23: + case SF_BO_MANA_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1937,8 +1842,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_PLAS */ - case 128 + 24: + case SF_BO_PLAS_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1948,8 +1852,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BO_ICEE */ - case 128 + 25: + case SF_BO_ICEE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1959,8 +1862,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_MISSILE */ - case 128 + 26: + case SF_MISSILE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -1970,8 +1872,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_SCARE */ - case 128 + 27: + case SF_SCARE_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -1994,8 +1895,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_BLIND */ - case 128 + 28: + case SF_BLIND_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2020,8 +1920,7 @@ static bool_ monst_spell_monst(int m_idx) } - /* RF5_CONF */ - case 128 + 29: + case SF_CONF_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2044,8 +1943,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_SLOW */ - case 128 + 30: + case SF_SLOW_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2068,8 +1966,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF5_HOLD */ - case 128 + 31: + case SF_HOLD_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2092,9 +1989,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - - /* RF6_HASTE */ - case 160 + 0: + case SF_HASTE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) @@ -2123,8 +2018,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_HAND_DOOM */ - case 160 + 1: + case SF_HAND_DOOM_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2155,8 +2049,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_HEAL */ - case 160 + 2: + case SF_HEAL_IDX: { if (disturb_other) disturb(1); @@ -2220,8 +2113,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_ANIMALS */ - case 160 + 3: + case SF_S_ANIMALS_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2237,8 +2129,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_BLINK */ - case 160 + 4: + case SF_BLINK_IDX: { if (disturb_other) disturb(1); if (see_m) monster_msg("%^s blinks away.", m_name); @@ -2246,8 +2137,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_TPORT */ - case 160 + 5: + case SF_TPORT_IDX: { if (dungeon_flags & DF_NO_TELEPORT) break; /* No teleport on special levels */ else @@ -2259,15 +2149,13 @@ static bool_ monst_spell_monst(int m_idx) } } - /* RF6_TELE_TO */ - case 160 + 6: + case SF_TELE_TO_IDX: { /* Not implemented */ break; } - /* RF6_TELE_AWAY */ - case 160 + 7: + case SF_TELE_AWAY_IDX: { if (dungeon_flags & DF_NO_TELEPORT) break; @@ -2308,15 +2196,13 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_TELE_LEVEL */ - case 160 + 8: + case SF_TELE_LEVEL_IDX: { /* Not implemented */ break; } - /* RF6_DARKNESS */ - case 160 + 9: + case SF_DARKNESS_IDX: { if (!direct) break; if (disturb_other) disturb(1); @@ -2330,22 +2216,19 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_TRAPS */ - case 160 + 10: + case SF_TRAPS_IDX: { /* Not implemented */ break; } - /* RF6_FORGET */ - case 160 + 11: + case SF_FORGET_IDX: { /* Not implemented */ break; } - /* RF6_S_BUG */ - case 160 + 13: + case SF_S_BUG_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2361,8 +2244,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_RNG */ - case 160 + 14: + case SF_S_RNG_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2378,9 +2260,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - - /* RF6_S_THUNDERLORD */ - case 160 + 15: + case SF_S_THUNDERLORD_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2396,8 +2276,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_SUMMON_KIN */ - case 160 + 16: + case SF_S_KIN_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2419,8 +2298,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_HI_DEMON */ - case 160 + 17: + case SF_S_HI_DEMON_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2433,8 +2311,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_MONSTER */ - case 160 + 18: + case SF_S_MONSTER_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2450,8 +2327,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_MONSTERS */ - case 160 + 19: + case SF_S_MONSTERS_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2467,8 +2343,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_ANT */ - case 160 + 20: + case SF_S_ANT_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2484,8 +2359,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_SPIDER */ - case 160 + 21: + case SF_S_SPIDER_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2501,8 +2375,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_HOUND */ - case 160 + 22: + case SF_S_HOUND_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2518,8 +2391,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_HYDRA */ - case 160 + 23: + case SF_S_HYDRA_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2535,8 +2407,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_ANGEL */ - case 160 + 24: + case SF_S_ANGEL_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2552,8 +2423,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_DEMON */ - case 160 + 25: + case SF_S_DEMON_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2569,8 +2439,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_UNDEAD */ - case 160 + 26: + case SF_S_UNDEAD_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2586,8 +2455,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_DRAGON */ - case 160 + 27: + case SF_S_DRAGON_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2603,8 +2471,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_HI_UNDEAD */ - case 160 + 28: + case SF_S_HI_UNDEAD_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2623,8 +2490,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_HI_DRAGON */ - case 160 + 29: + case SF_S_HI_DRAGON_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2643,8 +2509,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_WRAITH */ - case 160 + 30: + case SF_S_WRAITH_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2663,8 +2528,7 @@ static bool_ monst_spell_monst(int m_idx) break; } - /* RF6_S_UNIQUE */ - case 160 + 31: + case SF_S_UNIQUE_IDX: { if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); @@ -2860,9 +2724,12 @@ void curse_equipment_dg(int chance, int heavy_chance) */ static bool_ make_attack_spell(int m_idx) { - int k, chance, thrown_spell, rlev, failrate; - byte spell[96], num = 0; - u32b f4, f5, f6; + static const auto SF_BOLT_MASK = compute_bolt_mask(); + static const auto SF_SUMMON_MASK = compute_summoning_mask(); + static const auto SF_INT_MASK = compute_smart_mask(); + static const auto SF_INNATE_MASK = compute_innate_mask(); + + int k, chance, rlev, failrate; char m_name[80]; bool_ no_inate = FALSE; int x, y; @@ -2934,12 +2801,13 @@ static bool_ make_attack_spell(int m_idx) rlev = ((m_ptr->level >= 1) ? m_ptr->level : 1); /* Extract the racial spell flags */ - f4 = r_ptr->flags4; - f5 = r_ptr->flags5; - f6 = r_ptr->flags6; + monster_spell_flag_set allowed_spells = r_ptr->spells; /* Forbid inate attacks sometimes */ - if (no_inate) f4 = 0L; + if (no_inate) + { + allowed_spells &= ~SF_INNATE_MASK; + } /* Hack -- allow "desperate" spells */ if ((r_ptr->flags2 & RF2_SMART) && @@ -2947,67 +2815,44 @@ static bool_ make_attack_spell(int m_idx) (rand_int(100) < 50)) { /* Require intelligent spells */ - f4 &= RF4_INT_MASK; - f5 &= RF5_INT_MASK; - f6 &= RF6_INT_MASK; + allowed_spells &= SF_INT_MASK; - /* No spells left */ - if (!f4 && !f5 && !f6) return (FALSE); + /* No spells left? */ + if (!allowed_spells) return (FALSE); } /* Remove the "ineffective" spells */ - remove_bad_spells(m_idx, &f4, &f5, &f6); + remove_bad_spells(m_idx, &allowed_spells); /* No spells left */ - if (!f4 && !f5 && !f6) return (FALSE); + if (!allowed_spells) return (FALSE); /* Check for a clean bolt shot */ - if ((f4&RF4_BOLT_MASK || f5 & RF5_BOLT_MASK || - f6&RF6_BOLT_MASK) && + if ((allowed_spells & SF_BOLT_MASK) && !(r_ptr->flags2 & RF2_STUPID) && !clean_shot(m_ptr->fy, m_ptr->fx, y, x)) { /* Remove spells that will only hurt friends */ - f4 &= ~RF4_BOLT_MASK; - f5 &= ~RF5_BOLT_MASK; - f6 &= ~RF6_BOLT_MASK; + allowed_spells &= ~SF_BOLT_MASK; } /* Check for a possible summon */ - if ((f4 & RF4_SUMMON_MASK || f5 & RF5_SUMMON_MASK || - f6 & RF6_SUMMON_MASK) && + if ((allowed_spells & SF_SUMMON_MASK) && !(r_ptr->flags2 & RF2_STUPID) && !(summon_possible(y, x))) { /* Remove summoning spells */ - f4 &= ~RF4_SUMMON_MASK; - f5 &= ~RF5_SUMMON_MASK; - f6 &= ~RF6_SUMMON_MASK; + allowed_spells &= ~SF_SUMMON_MASK; } /* No spells left */ - if (!f4 && !f5 && !f6) return (FALSE); + if (!allowed_spells) return (FALSE); /* Extract the "inate" spells */ - for (k = 0; k < 32; k++) - { - if (f4 & (1L << k)) spell[num++] = k + 32 * 3; - } - - /* Extract the "normal" spells */ - for (k = 0; k < 32; k++) - { - if (f5 & (1L << k)) spell[num++] = k + 32 * 4; - } - - /* Extract the "bizarre" spells */ - for (k = 0; k < 32; k++) - { - if (f6 & (1L << k)) spell[num++] = k + 32 * 5; - } + auto spell = extract_spells(allowed_spells); /* No spells left */ - if (!num) return (FALSE); + if (spell.empty()) return (FALSE); /* Stop if player is dead or gone */ if (!alive || death) return (FALSE); @@ -3019,7 +2864,7 @@ static bool_ make_attack_spell(int m_idx) monster_desc(m_name, m_ptr, 0x00); /* Choose a spell to cast */ - thrown_spell = choose_attack_spell(m_idx, spell, num); + auto thrown_spell = choose_attack_spell(m_idx, spell); /* Abort if no spell was chosen */ if (!thrown_spell) return (FALSE); @@ -3031,7 +2876,7 @@ static bool_ make_attack_spell(int m_idx) if (r_ptr->flags2 & RF2_STUPID) failrate = 0; /* Check for spell failure (inate attacks never fail) */ - if ((thrown_spell >= 128) && (rand_int(100) < failrate)) + if ((!thrown_spell->is_innate) && (rand_int(100) < failrate)) { /* Message */ msg_format("%^s tries to cast a spell, but fails.", m_name); @@ -3040,7 +2885,7 @@ static bool_ make_attack_spell(int m_idx) } /* Can the player disrupt its puny attempts? */ - if ((p_ptr->antimagic_dis >= m_ptr->cdis) && (magik(p_ptr->antimagic)) && (thrown_spell >= 128)) + if ((p_ptr->antimagic_dis >= m_ptr->cdis) && magik(p_ptr->antimagic) && thrown_spell->is_magic) { char m_poss[80]; @@ -3061,10 +2906,9 @@ static bool_ make_attack_spell(int m_idx) monster_desc(ddesc, m_ptr, 0x88); /* Cast the spell. */ - switch (thrown_spell) + switch (thrown_spell->spell_idx) { - /* RF4_SHRIEK */ - case 96 + 0: + case SF_SHRIEK_IDX: { disturb(1); msg_format("%^s makes a high pitched shriek.", m_name); @@ -3072,14 +2916,12 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_MULTIPLY */ - case 96 + 1: + case SF_MULTIPLY_IDX: { break; } - /* RF4_S_ANIMAL */ - case 96 + 2: + case SF_S_ANIMAL_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3092,8 +2934,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_ROCKET */ - case 96 + 3: + case SF_ROCKET_IDX: { disturb(1); if (blind) msg_format("%^s shoots something.", m_name); @@ -3104,8 +2945,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_ARROW_1 */ - case 96 + 4: + case SF_ARROW_1_IDX: { disturb(1); if (blind) msg_format("%^s makes a strange noise.", m_name); @@ -3115,8 +2955,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_ARROW_2 */ - case 96 + 5: + case SF_ARROW_2_IDX: { disturb(1); if (blind) msg_format("%^s makes a strange noise.", m_name); @@ -3126,8 +2965,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_ARROW_3 */ - case 96 + 6: + case SF_ARROW_3_IDX: { disturb(1); if (blind) msg_format("%^s makes a strange noise.", m_name); @@ -3137,8 +2975,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_ARROW_4 */ - case 96 + 7: + case SF_ARROW_4_IDX: { disturb(1); if (blind) msg_format("%^s makes a strange noise.", m_name); @@ -3148,8 +2985,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_ACID */ - case 96 + 8: + case SF_BR_ACID_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3160,8 +2996,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_ELEC */ - case 96 + 9: + case SF_BR_ELEC_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3172,8 +3007,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_FIRE */ - case 96 + 10: + case SF_BR_FIRE_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3184,8 +3018,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_COLD */ - case 96 + 11: + case SF_BR_COLD_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3196,8 +3029,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_POIS */ - case 96 + 12: + case SF_BR_POIS_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3208,9 +3040,7 @@ static bool_ make_attack_spell(int m_idx) break; } - - /* RF4_BR_NETH */ - case 96 + 13: + case SF_BR_NETH_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3221,8 +3051,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_LITE */ - case 96 + 14: + case SF_BR_LITE_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3233,8 +3062,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_DARK */ - case 96 + 15: + case SF_BR_DARK_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3245,8 +3073,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_CONF */ - case 96 + 16: + case SF_BR_CONF_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3257,8 +3084,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_SOUN */ - case 96 + 17: + case SF_BR_SOUN_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3269,8 +3095,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_CHAO */ - case 96 + 18: + case SF_BR_CHAO_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3281,8 +3106,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_DISE */ - case 96 + 19: + case SF_BR_DISE_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3293,8 +3117,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_NEXU */ - case 96 + 20: + case SF_BR_NEXU_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3305,8 +3128,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_TIME */ - case 96 + 21: + case SF_BR_TIME_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3316,8 +3138,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_INER */ - case 96 + 22: + case SF_BR_INER_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3327,8 +3148,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_GRAV */ - case 96 + 23: + case SF_BR_GRAV_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3338,8 +3158,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_SHAR */ - case 96 + 24: + case SF_BR_SHAR_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3350,8 +3169,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_PLAS */ - case 96 + 25: + case SF_BR_PLAS_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3361,8 +3179,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_WALL */ - case 96 + 26: + case SF_BR_WALL_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3372,8 +3189,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_MANA */ - case 96 + 27: + case SF_BR_MANA_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3383,8 +3199,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BA_NUKE */ - case 96 + 28: + case SF_BA_NUKE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3394,8 +3209,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_NUKE */ - case 96 + 29: + case SF_BR_NUKE_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3406,8 +3220,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BA_CHAO */ - case 96 + 30: + case SF_BA_CHAO_IDX: { disturb(1); if (blind) msg_format("%^s mumbles frighteningly.", m_name); @@ -3417,8 +3230,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF4_BR_DISI -> Disintegration breath! */ - case 96 + 31: + case SF_BR_DISI_IDX: { disturb(1); if (blind) msg_format("%^s breathes.", m_name); @@ -3428,10 +3240,7 @@ static bool_ make_attack_spell(int m_idx) break; } - - - /* RF5_BA_ACID */ - case 128 + 0: + case SF_BA_ACID_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3442,8 +3251,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_ELEC */ - case 128 + 1: + case SF_BA_ELEC_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3454,8 +3262,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_FIRE */ - case 128 + 2: + case SF_BA_FIRE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3466,8 +3273,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_COLD */ - case 128 + 3: + case SF_BA_COLD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3478,8 +3284,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_POIS */ - case 128 + 4: + case SF_BA_POIS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3490,8 +3295,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_NETH */ - case 128 + 5: + case SF_BA_NETH_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3502,8 +3306,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_WATE */ - case 128 + 6: + case SF_BA_WATE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3514,8 +3317,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_MANA */ - case 128 + 7: + case SF_BA_MANA_IDX: { disturb(1); if (blind) msg_format("%^s mumbles powerfully.", m_name); @@ -3525,8 +3327,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BA_DARK */ - case 128 + 8: + case SF_BA_DARK_IDX: { disturb(1); if (blind) msg_format("%^s mumbles powerfully.", m_name); @@ -3537,8 +3338,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_DRAIN_MANA */ - case 128 + 9: + case SF_DRAIN_MANA_IDX: { if (p_ptr->csp) { @@ -3594,8 +3394,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_MIND_BLAST */ - case 128 + 10: + case SF_MIND_BLAST_IDX: { disturb(1); if (!seen) @@ -3630,8 +3429,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BRAIN_SMASH */ - case 128 + 11: + case SF_BRAIN_SMASH_IDX: { disturb(1); if (!seen) @@ -3678,8 +3476,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_CAUSE_1 */ - case 128 + 12: + case SF_CAUSE_1_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3696,8 +3493,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_CAUSE_2 */ - case 128 + 13: + case SF_CAUSE_2_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3714,8 +3510,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_CAUSE_3 */ - case 128 + 14: + case SF_CAUSE_3_IDX: { disturb(1); if (blind) msg_format("%^s mumbles loudly.", m_name); @@ -3732,8 +3527,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_CAUSE_4 */ - case 128 + 15: + case SF_CAUSE_4_IDX: { disturb(1); if (blind) msg_format("%^s screams the word 'DIE!'", m_name); @@ -3750,8 +3544,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_ACID */ - case 128 + 16: + case SF_BO_ACID_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3762,8 +3555,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_ELEC */ - case 128 + 17: + case SF_BO_ELEC_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3774,8 +3566,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_FIRE */ - case 128 + 18: + case SF_BO_FIRE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3786,8 +3577,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_COLD */ - case 128 + 19: + case SF_BO_COLD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3798,15 +3588,13 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_POIS */ - case 128 + 20: + case SF_BO_POIS_IDX: { /* XXX XXX XXX */ break; } - /* RF5_BO_NETH */ - case 128 + 21: + case SF_BO_NETH_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3817,8 +3605,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_WATE */ - case 128 + 22: + case SF_BO_WATE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3828,8 +3615,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_MANA */ - case 128 + 23: + case SF_BO_MANA_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3839,8 +3625,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_PLAS */ - case 128 + 24: + case SF_BO_PLAS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3850,8 +3635,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BO_ICEE */ - case 128 + 25: + case SF_BO_ICEE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3862,8 +3646,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_MISSILE */ - case 128 + 26: + case SF_MISSILE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3873,8 +3656,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_SCARE */ - case 128 + 27: + case SF_SCARE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles, and you hear scary noises.", m_name); @@ -3895,8 +3677,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_BLIND */ - case 128 + 28: + case SF_BLIND_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3917,8 +3698,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_CONF */ - case 128 + 29: + case SF_CONF_IDX: { disturb(1); if (blind) msg_format("%^s mumbles, and you hear puzzling noises.", m_name); @@ -3939,8 +3719,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_SLOW */ - case 128 + 30: + case SF_SLOW_IDX: { disturb(1); msg_format("%^s drains power from your muscles!", m_name); @@ -3960,8 +3739,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF5_HOLD */ - case 128 + 31: + case SF_HOLD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -3982,10 +3760,7 @@ static bool_ make_attack_spell(int m_idx) break; } - - - /* RF6_HASTE */ - case 160 + 0: + case SF_HASTE_IDX: { disturb(1); if (blind) @@ -4014,8 +3789,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_HAND_DOOM */ - case 160 + 1: + case SF_HAND_DOOM_IDX: { disturb(1); msg_format("%^s invokes the Hand of Doom!", m_name); @@ -4035,8 +3809,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_HEAL */ - case 160 + 2: + case SF_HEAL_IDX: { disturb(1); @@ -4099,8 +3872,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_ANIMALS */ - case 160 + 3: + case SF_S_ANIMALS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4113,8 +3885,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_BLINK */ - case 160 + 4: + case SF_BLINK_IDX: { disturb(1); msg_format("%^s blinks away.", m_name); @@ -4122,8 +3893,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_TPORT */ - case 160 + 5: + case SF_TPORT_IDX: { disturb(1); msg_format("%^s teleports away.", m_name); @@ -4131,8 +3901,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_TELE_TO */ - case 160 + 6: + case SF_TELE_TO_IDX: { disturb(1); msg_format("%^s commands you to return.", m_name); @@ -4140,8 +3909,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_TELE_AWAY */ - case 160 + 7: + case SF_TELE_AWAY_IDX: { disturb(1); msg_format("%^s teleports you away.", m_name); @@ -4149,8 +3917,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_TELE_LEVEL */ - case 160 + 8: + case SF_TELE_LEVEL_IDX: { disturb(1); if (blind) msg_format("%^s mumbles strangely.", m_name); @@ -4171,8 +3938,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_DARKNESS */ - case 160 + 9: + case SF_DARKNESS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4181,8 +3947,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_TRAPS */ - case 160 + 10: + case SF_TRAPS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles, and then cackles evilly.", m_name); @@ -4191,8 +3956,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_FORGET */ - case 160 + 11: + case SF_FORGET_IDX: { disturb(1); msg_format("%^s tries to blank your mind.", m_name); @@ -4208,8 +3972,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_BUG */ - case 160 + 13: + case SF_S_BUG_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4222,8 +3985,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_RNG */ - case 160 + 14: + case SF_S_RNG_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4236,8 +3998,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_THUNDERLORD */ - case 160 + 15: + case SF_S_THUNDERLORD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4250,8 +4011,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_SUMMON_KIN */ - case 160 + 16: + case SF_S_KIN_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4270,8 +4030,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_HI_DEMON */ - case 160 + 17: + case SF_S_HI_DEMON_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4281,8 +4040,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_MONSTER */ - case 160 + 18: + case SF_S_MONSTER_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4295,8 +4053,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_MONSTERS */ - case 160 + 19: + case SF_S_MONSTERS_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4309,8 +4066,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_ANT */ - case 160 + 20: + case SF_S_ANT_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4323,8 +4079,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_SPIDER */ - case 160 + 21: + case SF_S_SPIDER_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4337,8 +4092,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_HOUND */ - case 160 + 22: + case SF_S_HOUND_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4351,8 +4105,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_HYDRA */ - case 160 + 23: + case SF_S_HYDRA_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4365,8 +4118,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_ANGEL */ - case 160 + 24: + case SF_S_ANGEL_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4379,8 +4131,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_DEMON */ - case 160 + 25: + case SF_S_DEMON_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4393,8 +4144,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_UNDEAD */ - case 160 + 26: + case SF_S_UNDEAD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4407,8 +4157,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_DRAGON */ - case 160 + 27: + case SF_S_DRAGON_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4421,8 +4170,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_HI_UNDEAD */ - case 160 + 28: + case SF_S_HI_UNDEAD_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4438,8 +4186,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_HI_DRAGON */ - case 160 + 29: + case SF_S_HI_DRAGON_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4455,8 +4202,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_WRAITH */ - case 160 + 30: + case SF_S_WRAITH_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -4475,8 +4221,7 @@ static bool_ make_attack_spell(int m_idx) break; } - /* RF6_S_UNIQUE */ - case 160 + 31: + case SF_S_UNIQUE_IDX: { disturb(1); if (blind) msg_format("%^s mumbles.", m_name); @@ -6188,7 +5933,7 @@ static void process_monster(int m_idx, bool_ is_frien) ox = m_ptr->fx; /* Attempt to "multiply" if able and allowed */ - if ((r_ptr->flags4 & RF4_MULTIPLY) && (num_repro < MAX_REPRO)) + if ((r_ptr->spells & SF_MULTIPLY) && (num_repro < MAX_REPRO)) { if (ai_multiply(m_idx)) return; } -- cgit v1.2.3 From 68e2a10b2d76cb3a2f5aa6818b4b184b6a02ef14 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Rework RF{1,2,3,7,8,9}_* monster flags to use flag_set<> --- src/melee2.cc | 219 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 108 insertions(+), 111 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 3e03c8f6..9d09fb67 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -28,6 +28,7 @@ #include "monster2.hpp" #include "monster3.hpp" #include "monster_race.hpp" +#include "monster_race_flag.hpp" #include "monster_spell.hpp" #include "monster_spell_flag.hpp" #include "monster_type.hpp" @@ -69,7 +70,7 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) /* Some monsters are immune to death */ auto const r_ptr = m_ptr->race(); - if (r_ptr->flags7 & RF7_NO_DEATH) return FALSE; + if (r_ptr->flags & RF_NO_DEATH) return FALSE; /* Wake it up */ m_ptr->csleep = 0; @@ -80,7 +81,7 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) /* It is dead now... or is it? */ if (m_ptr->hp < 0) { - if (((r_ptr->flags1 & RF1_UNIQUE) && (m_ptr->status <= MSTATUS_NEUTRAL_P)) || + if (((r_ptr->flags & RF_UNIQUE) && (m_ptr->status <= MSTATUS_NEUTRAL_P)) || (m_ptr->mflag & MFLAG_QUEST)) { m_ptr->hp = 1; @@ -96,10 +97,10 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) monster_desc(m_name, m_ptr, 0); /* Make a sound */ - if ((r_ptr->flags3 & RF3_DEMON) || - (r_ptr->flags3 & RF3_UNDEAD) || - (r_ptr->flags2 & RF2_STUPID) || - (r_ptr->flags3 & RF3_NONLIVING) || + if ((r_ptr->flags & RF_DEMON) || + (r_ptr->flags & RF_UNDEAD) || + (r_ptr->flags & RF_STUPID) || + (r_ptr->flags & RF_NONLIVING) || (strchr("Evg", r_ptr->d_char))) { sound(SOUND_N_KILL); @@ -120,10 +121,10 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) /* Do nothing */ } /* Death by Physical attack -- non-living monster */ - else if ((r_ptr->flags3 & RF3_DEMON) || - (r_ptr->flags3 & RF3_UNDEAD) || - (r_ptr->flags2 & RF2_STUPID) || - (r_ptr->flags3 & RF3_NONLIVING) || + else if ((r_ptr->flags & RF_DEMON) || + (r_ptr->flags & RF_UNDEAD) || + (r_ptr->flags & RF_STUPID) || + (r_ptr->flags & RF_NONLIVING) || (strchr("Evg", r_ptr->d_char))) { cmonster_msg(TERM_L_RED, "%^s is destroyed.", m_name); @@ -174,7 +175,7 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) } /* When an Unique dies, it stays dead */ - if (r_ptr->flags1 & RF1_UNIQUE) + if (r_ptr->flags & RF_UNIQUE) { r_ptr->max_num = 0; } @@ -231,7 +232,7 @@ void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear) /* Sometimes a monster gets scared by damage */ auto const r_ptr = m_ptr->race(); - if (!m_ptr->monfear && !(r_ptr->flags3 & RF3_NO_FEAR)) + if (!m_ptr->monfear && !(r_ptr->flags & RF_NO_FEAR)) { int percentage; @@ -292,7 +293,7 @@ void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear) static bool_ int_outof(std::shared_ptr r_ptr, int prob) { /* Non-Smart monsters are half as "smart" */ - if (!(r_ptr->flags2 & RF2_SMART)) prob = prob / 2; + if (!(r_ptr->flags & RF_SMART)) prob = prob / 2; /* Roll the dice */ return (rand_int(100) < prob); @@ -313,7 +314,7 @@ static void remove_bad_spells(int m_idx, monster_spell_flag_set *spells_p) /* Too stupid to know anything? */ auto const r_ptr = m_ptr->race(); - if (r_ptr->flags2 & RF2_STUPID) return; + if (r_ptr->flags & RF_STUPID) return; /* Must be cheating or learning */ @@ -712,7 +713,7 @@ static monster_spell const *choose_attack_spell(int m_idx, std::vectorrace(); - if (r_ptr->flags2 & RF2_STUPID) + if (r_ptr->flags & RF_STUPID) { /* Pick at random */ return spells[rand_int(spells.size())]; @@ -847,7 +848,7 @@ static void breath(int m_idx, int typ, int dam_hp, int rad) auto const r_ptr = m_ptr->race(); /* Determine the radius of the blast */ - if (rad < 1) rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; + if (rad < 1) rad = (r_ptr->flags & RF_POWERFUL) ? 3 : 2; /* Target the player with a ball attack */ (void)project(m_idx, rad, p_ptr->py, p_ptr->px, dam_hp, typ, flg); @@ -867,7 +868,7 @@ static void monst_breath_monst(int m_idx, int y, int x, int typ, int dam_hp, int auto const r_ptr = m_ptr->race(); /* Determine the radius of the blast */ - if (rad < 1) rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; + if (rad < 1) rad = (r_ptr->flags & RF_POWERFUL) ? 3 : 2; (void)project(m_idx, rad, y, x, dam_hp, typ, flg); } @@ -1043,7 +1044,7 @@ static bool_ monst_spell_monst(int m_idx) monster_spell_flag_set allowed_spells = r_ptr->spells; /* Hack -- allow "desperate" spells */ - if ((r_ptr->flags2 & RF2_SMART) && + if ((r_ptr->flags & RF_SMART) && (m_ptr->hp < m_ptr->maxhp / 10) && (rand_int(100) < 50)) { @@ -1626,8 +1627,8 @@ static bool_ monst_spell_monst(int m_idx) } /* Attempt a saving throw */ - if ((tr_ptr->flags1 & RF1_UNIQUE) || - (tr_ptr->flags3 & RF3_NO_CONF) || + if ((tr_ptr->flags & RF_UNIQUE) || + (tr_ptr->flags & RF_NO_CONF) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { /* No obvious effect */ @@ -1663,8 +1664,8 @@ static bool_ monst_spell_monst(int m_idx) } /* Attempt a saving throw */ - if ((tr_ptr->flags1 & RF1_UNIQUE) || - (tr_ptr->flags3 & RF3_NO_CONF) || + if ((tr_ptr->flags & RF_UNIQUE) || + (tr_ptr->flags & RF_NO_CONF) || (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)) { /* No obvious effect */ @@ -1878,7 +1879,7 @@ static bool_ monst_spell_monst(int m_idx) if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles, and you hear scary noises.", m_name); else monster_msg("%^s casts a fearful illusion at %s.", m_name, t_name); - if (tr_ptr->flags3 & RF3_NO_FEAR) + if (tr_ptr->flags & RF_NO_FEAR) { if (see_t) monster_msg("%^s refuses to be frightened.", t_name); } @@ -1902,7 +1903,7 @@ static bool_ monst_spell_monst(int m_idx) if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a spell, burning %s%s eyes.", m_name, t_name, (!strcmp(t_name, "it") ? "s" : "'s")); - if (tr_ptr->flags3 & RF3_NO_CONF) /* Simulate blindness with confusion */ + if (tr_ptr->flags & RF_NO_CONF) /* Simulate blindness with confusion */ { if (see_t) monster_msg("%^s is unaffected.", t_name); } @@ -1926,7 +1927,7 @@ static bool_ monst_spell_monst(int m_idx) if (disturb_other) disturb(1); if (blind || !see_m) monster_msg("%^s mumbles, and you hear puzzling noises.", m_name); else monster_msg("%^s creates a mesmerising illusion in front of %s.", m_name, t_name); - if (tr_ptr->flags3 & RF3_NO_CONF) + if (tr_ptr->flags & RF_NO_CONF) { if (see_t) monster_msg("%^s disbelieves the feeble spell.", t_name); } @@ -1949,7 +1950,7 @@ static bool_ monst_spell_monst(int m_idx) if (disturb_other) disturb(1); if (!blind && see_either) monster_msg("%^s drains power from %s%s muscles.", m_name, t_name, (!strcmp(t_name, "it") ? "s" : "'s")); - if (tr_ptr->flags1 & RF1_UNIQUE) + if (tr_ptr->flags & RF_UNIQUE) { if (see_t) monster_msg("%^s is unaffected.", t_name); } @@ -1971,8 +1972,8 @@ static bool_ monst_spell_monst(int m_idx) if (!direct) break; if (disturb_other) disturb(1); if (!blind && see_m) monster_msg("%^s stares intently at %s.", m_name, t_name); - if ((tr_ptr->flags1 & RF1_UNIQUE) || - (tr_ptr->flags3 & RF3_NO_STUN)) + if ((tr_ptr->flags & RF_UNIQUE) || + (tr_ptr->flags & RF_NO_STUN)) { if (see_t) monster_msg("%^s is unaffected.", t_name); } @@ -2026,7 +2027,7 @@ static bool_ monst_spell_monst(int m_idx) else if (!blind) monster_msg("%^s invokes the Hand of Doom on %s.", m_name, t_name); else monster_msg ("You hear someone invoke the Hand of Doom!"); - if (tr_ptr->flags1 & RF1_UNIQUE) + if (tr_ptr->flags & RF_UNIQUE) { if (!blind && see_t) monster_msg("^%s is unaffected!", t_name); } @@ -2167,9 +2168,9 @@ static bool_ monst_spell_monst(int m_idx) monster_msg("%^s teleports %s away.", m_name, t_name); - if (tr_ptr->flags3 & RF3_RES_TELE) + if (tr_ptr->flags & RF_RES_TELE) { - if (tr_ptr->flags1 & RF1_UNIQUE) + if (tr_ptr->flags & RF_UNIQUE) { if (see_t) { @@ -2282,7 +2283,7 @@ static bool_ monst_spell_monst(int m_idx) if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s magically summons %s %s.", m_name, m_poss, - ((r_ptr->flags1) & RF1_UNIQUE ? + ((r_ptr->flags) & RF_UNIQUE ? "minions" : "kin")); summon_kin_type = r_ptr->d_char; /* Big hack */ for (int k = 0; k < 6; k++) @@ -2773,7 +2774,7 @@ static bool_ make_attack_spell(int m_idx) /* Cannot attack the player if mortal and player fated to never die by the ... */ auto const r_ptr = m_ptr->race(); - if ((r_ptr->flags7 & RF7_MORTAL) && (p_ptr->no_mortal)) return (FALSE); + if ((r_ptr->flags & RF_MORTAL) && (p_ptr->no_mortal)) return (FALSE); /* Hack -- Extract the spell probability */ chance = (r_ptr->freq_inate + r_ptr->freq_spell) / 2; @@ -2810,7 +2811,7 @@ static bool_ make_attack_spell(int m_idx) } /* Hack -- allow "desperate" spells */ - if ((r_ptr->flags2 & RF2_SMART) && + if ((r_ptr->flags & RF_SMART) && (m_ptr->hp < m_ptr->maxhp / 10) && (rand_int(100) < 50)) { @@ -2829,7 +2830,7 @@ static bool_ make_attack_spell(int m_idx) /* Check for a clean bolt shot */ if ((allowed_spells & SF_BOLT_MASK) && - !(r_ptr->flags2 & RF2_STUPID) && + !(r_ptr->flags & RF_STUPID) && !clean_shot(m_ptr->fy, m_ptr->fx, y, x)) { /* Remove spells that will only hurt friends */ @@ -2838,7 +2839,7 @@ static bool_ make_attack_spell(int m_idx) /* Check for a possible summon */ if ((allowed_spells & SF_SUMMON_MASK) && - !(r_ptr->flags2 & RF2_STUPID) && + !(r_ptr->flags & RF_STUPID) && !(summon_possible(y, x))) { /* Remove summoning spells */ @@ -2873,7 +2874,7 @@ static bool_ make_attack_spell(int m_idx) failrate = 25 - (rlev + 3) / 4; /* Hack -- Stupid monsters will never fail (for jellies and such) */ - if (r_ptr->flags2 & RF2_STUPID) failrate = 0; + if (r_ptr->flags & RF_STUPID) failrate = 0; /* Check for spell failure (inate attacks never fail) */ if ((!thrown_spell->is_innate) && (rand_int(100) < failrate)) @@ -4017,7 +4018,7 @@ static bool_ make_attack_spell(int m_idx) if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s magically summons %s %s.", m_name, m_poss, - ((r_ptr->flags1) & RF1_UNIQUE ? + ((r_ptr->flags) & RF_UNIQUE ? "minions" : "kin")); summon_kin_type = r_ptr->d_char; /* Big hack */ @@ -4645,7 +4646,7 @@ static void get_target_monster(int m_idx) if (m_idx == i) continue; /* Cannot be targeted */ - if (rt_ptr->flags7 & RF7_NO_TARGET) continue; + if (rt_ptr->flags & RF_NO_TARGET) continue; if (is_enemy(m_ptr, t_ptr) && (los(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx) && ((dd = distance(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) < d))) @@ -4705,13 +4706,13 @@ static bool_ get_moves(int m_idx, int *mm) const auto r_ptr = m_ptr->race(); /* A possessor is not interrested in the player, it only wants a corpse */ - if (r_ptr->flags7 & RF7_POSSESSOR) + if (r_ptr->flags & RF_POSSESSOR) { find_corpse(m_ptr, &y2, &x2); } /* Let quests redefine AI */ - if (r_ptr->flags7 & RF7_AI_SPECIAL) + if (r_ptr->flags & RF_AI_SPECIAL) { struct hook_monster_ai_in in = { m_idx, &m_list[m_idx] }; struct hook_monster_ai_out out = { 0, 0 }; @@ -4724,7 +4725,7 @@ static bool_ get_moves(int m_idx, int *mm) if (m_idx == p_ptr->control) { - if ((r_ptr->flags7 & RF7_AI_PLAYER) || magik(85)) + if ((r_ptr->flags & RF_AI_PLAYER) || magik(85)) { if (distance(p_ptr->py, p_ptr->px, m_ptr->fy, m_ptr->fx) < 50) { @@ -4739,7 +4740,7 @@ static bool_ get_moves(int m_idx, int *mm) int x = m_ptr->fx - x2; /* Tease the player */ - if (r_ptr->flags7 & RF7_AI_ANNOY) + if (r_ptr->flags & RF_AI_ANNOY) { if (distance(m_ptr->fy, m_ptr->fx, y2, x2) < 4) { @@ -4749,7 +4750,7 @@ static bool_ get_moves(int m_idx, int *mm) } /* Death orbs .. */ - if (r_ptr->flags2 & RF2_DEATH_ORB) + if (r_ptr->flags & RF_DEATH_ORB) { if (!los(m_ptr->fy, m_ptr->fx, y2, x2)) { @@ -4765,10 +4766,10 @@ static bool_ get_moves(int m_idx, int *mm) * Animal packs try to get the player out of corridors * (...unless they can move through walls -- TY) */ - if ((r_ptr->flags1 & RF1_FRIENDS) && - (r_ptr->flags3 & RF3_ANIMAL) && - !((r_ptr->flags2 & RF2_PASS_WALL) || - (r_ptr->flags2 & RF2_KILL_WALL))) + if ((r_ptr->flags & RF_FRIENDS) && + (r_ptr->flags & RF_ANIMAL) && + !((r_ptr->flags & RF_PASS_WALL) || + (r_ptr->flags & RF_KILL_WALL))) { int i, room = 0; @@ -4792,7 +4793,7 @@ static bool_ get_moves(int m_idx, int *mm) } /* Monster groups try to surround the player */ - if (!done && (r_ptr->flags1 & RF1_FRIENDS)) + if (!done && (r_ptr->flags & RF_FRIENDS)) { int i; @@ -5075,7 +5076,7 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) const auto tr_ptr = t_ptr->race(); /* Not allowed to attack */ - if (r_ptr->flags1 & RF1_NEVER_BLOW) return FALSE; + if (r_ptr->flags & RF_NEVER_BLOW) return FALSE; /* Total armor */ const int ac = t_ptr->ac; @@ -5487,8 +5488,8 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) if (touched) { /* Aura fire */ - if ((tr_ptr->flags2 & RF2_AURA_FIRE) && - !(r_ptr->flags3 & RF3_IM_FIRE)) + if ((tr_ptr->flags & RF_AURA_FIRE) && + !(r_ptr->flags & RF_IM_FIRE)) { if (m_ptr->ml || t_ptr->ml) { @@ -5502,7 +5503,7 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) } /* Aura elec */ - if ((tr_ptr->flags2 & RF2_AURA_ELEC) && !(r_ptr->flags3 & RF3_IM_ELEC)) + if ((tr_ptr->flags & RF_AURA_ELEC) && !(r_ptr->flags & RF_IM_ELEC)) { if (m_ptr->ml || t_ptr->ml) { @@ -5594,27 +5595,27 @@ static bool_ player_invis(monster_type * m_ptr) s16b inv = p_ptr->invis; s16b mlv = m_ptr->level; - if (r_ptr->flags3 & RF3_NO_SLEEP) + if (r_ptr->flags & RF_NO_SLEEP) mlv += 10; - if (r_ptr->flags3 & RF3_DRAGON) + if (r_ptr->flags & RF_DRAGON) mlv += 20; - if (r_ptr->flags3 & RF3_UNDEAD) + if (r_ptr->flags & RF_UNDEAD) mlv += 15; - if (r_ptr->flags3 & RF3_DEMON) + if (r_ptr->flags & RF_DEMON) mlv += 15; - if (r_ptr->flags3 & RF3_ANIMAL) + if (r_ptr->flags & RF_ANIMAL) mlv += 15; - if (r_ptr->flags3 & RF3_ORC) + if (r_ptr->flags & RF_ORC) mlv -= 15; - if (r_ptr->flags3 & RF3_TROLL) + if (r_ptr->flags & RF_TROLL) mlv -= 10; - if (r_ptr->flags2 & RF2_STUPID) + if (r_ptr->flags & RF_STUPID) mlv /= 2; - if (r_ptr->flags2 & RF2_SMART) + if (r_ptr->flags & RF_SMART) mlv = (mlv * 5) / 4; if (m_ptr->mflag & MFLAG_QUEST) inv = 0; - if (r_ptr->flags2 & RF2_INVISIBLE) + if (r_ptr->flags & RF_INVISIBLE) inv = 0; if (m_ptr->mflag & MFLAG_CONTROL) inv = 0; @@ -5659,7 +5660,7 @@ static void process_monster(int m_idx, bool_ is_frien) const bool_ inv = player_invis(m_ptr); auto const r_ptr = m_ptr->race(); - if (r_ptr->flags9 & RF9_DOPPLEGANGER) doppleganger = m_idx; + if (r_ptr->flags & RF_DOPPLEGANGER) doppleganger = m_idx; /* Handle "bleeding" */ if (m_ptr->bleeding) @@ -5872,12 +5873,12 @@ static void process_monster(int m_idx, bool_ is_frien) bool_ gets_angry = FALSE; /* No one wants to be your friend if you're aggravating */ - if ((m_ptr->status > MSTATUS_NEUTRAL) && (m_ptr->status < MSTATUS_COMPANION) && (p_ptr->aggravate) && !(r_ptr->flags7 & RF7_PET)) + if ((m_ptr->status > MSTATUS_NEUTRAL) && (m_ptr->status < MSTATUS_COMPANION) && (p_ptr->aggravate) && !(r_ptr->flags & RF_PET)) gets_angry = TRUE; /* Paranoia... no friendly uniques outside wizard mode -- TY */ if ((m_ptr->status > MSTATUS_NEUTRAL) && (m_ptr->status < MSTATUS_COMPANION) && !(wizard) && - (r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_PET)) + (r_ptr->flags & RF_UNIQUE) && !(r_ptr->flags & RF_PET)) gets_angry = TRUE; if (gets_angry) @@ -5940,7 +5941,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (randint(SPEAK_CHANCE) == 1) { - if (player_has_los_bold(oy, ox) && (r_ptr->flags2 & RF2_CAN_SPEAK)) + if (player_has_los_bold(oy, ox) && (r_ptr->flags & RF_CAN_SPEAK)) { char m_name[80]; char monmessage[1024]; @@ -6007,8 +6008,8 @@ static void process_monster(int m_idx, bool_ is_frien) } /* 75% random movement */ - else if ((r_ptr->flags1 & (RF1_RAND_50)) && - (r_ptr->flags1 & (RF1_RAND_25)) && + else if ((r_ptr->flags & RF_RAND_50) && + (r_ptr->flags & RF_RAND_25) && (rand_int(100) < 75)) { /* Try four "random" directions */ @@ -6016,7 +6017,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* 50% random movement */ - else if ((r_ptr->flags1 & (RF1_RAND_50)) && + else if ((r_ptr->flags & RF_RAND_50) && (rand_int(100) < 50)) { /* Try four "random" directions */ @@ -6024,7 +6025,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* 25% random movement */ - else if ((r_ptr->flags1 & (RF1_RAND_25)) && + else if ((r_ptr->flags & RF_RAND_25) && (rand_int(100) < 25)) { /* Try four "random" directions */ @@ -6087,7 +6088,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Hack -- check for Glyph of Warding */ if ((c_ptr->feat == FEAT_GLYPH) && - !(r_ptr->flags1 & RF1_NEVER_BLOW)) + !(r_ptr->flags & RF_NEVER_BLOW)) { /* Assume no move allowed */ do_move = FALSE; @@ -6113,7 +6114,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Hack -- trees are obstacle */ - else if ((cave[ny][nx].feat == FEAT_TREES) && (r_ptr->flags9 & RF9_KILL_TREES)) + else if ((cave[ny][nx].feat == FEAT_TREES) && (r_ptr->flags & RF_KILL_TREES)) { do_move = TRUE; @@ -6144,28 +6145,28 @@ static void process_monster(int m_idx, bool_ is_frien) /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_LEVITATE) && (r_ptr->flags7 & RF7_CAN_FLY)) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_LEVITATE) && (r_ptr->flags & RF_CAN_FLY)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_FLY) && (r_ptr->flags7 & RF7_CAN_FLY)) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_FLY) && (r_ptr->flags & RF_CAN_FLY)) { /* Pass through trees/... */ do_move = TRUE; } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_PASS_WALL)) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Monster destroys walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_KILL_WALL)) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_KILL_WALL)) { /* Eat through walls/doors/rubble */ do_move = TRUE; @@ -6186,7 +6187,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags2 & RF2_PASS_WALL)) + else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; @@ -6194,7 +6195,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Monster moves through webs */ else if ((f_info[c_ptr->feat].flags1 & FF1_WEB) && - (r_ptr->flags7 & RF7_SPIDER)) + (r_ptr->flags & RF_SPIDER)) { /* Pass through webs */ do_move = TRUE; @@ -6210,7 +6211,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Take a turn */ do_turn = TRUE; - if ((r_ptr->flags2 & RF2_OPEN_DOOR) && + if ((r_ptr->flags & RF_OPEN_DOOR) && ((is_friend(m_ptr) <= 0) || p_ptr->pet_open_doors)) { /* Closed doors and secret doors */ @@ -6245,7 +6246,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Stuck doors -- attempt to bash them down if allowed */ - if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) && + if (may_bash && (r_ptr->flags & RF_BASH_DOOR) && ((is_friend(m_ptr) <= 0) || p_ptr->pet_open_doors)) { int k; @@ -6294,7 +6295,7 @@ static void process_monster(int m_idx, bool_ is_frien) } } else if (do_move && (c_ptr->feat == FEAT_MINOR_GLYPH) - && !(r_ptr->flags1 & RF1_NEVER_BLOW)) + && !(r_ptr->flags & RF_NEVER_BLOW)) { /* Assume no move allowed */ do_move = FALSE; @@ -6339,7 +6340,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Access that cave grid's contents */ y_ptr = &m_list[c_ptr->m_idx]; - if (!(r_ptr->flags3 & RF3_IM_COLD)) + if (!(r_ptr->flags & RF_IM_COLD)) { if ((m_ptr->hp - distance(ny, nx, oy, ox)*2) <= 0) { @@ -6379,7 +6380,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Some monsters never attack */ if (do_move && (ny == p_ptr->py) && (nx == p_ptr->px) && - (r_ptr->flags1 & RF1_NEVER_BLOW)) + (r_ptr->flags & RF_NEVER_BLOW)) { /* Do not move */ do_move = FALSE; @@ -6416,12 +6417,12 @@ static void process_monster(int m_idx, bool_ is_frien) do_move = FALSE; /* Kill weaker monsters */ - if ((r_ptr->flags2 & RF2_KILL_BODY) && + if ((r_ptr->flags & RF_KILL_BODY) && (r_ptr->mexp > z_ptr->mexp) && (cave_floor_bold(ny, nx)) && /* Friends don't kill friends... */ !((is_friend(m_ptr) > 0) && (is_friend(m2_ptr) > 0)) && /* Uniques aren't faceless monsters in a crowd */ - !(z_ptr->flags1 & RF1_UNIQUE) && + !(z_ptr->flags & RF_UNIQUE) && /* Don't wreck quests */ !(m2_ptr->mflag & (MFLAG_QUEST | MFLAG_QUEST2)) && /* Don't punish summoners for relying on their friends */ @@ -6455,7 +6456,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Push past weaker monsters (unless leaving a wall) */ - else if ((r_ptr->flags2 & RF2_MOVE_BODY) && + else if ((r_ptr->flags & RF_MOVE_BODY) && (r_ptr->mexp > z_ptr->mexp) && cave_floor_bold(ny, nx) && (cave_floor_bold(m_ptr->fy, m_ptr->fx))) { @@ -6477,11 +6478,8 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Some monsters never move */ - if (do_move && (r_ptr->flags1 & RF1_NEVER_MOVE)) + if (do_move && (r_ptr->flags & RF_NEVER_MOVE)) { - /* Hack -- memorize lack of attacks */ - /* if (m_ptr->ml) r_ptr->r_flags1 |= RF1_NEVER_MOVE; */ - /* Do not move */ do_move = FALSE; } @@ -6573,7 +6571,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (o_ptr->tval == TV_GOLD) continue; /* Incarnate ? */ - if ((o_ptr->tval == TV_CORPSE) && (r_ptr->flags7 & RF7_POSSESSOR) && + if ((o_ptr->tval == TV_CORPSE) && (r_ptr->flags & RF_POSSESSOR) && ((o_ptr->sval == SV_CORPSE_CORPSE) || (o_ptr->sval == SV_CORPSE_SKELETON))) { if (ai_possessor(m_idx, this_o_idx)) return; @@ -6581,15 +6579,13 @@ static void process_monster(int m_idx, bool_ is_frien) /* Take or Kill objects on the floor */ /* rr9: Pets will no longer pick up/destroy items */ - if ((((r_ptr->flags2 & RF2_TAKE_ITEM) && + if ((((r_ptr->flags & RF_TAKE_ITEM) && ((is_friend(m_ptr) <= 0) || p_ptr->pet_pickup_items)) || - (r_ptr->flags2 & RF2_KILL_ITEM)) && + (r_ptr->flags & RF_KILL_ITEM)) && (is_friend(m_ptr) <= 0)) { u32b f1, f2, f3, f4, f5, esp; - u32b flg3 = 0L; - char m_name[80]; char o_name[80]; @@ -6603,23 +6599,24 @@ static void process_monster(int m_idx, bool_ is_frien) monster_desc(m_name, m_ptr, 0x04); /* React to objects that hurt the monster */ - if (f5 & (TR5_KILL_DEMON)) flg3 |= RF3_DEMON; - if (f5 & (TR5_KILL_UNDEAD)) flg3 |= RF3_UNDEAD; - if (f1 & (TR1_SLAY_DRAGON)) flg3 |= RF3_DRAGON; - if (f1 & (TR1_SLAY_TROLL)) flg3 |= RF3_TROLL; - if (f1 & (TR1_SLAY_GIANT)) flg3 |= RF3_GIANT; - if (f1 & (TR1_SLAY_ORC)) flg3 |= RF3_ORC; - if (f1 & (TR1_SLAY_DEMON)) flg3 |= RF3_DEMON; - if (f1 & (TR1_SLAY_UNDEAD)) flg3 |= RF3_UNDEAD; - if (f1 & (TR1_SLAY_ANIMAL)) flg3 |= RF3_ANIMAL; - if (f1 & (TR1_SLAY_EVIL)) flg3 |= RF3_EVIL; + monster_race_flag_set flg; + if (f5 & (TR5_KILL_DEMON)) flg |= RF_DEMON; + if (f5 & (TR5_KILL_UNDEAD)) flg |= RF_UNDEAD; + if (f1 & (TR1_SLAY_DRAGON)) flg |= RF_DRAGON; + if (f1 & (TR1_SLAY_TROLL)) flg |= RF_TROLL; + if (f1 & (TR1_SLAY_GIANT)) flg |= RF_GIANT; + if (f1 & (TR1_SLAY_ORC)) flg |= RF_ORC; + if (f1 & (TR1_SLAY_DEMON)) flg |= RF_DEMON; + if (f1 & (TR1_SLAY_UNDEAD)) flg |= RF_UNDEAD; + if (f1 & (TR1_SLAY_ANIMAL)) flg |= RF_ANIMAL; + if (f1 & (TR1_SLAY_EVIL)) flg |= RF_EVIL; /* The object cannot be picked up by the monster */ - if (artifact_p(o_ptr) || (r_ptr->flags3 & flg3) || + if (artifact_p(o_ptr) || (r_ptr->flags & flg) || (o_ptr->art_name)) { /* Only give a message for "take_item" */ - if (r_ptr->flags2 & RF2_TAKE_ITEM) + if (r_ptr->flags & RF_TAKE_ITEM) { /* Describe observable situations */ if (m_ptr->ml && player_has_los_bold(ny, nx)) @@ -6632,7 +6629,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Pick up the item */ - else if (r_ptr->flags2 & RF2_TAKE_ITEM) + else if (r_ptr->flags & RF_TAKE_ITEM) { /* Describe observable situations */ if (player_has_los_bold(ny, nx)) @@ -6678,7 +6675,7 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Update monster light */ - if (r_ptr->flags9 & RF9_HAS_LITE) p_ptr->update |= (PU_MON_LITE); + if (r_ptr->flags & RF_HAS_LITE) p_ptr->update |= (PU_MON_LITE); } /* Stop when done */ @@ -6810,7 +6807,7 @@ void process_monsters(void) monster_type *m_ptr; /* Check the doppleganger */ - if (doppleganger && !(r_info[m_list[doppleganger].r_idx].flags9 & RF9_DOPPLEGANGER)) + if (doppleganger && !(r_info[m_list[doppleganger].r_idx].flags & RF_DOPPLEGANGER)) doppleganger = 0; /* Hack -- calculate the "player noise" */ -- cgit v1.2.3 From 073ad3584fbf781ce10bef61ad4ff38850282f47 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 21 Jun 2016 13:37:02 +0200 Subject: Rework TR{1,2,3,4,5}_* flags to flag_set<> --- src/melee2.cc | 62 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 9d09fb67..f52c7061 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -34,6 +34,7 @@ #include "monster_type.hpp" #include "object1.hpp" #include "object2.hpp" +#include "object_flag.hpp" #include "options.hpp" #include "player_type.hpp" #include "quark.hpp" @@ -2571,7 +2572,6 @@ static bool_ monst_spell_monst(int m_idx) void curse_equipment(int chance, int heavy_chance) { bool_ changed = FALSE; - u32b o1, o2, o3, o4, esp, o5; object_type * o_ptr = &p_ptr->inventory[rand_range(INVEN_WIELD, INVEN_TOTAL - 1)]; @@ -2579,11 +2579,11 @@ void curse_equipment(int chance, int heavy_chance) if (!(o_ptr->k_idx)) return; - object_flags(o_ptr, &o1, &o2, &o3, &o4, &o5, &esp); + auto const flags = object_flags(o_ptr); /* Extra, biased saving throw for blessed items */ - if ((o3 & (TR3_BLESSED)) && (randint(888) > chance)) + if ((flags & TR_BLESSED) && (randint(888) > chance)) { char o_name[256]; object_desc(o_name, o_ptr, FALSE, 0); @@ -2596,17 +2596,17 @@ void curse_equipment(int chance, int heavy_chance) if ((randint(100) <= heavy_chance) && (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name)) { - if (!(o3 & TR3_HEAVY_CURSE)) + if (!(flags & TR_HEAVY_CURSE)) changed = TRUE; - o_ptr->art_flags3 |= TR3_HEAVY_CURSE; - o_ptr->art_flags3 |= TR3_CURSED; + o_ptr->art_flags |= TR_HEAVY_CURSE; + o_ptr->art_flags |= TR_CURSED; o_ptr->ident |= IDENT_CURSED; } else { - if (!(o_ptr->ident & (IDENT_CURSED))) + if (!(o_ptr->ident & IDENT_CURSED)) changed = TRUE; - o_ptr->art_flags3 |= TR3_CURSED; + o_ptr->art_flags |= TR_CURSED; o_ptr->ident |= IDENT_CURSED; } @@ -2627,7 +2627,7 @@ void curse_equipment(int chance, int heavy_chance) void curse_equipment_dg(int chance, int heavy_chance) { bool_ changed = FALSE; - u32b o1, o2, o3, o4, esp, o5; + object_type * o_ptr = &p_ptr->inventory[rand_range(INVEN_WIELD, INVEN_TOTAL - 1)]; @@ -2635,37 +2635,35 @@ void curse_equipment_dg(int chance, int heavy_chance) if (!(o_ptr->k_idx)) return; - object_flags(o_ptr, &o1, &o2, &o3, &o4, &o5, &esp); + auto const flags = object_flags(o_ptr); /* Extra, biased saving throw for blessed items */ - if ((o3 & (TR3_BLESSED)) && (randint(888) > chance)) + if ((flags & TR_BLESSED) && (randint(888) > chance)) { char o_name[256]; object_desc(o_name, o_ptr, FALSE, 0); msg_format("Your %s resist%s cursing!", o_name, ((o_ptr->number > 1) ? "" : "s")); - /* Hmmm -- can we wear multiple items? If not, this is unnecessary */ - /* DG -- Yes we can, in the quiver */ return; } if ((randint(100) <= heavy_chance) && (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name)) { - if (!(o3 & TR3_HEAVY_CURSE)) + if (!(flags & TR_HEAVY_CURSE)) changed = TRUE; - o_ptr->art_flags3 |= TR3_HEAVY_CURSE; - o_ptr->art_flags3 |= TR3_CURSED; - o_ptr->art_flags4 |= TR4_DG_CURSE; + o_ptr->art_flags |= TR_HEAVY_CURSE; + o_ptr->art_flags |= TR_CURSED; + o_ptr->art_flags |= TR_DG_CURSE; o_ptr->ident |= IDENT_CURSED; } else { - if (!(o_ptr->ident & (IDENT_CURSED))) + if (!(o_ptr->ident & IDENT_CURSED)) changed = TRUE; - o_ptr->art_flags3 |= TR3_CURSED; - o_ptr->art_flags4 |= TR4_DG_CURSE; + o_ptr->art_flags |= TR_CURSED; + o_ptr->art_flags |= TR_DG_CURSE; o_ptr->ident |= IDENT_CURSED; } @@ -6584,13 +6582,11 @@ static void process_monster(int m_idx, bool_ is_frien) (r_ptr->flags & RF_KILL_ITEM)) && (is_friend(m_ptr) <= 0)) { - u32b f1, f2, f3, f4, f5, esp; - char m_name[80]; char o_name[80]; /* Extract some flags */ - object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp); + auto const flags = object_flags(o_ptr); /* Acquire the object name */ object_desc(o_name, o_ptr, TRUE, 3); @@ -6600,16 +6596,16 @@ static void process_monster(int m_idx, bool_ is_frien) /* React to objects that hurt the monster */ monster_race_flag_set flg; - if (f5 & (TR5_KILL_DEMON)) flg |= RF_DEMON; - if (f5 & (TR5_KILL_UNDEAD)) flg |= RF_UNDEAD; - if (f1 & (TR1_SLAY_DRAGON)) flg |= RF_DRAGON; - if (f1 & (TR1_SLAY_TROLL)) flg |= RF_TROLL; - if (f1 & (TR1_SLAY_GIANT)) flg |= RF_GIANT; - if (f1 & (TR1_SLAY_ORC)) flg |= RF_ORC; - if (f1 & (TR1_SLAY_DEMON)) flg |= RF_DEMON; - if (f1 & (TR1_SLAY_UNDEAD)) flg |= RF_UNDEAD; - if (f1 & (TR1_SLAY_ANIMAL)) flg |= RF_ANIMAL; - if (f1 & (TR1_SLAY_EVIL)) flg |= RF_EVIL; + if (flags & TR_KILL_DEMON) flg |= RF_DEMON; + if (flags & TR_KILL_UNDEAD) flg |= RF_UNDEAD; + if (flags & TR_SLAY_DRAGON) flg |= RF_DRAGON; + if (flags & TR_SLAY_TROLL) flg |= RF_TROLL; + if (flags & TR_SLAY_GIANT) flg |= RF_GIANT; + if (flags & TR_SLAY_ORC) flg |= RF_ORC; + if (flags & TR_SLAY_DEMON) flg |= RF_DEMON; + if (flags & TR_SLAY_UNDEAD) flg |= RF_UNDEAD; + if (flags & TR_SLAY_ANIMAL) flg |= RF_ANIMAL; + if (flags & TR_SLAY_EVIL) flg |= RF_EVIL; /* The object cannot be picked up by the monster */ if (artifact_p(o_ptr) || (r_ptr->flags & flg) || -- cgit v1.2.3 From 3966bfb2f6836d13c1a93bfab1e9fa61ec4fff35 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 21 Jun 2016 21:17:20 +0200 Subject: Rework FF1_* flags to flags_set<> --- src/melee2.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index f52c7061..a0f43492 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -17,6 +17,7 @@ #include "cave_type.hpp" #include "cmd1.hpp" #include "dungeon_flag.hpp" +#include "feature_flag.hpp" #include "feature_type.hpp" #include "files.hpp" #include "hook_mon_speak_in.hpp" @@ -6136,35 +6137,35 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Permanent wall */ - else if (f_info[c_ptr->feat].flags1 & FF1_PERMANENT) + else if (f_info[c_ptr->feat].flags & FF_PERMANENT) { /* Nothing */ } /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_LEVITATE) && (r_ptr->flags & RF_CAN_FLY)) + else if ((f_info[c_ptr->feat].flags & FF_CAN_LEVITATE) && (r_ptr->flags & RF_CAN_FLY)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Some monsters can fly */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_FLY) && (r_ptr->flags & RF_CAN_FLY)) + else if ((f_info[c_ptr->feat].flags & FF_CAN_FLY) && (r_ptr->flags & RF_CAN_FLY)) { /* Pass through trees/... */ do_move = TRUE; } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) + else if ((f_info[c_ptr->feat].flags & FF_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Monster destroys walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_KILL_WALL)) + else if ((f_info[c_ptr->feat].flags & FF_CAN_PASS) && (r_ptr->flags & RF_KILL_WALL)) { /* Eat through walls/doors/rubble */ do_move = TRUE; @@ -6185,14 +6186,14 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Monster moves through walls (and doors) */ - else if ((f_info[c_ptr->feat].flags1 & FF1_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) + else if ((f_info[c_ptr->feat].flags & FF_CAN_PASS) && (r_ptr->flags & RF_PASS_WALL)) { /* Pass through walls/doors/rubble */ do_move = TRUE; } /* Monster moves through webs */ - else if ((f_info[c_ptr->feat].flags1 & FF1_WEB) && + else if ((f_info[c_ptr->feat].flags & FF_WEB) && (r_ptr->flags & RF_SPIDER)) { /* Pass through webs */ -- cgit v1.2.3 From 5e42771bae33ca475447dc34610addad8efdb74f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove unused variable in make_attack_spell() --- src/melee2.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index a0f43492..6d025511 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2746,9 +2746,6 @@ static bool_ make_attack_spell(int m_idx) /* Extract the "see-able-ness" */ bool_ seen = (!blind && m_ptr->ml); - /* Assume "normal" target */ - bool_ normal = TRUE; - /* Target location */ if (m_ptr->target > -1) { @@ -2787,8 +2784,7 @@ static bool_ make_attack_spell(int m_idx) /* Sometimes forbid inate attacks (breaths) */ if (rand_int(100) >= (chance * 2)) no_inate = TRUE; - /* Hack -- require projectable player */ - if (normal) + /* Require projectable player */ { /* Check range */ if (m_ptr->cdis > MAX_RANGE) return (FALSE); -- cgit v1.2.3 From ceb4551cfb0e3fd1bdf8bdb868e6758634486ecb Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove effectively dead sound() code --- src/melee2.cc | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 6d025511..1cebfb0b 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -98,20 +98,6 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) /* Extract monster name */ monster_desc(m_name, m_ptr, 0); - /* Make a sound */ - if ((r_ptr->flags & RF_DEMON) || - (r_ptr->flags & RF_UNDEAD) || - (r_ptr->flags & RF_STUPID) || - (r_ptr->flags & RF_NONLIVING) || - (strchr("Evg", r_ptr->d_char))) - { - sound(SOUND_N_KILL); - } - else - { - sound(SOUND_KILL); - } - /* Death by Missile/Spell attack */ if (note) { @@ -1147,7 +1133,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires an arrow at %s.", m_name, t_name); - sound(SOUND_SHOOT); monst_bolt_monst(m_idx, y, x, GF_ARROW, damroll(1, 6)); break; } @@ -1158,7 +1143,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires an arrow at %s.", m_name, t_name); - sound(SOUND_SHOOT); monst_bolt_monst(m_idx, y, x, GF_ARROW, damroll(3, 6)); break; } @@ -1170,7 +1154,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires a missile at %s.", m_name, t_name); - sound(SOUND_SHOOT); monst_bolt_monst(m_idx, y, x, GF_ARROW, damroll(5, 6)); break; } @@ -1181,7 +1164,6 @@ static bool_ monst_spell_monst(int m_idx) else if (disturb_other) disturb(1); if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires a missile at %s.", m_name, t_name); - sound(SOUND_SHOOT); monst_bolt_monst(m_idx, y, x, GF_ARROW, damroll(7, 6)); break; } @@ -1192,7 +1174,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes acid at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_ACID, ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); break; @@ -1204,7 +1185,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes lightning at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_ELEC, ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); break; @@ -1216,7 +1196,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes fire at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_FIRE, ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); break; @@ -1228,7 +1207,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes frost at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_COLD, ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); break; @@ -1240,7 +1218,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes gas at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_POIS, ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); break; @@ -1252,7 +1229,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes nether at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_NETHER, ((m_ptr->hp / 6) > 550 ? 550 : (m_ptr->hp / 6)), 0); break; @@ -1264,7 +1240,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes light at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_LITE, ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); break; @@ -1276,7 +1251,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes darkness at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_DARK, ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); break; @@ -1288,7 +1262,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes confusion at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_CONFUSION, ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); break; @@ -1300,7 +1273,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes sound at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_SOUND, ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); break; @@ -1312,7 +1284,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes chaos at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_CHAOS, ((m_ptr->hp / 6) > 600 ? 600 : (m_ptr->hp / 6)), 0); break; @@ -1324,7 +1295,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes disenchantment at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_DISENCHANT, ((m_ptr->hp / 6) > 500 ? 500 : (m_ptr->hp / 6)), 0); break; @@ -1336,7 +1306,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes nexus at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_NEXUS, ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); break; @@ -1348,7 +1317,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes time at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_TIME, ((m_ptr->hp / 3) > 150 ? 150 : (m_ptr->hp / 3)), 0); break; @@ -1360,7 +1328,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes inertia at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_INERTIA, ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); break; @@ -1372,7 +1339,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes gravity at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_GRAVITY, ((m_ptr->hp / 3) > 200 ? 200 : (m_ptr->hp / 3)), 0); break; @@ -1384,7 +1350,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes shards at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_SHARDS, ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); break; @@ -1396,7 +1361,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes plasma at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_PLASMA, ((m_ptr->hp / 6) > 150 ? 150 : (m_ptr->hp / 6)), 0); break; @@ -1408,7 +1372,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes force at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_FORCE, ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); break; @@ -1420,7 +1383,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes magical energy at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_MANA, ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); break; @@ -1432,7 +1394,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a ball of radiation at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_NUKE, (rlev + damroll(10, 6)), 2); break; @@ -1444,7 +1405,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes toxic waste at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_NUKE, ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); break; @@ -1456,7 +1416,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear someone mumble frighteningly."); else if (blind) monster_msg("%^s mumbles frighteningly.", m_name); else monster_msg("%^s invokes a raw Chaos upon %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_CHAOS, (rlev * 2) + damroll(10, 10), 4); break; @@ -1468,7 +1427,6 @@ static bool_ monst_spell_monst(int m_idx) if (!see_either) monster_msg("You hear breathing noise."); else if (blind) monster_msg("%^s breathes.", m_name); else monster_msg("%^s breathes disintegration at %s.", m_name, t_name); - sound(SOUND_BREATH); monst_breath_monst(m_idx, y, x, GF_DISINTEGRATE, ((m_ptr->hp / 3) > 300 ? 300 : (m_ptr->hp / 3)), 0); break; @@ -5552,7 +5510,6 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) if (explode) { - sound(SOUND_EXPLODE); mon_take_hit_mon(m_idx, m_idx, m_ptr->hp + 1, &fear, " explodes into tiny shreds."); blinked = FALSE; -- cgit v1.2.3 From 993cc3d53b2f2ca85a1b035b185d7515d2da2a16 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove lots of boilerplate for monster breaths --- src/melee2.cc | 347 +++++++++++++++------------------------------------------- 1 file changed, 89 insertions(+), 258 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 1cebfb0b..c43b2aae 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -1082,6 +1082,31 @@ static bool_ monst_spell_monst(int m_idx) see_either = (see_m || see_t); see_both = (see_m && see_t); + /* Do a breath */ + auto do_breath = [&](char const *element, int gf, s32b max, int divisor) -> void { + // Interrupt + if (disturb_other) + { + disturb(1); + } + // Message + if (!see_either) + { + monster_msg("You hear breathing noise."); + } + else if (blind) + { + monster_msg("%^s breathes.", m_name); + } + else + { + monster_msg("%^s breathes %s at %s.", m_name, element, t_name); + } + // Breathe + monst_breath_monst(m_idx, y, x, gf, std::min(max, m_ptr->hp / divisor), 0); + }; + + /* Spell effect */ int count = 0; switch (thrown_spell->spell_idx) { @@ -1170,227 +1195,127 @@ static bool_ monst_spell_monst(int m_idx) case SF_BR_ACID_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes acid at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_ACID, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); + do_breath("acid", GF_ACID, 1600, 3); break; } case SF_BR_ELEC_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes lightning at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_ELEC, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); + do_breath("lightning", GF_ELEC, 1600, 3); break; } case SF_BR_FIRE_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes fire at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_FIRE, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); + do_breath("fire", GF_FIRE, 1600, 3); break; } case SF_BR_COLD_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes frost at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_COLD, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); + do_breath("frost", GF_COLD, 1600, 3); break; } case SF_BR_POIS_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes gas at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_POIS, - ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); + do_breath("gas", GF_POIS, 800, 3); break; } case SF_BR_NETH_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes nether at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_NETHER, - ((m_ptr->hp / 6) > 550 ? 550 : (m_ptr->hp / 6)), 0); + do_breath("nether", GF_NETHER, 550, 6); break; } case SF_BR_LITE_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes light at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_LITE, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); + do_breath("light", GF_LITE, 400, 6); break; } case SF_BR_DARK_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes darkness at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_DARK, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); + do_breath("darkness", GF_DARK, 400, 6); break; } case SF_BR_CONF_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes confusion at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_CONFUSION, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); + do_breath("confusion", GF_CONFUSION, 400, 6); break; } case SF_BR_SOUN_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes sound at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_SOUND, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); + do_breath("sound", GF_SOUND, 400, 6); break; } case SF_BR_CHAO_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes chaos at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_CHAOS, - ((m_ptr->hp / 6) > 600 ? 600 : (m_ptr->hp / 6)), 0); + do_breath("chaos", GF_CHAOS, 600, 6); break; } case SF_BR_DISE_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes disenchantment at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_DISENCHANT, - ((m_ptr->hp / 6) > 500 ? 500 : (m_ptr->hp / 6)), 0); + do_breath("disenchantment", GF_DISENCHANT, 500, 6); break; } case SF_BR_NEXU_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes nexus at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_NEXUS, - ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); + do_breath("nexus", GF_NEXUS, 250, 3); break; } case SF_BR_TIME_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes time at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_TIME, - ((m_ptr->hp / 3) > 150 ? 150 : (m_ptr->hp / 3)), 0); + do_breath("time", GF_TIME, 150, 3); break; } case SF_BR_INER_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes inertia at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_INERTIA, - ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); + do_breath("inertia", GF_INERTIA, 200, 6); break; } case SF_BR_GRAV_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes gravity at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_GRAVITY, - ((m_ptr->hp / 3) > 200 ? 200 : (m_ptr->hp / 3)), 0); + do_breath("gravity", GF_GRAVITY, 200, 3); break; } case SF_BR_SHAR_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes shards at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_SHARDS, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); + do_breath("shards", GF_SHARDS, 400, 6); break; } case SF_BR_PLAS_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes plasma at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_PLASMA, - ((m_ptr->hp / 6) > 150 ? 150 : (m_ptr->hp / 6)), 0); + do_breath("plasma", GF_PLASMA, 150, 6); break; } case SF_BR_WALL_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes force at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_FORCE, - ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); + do_breath("force", GF_FORCE, 200, 6); break; } case SF_BR_MANA_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes magical energy at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_MANA, - ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); + do_breath("magical energy", GF_MANA, 250, 3); break; } case SF_BA_NUKE_IDX: { - if (disturb_other) disturb(1); + if (disturb_other) disturb(1); if (!see_either) monster_msg("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a ball of radiation at %s.", m_name, t_name); @@ -1401,12 +1326,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BR_NUKE_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes toxic waste at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_NUKE, - ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); + do_breath("toxic waste", GF_NUKE, 800, 3); break; } @@ -1423,12 +1343,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BR_DISI_IDX: { - if (disturb_other) disturb(1); - if (!see_either) monster_msg("You hear breathing noise."); - else if (blind) monster_msg("%^s breathes.", m_name); - else monster_msg("%^s breathes disintegration at %s.", m_name, t_name); - monst_breath_monst(m_idx, y, x, GF_DISINTEGRATE, - ((m_ptr->hp / 3) > 300 ? 300 : (m_ptr->hp / 3)), 0); + do_breath("disintegration", GF_DISINTEGRATE, 300, 3); break; } @@ -2859,6 +2774,25 @@ static bool_ make_attack_spell(int m_idx) /* Hack -- Get the "died from" name */ monster_desc(ddesc, m_ptr, 0x88); + /* Do a breath */ + auto do_breath = [&](char const *element, int gf, s32b max, int divisor, int smart_learn) -> void { + // Interrupt + disturb(1); + // Message + if (blind) + { + msg_format("%^s breathes.", m_name); + } + else + { + msg_format("%^s breathes %s.", m_name, element); + } + // Breathe + breath(m_idx, gf, std::min(m_ptr->hp / divisor, max), 0); + // Update "smart" monster knowledge + update_smart_learn(m_idx, smart_learn); + }; + /* Cast the spell. */ switch (thrown_spell->spell_idx) { @@ -2941,215 +2875,121 @@ static bool_ make_attack_spell(int m_idx) case SF_BR_ACID_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes acid.", m_name); - breath(m_idx, GF_ACID, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_ACID); + do_breath("acid", GF_ACID, 1600, 3, DRS_ACID); break; } case SF_BR_ELEC_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes lightning.", m_name); - breath(m_idx, GF_ELEC, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_ELEC); + do_breath("lightning", GF_ELEC, 1600, 3, DRS_ELEC); break; } case SF_BR_FIRE_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes fire.", m_name); - breath(m_idx, GF_FIRE, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_FIRE); + do_breath("fire", GF_FIRE, 1600, 3, DRS_FIRE); break; } case SF_BR_COLD_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes frost.", m_name); - breath(m_idx, GF_COLD, - ((m_ptr->hp / 3) > 1600 ? 1600 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_COLD); + do_breath("frost", GF_COLD, 1600, 3, DRS_COLD); break; } case SF_BR_POIS_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes gas.", m_name); - breath(m_idx, GF_POIS, - ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_POIS); + do_breath("gas", GF_POIS, 800, 3, DRS_POIS); break; } case SF_BR_NETH_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes nether.", m_name); - breath(m_idx, GF_NETHER, - ((m_ptr->hp / 6) > 550 ? 550 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_NETH); + do_breath("nether", GF_NETHER, 550, 6, DRS_NETH); break; } case SF_BR_LITE_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes light.", m_name); - breath(m_idx, GF_LITE, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_LITE); + do_breath("light", GF_LITE, 400, 6, DRS_LITE); break; } case SF_BR_DARK_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes darkness.", m_name); - breath(m_idx, GF_DARK, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_DARK); + do_breath("darkness", GF_DARK, 400, 6, DRS_DARK); break; } case SF_BR_CONF_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes confusion.", m_name); - breath(m_idx, GF_CONFUSION, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_CONF); + do_breath("confusion", GF_CONFUSION, 400, 6, DRS_CONF); break; } case SF_BR_SOUN_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes sound.", m_name); - breath(m_idx, GF_SOUND, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_SOUND); + do_breath("sound", GF_SOUND, 400, 6, DRS_SOUND); break; } case SF_BR_CHAO_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes chaos.", m_name); - breath(m_idx, GF_CHAOS, - ((m_ptr->hp / 6) > 600 ? 600 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_CHAOS); + do_breath("chaos", GF_CHAOS, 600, 6, DRS_CHAOS); break; } case SF_BR_DISE_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes disenchantment.", m_name); - breath(m_idx, GF_DISENCHANT, - ((m_ptr->hp / 6) > 500 ? 500 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_DISEN); + do_breath("disenchantment", GF_DISENCHANT, 500, 6, DRS_DISEN); break; } case SF_BR_NEXU_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes nexus.", m_name); - breath(m_idx, GF_NEXUS, - ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_NEXUS); + do_breath("nexus", GF_NEXUS, 250, 3, DRS_NEXUS); break; } case SF_BR_TIME_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes time.", m_name); - breath(m_idx, GF_TIME, - ((m_ptr->hp / 3) > 150 ? 150 : (m_ptr->hp / 3)), 0); + do_breath("time", GF_TIME, 150, 3, DRS_NONE); break; } case SF_BR_INER_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes inertia.", m_name); - breath(m_idx, GF_INERTIA, - ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); + do_breath("inertia", GF_INERTIA, 200, 6, DRS_NONE); break; } case SF_BR_GRAV_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes gravity.", m_name); - breath(m_idx, GF_GRAVITY, - ((m_ptr->hp / 3) > 200 ? 200 : (m_ptr->hp / 3)), 0); + do_breath("gravity", GF_GRAVITY, 200, 3, DRS_NONE); break; } case SF_BR_SHAR_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes shards.", m_name); - breath(m_idx, GF_SHARDS, - ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6)), 0); - update_smart_learn(m_idx, DRS_SHARD); + do_breath("shards", GF_SHARDS, 400, 6, DRS_SHARD); break; } case SF_BR_PLAS_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes plasma.", m_name); - breath(m_idx, GF_PLASMA, - ((m_ptr->hp / 6) > 150 ? 150 : (m_ptr->hp / 6)), 0); + do_breath("plasma", GF_PLASMA, 150, 6, DRS_NONE); break; } case SF_BR_WALL_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes force.", m_name); - breath(m_idx, GF_FORCE, - ((m_ptr->hp / 6) > 200 ? 200 : (m_ptr->hp / 6)), 0); + do_breath("force", GF_FORCE, 200, 6, DRS_NONE); break; } case SF_BR_MANA_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes magical energy.", m_name); - breath(m_idx, GF_MANA, - ((m_ptr->hp / 3) > 250 ? 250 : (m_ptr->hp / 3)), 0); + do_breath("magical energy", GF_MANA, 250, 3, DRS_NONE); break; } @@ -3165,12 +3005,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BR_NUKE_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes toxic waste.", m_name); - breath(m_idx, GF_NUKE, - ((m_ptr->hp / 3) > 800 ? 800 : (m_ptr->hp / 3)), 0); - update_smart_learn(m_idx, DRS_POIS); + do_breath("toxic waste", GF_NUKE, 800, 3, DRS_POIS); break; } @@ -3186,11 +3021,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BR_DISI_IDX: { - disturb(1); - if (blind) msg_format("%^s breathes.", m_name); - else msg_format("%^s breathes disintegration.", m_name); - breath(m_idx, GF_DISINTEGRATE, - ((m_ptr->hp / 3) > 300 ? 300 : (m_ptr->hp / 3)), 0); + do_breath("disintegration", GF_DISINTEGRATE, 300, 3, DRS_NONE); break; } -- cgit v1.2.3 From 0d6002ae3c1f2b4fc043bf5ff8cad1e918af7c80 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove lots of boilerplate for monster summoning --- src/melee2.cc | 728 ++++++++++++++++++++++------------------------------------ 1 file changed, 276 insertions(+), 452 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index c43b2aae..419282c6 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -1106,9 +1106,76 @@ static bool_ monst_spell_monst(int m_idx) monst_breath_monst(m_idx, y, x, gf, std::min(max, m_ptr->hp / divisor), 0); }; + /* Messages for summoning */ + struct summon_messages { + char const *singular; + char const *plural; + }; + + /* Default message for summoning when player is blinded */ + auto blind_msg_default = summon_messages { + "You hear something appear nearby.", + "You hear many things appear nearby." + }; + + /* Do a summoning spell */ + auto do_summon = [&](char const *action, int n, int friendly_type, int hostile_type, summon_messages const &blind_msg) -> void { + // Interrupt + if (disturb_other) + { + disturb(1); + } + // Message + if (blind || !see_m) + { + monster_msg("%^s mumbles.", m_name); + } + else + { + monster_msg("%^s magically %s", m_name, action); + } + // Do the actual summoning + int count = 0; + for (int k = 0; k < n; k++) + { + if (friendly) + { + count += summon_specific_friendly(y, x, rlev, friendly_type, TRUE); + } + else if (!friendly) + { + count += summon_specific(y, x, rlev, hostile_type); + } + } + // Message for blinded characters + if (blind) + { + if (count == 1) + { + monster_msg(blind_msg.singular); + } + else if (count > 1) + { + monster_msg(blind_msg.plural); + } + } + }; + + /* There's no summoning friendly uniques or Nazgul */ + auto spell_idx = thrown_spell->spell_idx; + + if (friendly) + { + if ((thrown_spell->spell_idx == SF_S_UNIQUE_IDX) && + (thrown_spell->spell_idx == SF_S_WRAITH_IDX)) + { + // Summon high undead instead + spell_idx = SF_S_HI_UNDEAD_IDX; + } + } + /* Spell effect */ - int count = 0; - switch (thrown_spell->spell_idx) + switch (spell_idx) { case SF_SHRIEK_IDX: { @@ -1125,22 +1192,6 @@ static bool_ monst_spell_monst(int m_idx) break; } - case SF_S_ANIMAL_IDX: - { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons an animal!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_ANIMAL, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_ANIMAL); - } - if (blind && count) monster_msg("You hear something appear nearby."); - break; - } - case SF_ROCKET_IDX: { if (disturb_other) disturb(1); @@ -1989,22 +2040,6 @@ static bool_ monst_spell_monst(int m_idx) break; } - case SF_S_ANIMALS_IDX: - { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons some animals!", m_name); - for (int k = 0; k < 4; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_ANIMAL, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_ANIMAL); - } - if (blind && count) monster_msg("You hear many things appear nearby."); - break; - } - case SF_BLINK_IDX: { if (disturb_other) disturb(1); @@ -2104,326 +2139,189 @@ static bool_ monst_spell_monst(int m_idx) break; } + case SF_S_ANIMAL_IDX: + { + do_summon("summons an animal!", 1, SUMMON_ANIMAL, SUMMON_ANIMAL, blind_msg_default); + break; + } + + case SF_S_ANIMALS_IDX: + { + do_summon("summons some animals!", 4, SUMMON_ANIMAL, SUMMON_ANIMAL, blind_msg_default); + break; + } + case SF_S_BUG_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically codes some software bugs.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_BUG, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_BUG); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("codes some software bugs.", 6, SUMMON_BUG, SUMMON_BUG, blind_msg_default); break; } case SF_S_RNG_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically codes some RNGs.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_RNG, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_RNG); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("codes some RNGs.", 6, SUMMON_RNG, SUMMON_RNG, blind_msg_default); break; } case SF_S_THUNDERLORD_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons a Thunderlord!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_THUNDERLORD, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_THUNDERLORD); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons a Thunderlord!", 1, SUMMON_THUNDERLORD, SUMMON_THUNDERLORD, blind_msg_default); break; } case SF_S_KIN_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons %s %s.", - m_name, m_poss, - ((r_ptr->flags) & RF_UNIQUE ? - "minions" : "kin")); - summon_kin_type = r_ptr->d_char; /* Big hack */ - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_KIN, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_KIN); - } - if (blind && count) monster_msg("You hear many things appear nearby."); - - + // Describe the summons + char action[256]; + sprintf(action, + "summons %s %s.", + m_poss, + (r_ptr->flags & RF_UNIQUE ? "minions" : "kin")); + // Force the right type of "kin" + summon_kin_type = r_ptr->d_char; + // Summon + do_summon(action, 6, SUMMON_KIN, SUMMON_KIN, blind_msg_default); break; } case SF_S_HI_DEMON_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons greater demons!", m_name); - if (blind && count) monster_msg("You hear heavy steps nearby."); - if (friendly) - summon_specific_friendly(y, x, rlev, SUMMON_HI_DEMON, TRUE); - else - summon_cyber(); + do_summon("summons greater demons!", 8, SUMMON_HI_DEMON, SUMMON_HI_DEMON, blind_msg_default); break; - } + } case SF_S_MONSTER_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons help!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_NO_UNIQUES, TRUE); - else - count += summon_specific(y, x, rlev, 0); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons help!", 1, SUMMON_NO_UNIQUES, 0, blind_msg_default); break; } case SF_S_MONSTERS_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons monsters!", m_name); - for (int k = 0; k < 8; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_NO_UNIQUES, TRUE); - else - count += summon_specific(y, x, rlev, 0); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("summons monsters!", 8, SUMMON_NO_UNIQUES, 0, blind_msg_default); break; } case SF_S_ANT_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons ants.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_ANT, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_ANT); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("summons ants.", 6, SUMMON_ANT, SUMMON_ANT, blind_msg_default); break; } case SF_S_SPIDER_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons spiders.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_SPIDER, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_SPIDER); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("summons spiders.", 6, SUMMON_SPIDER, SUMMON_SPIDER, blind_msg_default); break; } case SF_S_HOUND_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons hounds.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_HOUND, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_HOUND); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("summons hounds.", 6, SUMMON_HOUND, SUMMON_HOUND, blind_msg_default); break; } case SF_S_HYDRA_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons hydras.", m_name); - for (int k = 0; k < 6; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_HYDRA, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_HYDRA); - } - if (blind && count) monster_msg("You hear many things appear nearby."); + do_summon("summons hydras.", 6, SUMMON_HYDRA, SUMMON_HYDRA, blind_msg_default); break; } case SF_S_ANGEL_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons an angel!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_ANGEL, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_ANGEL); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons an angel!", 1, SUMMON_ANGEL, SUMMON_ANGEL, blind_msg_default); break; } case SF_S_DEMON_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons a demon!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_DEMON, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_DEMON); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons a demon!", 1, SUMMON_DEMON, SUMMON_DEMON, blind_msg_default); break; } case SF_S_UNDEAD_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons an undead adversary!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_UNDEAD, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_UNDEAD); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons an undead adversary!", 1, SUMMON_UNDEAD, SUMMON_UNDEAD, blind_msg_default); break; } case SF_S_DRAGON_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons a dragon!", m_name); - for (int k = 0; k < 1; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_DRAGON, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_DRAGON); - } - if (blind && count) monster_msg("You hear something appear nearby."); + do_summon("summons a dragon!", 1, SUMMON_DRAGON, SUMMON_DRAGON, blind_msg_default); break; } case SF_S_HI_UNDEAD_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons greater undead!", m_name); - for (int k = 0; k < 8; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_HI_UNDEAD_NO_UNIQUES, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); - } - if (blind && count) - { - monster_msg("You hear many creepy things appear nearby."); - } + summon_messages blind_msg { + "You hear a creepy thing appear nearby.", + "You hear many creepy things appear nearby." + }; + do_summon("summons greater undead!", 8, SUMMON_HI_UNDEAD_NO_UNIQUES, SUMMON_HI_UNDEAD, blind_msg); break; } case SF_S_HI_DRAGON_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons ancient dragons!", m_name); - for (int k = 0; k < 8; k++) - { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_HI_DRAGON_NO_UNIQUES, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_HI_DRAGON); - } - if (blind && count) - { - monster_msg("You hear many powerful things appear nearby."); - } + summon_messages blind_msg { + "You hear many a powerful thing appear nearby.", + "You hear many powerful things appear nearby." + }; + do_summon("summons ancient dragons!", 8, SUMMON_HI_DRAGON_NO_UNIQUES, SUMMON_HI_DRAGON, blind_msg); break; } case SF_S_WRAITH_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons a wraith!", m_name); - - - for (int k = 0; k < 8; k++) - { - count += summon_specific(y, x, rlev, SUMMON_WRAITH); - } - - if (blind && count) - { - monster_msg("You hear immortal beings appear nearby."); - } + // No summoning Nazgul; see the remapping code above the switch. + assert(!friendly); + // Summon + summon_messages blind_msg { + "You hear an immortal being appear nearby.", + "You hear immortal beings appear nearby." + }; + do_summon("summons a wraith!", 8, 0 /* not used */, SUMMON_WRAITH, blind_msg); break; } case SF_S_UNIQUE_IDX: { - if (disturb_other) disturb(1); - if (blind || !see_m) monster_msg("%^s mumbles.", m_name); - else monster_msg("%^s magically summons special opponents!", m_name); + // No summoning uniques; see the remapping code above the switch. + assert(!friendly); + // Interrupt + if (disturb_other) + { + disturb(1); + } + // Message + if (blind || !see_m) + { + monster_msg("%^s mumbles.", m_name); + } + else + { + monster_msg("%^s magically summons special opponents!", m_name); + } + // Summon + int count = 0; for (int k = 0; k < 8; k++) { - if (!friendly) - count += summon_specific(y, x, rlev, SUMMON_UNIQUE); + count += summon_specific(y, x, rlev, SUMMON_UNIQUE); } for (int k = 0; k < 8; k++) { - if (friendly) - count += summon_specific_friendly(y, x, rlev, SUMMON_HI_UNDEAD_NO_UNIQUES, TRUE); - else - count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); + count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); } - if (blind && count) + // Message + if (blind) { - monster_msg("You hear many powerful things appear nearby."); + if (count == 1) + { + monster_msg("You hear a powerful thing appear nearby."); + } + else if (count > 1) + { + monster_msg("You hear many powerful things appear nearby."); + } } break; } @@ -2602,14 +2500,11 @@ static bool_ make_attack_spell(int m_idx) static const auto SF_INT_MASK = compute_smart_mask(); static const auto SF_INNATE_MASK = compute_innate_mask(); - int k, chance, rlev, failrate; + int chance, rlev, failrate; char m_name[80]; bool_ no_inate = FALSE; int x, y; - /* Summon count */ - int count = 0; - /* Extract the blind-ness */ bool_ blind = (p_ptr->blind ? TRUE : FALSE); @@ -2793,6 +2688,51 @@ static bool_ make_attack_spell(int m_idx) update_smart_learn(m_idx, smart_learn); }; + /* Messages for summoning */ + struct summon_messages { + char const *singular; + char const *plural; + }; + + /* Default message for summoning when player is blinded */ + summon_messages blind_msg_default { + "You hear something appear nearby.", + "You hear many things appear nearby." + }; + + /* Do a summoning spell */ + auto do_summon = [&](char const *action, int n, int type, summon_messages const &blind_msg) -> void { + // Interrupt + disturb(1); + // Message + if (blind) + { + msg_format("%^s mumbles.", m_name); + } + else + { + msg_format("%^s magically %s", m_name, action); + } + // Do the actual summoning + int count = 0; + for (int k = 0; k < n; k++) + { + count += summon_specific(y, x, rlev, type); + } + // Message for blinded characters + if (blind) + { + if (count == 1) + { + msg_print(blind_msg.singular); + } + else if (count > 1) + { + msg_print(blind_msg.plural); + } + } + }; + /* Cast the spell. */ switch (thrown_spell->spell_idx) { @@ -2809,19 +2749,6 @@ static bool_ make_attack_spell(int m_idx) break; } - case SF_S_ANIMAL_IDX: - { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons an animal!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_ANIMAL); - } - if (blind && count) msg_print("You hear something appear nearby."); - break; - } - case SF_ROCKET_IDX: { disturb(1); @@ -3657,19 +3584,6 @@ static bool_ make_attack_spell(int m_idx) break; } - case SF_S_ANIMALS_IDX: - { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons some animals!", m_name); - for (k = 0; k < 4; k++) - { - count += summon_specific(y, x, rlev, SUMMON_ANIMAL); - } - if (blind && count) msg_print("You hear something appear nearby."); - break; - } - case SF_BLINK_IDX: { disturb(1); @@ -3757,271 +3671,181 @@ static bool_ make_attack_spell(int m_idx) break; } + case SF_S_ANIMAL_IDX: + { + do_summon("summons an animal!", 1, SUMMON_ANIMAL, blind_msg_default); + break; + } + + case SF_S_ANIMALS_IDX: + { + do_summon("summons some animals!", 4, SUMMON_ANIMAL, blind_msg_default); + break; + } + case SF_S_BUG_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically codes some software bugs.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_BUG); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("codes some software bugs.", 6, SUMMON_BUG, blind_msg_default); break; } case SF_S_RNG_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically codes some RNGs.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_RNG); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("codes some RNGs.", 6, SUMMON_RNG, blind_msg_default); break; } case SF_S_THUNDERLORD_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons a Thunderlord!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_THUNDERLORD); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons a Thunderlord!", 1, SUMMON_THUNDERLORD, blind_msg_default); break; } case SF_S_KIN_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons %s %s.", - m_name, m_poss, - ((r_ptr->flags) & RF_UNIQUE ? - "minions" : "kin")); - summon_kin_type = r_ptr->d_char; /* Big hack */ - - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_KIN); - } - if (blind && count) msg_print("You hear many things appear nearby."); - + // Describe the summons + char action[256]; + sprintf(action, + "summons %s %s.", + m_poss, + (r_ptr->flags & RF_UNIQUE) ? "minions" : "kin"); + // Force the correct type of "kin" + summon_kin_type = r_ptr->d_char; + // Summon + do_summon(action, 6, SUMMON_KIN, blind_msg_default); break; } case SF_S_HI_DEMON_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons greater demons!", m_name); - if (blind && count) msg_print("You hear heavy steps nearby."); - summon_cyber(); + do_summon("summons greater demons!", 8, SUMMON_HI_DEMON, blind_msg_default); break; } case SF_S_MONSTER_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons help!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, 0); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons help!", 1, 0, blind_msg_default); break; } case SF_S_MONSTERS_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons monsters!", m_name); - for (k = 0; k < 8; k++) - { - count += summon_specific(y, x, rlev, 0); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("summons monsters!", 8, 0, blind_msg_default); break; } case SF_S_ANT_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons ants.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_ANT); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("summons ants.", 6, SUMMON_ANT, blind_msg_default); break; } case SF_S_SPIDER_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons spiders.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_SPIDER); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("summons spiders.", 6, SUMMON_SPIDER, blind_msg_default); break; } case SF_S_HOUND_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons hounds.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_HOUND); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("summons hounds.", 6, SUMMON_HOUND, blind_msg_default); break; } case SF_S_HYDRA_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons hydras.", m_name); - for (k = 0; k < 6; k++) - { - count += summon_specific(y, x, rlev, SUMMON_HYDRA); - } - if (blind && count) msg_print("You hear many things appear nearby."); + do_summon("summons hydras.", 6, SUMMON_HYDRA, blind_msg_default); break; } case SF_S_ANGEL_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons an angel!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_ANGEL); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons an angel!", 1, SUMMON_ANGEL, blind_msg_default); break; } case SF_S_DEMON_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons a demon!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_DEMON); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons a demon!", 1, SUMMON_DEMON, blind_msg_default); break; } case SF_S_UNDEAD_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons an undead adversary!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_UNDEAD); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons an undead adversary!", 1, SUMMON_UNDEAD, blind_msg_default); break; } case SF_S_DRAGON_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons a dragon!", m_name); - for (k = 0; k < 1; k++) - { - count += summon_specific(y, x, rlev, SUMMON_DRAGON); - } - if (blind && count) msg_print("You hear something appear nearby."); + do_summon("summons a dragon!", 1, SUMMON_DRAGON, blind_msg_default); break; } case SF_S_HI_UNDEAD_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons greater undead!", m_name); - for (k = 0; k < 8; k++) - { - count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); - } - if (blind && count) - { - msg_print("You hear many creepy things appear nearby."); - } + summon_messages blind_msg { + "You hear a creepy thing appear nearby.", + "You hear many creepy things appear nearby." + }; + do_summon("summons greater undead!", 8, SUMMON_HI_UNDEAD, blind_msg); break; } case SF_S_HI_DRAGON_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons ancient dragons!", m_name); - for (k = 0; k < 8; k++) - { - count += summon_specific(y, x, rlev, SUMMON_HI_DRAGON); - } - if (blind && count) - { - msg_print("You hear many powerful things appear nearby."); - } + summon_messages blind_msg { + "You hear a powerful thing appear nearby.", + "You hear many powerful things appear nearby." + }; + do_summon("summons ancient dragons!", 8, SUMMON_HI_DRAGON, blind_msg); break; } case SF_S_WRAITH_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons Wraith!", m_name); - - - for (k = 0; k < 8; k++) - { - count += summon_specific(y, x, rlev, SUMMON_WRAITH); - } - - if (blind && count) - { - msg_print("You hear immortal beings appear nearby."); - } + summon_messages blind_msg { + "You hear an immortal being appear nearby.", + "You hear immortal beings appear nearby." + }; + do_summon("summons Wraiths!", 8, SUMMON_WRAITH, blind_msg); break; } case SF_S_UNIQUE_IDX: { - disturb(1); - if (blind) msg_format("%^s mumbles.", m_name); - else msg_format("%^s magically summons special opponents!", m_name); - for (k = 0; k < 8; k++) + // Interrupt + disturb(1); + // Message + if (blind) + { + msg_format("%^s mumbles.", m_name); + } + else + { + msg_format("%^s magically summons special opponents!", m_name); + } + // Summon + int count = 0; + for (int k = 0; k < 8; k++) { count += summon_specific(y, x, rlev, SUMMON_UNIQUE); } - for (k = 0; k < 8; k++) + for (int k = 0; k < 8; k++) { count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); } - if (blind && count) + // Message + if (blind) { - msg_print("You hear many powerful things appear nearby."); + if (count == 1) + { + msg_print("You hear a powerful thing appear nearby."); + } + else if (count > 1) + { + msg_print("You hear many powerful things appear nearby."); + } } break; } -- cgit v1.2.3 From d191da218fc81d989d0ebdcfd66a4e0b00405121 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Clean up conditional in monst_spell_monst() --- src/melee2.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 419282c6..59f85803 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -962,7 +962,6 @@ static bool_ monst_spell_monst(int m_idx) static const monster_spell_flag_set SF_INT_MASK = compute_smart_mask(); int y = 0, x = 0; - int i = 1; char m_name[80], t_name[80]; char m_poss[80]; char ddesc[80]; @@ -997,20 +996,14 @@ static bool_ monst_spell_monst(int m_idx) if ((rand_int(100) >= chance) && (monst_spell_monst_spell == -1)) return (FALSE); - /* Target location */ - if (m_ptr->target > -1) + /* Make sure monster actually has a target */ + if (m_ptr->target <= 0) { - if (m_ptr->target > 0) - { - i = m_ptr->target; - } - else return FALSE; + return FALSE; } - else return FALSE; - { - int t_idx = i; + int t_idx = m_ptr->target; monster_type *t_ptr = &m_list[t_idx]; auto const tr_ptr = t_ptr->race(); -- cgit v1.2.3 From 03c402d63f5bef5d880c81bf7253a1274aaacf01 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Clean up conditional in make_attack_spell() --- src/melee2.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 59f85803..a31ca1f7 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2496,7 +2496,6 @@ static bool_ make_attack_spell(int m_idx) int chance, rlev, failrate; char m_name[80]; bool_ no_inate = FALSE; - int x, y; /* Extract the blind-ness */ bool_ blind = (p_ptr->blind ? TRUE : FALSE); @@ -2508,19 +2507,12 @@ static bool_ make_attack_spell(int m_idx) bool_ seen = (!blind && m_ptr->ml); /* Target location */ - if (m_ptr->target > -1) + if (m_ptr->target != 0) { - if (!m_ptr->target) - { - y = p_ptr->py; - x = p_ptr->px; - } - else - { - return (FALSE); - } + return FALSE; } - else return FALSE; + int y = p_ptr->py; + int x = p_ptr->px; /* Cannot cast spells when confused */ if (m_ptr->confused) return (FALSE); -- cgit v1.2.3 From bef0f98085526b80b316580bb5a07fcd8b1af2c5 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Make summons appear around summoner instead of player --- src/melee2.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index a31ca1f7..c246343b 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -1127,17 +1127,18 @@ static bool_ monst_spell_monst(int m_idx) { monster_msg("%^s magically %s", m_name, action); } + // Do the actual summoning int count = 0; for (int k = 0; k < n; k++) { if (friendly) { - count += summon_specific_friendly(y, x, rlev, friendly_type, TRUE); + count += summon_specific_friendly(m_ptr->fy, m_ptr->fx, rlev, friendly_type, TRUE); } else if (!friendly) { - count += summon_specific(y, x, rlev, hostile_type); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, hostile_type); } } // Message for blinded characters @@ -2298,11 +2299,11 @@ static bool_ monst_spell_monst(int m_idx) int count = 0; for (int k = 0; k < 8; k++) { - count += summon_specific(y, x, rlev, SUMMON_UNIQUE); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, SUMMON_UNIQUE); } for (int k = 0; k < 8; k++) { - count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, SUMMON_HI_UNDEAD); } // Message if (blind) @@ -2702,7 +2703,7 @@ static bool_ make_attack_spell(int m_idx) int count = 0; for (int k = 0; k < n; k++) { - count += summon_specific(y, x, rlev, type); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, type); } // Message for blinded characters if (blind) @@ -3814,11 +3815,11 @@ static bool_ make_attack_spell(int m_idx) int count = 0; for (int k = 0; k < 8; k++) { - count += summon_specific(y, x, rlev, SUMMON_UNIQUE); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, SUMMON_UNIQUE); } for (int k = 0; k < 8; k++) { - count += summon_specific(y, x, rlev, SUMMON_HI_UNDEAD); + count += summon_specific(m_ptr->fy, m_ptr->fx, rlev, SUMMON_HI_UNDEAD); } // Message if (blind) -- cgit v1.2.3 From 55729f1d5e1c656fa909e9c18275107d206aedea Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Factor out 'disturb_other' option handling --- src/melee2.cc | 108 +++++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 58 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index c246343b..91dfcaf2 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -1078,10 +1078,7 @@ static bool_ monst_spell_monst(int m_idx) /* Do a breath */ auto do_breath = [&](char const *element, int gf, s32b max, int divisor) -> void { // Interrupt - if (disturb_other) - { - disturb(1); - } + disturb_on_other(); // Message if (!see_either) { @@ -1114,10 +1111,8 @@ static bool_ monst_spell_monst(int m_idx) /* Do a summoning spell */ auto do_summon = [&](char const *action, int n, int friendly_type, int hostile_type, summon_messages const &blind_msg) -> void { // Interrupt - if (disturb_other) - { - disturb(1); - } + disturb_on_other(); + // Message if (blind || !see_m) { @@ -1174,7 +1169,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_SHRIEK_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_m) monster_msg("You hear a shriek."); else monster_msg("%^s shrieks at %s.", m_name, t_name); wake_up = TRUE; @@ -1188,7 +1183,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_ROCKET_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear an explosion!"); else if (blind) monster_msg("%^s shoots something.", m_name); else monster_msg("%^s fires a rocket at %s.", m_name, t_name); @@ -1199,7 +1194,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_ARROW_1_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires an arrow at %s.", m_name, t_name); @@ -1209,7 +1204,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_ARROW_2_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires an arrow at %s.", m_name, t_name); @@ -1219,7 +1214,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_ARROW_3_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear a strange noise."); else if (blind) monster_msg("%^s makes a strange noise.", m_name); @@ -1231,7 +1226,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_ARROW_4_IDX: { if (!see_either) monster_msg("You hear a strange noise."); - else if (disturb_other) disturb(1); + else disturb_on_other(); if (blind) monster_msg("%^s makes a strange noise.", m_name); else monster_msg("%^s fires a missile at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_ARROW, damroll(7, 6)); @@ -1360,7 +1355,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_NUKE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a ball of radiation at %s.", m_name, t_name); @@ -1377,7 +1372,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_CHAO_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg("You hear someone mumble frighteningly."); else if (blind) monster_msg("%^s mumbles frighteningly.", m_name); else monster_msg("%^s invokes a raw Chaos upon %s.", m_name, t_name); @@ -1394,7 +1389,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_ACID_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts an acid ball at %s.", m_name, t_name); @@ -1404,7 +1399,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_ELEC_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1415,7 +1410,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_FIRE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1426,7 +1421,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_COLD_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1437,7 +1432,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_POIS_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1448,7 +1443,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_NETH_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1459,7 +1454,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_WATE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble."); else if (blind) monster_msg("%^s mumbles.", m_name); @@ -1471,7 +1466,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_MANA_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble powerfully."); else if (blind) monster_msg("%^s mumbles powerfully.", m_name); @@ -1482,7 +1477,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BA_DARK_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_either) monster_msg ("You hear someone mumble powerfully."); else if (blind) monster_msg("%^s mumbles powerfully.", m_name); @@ -1535,7 +1530,7 @@ static bool_ monst_spell_monst(int m_idx) { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!seen) { @@ -1573,7 +1568,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BRAIN_SMASH_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!seen) { /* */ @@ -1613,7 +1608,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_CAUSE_1_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s points at %s and curses.", m_name, t_name); if (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10) @@ -1633,7 +1628,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_CAUSE_2_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s points at %s and curses horribly.", m_name, t_name); if (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10) @@ -1652,7 +1647,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_CAUSE_3_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s points at %s, incanting terribly!", m_name, t_name); if (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10) @@ -1671,7 +1666,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_CAUSE_4_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s points at %s, screaming the word 'DIE!'", m_name, t_name); if (t_ptr->level > randint((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10) @@ -1689,7 +1684,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_ACID_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts an acid bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_ACID, @@ -1699,7 +1694,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_ELEC_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a lightning bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_ELEC, @@ -1709,7 +1704,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_FIRE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a fire bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_FIRE, @@ -1719,7 +1714,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_COLD_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a frost bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_COLD, @@ -1735,7 +1730,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_NETH_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a nether bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_NETHER, @@ -1745,7 +1740,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_WATE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a water bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_WATER, @@ -1755,7 +1750,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_MANA_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a mana bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_MANA, @@ -1765,7 +1760,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_PLAS_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a plasma bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_PLASMA, @@ -1775,7 +1770,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BO_ICEE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts an ice bolt at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_ICE, @@ -1785,7 +1780,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_MISSILE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a magic missile at %s.", m_name, t_name); monst_bolt_monst(m_idx, y, x, GF_MISSILE, @@ -1796,7 +1791,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_SCARE_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles, and you hear scary noises.", m_name); else monster_msg("%^s casts a fearful illusion at %s.", m_name, t_name); if (tr_ptr->flags & RF_NO_FEAR) @@ -1819,7 +1814,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BLIND_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s casts a spell, burning %s%s eyes.", m_name, t_name, (!strcmp(t_name, "it") ? "s" : "'s")); @@ -1844,7 +1839,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_CONF_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) monster_msg("%^s mumbles, and you hear puzzling noises.", m_name); else monster_msg("%^s creates a mesmerising illusion in front of %s.", m_name, t_name); if (tr_ptr->flags & RF_NO_CONF) @@ -1867,7 +1862,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_SLOW_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!blind && see_either) monster_msg("%^s drains power from %s%s muscles.", m_name, t_name, (!strcmp(t_name, "it") ? "s" : "'s")); if (tr_ptr->flags & RF_UNIQUE) @@ -1890,7 +1885,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_HOLD_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!blind && see_m) monster_msg("%^s stares intently at %s.", m_name, t_name); if ((tr_ptr->flags & RF_UNIQUE) || (tr_ptr->flags & RF_NO_STUN)) @@ -1912,7 +1907,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_HASTE_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (blind || !see_m) { monster_msg("%^s mumbles.", m_name); @@ -1942,7 +1937,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_HAND_DOOM_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (!see_m) monster_msg("You hear someone invoke the Hand of Doom!"); else if (!blind) monster_msg("%^s invokes the Hand of Doom on %s.", m_name, t_name); else @@ -1972,7 +1967,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_HEAL_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); /* Message */ if (blind || !see_m) @@ -2036,7 +2031,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_BLINK_IDX: { - if (disturb_other) disturb(1); + disturb_on_other(); if (see_m) monster_msg("%^s blinks away.", m_name); teleport_away(m_idx, 10); break; @@ -2047,7 +2042,7 @@ static bool_ monst_spell_monst(int m_idx) if (dungeon_flags & DF_NO_TELEPORT) break; /* No teleport on special levels */ else { - if (disturb_other) disturb(1); + disturb_on_other(); if (see_m) monster_msg("%^s teleports away.", m_name); teleport_away(m_idx, MAX_SIGHT * 2 + 5); break; @@ -2068,7 +2063,7 @@ static bool_ monst_spell_monst(int m_idx) else { bool_ resists_tele = FALSE; - if (disturb_other) disturb(1); + disturb_on_other(); monster_msg("%^s teleports %s away.", m_name, t_name); @@ -2110,7 +2105,7 @@ static bool_ monst_spell_monst(int m_idx) case SF_DARKNESS_IDX: { if (!direct) break; - if (disturb_other) disturb(1); + disturb_on_other(); if (blind) monster_msg("%^s mumbles.", m_name); else monster_msg("%^s gestures in shadow.", m_name); if (seen) @@ -2282,10 +2277,7 @@ static bool_ monst_spell_monst(int m_idx) // No summoning uniques; see the remapping code above the switch. assert(!friendly); // Interrupt - if (disturb_other) - { - disturb(1); - } + disturb_on_other(); // Message if (blind || !see_m) { @@ -4739,7 +4731,7 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) if (!effect || check_hit2(power, rlev, ac)) { /* Always disturbing */ - if (disturb_other) disturb(1); + disturb_on_other(); /* Describe the attack method */ switch (method) -- cgit v1.2.3 From f035201f330a3b1f50a2041ea9ad3f854f7d4e00 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Move all options to a struct instead of using globals --- src/melee2.cc | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 91dfcaf2..49742a59 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -302,23 +302,22 @@ static void remove_bad_spells(int m_idx, monster_spell_flag_set *spells_p) /* Too stupid to know anything? */ auto const r_ptr = m_ptr->race(); - if (r_ptr->flags & RF_STUPID) return; - + if (r_ptr->flags & RF_STUPID) + { + return; + } /* Must be cheating or learning */ - if (!smart_learn) return; - - - /* Update acquired knowledge */ - if (smart_learn) + if (!options->smart_learn) { - /* Hack -- Occasionally forget player status */ - if (m_ptr->smart && magik(1)) m_ptr->smart = 0L; - - /* Use the memorized flags */ - smart = m_ptr->smart; + return; } + /* Hack -- Occasionally forget player status */ + if (m_ptr->smart && magik(1)) m_ptr->smart = 0L; + + /* Use the memorized flags */ + smart = m_ptr->smart; /* Nothing known */ if (!smart) return; @@ -897,7 +896,7 @@ static void monster_msg(cptr fmt, ...) void monster_msg_simple(cptr s) { /* Display */ - if (disturb_other) + if (options->disturb_other) { msg_print(s); } @@ -924,7 +923,7 @@ void cmonster_msg(char a, cptr fmt, ...) va_end(vp); /* Display */ - if (disturb_other) + if (options->disturb_other) cmsg_print(a, buf); else { @@ -3933,7 +3932,10 @@ static int mon_will_run(int m_idx) static bool_ get_fear_moves_aux(int m_idx, int *yp, int *xp) { /* Monster flowing disabled */ - if (!flow_by_sound) return (FALSE); + if (!options->flow_by_sound) + { + return (FALSE); + } /* Monster location */ monster_type *m_ptr = &m_list[m_idx]; @@ -4051,7 +4053,7 @@ static bool_ find_safety(int m_idx, int *yp, int *xp) if (distance(y, x, fy, fx) != d) continue; /* Check for "availability" (if monsters can flow) */ - if (flow_by_sound) + if (options->flow_by_sound) { /* Ignore grids very far from the player */ if (cave[y][x].when < cave[p_ptr->py][p_ptr->px].when) continue; @@ -4439,7 +4441,7 @@ static bool_ get_moves(int m_idx, int *mm) else { /* Attempt to avoid the player */ - if (flow_by_sound) + if (options->flow_by_sound) { /* Adjust movement */ (void)get_fear_moves_aux(m_idx, &y, &x); @@ -5846,7 +5848,10 @@ static void process_monster(int m_idx, bool_ is_frien) msg_print("You hear a door burst open!"); /* Disturb (sometimes) */ - if (disturb_minor) disturb(0); + if (options->disturb_minor) + { + disturb(0); + } /* The door was bashed open */ did_bash_door = TRUE; @@ -6127,12 +6132,12 @@ static void process_monster(int m_idx, bool_ is_frien) } /* Possible disturb */ - if (m_ptr->ml && (disturb_move || + if (m_ptr->ml && (options->disturb_move || ((m_ptr->mflag & (MFLAG_VIEW)) && - disturb_near))) + options->disturb_near))) { /* Disturb */ - if ((is_friend(m_ptr) < 0) || disturb_pets) + if ((is_friend(m_ptr) < 0) || options->disturb_pets) disturb(0); } @@ -6485,7 +6490,7 @@ void process_monsters(void) /* Hack -- Monsters can "smell" the player from far away */ /* Note that most monsters have "aaf" of "20" or so */ - else if (flow_by_sound && + else if (options->flow_by_sound && (cave[p_ptr->py][p_ptr->px].when == cave[fy][fx].when) && (cave[fy][fx].cost < MONSTER_FLOW_DEPTH) && (cave[fy][fx].cost < r_ptr->aaf)) -- cgit v1.2.3 From 39eb6a171792b3bd34e0afdafa72a1a2b7d9fd78 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Add explicit braces in a few places --- src/melee2.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 49742a59..d519dd8a 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -924,7 +924,9 @@ void cmonster_msg(char a, cptr fmt, ...) /* Display */ if (options->disturb_other) + { cmsg_print(a, buf); + } else { message_add(buf, a); @@ -2038,7 +2040,10 @@ static bool_ monst_spell_monst(int m_idx) case SF_TPORT_IDX: { - if (dungeon_flags & DF_NO_TELEPORT) break; /* No teleport on special levels */ + if (dungeon_flags & DF_NO_TELEPORT) + { + break; /* No teleport on special levels */ + } else { disturb_on_other(); @@ -2056,9 +2061,15 @@ static bool_ monst_spell_monst(int m_idx) case SF_TELE_AWAY_IDX: { - if (dungeon_flags & DF_NO_TELEPORT) break; + if (dungeon_flags & DF_NO_TELEPORT) + { + break; + } - if (!direct) break; + if (!direct) + { + break; + } else { bool_ resists_tele = FALSE; -- cgit v1.2.3 From b15461dbcedf27f28a843f700ce0473d57364230 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove redundant checks "around" artifact_p() Turns out artifact_p() already performs the necessary checks. --- src/melee2.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index d519dd8a..130b74ee 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -6211,8 +6211,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (flags & TR_SLAY_EVIL) flg |= RF_EVIL; /* The object cannot be picked up by the monster */ - if (artifact_p(o_ptr) || (r_ptr->flags & flg) || - (o_ptr->art_name)) + if (artifact_p(o_ptr) || (r_ptr->flags & flg)) { /* Only give a message for "take_item" */ if (r_ptr->flags & RF_TAKE_ITEM) -- cgit v1.2.3 From 013e27d39ee8ee513208d2855c7e3f6252f0c0bf Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Refactor object_type 'inscription' field to std::string We don't really need quarks for this since we're not nearly as memory-constrained these days. --- src/melee2.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 130b74ee..562bca57 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2381,12 +2381,9 @@ void curse_equipment(int chance, int heavy_chance) if (changed) { msg_print("There is a malignant black aura surrounding you..."); - if (o_ptr->note) + if (o_ptr->inscription == "uncursed") { - if (streq(quark_str(o_ptr->note), "uncursed")) - { - o_ptr->note = 0; - } + o_ptr->inscription.clear(); } } } @@ -2438,12 +2435,9 @@ void curse_equipment_dg(int chance, int heavy_chance) if (changed) { msg_print("There is a malignant black aura surrounding you..."); - if (o_ptr->note) + if (o_ptr->inscription == "uncursed") { - if (streq(quark_str(o_ptr->note), "uncursed")) - { - o_ptr->note = 0; - } + o_ptr->inscription.clear(); } } } -- cgit v1.2.3 From 8bbf783ead4517465445272f9144cf06bdac9be7 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Refactor object_type 'artifact name' field to std::string We don't really need quarks for this since we're not nearly as memory-constrained these days. --- src/melee2.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 562bca57..41756550 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2362,7 +2362,7 @@ void curse_equipment(int chance, int heavy_chance) } if ((randint(100) <= heavy_chance) && - (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name)) + (o_ptr->name1 || o_ptr->name2 || (!o_ptr->artifact_name.empty()))) { if (!(flags & TR_HEAVY_CURSE)) changed = TRUE; @@ -2414,7 +2414,7 @@ void curse_equipment_dg(int chance, int heavy_chance) } if ((randint(100) <= heavy_chance) && - (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name)) + (o_ptr->name1 || o_ptr->name2 || (!o_ptr->artifact_name.empty()))) { if (!(flags & TR_HEAVY_CURSE)) changed = TRUE; -- cgit v1.2.3 From 288c3d3f725eabfee06507966a0ba63bf587c3da Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove quark.{cc,hpp} --- src/melee2.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 41756550..773cdad1 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -38,7 +38,6 @@ #include "object_flag.hpp" #include "options.hpp" #include "player_type.hpp" -#include "quark.hpp" #include "skills.hpp" #include "spells1.hpp" #include "spells2.hpp" -- cgit v1.2.3 From 0c2f30b56c221a826ba64f0ec864c29d0f717644 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move r_info into GameEditData --- src/melee2.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 773cdad1..d1fc3767 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -20,6 +20,7 @@ #include "feature_flag.hpp" #include "feature_type.hpp" #include "files.hpp" +#include "game.hpp" #include "hook_mon_speak_in.hpp" #include "hook_monster_ai_in.hpp" #include "hook_monster_ai_out.hpp" @@ -4175,19 +4176,20 @@ static bool_ find_hiding(int m_idx, int *yp, int *xp) /* Find an appropriate corpse */ void find_corpse(monster_type *m_ptr, int *y, int *x) { + auto const &r_info = game->edit_data.r_info; + int k, last = -1; for (k = 0; k < max_o_idx; k++) { object_type *o_ptr = &o_list[k]; - monster_race *rt_ptr, *rt2_ptr; if (!o_ptr->k_idx) continue; if (o_ptr->tval != TV_CORPSE) continue; if ((o_ptr->sval != SV_CORPSE_CORPSE) && (o_ptr->sval != SV_CORPSE_SKELETON)) continue; - rt_ptr = &r_info[o_ptr->pval2]; + auto rt_ptr = &r_info[o_ptr->pval2]; /* Cannot incarnate into a higher level monster */ if (rt_ptr->level > m_ptr->level) continue; @@ -4197,9 +4199,16 @@ void find_corpse(monster_type *m_ptr, int *y, int *x) if (last != -1) { - rt2_ptr = &r_info[o_list[last].pval2]; - if (rt_ptr->level > rt2_ptr->level) last = k; - else continue; + auto rt2_ptr = &r_info[o_list[last].pval2]; + + if (rt_ptr->level > rt2_ptr->level) + { + last = k; + } + else + { + continue; + } } else { @@ -4220,6 +4229,8 @@ void find_corpse(monster_type *m_ptr, int *y, int *x) */ static void get_target_monster(int m_idx) { + auto const &r_info = game->edit_data.r_info; + monster_type *m_ptr = &m_list[m_idx]; int i, t = -1, d = 9999; @@ -4229,7 +4240,7 @@ static void get_target_monster(int m_idx) /* Access the monster */ monster_type *t_ptr = &m_list[i]; /* hack should call the function for ego monsters ... but no_target i not meant to be added by ego and it speeds up the code */ - monster_race *rt_ptr = &r_info[t_ptr->r_idx]; + auto rt_ptr = &r_info[t_ptr->r_idx]; int dd; /* Ignore "dead" monsters */ @@ -6389,6 +6400,8 @@ void summon_maint(int m_idx) */ void process_monsters(void) { + auto const &r_info = game->edit_data.r_info; + int i, e; int fx, fy; -- cgit v1.2.3 From b9fca0267b1d6a32d57e1fb4387f52c19d1c3fa6 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move f_info into GameEditData --- src/melee2.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index d1fc3767..415fd478 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -5254,6 +5254,8 @@ static bool_ player_invis(monster_type * m_ptr) */ static void process_monster(int m_idx, bool_ is_frien) { + auto const &f_info = game->edit_data.f_info; + int i, d, oy, ox, ny, nx; int mm[8]; -- cgit v1.2.3 From cbafbc638c2e1d5bb40ee6bc419007062e9615e4 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:09 +0200 Subject: Remove traps Credit goes mostly to "miramor" who did most of the actual work. I just did a few minor tweaks and fixes + rebased onto master. --- src/melee2.cc | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 415fd478..df9ee6d3 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -44,7 +44,6 @@ #include "spells2.hpp" #include "stats.hpp" #include "tables.hpp" -#include "traps.hpp" #include "util.hpp" #include "variable.hpp" #include "xtra2.hpp" @@ -2126,12 +2125,6 @@ static bool_ monst_spell_monst(int m_idx) break; } - case SF_TRAPS_IDX: - { - /* Not implemented */ - break; - } - case SF_FORGET_IDX: { /* Not implemented */ @@ -3628,15 +3621,6 @@ static bool_ make_attack_spell(int m_idx) break; } - case SF_TRAPS_IDX: - { - disturb(1); - if (blind) msg_format("%^s mumbles, and then cackles evilly.", m_name); - else msg_format("%^s casts a spell and cackles evilly.", m_name); - (void)trap_creation(); - break; - } - case SF_FORGET_IDX: { disturb(1); @@ -5683,13 +5667,6 @@ static void process_monster(int m_idx, bool_ is_frien) do_move = TRUE; } - /* Floor is trapped? */ - else if (c_ptr->feat == FEAT_MON_TRAP) - { - /* Go ahead and move */ - do_move = TRUE; - } - /* Hack -- check for Glyph of Warding */ if ((c_ptr->feat == FEAT_GLYPH) && !(r_ptr->flags & RF_NEVER_BLOW)) @@ -6158,12 +6135,7 @@ static void process_monster(int m_idx, bool_ is_frien) disturb(0); } - /* Check for monster trap */ - if (c_ptr->feat == FEAT_MON_TRAP) - { - if (mon_hit_trap(m_idx)) return; - } - else + { /* Copy list of objects; we need a copy because we're mutating the list. */ auto const object_idxs(c_ptr->o_idxs); -- cgit v1.2.3 From b3d136333c1b516123cc83e3dc96d4bd79dd52ca Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 20:01:12 +0200 Subject: Fix indentation --- src/melee2.cc | 174 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 86 insertions(+), 88 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index df9ee6d3..691021a5 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -6136,116 +6136,114 @@ static void process_monster(int m_idx, bool_ is_frien) } + /* Copy list of objects; we need a copy because we're mutating the list. */ + auto const object_idxs(c_ptr->o_idxs); + + /* Scan all objects in the grid */ + for (auto const this_o_idx: object_idxs) { - /* Copy list of objects; we need a copy because we're mutating the list. */ - auto const object_idxs(c_ptr->o_idxs); + /* Acquire object */ + object_type * o_ptr = &o_list[this_o_idx]; + + /* Skip gold */ + if (o_ptr->tval == TV_GOLD) continue; + + /* Incarnate ? */ + if ((o_ptr->tval == TV_CORPSE) && (r_ptr->flags & RF_POSSESSOR) && + ((o_ptr->sval == SV_CORPSE_CORPSE) || (o_ptr->sval == SV_CORPSE_SKELETON))) + { + if (ai_possessor(m_idx, this_o_idx)) return; + } - /* Scan all objects in the grid */ - for (auto const this_o_idx: object_idxs) + /* Take or Kill objects on the floor */ + /* rr9: Pets will no longer pick up/destroy items */ + if ((((r_ptr->flags & RF_TAKE_ITEM) && + ((is_friend(m_ptr) <= 0) || p_ptr->pet_pickup_items)) || + (r_ptr->flags & RF_KILL_ITEM)) && + (is_friend(m_ptr) <= 0)) { - /* Acquire object */ - object_type * o_ptr = &o_list[this_o_idx]; + char m_name[80]; + char o_name[80]; - /* Skip gold */ - if (o_ptr->tval == TV_GOLD) continue; + /* Extract some flags */ + auto const flags = object_flags(o_ptr); - /* Incarnate ? */ - if ((o_ptr->tval == TV_CORPSE) && (r_ptr->flags & RF_POSSESSOR) && - ((o_ptr->sval == SV_CORPSE_CORPSE) || (o_ptr->sval == SV_CORPSE_SKELETON))) - { - if (ai_possessor(m_idx, this_o_idx)) return; - } + /* Acquire the object name */ + object_desc(o_name, o_ptr, TRUE, 3); - /* Take or Kill objects on the floor */ - /* rr9: Pets will no longer pick up/destroy items */ - if ((((r_ptr->flags & RF_TAKE_ITEM) && - ((is_friend(m_ptr) <= 0) || p_ptr->pet_pickup_items)) || - (r_ptr->flags & RF_KILL_ITEM)) && - (is_friend(m_ptr) <= 0)) + /* Acquire the monster name */ + monster_desc(m_name, m_ptr, 0x04); + + /* React to objects that hurt the monster */ + monster_race_flag_set flg; + if (flags & TR_KILL_DEMON) flg |= RF_DEMON; + if (flags & TR_KILL_UNDEAD) flg |= RF_UNDEAD; + if (flags & TR_SLAY_DRAGON) flg |= RF_DRAGON; + if (flags & TR_SLAY_TROLL) flg |= RF_TROLL; + if (flags & TR_SLAY_GIANT) flg |= RF_GIANT; + if (flags & TR_SLAY_ORC) flg |= RF_ORC; + if (flags & TR_SLAY_DEMON) flg |= RF_DEMON; + if (flags & TR_SLAY_UNDEAD) flg |= RF_UNDEAD; + if (flags & TR_SLAY_ANIMAL) flg |= RF_ANIMAL; + if (flags & TR_SLAY_EVIL) flg |= RF_EVIL; + + /* The object cannot be picked up by the monster */ + if (artifact_p(o_ptr) || (r_ptr->flags & flg)) { - char m_name[80]; - char o_name[80]; - - /* Extract some flags */ - auto const flags = object_flags(o_ptr); - - /* Acquire the object name */ - object_desc(o_name, o_ptr, TRUE, 3); - - /* Acquire the monster name */ - monster_desc(m_name, m_ptr, 0x04); - - /* React to objects that hurt the monster */ - monster_race_flag_set flg; - if (flags & TR_KILL_DEMON) flg |= RF_DEMON; - if (flags & TR_KILL_UNDEAD) flg |= RF_UNDEAD; - if (flags & TR_SLAY_DRAGON) flg |= RF_DRAGON; - if (flags & TR_SLAY_TROLL) flg |= RF_TROLL; - if (flags & TR_SLAY_GIANT) flg |= RF_GIANT; - if (flags & TR_SLAY_ORC) flg |= RF_ORC; - if (flags & TR_SLAY_DEMON) flg |= RF_DEMON; - if (flags & TR_SLAY_UNDEAD) flg |= RF_UNDEAD; - if (flags & TR_SLAY_ANIMAL) flg |= RF_ANIMAL; - if (flags & TR_SLAY_EVIL) flg |= RF_EVIL; - - /* The object cannot be picked up by the monster */ - if (artifact_p(o_ptr) || (r_ptr->flags & flg)) + /* Only give a message for "take_item" */ + if (r_ptr->flags & RF_TAKE_ITEM) { - /* Only give a message for "take_item" */ - if (r_ptr->flags & RF_TAKE_ITEM) + /* Describe observable situations */ + if (m_ptr->ml && player_has_los_bold(ny, nx)) { - /* Describe observable situations */ - if (m_ptr->ml && player_has_los_bold(ny, nx)) - { - /* Dump a message */ - msg_format("%^s tries to pick up %s, but fails.", - m_name, o_name); - } + /* Dump a message */ + msg_format("%^s tries to pick up %s, but fails.", + m_name, o_name); } } + } - /* Pick up the item */ - else if (r_ptr->flags & RF_TAKE_ITEM) + /* Pick up the item */ + else if (r_ptr->flags & RF_TAKE_ITEM) + { + /* Describe observable situations */ + if (player_has_los_bold(ny, nx)) { - /* Describe observable situations */ - if (player_has_los_bold(ny, nx)) - { - /* Dump a message */ - msg_format("%^s picks up %s.", m_name, o_name); - } + /* Dump a message */ + msg_format("%^s picks up %s.", m_name, o_name); + } - /* Put into inventory of monster */ - { - /* Excise the object */ - excise_object_idx(this_o_idx); + /* Put into inventory of monster */ + { + /* Excise the object */ + excise_object_idx(this_o_idx); - /* Forget mark */ - o_ptr->marked = FALSE; + /* Forget mark */ + o_ptr->marked = FALSE; - /* Forget location */ - o_ptr->iy = o_ptr->ix = 0; + /* Forget location */ + o_ptr->iy = o_ptr->ix = 0; - /* Memorize monster */ - o_ptr->held_m_idx = m_idx; + /* Memorize monster */ + o_ptr->held_m_idx = m_idx; - /* Carry object */ - m_ptr->hold_o_idxs.push_back(this_o_idx); - } + /* Carry object */ + m_ptr->hold_o_idxs.push_back(this_o_idx); } + } - /* Destroy the item */ - else + /* Destroy the item */ + else + { + /* Describe observable situations */ + if (player_has_los_bold(ny, nx)) { - /* Describe observable situations */ - if (player_has_los_bold(ny, nx)) - { - /* Dump a message */ - msg_format("%^s crushes %s.", m_name, o_name); - } - - /* Delete the object */ - delete_object_idx(this_o_idx); + /* Dump a message */ + msg_format("%^s crushes %s.", m_name, o_name); } + + /* Delete the object */ + delete_object_idx(this_o_idx); } } } -- cgit v1.2.3 From 71a820e7298a670c13bd68cb3e6f2274a4dc3ba9 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 8 Oct 2016 11:38:29 +0200 Subject: Remove unused parameter from disturb() --- src/melee2.cc | 110 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 691021a5..0988d2af 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -2647,7 +2647,7 @@ static bool_ make_attack_spell(int m_idx) /* Do a breath */ auto do_breath = [&](char const *element, int gf, s32b max, int divisor, int smart_learn) -> void { // Interrupt - disturb(1); + disturb(); // Message if (blind) { @@ -2678,7 +2678,7 @@ static bool_ make_attack_spell(int m_idx) /* Do a summoning spell */ auto do_summon = [&](char const *action, int n, int type, summon_messages const &blind_msg) -> void { // Interrupt - disturb(1); + disturb(); // Message if (blind) { @@ -2713,7 +2713,7 @@ static bool_ make_attack_spell(int m_idx) { case SF_SHRIEK_IDX: { - disturb(1); + disturb(); msg_format("%^s makes a high pitched shriek.", m_name); aggravate_monsters(m_idx); break; @@ -2726,7 +2726,7 @@ static bool_ make_attack_spell(int m_idx) case SF_ROCKET_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s shoots something.", m_name); else msg_format("%^s fires a rocket.", m_name); breath(m_idx, GF_ROCKET, @@ -2737,7 +2737,7 @@ static bool_ make_attack_spell(int m_idx) case SF_ARROW_1_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s makes a strange noise.", m_name); else msg_format("%^s fires an arrow.", m_name); bolt(m_idx, GF_ARROW, damroll(1, 6)); @@ -2747,7 +2747,7 @@ static bool_ make_attack_spell(int m_idx) case SF_ARROW_2_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s makes a strange noise.", m_name); else msg_format("%^s fires an arrow!", m_name); bolt(m_idx, GF_ARROW, damroll(3, 6)); @@ -2757,7 +2757,7 @@ static bool_ make_attack_spell(int m_idx) case SF_ARROW_3_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s makes a strange noise.", m_name); else msg_format("%^s fires a missile.", m_name); bolt(m_idx, GF_ARROW, damroll(5, 6)); @@ -2767,7 +2767,7 @@ static bool_ make_attack_spell(int m_idx) case SF_ARROW_4_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s makes a strange noise.", m_name); else msg_format("%^s fires a missile!", m_name); bolt(m_idx, GF_ARROW, damroll(7, 6)); @@ -2897,7 +2897,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_NUKE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a ball of radiation.", m_name); breath(m_idx, GF_NUKE, (rlev + damroll(10, 6)), 2); @@ -2913,7 +2913,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_CHAO_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles frighteningly.", m_name); else msg_format("%^s invokes a raw chaos.", m_name); breath(m_idx, GF_CHAOS, (rlev * 2) + damroll(10, 10), 4); @@ -2929,7 +2929,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_ACID_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts an acid ball.", m_name); breath(m_idx, GF_ACID, @@ -2940,7 +2940,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_ELEC_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a lightning ball.", m_name); breath(m_idx, GF_ELEC, @@ -2951,7 +2951,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_FIRE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a fire ball.", m_name); breath(m_idx, GF_FIRE, @@ -2962,7 +2962,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_COLD_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a frost ball.", m_name); breath(m_idx, GF_COLD, @@ -2973,7 +2973,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_POIS_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a stinking cloud.", m_name); breath(m_idx, GF_POIS, @@ -2984,7 +2984,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_NETH_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a nether ball.", m_name); breath(m_idx, GF_NETHER, @@ -2995,7 +2995,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_WATE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s gestures fluidly.", m_name); msg_print("You are engulfed in a whirlpool."); @@ -3006,7 +3006,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_MANA_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles powerfully.", m_name); else msg_format("%^s invokes a mana storm.", m_name); breath(m_idx, GF_MANA, @@ -3016,7 +3016,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BA_DARK_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles powerfully.", m_name); else msg_format("%^s invokes a darkness storm.", m_name); breath(m_idx, GF_DARK, @@ -3032,7 +3032,7 @@ static bool_ make_attack_spell(int m_idx) int r1; /* Disturb if legal */ - disturb(1); + disturb(); /* Basic message */ msg_format("%^s draws psychic energy from you!", m_name); @@ -3083,7 +3083,7 @@ static bool_ make_attack_spell(int m_idx) case SF_MIND_BLAST_IDX: { - disturb(1); + disturb(); if (!seen) { msg_print("You feel something focusing on your mind."); @@ -3118,7 +3118,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BRAIN_SMASH_IDX: { - disturb(1); + disturb(); if (!seen) { msg_print("You feel something focusing on your mind."); @@ -3165,7 +3165,7 @@ static bool_ make_attack_spell(int m_idx) case SF_CAUSE_1_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s points at you and curses.", m_name); if (rand_int(100) < p_ptr->skill_sav) @@ -3182,7 +3182,7 @@ static bool_ make_attack_spell(int m_idx) case SF_CAUSE_2_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s points at you and curses horribly.", m_name); if (rand_int(100) < p_ptr->skill_sav) @@ -3199,7 +3199,7 @@ static bool_ make_attack_spell(int m_idx) case SF_CAUSE_3_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles loudly.", m_name); else msg_format("%^s points at you, incanting terribly!", m_name); if (rand_int(100) < p_ptr->skill_sav) @@ -3216,7 +3216,7 @@ static bool_ make_attack_spell(int m_idx) case SF_CAUSE_4_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s screams the word 'DIE!'", m_name); else msg_format("%^s points at you, screaming the word DIE!", m_name); if (rand_int(100) < p_ptr->skill_sav) @@ -3233,7 +3233,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_ACID_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a acid bolt.", m_name); bolt(m_idx, GF_ACID, damroll(7, 8) + (rlev / 3)); @@ -3244,7 +3244,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_ELEC_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a lightning bolt.", m_name); bolt(m_idx, GF_ELEC, damroll(4, 8) + (rlev / 3)); @@ -3255,7 +3255,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_FIRE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a fire bolt.", m_name); bolt(m_idx, GF_FIRE, damroll(9, 8) + (rlev / 3)); @@ -3266,7 +3266,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_COLD_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a frost bolt.", m_name); bolt(m_idx, GF_COLD, damroll(6, 8) + (rlev / 3)); @@ -3283,7 +3283,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_NETH_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a nether bolt.", m_name); bolt(m_idx, GF_NETHER, 30 + damroll(5, 5) + (rlev * 3) / 2); @@ -3294,7 +3294,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_WATE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a water bolt.", m_name); bolt(m_idx, GF_WATER, damroll(10, 10) + (rlev)); @@ -3304,7 +3304,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_MANA_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a mana bolt.", m_name); bolt(m_idx, GF_MANA, randint(rlev * 7 / 2) + 50); @@ -3314,7 +3314,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_PLAS_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a plasma bolt.", m_name); bolt(m_idx, GF_PLASMA, 10 + damroll(8, 7) + (rlev)); @@ -3324,7 +3324,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BO_ICEE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts an ice bolt.", m_name); bolt(m_idx, GF_ICE, damroll(6, 6) + (rlev)); @@ -3335,7 +3335,7 @@ static bool_ make_attack_spell(int m_idx) case SF_MISSILE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a magic missile.", m_name); bolt(m_idx, GF_MISSILE, damroll(2, 6) + (rlev / 3)); @@ -3345,7 +3345,7 @@ static bool_ make_attack_spell(int m_idx) case SF_SCARE_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles, and you hear scary noises.", m_name); else msg_format("%^s casts a fearful illusion.", m_name); if (p_ptr->resist_fear) @@ -3366,7 +3366,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BLIND_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s casts a spell, burning your eyes!", m_name); if (p_ptr->resist_blind) @@ -3387,7 +3387,7 @@ static bool_ make_attack_spell(int m_idx) case SF_CONF_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles, and you hear puzzling noises.", m_name); else msg_format("%^s creates a mesmerizing illusion.", m_name); if (p_ptr->resist_conf) @@ -3408,7 +3408,7 @@ static bool_ make_attack_spell(int m_idx) case SF_SLOW_IDX: { - disturb(1); + disturb(); msg_format("%^s drains power from your muscles!", m_name); if (p_ptr->free_act) { @@ -3428,7 +3428,7 @@ static bool_ make_attack_spell(int m_idx) case SF_HOLD_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s stares deep into your eyes!", m_name); if (p_ptr->free_act) @@ -3449,7 +3449,7 @@ static bool_ make_attack_spell(int m_idx) case SF_HASTE_IDX: { - disturb(1); + disturb(); if (blind) { msg_format("%^s mumbles.", m_name); @@ -3478,7 +3478,7 @@ static bool_ make_attack_spell(int m_idx) case SF_HAND_DOOM_IDX: { - disturb(1); + disturb(); msg_format("%^s invokes the Hand of Doom!", m_name); if (rand_int(100) < p_ptr->skill_sav) { @@ -3498,7 +3498,7 @@ static bool_ make_attack_spell(int m_idx) case SF_HEAL_IDX: { - disturb(1); + disturb(); /* Message */ if (blind) @@ -3561,7 +3561,7 @@ static bool_ make_attack_spell(int m_idx) case SF_BLINK_IDX: { - disturb(1); + disturb(); msg_format("%^s blinks away.", m_name); teleport_away(m_idx, 10); break; @@ -3569,7 +3569,7 @@ static bool_ make_attack_spell(int m_idx) case SF_TPORT_IDX: { - disturb(1); + disturb(); msg_format("%^s teleports away.", m_name); teleport_away(m_idx, MAX_SIGHT * 2 + 5); break; @@ -3577,7 +3577,7 @@ static bool_ make_attack_spell(int m_idx) case SF_TELE_TO_IDX: { - disturb(1); + disturb(); msg_format("%^s commands you to return.", m_name); teleport_player_to(m_ptr->fy, m_ptr->fx); break; @@ -3585,7 +3585,7 @@ static bool_ make_attack_spell(int m_idx) case SF_TELE_AWAY_IDX: { - disturb(1); + disturb(); msg_format("%^s teleports you away.", m_name); teleport_player(100); break; @@ -3593,7 +3593,7 @@ static bool_ make_attack_spell(int m_idx) case SF_TELE_LEVEL_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles strangely.", m_name); else msg_format("%^s gestures at your feet.", m_name); if (p_ptr->resist_nexus) @@ -3614,7 +3614,7 @@ static bool_ make_attack_spell(int m_idx) case SF_DARKNESS_IDX: { - disturb(1); + disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s gestures in shadow.", m_name); (void)unlite_area(0, 3); @@ -3623,7 +3623,7 @@ static bool_ make_attack_spell(int m_idx) case SF_FORGET_IDX: { - disturb(1); + disturb(); msg_format("%^s tries to blank your mind.", m_name); if (rand_int(100) < p_ptr->skill_sav) @@ -3781,7 +3781,7 @@ static bool_ make_attack_spell(int m_idx) case SF_S_UNIQUE_IDX: { // Interrupt - disturb(1); + disturb(); // Message if (blind) { @@ -5130,7 +5130,7 @@ static bool_ monst_attack_monst(int m_idx, int t_idx) if (m_ptr->ml) { /* Disturbing */ - disturb(1); + disturb(); /* Message */ monster_msg("%^s misses %s.", m_name, t_name); @@ -5844,7 +5844,7 @@ static void process_monster(int m_idx, bool_ is_frien) /* Disturb (sometimes) */ if (options->disturb_minor) { - disturb(0); + disturb(); } /* The door was bashed open */ @@ -6132,7 +6132,7 @@ static void process_monster(int m_idx, bool_ is_frien) { /* Disturb */ if ((is_friend(m_ptr) < 0) || options->disturb_pets) - disturb(0); + disturb(); } -- cgit v1.2.3 From 128b467fcc9a36fc1f8d1794f8c66ae1a9d08274 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 16 Oct 2016 12:28:53 +0200 Subject: Fix monster spell selection caused by 'missing' TRAPS spell --- src/melee2.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 0988d2af..fbc793bd 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -941,11 +941,11 @@ static std::vector extract_spells(monster_spell_flag_set auto result = std::vector(); result.reserve(spell_flag_set.nbits); - for (std::size_t k = 0; k < monster_spell_flag_set::nbits; k++) + for (auto const &monster_spell: monster_spells()) { - if (spell_flag_set.bit(k)) + if (bool(spell_flag_set & monster_spell->flag_set)) { - result.push_back(monster_spells()[k]); + result.push_back(monster_spell); } } -- cgit v1.2.3 From 6a35e3de332df186eab39c3b67506882409a3ca2 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 2 May 2017 19:20:57 +0200 Subject: Remove redundant (void) parameters and return value casts --- src/melee2.cc | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index fbc793bd..3ab3cc1c 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -607,7 +607,7 @@ static void bolt(int m_idx, int typ, int dam_hp) int flg = PROJECT_STOP | PROJECT_KILL; /* Target the player with a bolt attack */ - (void)project(m_idx, 0, p_ptr->py, p_ptr->px, dam_hp, typ, flg); + project(m_idx, 0, p_ptr->py, p_ptr->px, dam_hp, typ, flg); } @@ -837,7 +837,7 @@ static void breath(int m_idx, int typ, int dam_hp, int rad) if (rad < 1) rad = (r_ptr->flags & RF_POWERFUL) ? 3 : 2; /* Target the player with a ball attack */ - (void)project(m_idx, rad, p_ptr->py, p_ptr->px, dam_hp, typ, flg); + project(m_idx, rad, p_ptr->py, p_ptr->px, dam_hp, typ, flg); } @@ -856,7 +856,7 @@ static void monst_breath_monst(int m_idx, int y, int x, int typ, int dam_hp, int /* Determine the radius of the blast */ if (rad < 1) rad = (r_ptr->flags & RF_POWERFUL) ? 3 : 2; - (void)project(m_idx, rad, y, x, dam_hp, typ, flg); + project(m_idx, rad, y, x, dam_hp, typ, flg); } @@ -869,7 +869,7 @@ static void monst_bolt_monst(int m_idx, int y, int x, int typ, int dam_hp) { int flg = PROJECT_STOP | PROJECT_KILL; - (void)project(m_idx, 0, y, x, dam_hp, typ, flg); + project(m_idx, 0, y, x, dam_hp, typ, flg); } @@ -883,7 +883,7 @@ static void monster_msg(cptr fmt, ...) va_start(vp, fmt); /* Format the args, save the length */ - (void)vstrnfmt(buf, 1024, fmt, vp); + vstrnfmt(buf, 1024, fmt, vp); /* End the Varargs Stuff */ va_end(vp); @@ -916,7 +916,7 @@ void cmonster_msg(char a, cptr fmt, ...) va_start(vp, fmt); /* Format the args, save the length */ - (void)vstrnfmt(buf, 1024, fmt, vp); + vstrnfmt(buf, 1024, fmt, vp); /* End the Varargs Stuff */ va_end(vp); @@ -2119,7 +2119,7 @@ static bool_ monst_spell_monst(int m_idx) else monster_msg("%^s gestures in shadow.", m_name); if (seen) monster_msg("%^s is surrounded by darkness.", t_name); - (void)project(m_idx, 3, y, x, 0, GF_DARK_WEAK, PROJECT_GRID | PROJECT_KILL); + project(m_idx, 3, y, x, 0, GF_DARK_WEAK, PROJECT_GRID | PROJECT_KILL); /* Lite up the room */ unlite_room(y, x); break; @@ -3103,12 +3103,12 @@ static bool_ make_attack_spell(int m_idx) if (!p_ptr->resist_conf) { - (void)set_confused(p_ptr->confused + rand_int(4) + 4); + set_confused(p_ptr->confused + rand_int(4) + 4); } if ((!p_ptr->resist_chaos) && (randint(3) == 1)) { - (void) set_image(p_ptr->image + rand_int(250) + 150); + set_image(p_ptr->image + rand_int(250) + 150); } take_sanity_hit(damroll(8, 8), ddesc); @@ -3138,26 +3138,26 @@ static bool_ make_attack_spell(int m_idx) take_sanity_hit(damroll(12, 15), ddesc); if (!p_ptr->resist_blind) { - (void)set_blind(p_ptr->blind + 8 + rand_int(8)); + set_blind(p_ptr->blind + 8 + rand_int(8)); } if (!p_ptr->resist_conf) { - (void)set_confused(p_ptr->confused + rand_int(4) + 4); + set_confused(p_ptr->confused + rand_int(4) + 4); } if (!p_ptr->free_act) { - (void)set_paralyzed(rand_int(4) + 4); + set_paralyzed(rand_int(4) + 4); } - (void)set_slow(p_ptr->slow + rand_int(4) + 4); + set_slow(p_ptr->slow + rand_int(4) + 4); while (rand_int(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_INT, STAT_DEC_NORMAL); + do_dec_stat(A_INT, STAT_DEC_NORMAL); while (rand_int(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_WIS, STAT_DEC_NORMAL); + do_dec_stat(A_WIS, STAT_DEC_NORMAL); if (!p_ptr->resist_chaos) { - (void) set_image(p_ptr->image + rand_int(250) + 150); + set_image(p_ptr->image + rand_int(250) + 150); } } break; @@ -3226,7 +3226,7 @@ static bool_ make_attack_spell(int m_idx) else { take_hit(damroll(15, 15), ddesc); - (void)set_cut(p_ptr->cut + damroll(10, 10)); + set_cut(p_ptr->cut + damroll(10, 10)); } break; } @@ -3358,7 +3358,7 @@ static bool_ make_attack_spell(int m_idx) } else { - (void)set_afraid(p_ptr->afraid + rand_int(4) + 4); + set_afraid(p_ptr->afraid + rand_int(4) + 4); } update_smart_learn(m_idx, DRS_FEAR); break; @@ -3379,7 +3379,7 @@ static bool_ make_attack_spell(int m_idx) } else { - (void)set_blind(12 + rand_int(4)); + set_blind(12 + rand_int(4)); } update_smart_learn(m_idx, DRS_BLIND); break; @@ -3400,7 +3400,7 @@ static bool_ make_attack_spell(int m_idx) } else { - (void)set_confused(p_ptr->confused + rand_int(4) + 4); + set_confused(p_ptr->confused + rand_int(4) + 4); } update_smart_learn(m_idx, DRS_CONF); break; @@ -3420,7 +3420,7 @@ static bool_ make_attack_spell(int m_idx) } else { - (void)set_slow(p_ptr->slow + rand_int(4) + 4); + set_slow(p_ptr->slow + rand_int(4) + 4); } update_smart_learn(m_idx, DRS_FREE); break; @@ -3441,7 +3441,7 @@ static bool_ make_attack_spell(int m_idx) } else { - (void)set_paralyzed(rand_int(4) + 4); + set_paralyzed(rand_int(4) + 4); } update_smart_learn(m_idx, DRS_FREE); break; @@ -3617,7 +3617,7 @@ static bool_ make_attack_spell(int m_idx) disturb(); if (blind) msg_format("%^s mumbles.", m_name); else msg_format("%^s gestures in shadow.", m_name); - (void)unlite_area(0, 3); + unlite_area(0, 3); break; } @@ -4443,7 +4443,7 @@ static bool_ get_moves(int m_idx, int *mm) if (options->flow_by_sound) { /* Adjust movement */ - (void)get_fear_moves_aux(m_idx, &y, &x); + get_fear_moves_aux(m_idx, &y, &x); } } } @@ -5974,7 +5974,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (do_move && (ny == p_ptr->py) && (nx == p_ptr->px)) { /* Do the attack */ - (void)make_attack_normal(m_idx, 1); + make_attack_normal(m_idx, 1); /* Do not move */ do_move = FALSE; @@ -6370,7 +6370,7 @@ void summon_maint(int m_idx) * changes (flags, attacks, spells), we induce a redraw of the monster * recall window. */ -void process_monsters(void) +void process_monsters() { auto const &r_info = game->edit_data.r_info; -- cgit v1.2.3 From 554ff9a63d5d9bc64f668a00b6baa9b91dc41306 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 13 Jun 2017 18:24:42 +0200 Subject: Move "messages" to Game struct --- src/melee2.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 3ab3cc1c..10807b44 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -894,6 +894,8 @@ static void monster_msg(cptr fmt, ...) void monster_msg_simple(cptr s) { + auto &messages = game->messages; + /* Display */ if (options->disturb_other) { @@ -901,7 +903,7 @@ void monster_msg_simple(cptr s) } else { - message_add(s, TERM_WHITE); + messages.add(s, TERM_WHITE); p_ptr->window |= PW_MESSAGE; } } @@ -910,6 +912,7 @@ void cmonster_msg(char a, cptr fmt, ...) { va_list vp; + auto &messages = game->messages; char buf[1024]; /* Begin the Varargs Stuff */ @@ -928,7 +931,7 @@ void cmonster_msg(char a, cptr fmt, ...) } else { - message_add(buf, a); + messages.add(buf, a); p_ptr->window |= PW_MESSAGE; } } -- cgit v1.2.3 From 6f14a3a6846868dc07e60ba1350ffe0cea5ad4ae Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 13 Jun 2017 18:24:42 +0200 Subject: Clean up cmonster_msg() --- src/melee2.cc | 66 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'src/melee2.cc') diff --git a/src/melee2.cc b/src/melee2.cc index 10807b44..d769355a 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -56,7 +56,6 @@ #define FOLLOW_DISTANCE 6 -static void cmonster_msg(char a, cptr fmt, ...); /* * Based on mon_take_hit... all monster attacks on @@ -66,6 +65,28 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) { monster_type *m_ptr = &m_list[m_idx], *s_ptr = &m_list[s_idx]; + /* Output */ + auto cmonster_msg = [m_ptr](std::string const &suffix) { + auto &messages = game->messages; + // Build monster name + char m_name[80]; + monster_desc(m_name, m_ptr, 0); + capitalize(m_name); + // Add suffix + auto msg = std::string(m_name); + msg += suffix; + // Display + if (options->disturb_other) + { + cmsg_print(TERM_L_RED, msg); + } + else + { + messages.add(msg, TERM_L_RED); + p_ptr->window |= PW_MESSAGE; + } + }; + /* Redraw (later) if needed */ if (health_who == m_idx) p_ptr->redraw |= (PR_FRAME); @@ -89,18 +110,17 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) } else { - char m_name[80]; s32b dive = s_ptr->level; - if (!dive) dive = 1; - - /* Extract monster name */ - monster_desc(m_name, m_ptr, 0); + if (!dive) + { + dive = 1; + } /* Death by Missile/Spell attack */ if (note) { - cmonster_msg(TERM_L_RED, "%^s%s", m_name, note); + cmonster_msg(note); } /* Death by Physical attack -- living monster */ else if (!m_ptr->ml) @@ -114,11 +134,11 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note) (r_ptr->flags & RF_NONLIVING) || (strchr("Evg", r_ptr->d_char))) { - cmonster_msg(TERM_L_RED, "%^s is destroyed.", m_name); + cmonster_msg(" is destroyed."); } else { - cmonster_msg(TERM_L_RED, "%^s is killed.", m_name); + cmonster_msg(" is killed."); } dive = r_ptr->mexp * m_ptr->level / dive; @@ -908,34 +928,6 @@ void monster_msg_simple(cptr s) } } -void cmonster_msg(char a, cptr fmt, ...) -{ - va_list vp; - - auto &messages = game->messages; - char buf[1024]; - - /* Begin the Varargs Stuff */ - va_start(vp, fmt); - - /* Format the args, save the length */ - vstrnfmt(buf, 1024, fmt, vp); - - /* End the Varargs Stuff */ - va_end(vp); - - /* Display */ - if (options->disturb_other) - { - cmsg_print(a, buf); - } - else - { - messages.add(buf, a); - p_ptr->window |= PW_MESSAGE; - } -} - /** * Extract list of spell indexes from a flag set. */ -- cgit v1.2.3