Angband
Data Structures | Functions | Variables
mon-lore.h File Reference

Structures and functions for monster recall. More...

#include "z-textblock.h"
#include "monster.h"

Go to the source code of this file.

Data Structures

struct  monster_lore
 Monster "lore" information. More...

Functions

void get_attack_colors (int melee_colors[RBE_MAX], int spell_colors[RSF_MAX])
 Initializes the color-coding of monster attacks / spells.
void lore_append_kills (textblock *tb, const monster_race *race, const monster_lore *lore, const bitflag known_flags[RF_SIZE])
 Append the kill history to a texblock for a given monster race.
void lore_append_flavor (textblock *tb, const monster_race *race, bool append_utf8)
 Append the monster race description to a textblock.
void lore_append_movement (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append the monster type, location, and movement patterns to a textblock.
void lore_append_toughness (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append the monster AC, HP, and hit chance to a textblock.
void lore_append_exp (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append the experience value description to a textblock.
void lore_append_drop (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append the monster drop description to a textblock.
void lore_append_abilities (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append the monster abilities (resists, weaknesses, other traits) to a textblock.
void lore_append_awareness (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append how the monster reacts to intruders and at what distance it does so.
void lore_append_friends (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE])
 Append information about what other races the monster appears with and if they work together.
void lore_append_spells (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE], const int spell_colors[RSF_MAX])
 Append the monster's attack spells to a textblock.
void lore_append_attack (textblock *tb, const monster_race *race, const monster_lore *lore, bitflag known_flags[RF_SIZE], const int melee_colors[RBE_MAX])
 Append the monster's melee attacks to a textblock.
void lore_update (const monster_race *race, monster_lore *lore)
 Update which bits of lore are known.
void cheat_monster_lore (const monster_race *r_ptr, monster_lore *l_ptr)
 Learn everything about a monster.
void wipe_monster_lore (const monster_race *r_ptr, monster_lore *l_ptr)
 Forget everything about a monster.
void lore_do_probe (struct monster *m)
 Learn about a monster (by "probing" it)
void monster_flags_known (const monster_race *r_ptr, const monster_lore *l_ptr, bitflag flags[RF_SIZE])
 Copies into flags the flags of the given monster race that are known to the given lore structure (usually the player's knowledge).
void lore_treasure (struct monster *m_ptr, int num_item, int num_gold)
 Take note that the given monster just dropped some treasure.
monster_loreget_lore (const monster_race *race)
 Get the lore record for this monster race.
bool lore_save (const char *name)
 Save the lore to a file in the user directory.

Variables

monster_lorel_list
 Array[z_info->r_max] of monster lore.

Detailed Description

Structures and functions for monster recall.

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.

Function Documentation

void cheat_monster_lore ( const monster_race r_ptr,
monster_lore l_ptr 
)

Learn everything about a monster.

Sets the all_known variable, all flags and all relevant spell flags.

References monster_lore::all_known, monster_lore::flags, lore_update(), rf_setall, rsf_copy, monster_lore::spell_flags, monster_race::spell_flags, and TRUE.

Referenced by get_debug_command(), and lore_description().

void get_attack_colors ( int  melee_colors[RBE_MAX],
int  spell_colors[RSF_MAX] 
)

Initializes the color-coding of monster attacks / spells.

This function assigns a color to each monster melee attack type and each monster spell, depending on how dangerous the attack is to the player given current gear and state. Attacks may be colored green (least dangerous), yellow, orange, or red (most dangerous). The colors are stored in melee_colors and spell_colors, which the calling function then uses when printing the monster recall.

TODO: Is it possible to simplify this using the new monster spell refactor? We should be able to loop over all spell effects and check for resistance in a nicer way.

References adj_dex_safe, object::artifact, player::au, player::body, COLOUR_L_GREEN, COLOUR_L_RED, COLOUR_ORANGE, COLOUR_YELLOW, player_state::el_info, player_state::flags, player::gear, i, player::known_state, player::lev, object::next, object_flags_known(), object_is_equipped(), object_is_known(), of_has, OF_SIZE, object::pval, element_info::res_level, SKILL_SAVE, player_state::skills, player_state::stat_ind, player::timed, object::timeout, object::to_a, object::to_d, object::to_h, tval_can_have_charges(), tval_is_food(), and tval_is_light().

Referenced by lore_description().

monster_lore* get_lore ( const monster_race race)
void lore_append_abilities ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append the monster abilities (resists, weaknesses, other traits) to a textblock.

Known race flags are passed in for simplicity/efficiency. Note the macros that are used to simplify the code.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References COLOUR_L_UMBER, COLOUR_ORANGE, COLOUR_VIOLET, COLOUR_WHITE, FALSE, monster_lore::flags, lore_append_list(), LORE_INSERT_FLAG_DESCRIPTION, LORE_INSERT_UNKNOWN_VULN, lore_monster_sex(), lore_pronoun_nominative(), lore_pronoun_possessive(), MON_SEX_NEUTER, prev, rf_has, textblock_append(), textblock_append_c(), and TRUE.

Referenced by lore_description().

void lore_append_attack ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE],
const int  melee_colors[RBE_MAX] 
)

Append the monster's melee attacks to a textblock.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.
melee_colorsis a list of colors that is associated with each RBE_ effect.

References random::base, monster_race::blow, monster_lore::blow_known, COLOUR_L_GREEN, random::dice, monster_blow::dice, monster_blow::effect, FALSE, i, lore_describe_blow_effect(), lore_describe_blow_method(), lore_monster_sex(), lore_pronoun_nominative(), lore_pronoun_possessive(), random::m_bonus, monster_blow::method, angband_constants::mon_blows_max, MON_SEX_NEUTER, rf_has, random::sides, textblock_append(), textblock_append_c(), TRUE, and z_info.

Referenced by lore_description().

void lore_append_awareness ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append how the monster reacts to intruders and at what distance it does so.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References monster_race::aaf, COLOUR_L_BLUE, FALSE, lore_describe_awareness(), lore_monster_sex(), lore_pronoun_nominative(), MON_SEX_NEUTER, monster_race::sleep, monster_lore::sleep_known, textblock_append(), textblock_append_c(), and TRUE.

Referenced by lore_description().

void lore_append_drop ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append the monster drop description to a textblock.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References COLOUR_BLUE, monster_lore::drop_known, format(), lore_monster_sex(), lore_pronoun_nominative(), mon_create_drop_count(), MON_SEX_NEUTER, PLURAL, rf_has, textblock_append(), textblock_append_c(), and TRUE.

Referenced by lore_description().

void lore_append_exp ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append the experience value description to a textblock.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References buf, COLOUR_BLUE, format(), player::lev, monster_race::level, level, monster_race::mexp, my_strcat(), PLURAL, rf_has, strnfmt(), textblock_append(), and textblock_append_c().

Referenced by lore_description().

void lore_append_flavor ( textblock tb,
const monster_race race,
bool  append_utf8 
)

Append the monster race description to a textblock.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
append_utf8indicates if we should append the flavor text as UTF-8 (which is preferred for spoiler files).

References monster_race::text, textblock_append(), and textblock_append_utf8().

Referenced by lore_description().

void lore_append_friends ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append information about what other races the monster appears with and if they work together.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References monster_race::friends, monster_race::friends_base, lore_monster_sex(), lore_pronoun_nominative(), MON_SEX_NEUTER, rf_has, textblock_append(), and TRUE.

Referenced by lore_description().

void lore_append_kills ( textblock tb,
const monster_race race,
const monster_lore lore,
const bitflag  known_flags[RF_SIZE] 
)

Append the kill history to a texblock for a given monster race.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References COLOUR_RED, monster_lore::deaths, FALSE, lore_monster_sex(), lore_pronoun_nominative(), monster_race::max_num, MON_SEX_NEUTER, monster_lore::pkills, rf_has, textblock_append(), textblock_append_c(), monster_lore::tkills, TRUE, and VERB_AGREEMENT.

Referenced by lore_description().

void lore_append_movement ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append the monster type, location, and movement patterns to a textblock.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References COLOUR_GREEN, COLOUR_L_BLUE, COLOUR_L_GREEN, COLOUR_RED, FLAG_END, monster_race::flags, flags_test(), monster_race::level, lore_describe_speed(), player::max_depth, rf_has, monster_race::speed, textblock_append(), and textblock_append_c().

Referenced by lore_description().

void lore_append_spells ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE],
const int  spell_colors[RSF_MAX] 
)

Append the monster's attack spells to a textblock.

Known race flags are passed in for simplicity/efficiency. Note the macros that are used to simplify the code.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.
spell_colorsis a list of colors that is associated with each RSF_ spell.

References monster_lore::armour_known, breath, monster_lore::cast_innate, monster_lore::cast_spell, COLOUR_L_GREEN, COLOUR_L_RED, FALSE, monster_race::freq_innate, monster_race::freq_spell, i, lore_append_spell_descriptions(), LORE_INSERT_SPELL_DESCRIPTION, lore_monster_sex(), lore_pronoun_nominative(), LORE_RESET_LISTS, MON_SEX_NEUTER, rf_has, monster_lore::spell_freq_known, textblock_append(), textblock_append_c(), and TRUE.

Referenced by lore_description().

void lore_append_toughness ( textblock tb,
const monster_race race,
const monster_lore lore,
bitflag  known_flags[RF_SIZE] 
)

Append the monster AC, HP, and hit chance to a textblock.

Known race flags are passed in for simplicity/efficiency.

Parameters
tbis the textblock we are adding to.
raceis the monster race we are describing.
loreis the known information about the monster race.
known_flagsis the preprocessed bitfield of race flags known to the player.

References monster_race::ac, monster_lore::armour_known, monster_race::avg_hp, COLOUR_L_BLUE, equipped_item_by_slot_name(), lore_monster_sex(), lore_pronoun_nominative(), MON_SEX_NEUTER, py_attack_hit_chance(), rf_has, textblock_append(), textblock_append_c(), and TRUE.

Referenced by lore_description().

void lore_do_probe ( struct monster m)
bool lore_save ( const char *  name)

Save the lore to a file in the user directory.

Parameters
nameis the filename
Returns
TRUE on success, FALSE otherwise.

References ANGBAND_DIR_USER, FALSE, msg, path, path_build(), text_lines_to_file(), and TRUE.

Referenced by close_game().

void lore_treasure ( struct monster m_ptr,
int  num_item,
int  num_gold 
)

Take note that the given monster just dropped some treasure.

Note that learning the "GOOD"/"GREAT" flags gives information about the treasure (even when the monster is killed for the first time, such as uniques, and the treasure has not been examined yet).

This "indirect" method is used to prevent the player from learning exactly how much treasure a monster can drop from observing only a single example of a drop. This method actually observes how much gold and items are dropped, and remembers that information to be described later by the monster recall code.

References monster_lore::drop_gold, monster_lore::drop_item, monster_lore::flags, get_lore(), player_upkeep::monster_race, PR_MONSTER, monster::race, player_upkeep::redraw, rf_on, and player::upkeep.

Referenced by monster_death().

void lore_update ( const monster_race race,
monster_lore lore 
)
void monster_flags_known ( const monster_race r_ptr,
const monster_lore l_ptr,
bitflag  flags[RF_SIZE] 
)

Copies into flags the flags of the given monster race that are known to the given lore structure (usually the player's knowledge).

Known flags will be 1 for present, or 0 for not present. Unknown flags will always be 0.

References monster_lore::flags, monster_race::flags, flags, rf_copy, and rf_inter.

Referenced by lore_description().

void wipe_monster_lore ( const monster_race r_ptr,
monster_lore l_ptr 
)

Variable Documentation

monster_lore* l_list