Angband
Data Structures | Macros | Functions | Variables
mon-msg.c File Reference

Monster message code. More...

#include "angband.h"
#include "mon-desc.h"
#include "mon-msg.h"
#include "mon-predicate.h"
#include "mon-util.h"
#include "game-input.h"
#include "player-calcs.h"
#include "list-mon-message.h"

Data Structures

struct  monster_race_message
 A stacked monster message entry. More...
 
struct  monster_message_history
 A (monster, message type) pair used for duplicate checking. More...
 

Macros

#define MAX_STORED_MON_MSG   200
 Maxinum number of stacked monster messages. More...
 
#define MAX_STORED_MON_CODES   400
 
#define MON_MSG_FLAG_OFFSCREEN   0x01
 Flags for whether monsters are offscreen or invisible. More...
 
#define MON_MSG_FLAG_INVISIBLE   0x02
 
#define MON_MSG(x, t, o, s)   { s, o, t },
 
#define MSG_PARSE_NORMAL   0
 
#define MSG_PARSE_SINGLE   1
 
#define MSG_PARSE_PLURAL   2
 

Functions

void message_pain (struct monster *mon, int dam)
 Adds to the message queue a message describing a monster's reaction to damage. More...
 
static bool redundant_monster_message (struct monster *mon, int msg_code)
 Tracks which monster has had which pain message stored, so redundant messages don't happen due to monster attacks hitting other monsters. More...
 
static int message_flags (const struct monster *mon)
 Work out what flags a message should have from a monster. More...
 
static void store_monster (struct monster *mon, int msg_code)
 Store the monster in the monster history for duplicate checking later. More...
 
static bool stack_message (struct monster *mon, int msg_code, int flags)
 Try to stack a message on top of existing ones. More...
 
static int what_delay (int msg_code, int delay)
 
bool add_monster_message (struct monster *mon, int msg_code, bool delay)
 Stack a codified message for the given monster race. More...
 
static void get_subject (char *buf, size_t buflen, struct monster_race *race, int count, bool invisible, bool offscreen)
 Create the subject of the sentence for monster messages. More...
 
static void get_message_text (char *buf, size_t buflen, int msg_code, const struct monster_race *race, bool do_plural)
 Formats a message based on the given message code and the plural flag. More...
 
static bool skip_subject (int msg_code)
 Accessor function - should we skip the monster name for this message type? More...
 
static int get_message_type (int msg_code, const struct monster_race *race)
 Return a MSG_ type for the given message code (and monster) More...
 
static void show_message (struct monster_race_message *msg)
 Show the given monster message. More...
 
void show_monster_messages (void)
 Show and then cler all stacked monster messages. More...
 

Variables

static int size_mon_hist = 0
 
static int size_mon_msg = 0
 
static struct monster_race_message mon_msg [MAX_STORED_MON_MSG]
 
static struct
monster_message_history 
mon_message_hist [MAX_STORED_MON_CODES]
 
struct {
   const char *   msg
 
   bool   omit_subject
 
   int   type
 
msg_repository []
 An array of monster messages in order of monster message type. More...
 

Detailed Description

Monster message code.

Copyright (c) 1997-2016 Jeff Greene, Andi Sidwell

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.

Macro Definition Documentation

#define MAX_STORED_MON_CODES   400

Referenced by store_monster().

#define MAX_STORED_MON_MSG   200

Maxinum number of stacked monster messages.

Referenced by add_monster_message().

#define MON_MSG (   x,
  t,
  o,
 
)    { s, o, t },
#define MON_MSG_FLAG_INVISIBLE   0x02

Referenced by message_flags(), and show_message().

#define MON_MSG_FLAG_OFFSCREEN   0x01

Flags for whether monsters are offscreen or invisible.

Referenced by message_flags(), and show_message().

#define MSG_PARSE_NORMAL   0

Referenced by get_message_text().

#define MSG_PARSE_PLURAL   2

Referenced by get_message_text().

#define MSG_PARSE_SINGLE   1

Referenced by get_message_text().

Function Documentation

bool add_monster_message ( struct monster mon,
int  msg_code,
bool  delay 
)
static void get_message_text ( char *  buf,
size_t  buflen,
int  msg_code,
const struct monster_race race,
bool  do_plural 
)
static

Formats a message based on the given message code and the plural flag.

Parameters
posthe position in buf to start writing the message into

References monster_race::base, i, monster_pain::messages, MSG_PARSE_NORMAL, MSG_PARSE_PLURAL, MSG_PARSE_SINGLE, msg_repository, NULL, and monster_base::pain.

Referenced by show_message().

static int get_message_type ( int  msg_code,
const struct monster_race race 
)
static

Return a MSG_ type for the given message code (and monster)

References monster_race::base, monster_race::flags, lookup_monster_base(), msg_repository, rf_has, RF_UNIQUE, and type.

Referenced by show_message().

static void get_subject ( char *  buf,
size_t  buflen,
struct monster_race race,
int  count,
bool  invisible,
bool  offscreen 
)
static

Create the subject of the sentence for monster messages.

References monster_race::flags, my_strcat(), my_strcpy(), monster_race::name, NULL, monster_race::plural, plural_aux(), rf_has, RF_UNIQUE, and strnfmt().

Referenced by show_message().

static int message_flags ( const struct monster mon)
static

Work out what flags a message should have from a monster.

References flags, monster::fx, monster::fy, MON_MSG_FLAG_INVISIBLE, MON_MSG_FLAG_OFFSCREEN, monster_is_visible(), and panel_contains().

Referenced by add_monster_message().

void message_pain ( struct monster mon,
int  dam 
)

Adds to the message queue a message describing a monster's reaction to damage.

References add_monster_message(), monster::hp, and int.

Referenced by project_m_monster_attack(), project_m_player_attack(), and ranged_helper().

static bool redundant_monster_message ( struct monster mon,
int  msg_code 
)
static

Tracks which monster has had which pain message stored, so redundant messages don't happen due to monster attacks hitting other monsters.

Returns true if the message is redundant.

References i, mon_message_hist, and size_mon_hist.

Referenced by add_monster_message().

static void show_message ( struct monster_race_message msg)
static
void show_monster_messages ( void  )

Show and then cler all stacked monster messages.

References monster_race_message::delay, i, mon_msg, msg, show_message(), size_mon_hist, and size_mon_msg.

Referenced by notice_stuff().

static bool skip_subject ( int  msg_code)
static

Accessor function - should we skip the monster name for this message type?

References msg_repository.

Referenced by show_message().

static bool stack_message ( struct monster mon,
int  msg_code,
int  flags 
)
static

Try to stack a message on top of existing ones.

Returns
true if successful, false if failed

References monster_race_message::count, monster_race_message::flags, i, mon_msg, monster_race_message::msg_code, monster::race, size_mon_msg, and store_monster().

Referenced by add_monster_message().

static void store_monster ( struct monster mon,
int  msg_code 
)
static

Store the monster in the monster history for duplicate checking later.

References MAX_STORED_MON_CODES, monster_message_history::message_code, monster_message_history::mon, mon_message_hist, and size_mon_hist.

Referenced by add_monster_message(), and stack_message().

static int what_delay ( int  msg_code,
int  delay 
)
static

Referenced by add_monster_message().

Variable Documentation

struct monster_message_history mon_message_hist[MAX_STORED_MON_CODES]
static
struct monster_race_message mon_msg[MAX_STORED_MON_MSG]
static
const char* msg

Referenced by activation_message(), apply_autoinscription(), become_aware(), brand_object(), build_quest_stairs(), calc_inventory(), calc_spells(), cave_generate(), cheat_death(), check_devices(), check_for_player_interrupt(), chest_trap(), cleanup_trap(), close_game(), cmd_get_string(), combine_pack(), compact_monsters(), context_menu_cave(), context_menu_player(), death_file(), describe_effect(), disconnect_stats(), display_feeling(), display_message(), do_cmd_activate(), do_cmd_aim_wand(), do_cmd_alter_aux(), do_cmd_birth_init(), do_cmd_buy(), do_cmd_cast(), do_cmd_change_name(), do_cmd_close(), do_cmd_close_aux(), do_cmd_close_test(), do_cmd_disarm(), do_cmd_disarm_aux(), do_cmd_disarm_chest(), do_cmd_disarm_test(), do_cmd_drop(), do_cmd_equip(), do_cmd_go_down(), do_cmd_go_up(), do_cmd_inven(), do_cmd_lock_door(), do_cmd_look(), do_cmd_messages(), do_cmd_note(), do_cmd_open(), do_cmd_open_test(), do_cmd_pref_file_hack(), do_cmd_quiver(), do_cmd_refill(), do_cmd_rerate(), do_cmd_retrieve(), do_cmd_save_screen_html(), do_cmd_sell(), do_cmd_stash(), do_cmd_study_book(), do_cmd_tunnel(), do_cmd_tunnel_aux(), do_cmd_tunnel_test(), do_cmd_uninscribe(), do_cmd_use(), do_cmd_use_staff(), do_cmd_wield(), do_cmd_wiz_bamf(), do_cmd_wiz_cure_all(), do_cmd_wiz_effect(), do_cmd_wiz_features(), do_cmd_wiz_jump(), do_cmd_wiz_learn(), do_cmd_wiz_play(), do_cmd_wiz_query(), do_cmd_wizard(), do_cmd_zap_rod(), do_mon_spell(), do_randart(), drop_near(), dump_pref_file(), dump_save(), effect_do(), effect_handler_ALTER_REALITY(), effect_handler_BIZARRE(), effect_handler_CONFUSING(), effect_handler_CREATE_STAIRS(), effect_handler_CRUNCH(), effect_handler_CURSE_ARMOR(), effect_handler_CURSE_WEAPON(), effect_handler_DARKEN_AREA(), effect_handler_DESTRUCTION(), effect_handler_DETECT_DOORS(), effect_handler_DETECT_EVIL(), effect_handler_DETECT_GOLD(), effect_handler_DETECT_INVISIBLE_MONSTERS(), effect_handler_DETECT_OBJECTS(), effect_handler_DETECT_STAIRS(), effect_handler_DETECT_TRAPS(), effect_handler_DETECT_VISIBLE_MONSTERS(), effect_handler_DISENCHANT(), effect_handler_DRAIN_LIGHT(), effect_handler_DRAIN_MANA(), effect_handler_DRAIN_STAT(), effect_handler_EARTHQUAKE(), effect_handler_GAIN_EXP(), effect_handler_GAIN_STAT(), effect_handler_HEAL_HP(), effect_handler_LIGHT_AREA(), effect_handler_LIGHT_LEVEL(), effect_handler_LOSE_EXP(), effect_handler_MON_HEAL_HP(), effect_handler_MON_HEAL_KIN(), effect_handler_PROBE(), effect_handler_RECALL(), effect_handler_RECHARGE(), effect_handler_RESTORE_EXP(), effect_handler_RESTORE_MANA(), effect_handler_RESTORE_STAT(), effect_handler_RUNE(), effect_handler_SENSE_OBJECTS(), effect_handler_STAR(), effect_handler_SUMMON(), effect_handler_TELEPORT(), effect_handler_TELEPORT_LEVEL(), effect_handler_THRUST_AWAY(), effect_handler_WAKE(), effect_handler_WONDER(), enchant_spell(), enter_score(), enter_store(), equip_learn_element(), flag_message(), floor_carry_fail(), floor_item_charges(), floor_object_for_use(), gear_object_for_use(), get_debug_command(), grab_name(), highscore_write(), hit_trap(), init_arrays(), init_graphics_modes(), inven_carry(), inven_drop(), inven_item_charges(), lookup_kind(), lore_save(), make_attack_normal(), make_attack_spell(), melee_effect_elemental(), melee_effect_experience(), melee_effect_handler_DRAIN_CHARGES(), melee_effect_handler_EAT_FOOD(), melee_effect_handler_EAT_GOLD(), melee_effect_handler_EAT_ITEM(), melee_effect_timed(), minus_ac(), mod_message(), mon_pop(), monster_reduce_sleep(), object_curses_find_element(), object_value_real(), pack_overflow(), parse_object_property_msg(), pick_and_place_distant_monster(), pit_stats(), place_new_monster_one(), player_can_cast(), player_can_fire(), player_can_read(), player_can_refuel(), player_can_study(), player_confuse_dir(), player_inc_check(), player_know_object(), player_learn_rune(), player_restore_mana(), player_set_food(), player_update_light(), print_error(), process_monster_can_move(), process_monster_glyph(), process_monster_grab_objects(), process_monster_try_push(), process_pref_file_named(), process_world(), project_feature_handler_KILL_DOOR(), project_feature_handler_KILL_TRAP(), project_feature_handler_KILL_WALL(), project_monster_resist_other(), project_o(), project_object_handler_KILL_TRAP(), project_p(), project_player_drain_stats(), project_player_handler_CHAOS(), project_player_handler_DARK(), project_player_handler_DARK_WEAK(), project_player_handler_DISEN(), project_player_handler_GRAVITY(), project_player_handler_ICE(), project_player_handler_LIGHT(), project_player_handler_NETHER(), project_player_handler_NEXUS(), project_player_handler_POIS(), project_player_handler_SHARD(), project_player_handler_SOUND(), project_player_handler_TIME(), prt_welcome(), quest_check(), recharged_notice(), refill_lamp(), remove_object_curse(), remove_old_dump(), save_game(), search(), see_floor_items(), show_file(), show_monster_messages(), spell_cast(), spell_learn(), spoil_artifact(), spoil_mon_desc(), spoil_mon_info(), spoil_obj_desc(), square_reveal_trap(), square_set_trap_timeout(), stats_collect(), store_purchase(), store_sell(), store_update(), target_set_closest(), textui_book_browse(), textui_cmd_debug(), textui_get_item(), textui_process_click(), textui_target(), uncurse_object(), update_bonuses(), update_messages_subwindow(), visuals_reset(), wiz_cheat_death(), wiz_statistics(), and wiz_test_kind().

const { ... } msg_repository[]

An array of monster messages in order of monster message type.

Singular and plural modifiers are encoded in the same string. Example: "[is|are] hurt" is expanded to "is hurt" if you request the singular form. The string is expanded to "are hurt" if the plural form is requested.

The singular and plural parts are optional. Example: "rear[s] up in anger" only includes a modifier for the singular form.

Any of these strings can start with "~", in which case we consider that string as a whole message, not as a part of a larger message. This is useful to display Moria-like death messages.

Referenced by get_message_text(), get_message_type(), and skip_subject().

bool omit_subject
int size_mon_hist = 0
static
int size_mon_msg = 0
static