Angband
Enumerations | Functions
mon-blows.c File Reference

Monster melee module. More...

#include "angband.h"
#include "effects.h"
#include "init.h"
#include "monster.h"
#include "mon-attack.h"
#include "mon-blows.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-make.h"
#include "mon-msg.h"
#include "mon-util.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-slays.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-calcs.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"

Enumerations

enum  blow_tag_t { BLOW_TAG_NONE, BLOW_TAG_TARGET, BLOW_TAG_OF_TARGET, BLOW_TAG_HAS }
 

Monster blow methods

More...
 

Functions

static blow_tag_t blow_tag_lookup (const char *tag)
 
char * monster_blow_method_action (struct blow_method *method, int midx)
 Print a monster blow message. More...
 
int blow_index (const char *name)
 

Monster blow effect helper functions

More...
 
static void steal_player_item (melee_effect_handler_context_t *context)
 Monster steals an item from the player. More...
 
static int monster_elemental_damage (melee_effect_handler_context_t *context, int type, enum mon_messages *hurt_msg, enum mon_messages *die_msg)
 Get the elemental damage taken by a monster from another monster's melee. More...
 
static bool monster_damage_target (melee_effect_handler_context_t *context, bool no_further_monster_effect)
 Deal the actual melee damage from a monster to a target player or monster. More...
 
static void melee_effect_elemental (melee_effect_handler_context_t *context, int type, bool pure_element)
 

Monster blow multi-effect handlers

These are each called by several individual effect handlers

More...
 
static void melee_effect_timed (melee_effect_handler_context_t *context, int type, int amount, int of_flag, bool save, const char *save_msg)
 Do damage as the result of a melee attack that has a status effect. More...
 
static void melee_effect_stat (melee_effect_handler_context_t *context, int stat)
 Do damage as the result of a melee attack that drains a stat. More...
 
static void melee_effect_experience (melee_effect_handler_context_t *context, int chance, int drain_amount)
 Do damage as the result of an experience draining melee attack. More...
 
static void melee_effect_handler_NONE (melee_effect_handler_context_t *context)
 

Monster blow effect handlers

More...
 
static void melee_effect_handler_HURT (melee_effect_handler_context_t *context)
 Melee effect handler: Hurt the player with no side effects. More...
 
static void melee_effect_handler_POISON (melee_effect_handler_context_t *context)
 Melee effect handler: Poison the player. More...
 
static void melee_effect_handler_DISENCHANT (melee_effect_handler_context_t *context)
 Melee effect handler: Disenchant the player. More...
 
static void melee_effect_handler_DRAIN_CHARGES (melee_effect_handler_context_t *context)
 Melee effect handler: Drain charges from the player's inventory. More...
 
static void melee_effect_handler_EAT_GOLD (melee_effect_handler_context_t *context)
 Melee effect handler: Take the player's gold. More...
 
static void melee_effect_handler_EAT_ITEM (melee_effect_handler_context_t *context)
 Melee effect handler: Take something from the player's inventory. More...
 
static void melee_effect_handler_EAT_FOOD (melee_effect_handler_context_t *context)
 Melee effect handler: Eat the player's food. More...
 
static void melee_effect_handler_EAT_LIGHT (melee_effect_handler_context_t *context)
 Melee effect handler: Absorb the player's light. More...
 
static void melee_effect_handler_ACID (melee_effect_handler_context_t *context)
 Melee effect handler: Attack the player with acid. More...
 
static void melee_effect_handler_ELEC (melee_effect_handler_context_t *context)
 Melee effect handler: Attack the player with electricity. More...
 
static void melee_effect_handler_FIRE (melee_effect_handler_context_t *context)
 Melee effect handler: Attack the player with fire. More...
 
static void melee_effect_handler_COLD (melee_effect_handler_context_t *context)
 Melee effect handler: Attack the player with cold. More...
 
static void melee_effect_handler_BLIND (melee_effect_handler_context_t *context)
 Melee effect handler: Blind the player. More...
 
static void melee_effect_handler_CONFUSE (melee_effect_handler_context_t *context)
 Melee effect handler: Confuse the player. More...
 
static void melee_effect_handler_TERRIFY (melee_effect_handler_context_t *context)
 Melee effect handler: Terrify the player. More...
 
static void melee_effect_handler_PARALYZE (melee_effect_handler_context_t *context)
 Melee effect handler: Paralyze the player. More...
 
static void melee_effect_handler_LOSE_STR (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's strength. More...
 
static void melee_effect_handler_LOSE_INT (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's intelligence. More...
 
static void melee_effect_handler_LOSE_WIS (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's wisdom. More...
 
static void melee_effect_handler_LOSE_DEX (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's dexterity. More...
 
static void melee_effect_handler_LOSE_CON (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's constitution. More...
 
static void melee_effect_handler_LOSE_ALL (melee_effect_handler_context_t *context)
 Melee effect handler: Drain all of the player's stats. More...
 
static void melee_effect_handler_SHATTER (melee_effect_handler_context_t *context)
 Melee effect handler: Cause an earthquake around the player. More...
 
static void melee_effect_handler_EXP_10 (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's experience. More...
 
static void melee_effect_handler_EXP_20 (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's experience. More...
 
static void melee_effect_handler_EXP_40 (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's experience. More...
 
static void melee_effect_handler_EXP_80 (melee_effect_handler_context_t *context)
 Melee effect handler: Drain the player's experience. More...
 
static void melee_effect_handler_HALLU (melee_effect_handler_context_t *context)
 Melee effect handler: Make the player hallucinate. More...
 
static void melee_effect_handler_BLACK_BREATH (melee_effect_handler_context_t *context)
 Melee effect handler: Give the player Black Breath. More...
 
melee_effect_handler_f melee_handler_for_blow_effect (const char *name)
 

Monster blow melee handler selection

More...
 

Detailed Description

Monster melee module.

Copyright (c) 1997 Ben Harrison, David Reeve Sward, Keldon Jones. 2013 Ben Semmler 2016 Nick McConnell

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.

Enumeration Type Documentation

◆ blow_tag_t

enum blow_tag_t


Monster blow methods

Enumerator
BLOW_TAG_NONE 
BLOW_TAG_TARGET 
BLOW_TAG_OF_TARGET 
BLOW_TAG_HAS 

Function Documentation

◆ blow_index()

int blow_index ( const char *  name)


Monster blow effect helper functions

References blow_effects, angband_constants::blow_effects_max, i, my_stricmp(), blow_effect::name, and z_info.

Referenced by lore_append_attack().

◆ blow_tag_lookup()

static blow_tag_t blow_tag_lookup ( const char *  tag)
static

◆ melee_effect_elemental()

static void melee_effect_elemental ( melee_effect_handler_context_t context,
int  type,
bool  pure_element 
)
static


Monster blow multi-effect handlers

These are each called by several individual effect handlers

Do damage as the result of a melee attack that has an elemental aspect.

Parameters
contextis information for the current attack.
typeis the PROJ_ constant for the element.
pure_elementshould be true if no side effects (mostly a hack for poison).

References melee_effect_handler_context_s::ac, adjust_dam(), adjust_dam_armor(), melee_effect_handler_context_s::damage, melee_effect_handler_context_s::ddesc, inven_damage(), melee_effect_handler_context_s::method, MIN, melee_effect_handler_context_s::mon, mon_take_nonplayer_hit(), monster_elemental_damage(), msg, melee_effect_handler_context_s::obvious, melee_effect_handler_context_s::p, blow_method::phys, RANDOMISE, melee_effect_handler_context_s::t_mon, take_hit(), update_smart_learn(), and void().

Referenced by melee_effect_handler_ACID(), melee_effect_handler_COLD(), melee_effect_handler_ELEC(), melee_effect_handler_FIRE(), and melee_effect_handler_POISON().

◆ melee_effect_experience()

static void melee_effect_experience ( melee_effect_handler_context_t context,
int  chance,
int  drain_amount 
)
static

◆ melee_effect_handler_ACID()

static void melee_effect_handler_ACID ( melee_effect_handler_context_t context)
static

Melee effect handler: Attack the player with acid.

References melee_effect_elemental().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_BLACK_BREATH()

static void melee_effect_handler_BLACK_BREATH ( melee_effect_handler_context_t context)
static

Melee effect handler: Give the player Black Breath.

Note that we don't use melee_effect_timed(), as this is unresistable.

References melee_effect_handler_context_s::damage, monster_damage_target(), melee_effect_handler_context_s::obvious, one_in_, melee_effect_handler_context_s::p, and player_inc_timed().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_BLIND()

static void melee_effect_handler_BLIND ( melee_effect_handler_context_t context)
static

Melee effect handler: Blind the player.

References melee_effect_timed(), randint1, and melee_effect_handler_context_s::rlev.

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_COLD()

static void melee_effect_handler_COLD ( melee_effect_handler_context_t context)
static

Melee effect handler: Attack the player with cold.

References melee_effect_elemental().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_CONFUSE()

static void melee_effect_handler_CONFUSE ( melee_effect_handler_context_t context)
static

Melee effect handler: Confuse the player.

References melee_effect_timed(), randint1, and melee_effect_handler_context_s::rlev.

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_DISENCHANT()

static void melee_effect_handler_DISENCHANT ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_DRAIN_CHARGES()

static void melee_effect_handler_DRAIN_CHARGES ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_EAT_FOOD()

static void melee_effect_handler_EAT_FOOD ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_EAT_GOLD()

static void melee_effect_handler_EAT_GOLD ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_EAT_ITEM()

static void melee_effect_handler_EAT_ITEM ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_EAT_LIGHT()

static void melee_effect_handler_EAT_LIGHT ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_ELEC()

static void melee_effect_handler_ELEC ( melee_effect_handler_context_t context)
static

Melee effect handler: Attack the player with electricity.

References melee_effect_elemental().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_EXP_10()

static void melee_effect_handler_EXP_10 ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's experience.

References damroll(), and melee_effect_experience().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_EXP_20()

static void melee_effect_handler_EXP_20 ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's experience.

References damroll(), and melee_effect_experience().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_EXP_40()

static void melee_effect_handler_EXP_40 ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's experience.

References damroll(), and melee_effect_experience().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_EXP_80()

static void melee_effect_handler_EXP_80 ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's experience.

References damroll(), and melee_effect_experience().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_FIRE()

static void melee_effect_handler_FIRE ( melee_effect_handler_context_t context)
static

Melee effect handler: Attack the player with fire.

References melee_effect_elemental().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_HALLU()

static void melee_effect_handler_HALLU ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_HURT()

static void melee_effect_handler_HURT ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_LOSE_ALL()

static void melee_effect_handler_LOSE_ALL ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_LOSE_CON()

static void melee_effect_handler_LOSE_CON ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's constitution.

References melee_effect_stat().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_LOSE_DEX()

static void melee_effect_handler_LOSE_DEX ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's dexterity.

References melee_effect_stat().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_LOSE_INT()

static void melee_effect_handler_LOSE_INT ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's intelligence.

References melee_effect_stat().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_LOSE_STR()

static void melee_effect_handler_LOSE_STR ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's strength.

References melee_effect_stat().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_LOSE_WIS()

static void melee_effect_handler_LOSE_WIS ( melee_effect_handler_context_t context)
static

Melee effect handler: Drain the player's wisdom.

References melee_effect_stat().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_NONE()

static void melee_effect_handler_NONE ( melee_effect_handler_context_t context)
static


Monster blow effect handlers

Melee effect handler: Hit the player, but don't do any damage.

References melee_effect_handler_context_s::damage, and melee_effect_handler_context_s::obvious.

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_PARALYZE()

static void melee_effect_handler_PARALYZE ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_POISON()

static void melee_effect_handler_POISON ( melee_effect_handler_context_t context)
static

Melee effect handler: Poison the player.

We can't use melee_effect_timed(), because this is both and elemental attack and a status attack. Note the false value for pure_element for melee_effect_elemental().

References player::is_dead, melee_effect_elemental(), melee_effect_handler_context_s::mon, melee_effect_handler_context_s::obvious, melee_effect_handler_context_s::p, player_inc_timed(), randint1, melee_effect_handler_context_s::rlev, and update_smart_learn().

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_handler_SHATTER()

static void melee_effect_handler_SHATTER ( melee_effect_handler_context_t context)
static

◆ melee_effect_handler_TERRIFY()

static void melee_effect_handler_TERRIFY ( melee_effect_handler_context_t context)
static

Melee effect handler: Terrify the player.

References melee_effect_timed(), randint1, and melee_effect_handler_context_s::rlev.

Referenced by melee_handler_for_blow_effect().

◆ melee_effect_stat()

static void melee_effect_stat ( melee_effect_handler_context_t context,
int  stat 
)
static

Do damage as the result of a melee attack that drains a stat.

Parameters
contextis the information for the current attack.
statis the STAT_ constant for the desired stat.

References effect_simple(), monster::midx, melee_effect_handler_context_s::mon, monster_damage_target(), melee_effect_handler_context_s::obvious, and source_monster().

Referenced by melee_effect_handler_LOSE_CON(), melee_effect_handler_LOSE_DEX(), melee_effect_handler_LOSE_INT(), melee_effect_handler_LOSE_STR(), and melee_effect_handler_LOSE_WIS().

◆ melee_effect_timed()

static void melee_effect_timed ( melee_effect_handler_context_t context,
int  type,
int  amount,
int  of_flag,
bool  save,
const char *  save_msg 
)
static

Do damage as the result of a melee attack that has a status effect.

Parameters
contextis the information for the current attack.
typeis the TMD_ constant for the effect.
amountis the amount that the timer should be increased by.
of_flagis the OF_ flag that is passed on to monster learning for this effect.
attempt_saveindicates if a saving throw should be attempted for this effect.
save_msgis the message that is displayed if the saving throw is successful.

References melee_effect_handler_context_s::mon, mon_inc_timed(), monster_damage_target(), msg, melee_effect_handler_context_s::obvious, melee_effect_handler_context_s::p, player_inc_timed(), randint0, SKILL_SAVE, player_state::skills, player::state, melee_effect_handler_context_s::t_mon, and update_smart_learn().

Referenced by melee_effect_handler_BLIND(), melee_effect_handler_CONFUSE(), melee_effect_handler_PARALYZE(), and melee_effect_handler_TERRIFY().

◆ melee_handler_for_blow_effect()

melee_effect_handler_f melee_handler_for_blow_effect ( const char *  name)

◆ monster_blow_method_action()

char* monster_blow_method_action ( struct blow_method method,
int  midx 
)

Print a monster blow message.

We fill in the monster name and/or pronoun where necessary in the message to replace instances of {name} or {pronoun}.

References blow_message::act_msg, BLOW_TAG_HAS, blow_tag_lookup(), BLOW_TAG_OF_TARGET, BLOW_TAG_TARGET, buf, cave, cave_monster(), MDESC_TARG, blow_method::messages, monster_desc(), msg, blow_message::next, blow_method::next, blow_method::num_messages, randint0, string_make(), strnfcat(), and tag.

Referenced by make_attack_normal(), and monster_attack_monster().

◆ monster_damage_target()

static bool monster_damage_target ( melee_effect_handler_context_t context,
bool  no_further_monster_effect 
)
static

◆ monster_elemental_damage()

static int monster_elemental_damage ( melee_effect_handler_context_t context,
int  type,
enum mon_messages hurt_msg,
enum mon_messages die_msg 
)
static

Get the elemental damage taken by a monster from another monster's melee.

References melee_effect_handler_context_s::damage, monster_lore::flags, monster_race::flags, get_lore(), monster::race, rf_has, rf_on, and melee_effect_handler_context_s::t_mon.

Referenced by melee_effect_elemental().

◆ steal_player_item()

static void steal_player_item ( melee_effect_handler_context_t context)
static