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

Monster timed effects. More...

#include "angband.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-msg.h"
#include "mon-spell.h"
#include "mon-timed.h"
#include "mon-util.h"
#include "player-calcs.h"
#include "list-mon-timed.h"

Data Structures

struct  mon_timed_effect
 Monster timed effects. More...
 

Macros

#define MON_TMD(a, b, c, d, e, f, g, h)   { #a, b, STACK_##c, d, e, f, g, h },
 
#define MON_INC_MIN_TURNS   2
 Minimum number of turns a new timed effect can last. More...
 

Enumerations

enum  stack_type { STACK_NO, STACK_INCR, STACK_MAX }
 The different ways increases can stack - see mon_inc_timed() More...
 

Functions

int mon_timed_name_to_idx (const char *name)
 Find the timed monster effect with the name name. More...
 
static bool saving_throw (const struct monster *mon, int effect_type, int timer, int flag)
 Roll the saving throw for monsters resisting a timed effect. More...
 
static bool does_resist (const struct monster *mon, int effect_type, int timer, int flag)
 Determines whether the given monster successfully resists the given effect. More...
 
static bool mon_set_timed (struct monster *mon, int effect_type, int timer, int flag, bool id)
 Attempts to set the timer of the given monster effect to timer. More...
 
bool mon_inc_timed (struct monster *mon, int effect_type, int timer, int flag, bool id)
 Increases the timed effect effect_type by timer. More...
 
bool mon_dec_timed (struct monster *mon, int effect_type, int timer, int flag, bool id)
 Decreases the timed effect effect_type by timer. More...
 
bool mon_clear_timed (struct monster *mon, int effect_type, int flag, bool id)
 Clears the timed effect effect_type. More...
 

Variables

static struct mon_timed_effect effects []
 

Detailed Description

Monster timed effects.

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_INC_MIN_TURNS   2

Minimum number of turns a new timed effect can last.

Referenced by mon_inc_timed().

#define MON_TMD (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    { #a, b, STACK_##c, d, e, f, g, h },

Enumeration Type Documentation

enum stack_type

The different ways increases can stack - see mon_inc_timed()

Enumerator
STACK_NO 
STACK_INCR 
STACK_MAX 

Function Documentation

static bool does_resist ( const struct monster mon,
int  effect_type,
int  timer,
int  flag 
)
static

Determines whether the given monster successfully resists the given effect.

References effects, mon_timed_effect::flag_resist, monster_race::flags, get_lore(), mon_timed_effect::gets_save, lore_learn_flag_if_visible(), MON_TMD_FLG_NOFAIL, NULL, monster::race, rf_has, and saving_throw().

Referenced by mon_set_timed().

bool mon_clear_timed ( struct monster mon,
int  effect_type,
int  flag,
bool  id 
)
bool mon_dec_timed ( struct monster mon,
int  effect_type,
int  timer,
int  flag,
bool  id 
)

Decreases the timed effect effect_type by timer.

Calculates the new timer, then passes that to mon_set_timed(). If a timer would be set to a negative number, it is set to 0 instead. Note that decreasing a timed effect should never fail.

Returns true if the monster's timer changed.

References monster::m_timed, and mon_set_timed().

Referenced by mon_take_hit(), and process_monster_timed().

bool mon_inc_timed ( struct monster mon,
int  effect_type,
int  timer,
int  flag,
bool  id 
)

Increases the timed effect effect_type by timer.

Calculates the new timer, then passes that to mon_set_timed(). Note that each effect has a maximum number of turns it can be active for. If this function would put an effect timer over that cap, it sets it for that cap instead.

Returns true if the monster's timer changed.

References effects, monster::m_timed, MAX, MON_INC_MIN_TURNS, mon_set_timed(), STACK_INCR, STACK_MAX, STACK_NO, and mon_timed_effect::stacking.

Referenced by blow_side_effects(), effect_handler_MON_TIMED_INC(), mon_take_hit(), project_m_apply_side_effects(), project_monster_handler_MON_CLONE(), and summon_specific().

static bool mon_set_timed ( struct monster mon,
int  effect_type,
int  timer,
int  flag,
bool  id 
)
static

Attempts to set the timer of the given monster effect to timer.

Checks to see if the monster resists the effect, using does_resist(). If not, the effect is set to timer turns. If timer is 0, or if the effect timer was 0, or if MON_TMD_FLG_NOTIFY is set in flag, then a message is printed, unless MON_TMD_FLG_NOMESSAGE is set in flag.

Set a timed monster event to 'v'. Give messages if the right flags are set. Check if the monster is able to resist the spell. Mark the lore.

Returns true if the monster was affected, false if not.

References add_monster_message(), does_resist(), effects, player_upkeep::health_who, monster::m_timed, mon_timed_effect::max_timer, MDESC_IND_HID, mon_timed_effect::message_begin, mon_timed_effect::message_end, mon_timed_effect::message_increase, monster::mflag, mflag_has, MON_TMD_FLG_NOMESSAGE, MON_TMD_FLG_NOTIFY, monster_desc(), NULL, PR_HEALTH, PR_MONLIST, monster::race, player_upkeep::redraw, and player::upkeep.

Referenced by mon_clear_timed(), mon_dec_timed(), and mon_inc_timed().

int mon_timed_name_to_idx ( const char *  name)

Find the timed monster effect with the name name.

Functions.

Returns -1 on failure.

References effects, i, and streq.

Referenced by effect_param().

static bool saving_throw ( const struct monster mon,
int  effect_type,
int  timer,
int  flag 
)
static

Roll the saving throw for monsters resisting a timed effect.

References monster_race::flags, monster_race::level, monster::race, randint0, rf_has, and RF_UNIQUE.

Referenced by does_resist().

Variable Documentation

struct mon_timed_effect effects[]
static
Initial value:
= {
#define MON_TMD(a, b, c, d, e, f, g, h)
}

Referenced by does_resist(), mon_inc_timed(), mon_set_timed(), and mon_timed_name_to_idx().