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

Monster message code. More...

#include "angband.h"
#include "init.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-msg.h"
#include "mon-util.h"
#include "list-mon-message.h"

Macros

#define MON_MSG(x, s)   s,
#define SINGULAR_MON   1
#define PLURAL_MON   2

Functions

void message_pain (struct monster *m_ptr, int dam)
 Adds to the message queue a message describing a monster's reaction to damage.
static char * get_mon_msg_action (byte msg_code, bool do_plural, const struct monster_race *race)
 Returns a pointer to a statically allocatted string containing a formatted message based on the given message code and the quantity flag.
static bool redundant_monster_message (struct monster *m_ptr, 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.
bool add_monster_message (const char *mon_name, struct monster *m_ptr, int msg_code, bool delay)
 Stack a codified message for the given monster race.
static void flush_monster_messages (bool delay, byte delay_tag)
 Show and delete the stacked monster messages.
void flush_all_monster_messages (void)
 Print and delete all stacked monster messages.
static void monmsg_init (void)
static void monmsg_cleanup (void)

Variables

static u16b size_mon_hist = 0
static u16b size_mon_msg = 0
monster_race_messagemon_msg
 Variables.
monster_message_historymon_message_hist
static const char * msg_repository []
 The NULL-terminated array of string actions used to format stacked messages.
struct init_module monmsg_module

Detailed Description

Monster message code.

Copyright (c) 1997-2007 Ben Harrison, James E. Wilson, Robert A. Koeneke

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 MON_MSG (   x,
 
)    s,
#define PLURAL_MON   2

Referenced by get_mon_msg_action().

#define SINGULAR_MON   1

Referenced by get_mon_msg_action().

Function Documentation

bool add_monster_message ( const char *  mon_name,
struct monster m_ptr,
int  msg_code,
bool  delay 
)
void flush_all_monster_messages ( void  )

Print and delete all stacked monster messages.

References FALSE, flush_monster_messages(), MON_DELAY_TAG_DEATH, MON_DELAY_TAG_DEFAULT, size_mon_hist, size_mon_msg, and TRUE.

Referenced by notice_stuff().

static void flush_monster_messages ( bool  delay,
byte  delay_tag 
)
static

Show and delete the stacked monster messages.

Some messages are delayed so that they show up after everything else. This is to avoid things like "The snaga dies. The snaga runs in fear!" So we only flush messages matching the delay parameter.

References action, monster_race::base, buf, monster_race::flags, get_mon_msg_action(), i, lookup_monster_base(), monster_race_message::mon_count, MON_MSG_FLAG_INVISIBLE, MON_MSG_FLAG_OFFSCREEN, msgt(), my_strcat(), my_strcpy(), monster_race::name, monster_race::plural, plural_aux(), monster_race_message::race, race_name(), rf_has, size_mon_msg, strnfmt(), and type.

Referenced by flush_all_monster_messages().

static char* get_mon_msg_action ( byte  msg_code,
bool  do_plural,
const struct monster_race race 
)
static

Returns a pointer to a statically allocatted string containing a formatted message based on the given message code and the quantity flag.

The contents of the returned value will change with the next call to this function

References action, monster_race::base, buf, flag, monster_pain::messages, msg_repository, monster_base::pain, PLURAL_MON, and SINGULAR_MON.

Referenced by flush_monster_messages().

void message_pain ( struct monster m_ptr,
int  dam 
)

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

Functions.

References add_monster_message(), FALSE, monster::hp, int, MDESC_DEFAULT, and monster_desc().

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

static void monmsg_cleanup ( void  )
static

References mem_free().

static void monmsg_init ( void  )
static
static bool redundant_monster_message ( struct monster m_ptr,
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 FALSE, i, size_mon_hist, and TRUE.

Referenced by add_monster_message().

Variable Documentation

monster_message_history* mon_message_hist

Variables.

struct init_module monmsg_module
Initial value:
{
.name = "mosnter message",
.init = monmsg_init,
.cleanup = monmsg_cleanup
}
const char* msg_repository[]
static

The NULL-terminated array of string actions used to format stacked messages.

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_mon_msg_action().

u16b size_mon_hist = 0
static
u16b size_mon_msg = 0
static