Angband
Data Structures | Macros | 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 "list-mon-timed.h"

Data Structures

struct  mon_timed_effect
 Monster timed effects. More...

Macros

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

Functions

int mon_timed_name_to_idx (const char *name)
 Functions.
static bool mon_resist_effect (const struct monster *mon, int ef_idx, int timer, u16b flag)
 Determines whether the given monster successfully resists the given effect.
static bool mon_set_timed (monster_type *m_ptr, int ef_idx, int timer, u16b flag, bool id)
 Attempts to set the timer of the given monster effect to timer.
bool mon_inc_timed (struct monster *m_ptr, int ef_idx, int timer, u16b flag, bool id)
 Increases the timed effect ef_idx by timer.
bool mon_dec_timed (struct monster *m_ptr, int ef_idx, int timer, u16b flag, bool id)
 Decreases the timed effect ef_idx by timer.
bool mon_clear_timed (struct monster *m_ptr, int ef_idx, u16b flag, bool id)
 Clears the timed effect ef_idx.

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_TMD (   a,
  b,
  c,
  d,
  e,
 
)    { #a, b, c, d, e, f },

Function Documentation

bool mon_clear_timed ( struct monster m_ptr,
int  ef_idx,
u16b  flag,
bool  id 
)
bool mon_dec_timed ( struct monster m_ptr,
int  ef_idx,
int  timer,
u16b  flag,
bool  id 
)

Decreases the timed effect ef_idx 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, mon_set_timed(), and MON_TMD_FLG_NOFAIL.

Referenced by mon_take_hit(), and process_monster_timed().

bool mon_inc_timed ( struct monster m_ptr,
int  ef_idx,
int  timer,
u16b  flag,
bool  id 
)

Increases the timed effect ef_idx 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 effect, effects, monster::m_timed, MAX_SHORT, mon_timed_effect::max_timer, and mon_set_timed().

Referenced by blow_side_effects(), effect_handler_AGGRAVATE(), effect_handler_MON_TIMED_INC(), make_attack_spell(), mon_take_hit(), project_m_apply_side_effects(), project_monster_handler_OLD_CLONE(), and summon_specific().

static bool mon_resist_effect ( const struct monster mon,
int  ef_idx,
int  timer,
u16b  flag 
)
static

Determines whether the given monster successfully resists the given effect.

If MON_TMD_FLG_NOFAIL is set in flag, this returns FALSE. Then we determine if the monster resists the effect for some racial reason. For example, the monster might have the NO_SLEEP flag, in which case it always resists sleep. Or if it breathes chaos, it always resists confusion. If the given monster doesn't resist for any of these reasons, then it makes a saving throw. If MON_TMD_MON_SOURCE is set in flag, indicating that another monster caused this effect, then the chance of success on the saving throw just depends on the monster's native depth. Otherwise, the chance of success decreases as timer increases.

Also marks the lore for any appropriate resists.

References effect, effects, FALSE, mon_timed_effect::flag_resist, monster_lore::flags, monster_race::flags, get_lore(), monster_race::level, monster::m_timed, monster::mflag, mflag_has, MON_TMD_FLG_NOFAIL, MON_TMD_MON_SOURCE, monster::race, randint0, rf_has, rf_on, rsf_has, rsf_on, monster_lore::spell_flags, monster_race::spell_flags, and TRUE.

Referenced by mon_set_timed().

static bool mon_set_timed ( monster_type m_ptr,
int  ef_idx,
int  timer,
u16b  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 mon_resist_effect(). 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. Return FALSE if the monster was unaffected.

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

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

int mon_timed_name_to_idx ( const char *  name)

Functions.

References effects, i, and streq.

Referenced by effect_param().

Variable Documentation

struct mon_timed_effect effects[]
static