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

functions to deal with spell attacks and effects More...

#include "angband.h"
#include "effects.h"
#include "mon-attack.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-make.h"
#include "mon-spell.h"
#include "mon-timed.h"
#include "mon-util.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"
#include "list-mon-spells.h"
#include "list-elements.h"

Data Structures

struct  mon_spell_info
 Info details of the different monster spells in the game. More...
struct  breath_damage

Macros

#define RSF(a, b, c, d, e, f, g, h)   { RSF_##a, b, c, d, e, f, g, h },
#define ELEM(a, b, c, d, e, f, g, col)   { f, g },

Functions

static struct monster_spellmonster_spell_by_index (int index)
void do_mon_spell (int index, struct monster *mon, bool seen)
 Process a monster spell.
bool test_spells (bitflag *f, int types)
 Test a spell bitflag for a type of spell.
void set_spells (bitflag *f, int types)
 Set a spell bitflag to allow only a specific set of spell types.
void unset_spells (bitflag *spells, bitflag *flags, bitflag *pflags, struct element_info *el, const monster_race *r_ptr)
 Turn off spells with a side effect or a gf_type that is resisted by something in flags, subject to intelligence and chance.
static bool monster_spell_is_projectable (int index)
static int nonhp_dam (const struct monster_spell *spell, const monster_race *race, aspect dam_aspect)
 Determine the damage of a spell attack which ignores monster hp (i.e.
int breath_dam (int element, int hp)
 Determine the damage of a monster breath attack.
static int mon_spell_dam (int index, int hp, const monster_race *race, aspect dam_aspect)
 Calculate the damage of a monster spell.
int best_spell_power (const monster_race *r_ptr, int resist)
 Calculate a monster's maximum spell power.
static bool mon_spell_is_valid (int index)
static bool mon_spell_has_damage (int index)
const char * mon_spell_lore_description (int index)
int mon_spell_lore_damage (int index, const monster_race *race, bool know_hp)

Variables

static struct mon_spell_info mon_spell_info_table []
static struct breath_damage breath []

Detailed Description

functions to deal with spell attacks and effects

Copyright (c) 2010-14 Chris Carr and Nick McConnell

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 ELEM (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  col 
)    { f, g },
#define RSF (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    { RSF_##a, b, c, d, e, f, g, h },

Function Documentation

int best_spell_power ( const monster_race r_ptr,
int  resist 
)

Calculate a monster's maximum spell power.

Parameters
r_ptris the monster we're studying
resistis the degree of resistance we're assuming to any attack type (-1 = vulnerable ... 3 = immune)

References adjust_dam(), random::base, random::dice, monster_spell::effect, mon_spell_info::index, monster_race::level, random::m_bonus, MAXIMISE, mon_hp(), mon_spell_dam(), mon_spell_info_table, monster_spell_by_index(), monster_spell_is_projectable(), effect::params, monster_spell::power, rsf_has, mon_spell_info::save, random::sides, and monster_race::spell_flags.

Referenced by eval_max_dam().

int breath_dam ( int  element,
int  hp 
)

Determine the damage of a monster breath attack.

Functions.

Parameters
elementis the attack element
hpis the monster's hp

References breath, breath_damage::cap, and breath_damage::divisor.

Referenced by effect_handler_BREATH(), and mon_spell_dam().

void do_mon_spell ( int  index,
struct monster mon,
bool  seen 
)
static int mon_spell_dam ( int  index,
int  hp,
const monster_race race,
aspect  dam_aspect 
)
static

Calculate the damage of a monster spell.

Parameters
indexis the index of the spell in question.
hpis the hp of the casting monster.
raceis the race of the casting monster.
dam_aspectis the damage calc we want (min, max, avg, random).

References breath_dam(), monster_spell::effect, monster_spell_by_index(), monster_spell_is_projectable(), nonhp_dam(), and effect::params.

Referenced by best_spell_power(), and mon_spell_lore_damage().

static bool mon_spell_has_damage ( int  index)
static
static bool mon_spell_is_valid ( int  index)
static
int mon_spell_lore_damage ( int  index,
const monster_race race,
bool  know_hp 
)
const char* mon_spell_lore_description ( int  index)
static struct monster_spell* monster_spell_by_index ( int  index)
staticread
static bool monster_spell_is_projectable ( int  index)
static
static int nonhp_dam ( const struct monster_spell spell,
const monster_race race,
aspect  dam_aspect 
)
static

Determine the damage of a spell attack which ignores monster hp (i.e.

bolts and balls, including arrows/boulders/storms/etc.)

Parameters
spellis the attack type
raceis the monster race of the attacker
dam_aspectis the damage calc required (min, avg, max, random)

References effect::dice, dice_roll(), monster_spell::effect, effect::next, randcalc(), and ref_race.

Referenced by mon_spell_dam().

void set_spells ( bitflag f,
int  types 
)

Set a spell bitflag to allow only a specific set of spell types.

Parameters
fis the set of spell flags we're pruning
typesis the spell type(s) we're allowing

References mon_spell_info::index, mon_spell_info_table, rsf_has, rsf_off, and mon_spell_info::type.

Referenced by make_attack_spell().

bool test_spells ( bitflag f,
int  types 
)

Test a spell bitflag for a type of spell.

Returns TRUE if any desired type is among the flagset

Parameters
fis the set of spell flags we're testing
typesis the spell type(s) we're looking for

References FALSE, mon_spell_info::index, mon_spell_info_table, rsf_has, TRUE, and mon_spell_info::type.

Referenced by make_attack_spell().

void unset_spells ( bitflag spells,
bitflag flags,
bitflag pflags,
struct element_info el,
const monster_race r_ptr 
)

Turn off spells with a side effect or a gf_type that is resisted by something in flags, subject to intelligence and chance.

Parameters
spellsis the set of spells we're pruning
flagsis the set of object flags we're testing
pflagsis the set of player flags we're testing
elis what we know about the monster's elemental resists
r_ptris the monster type we're operating on

References effect, monster_spell::effect, monster_race::flags, effect::index, mon_spell_info::index, mon_spell_info_table, monster_spell_by_index(), effect::next, of_has, one_in_, effect::params, pf_has, randint0, element_info::res_level, rf_has, rsf_has, rsf_off, RST_BALL, RST_BOLT, RST_BREATH, timed_protect_flag(), and mon_spell_info::type.

Referenced by remove_bad_spells().

Variable Documentation

struct breath_damage breath[]
static

Referenced by breath_dam(), and lore_append_spells().

struct mon_spell_info mon_spell_info_table[]
static