Monster attacks. More...
|static void||remove_bad_spells (struct monster *mon, bitflag f[RSF_SIZE])|
|This file deals with monster attacks (including spells) as follows: More...|
|static bool||summon_possible (int y1, int x1)|
|Determine if there is a space near the selected spot in which a summoned creature can appear. More...|
|static int||choose_attack_spell (bitflag f[RSF_SIZE])|
|Have a monster choose a spell to cast. More...|
|bool||make_attack_spell (struct monster *mon)|
|Creatures can cast spells, shoot missiles, and breathe. More...|
|static int||monster_critical (random_value dice, int rlev, int dam)|
|Critical blow. More...|
|bool||check_hit (struct player *p, int power, int level, int debuff)|
|Determine if a monster attack against the player succeeds. More...|
|int||adjust_dam_armor (int damage, int ac)|
|Calculate how much damage remains after armor is taken into account (does for a physical attack what adjust_dam does for an elemental attack). More...|
|bool||make_attack_normal (struct monster *mon, struct player *p)|
|Attack the player via physical attacks. More...|
|bool(*||testfn_make_attack_normal )(struct monster *m, struct player *p) = make_attack_normal|
Monster ranged attacks - choosing an attack spell or shot and making it. Monster melee attacks - monster critical blows, whether a monster attack hits, what happens when a monster attacks an adjacent player.
Copyright (c) 1997 Ben Harrison, David Reeve Sward, Keldon Jones.
This work is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation, version 2, or
b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.
Have a monster choose a spell to cast.
Note that the monster's spell list has already had "useless" spells (bolts that won't hit the player, summons without room, etc.) removed. Perhaps that should be done by this function.
Stupid monsters will just pick a spell randomly. Smart monsters will choose more "intelligently".
This function could be an efficiency bottleneck.
Referenced by make_attack_spell().
Attack the player via physical attacks.
References player_state::ac, melee_effect_handler_context_s::blinked, monster_race::blow, monster_lore::blows, check_hit(), blow_method::cut, melee_effect_handler_context_s::damage, monster_lore::deaths, monster_blow::dice, disturb(), melee_effect_handler_context_s::do_break, monster_blow::effect, effect_simple(), monster_lore::flags, monster_race::flags, player_upkeep::generate_level, get_lore(), player::is_dead, player::lev, monster_race::level, lore_update(), monster::m_timed, angband_constants::max_sight, MDESC_IND_VIS, MDESC_SHOW, MDESC_STANDARD, melee_handler_for_blow_effect(), monster_blow::method, method, monster::mflag, mflag_has, monster::midx, blow_method::miss, angband_constants::mon_blows_max, monster_blow_method_action(), monster_critical(), monster_desc(), msg, blow_method::msgt, msgt(), blow_effect::name, NULL, melee_effect_handler_context_s::obvious, OPT, p, player_inc_timed(), blow_effect::power, monster::race, randcalc(), randint0, randint1, RANDOMISE, rf_has, rf_on, source_monster(), player::state, streq, strnfmt(), blow_method::stun, STUN_DAM_REDUCTION, STUN_HIT_REDUCTION, player::timed, monster_blow::times_seen, player_state::to_a, player::upkeep, void(), and z_info.
Referenced by process_monster().
|bool make_attack_spell||(||struct monster *||mon||)|
Creatures can cast spells, shoot missiles, and breathe.
Returns "true" if a spell (or whatever) was (successfully) cast.
XXX XXX XXX This function could use some work, but remember to keep it as optimized as possible, while retaining generic code.
Verify the various "blind-ness" checks in the code.
XXX XXX XXX Note that several effects should really not be "seen" if the player is blind.
Perhaps monsters should breathe at locations near the player, since this would allow them to inflict "partial" damage.
Perhaps smart monsters should decline to use "bolt" spells if there is a monster in the way, unless they wish to kill it.
It will not be possible to "correctly" handle the case in which a monster attempts to attack a location which is thought to contain the player, but which in fact is nowhere near the player, since this might induce all sorts of messages about the attack itself, and about the effects of the attack, which the player might or might not be in a position to observe. Thus, for simplicity, it is probably best to only allow "faulty" attacks by a monster if one of the important grids (probably the initial or final grid) is in fact in view of the player. It may be necessary to actually prevent spell attacks except when the monster actually has line of sight to the player. Note that a monster could be left in a bizarre situation after the player ducked behind a pillar and then teleported away, for example.
Note that this function attempts to optimize the use of spells for the cases in which the monster has no spells, or has spells but cannot use them, or has spells but they will have no "useful" effect. Note that this function has been an efficiency bottleneck in the past.
Note the special "MFLAG_NICE" flag, which prevents a monster from using any spell attacks until the player has had a single chance to move.
References become_aware(), monster_lore::cast_innate, monster_lore::cast_spell, cave, monster::cdis, choose_attack_spell(), monster_lore::deaths, disturb(), do_mon_spell(), monster_race::flags, monster_race::freq_innate, monster_race::freq_spell, monster::fx, monster::fy, get_lore(), monster::hp, ignore_spells(), player::is_dead, monster_race::level, lore_update(), monster::m_timed, angband_constants::max_range, monster::maxhp, MDESC_DIED_FROM, MDESC_POSS, MDESC_PRO_VIS, MDESC_STANDARD, monster::mflag, mflag_has, mon_spell_is_innate(), monster_desc(), msg, PROJECT_NONE, PROJECT_STOP, projectable(), player::px, player::py, monster::race, randint0, remove_bad_spells(), rf_has, rsf_copy, rsf_is_empty, rsf_on, RSF_SIZE, RST_ATTACK, RST_BALL, RST_BOLT, RST_BREATH, RST_INNATE, RST_SUMMON, monster_lore::spell_flags, monster_race::spell_flags, summon_possible(), test_spells(), player::timed, and z_info.
Referenced by process_monster().
This file deals with monster attacks (including spells) as follows:
Give monsters more intelligent attack/spell selection based on observations of previous attacks on the player, and/or by allowing the monster to "cheat" and know the player status.
Maintain an idea of the player status, and use that information to occasionally eliminate "ineffective" spell attacks. We could also eliminate ineffective normal attacks, but there is no reason for the monster to do this, since he gains no benefit. Note that MINDLESS monsters are not allowed to use this code. And non-INTELLIGENT monsters only use it partially effectively.
Actually learn what the player resists, and use that information to remove attacks or spells before using them.
This has the added advantage that attacks and spells are related. The "smart_learn" option means that the monster "learns" the flags that should be set, and "smart_cheat" means that he "knows" them. So "smart_cheat" means that the "smart" field is always up to date, while "smart_learn" means that the "smart" field is slowly learned. Both of them have the same effect on the "choose spell" routine. Remove the "bad" spells from a spell list
References monster::cdis, player_state::el_info, ELEM_MAX, f2, monster_race::flags, player_state::flags, monster::hp, i, monster::known_pstate, monster::m_timed, monster::maxhp, of_copy, of_is_empty, OF_SIZE, of_wipe, one_in_, OPT, pf_copy, pf_is_empty, PF_SIZE, pf_wipe, player_state::pflags, monster::race, element_info::res_level, rf_has, rsf_copy, rsf_off, RSF_SIZE, and unset_spells().
Referenced by make_attack_spell().