Angband
Functions | Variables
player-spell.c File Reference

Spell and prayer casting/praying. More...

#include "angband.h"
#include "cave.h"
#include "cmd-core.h"
#include "effects.h"
#include "init.h"
#include "monster.h"
#include "obj-gear.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "object.h"
#include "player-calcs.h"
#include "player-spell.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"

Functions

void player_spells_init (struct player *p)
 Initialise player spells. More...
 
void player_spells_free (struct player *p)
 Free player spells. More...
 
const struct class_bookobject_to_book (const struct object *obj)
 Get the spellbook structure from an object which is a book the player can cast from. More...
 
const struct class_spellspell_by_index (int index)
 
int spell_collect_from_book (const struct object *obj, int **spells)
 Collect spells from a book into the spells[] array, allocating appropriate memory. More...
 
int spell_book_count_spells (const struct object *obj, bool(*tester)(int spell))
 Return the number of castable spells in the spellbook 'obj'. More...
 
bool spell_okay_list (bool(*spell_test)(int spell), const int spells[], int n_spells)
 True if at least one spell in spells[] is OK according to spell_test. More...
 
bool spell_okay_to_cast (int spell)
 True if the spell is castable. More...
 
bool spell_okay_to_study (int spell_index)
 True if the spell can be studied. More...
 
bool spell_okay_to_browse (int spell_index)
 True if the spell is browsable. More...
 
int fail_adjust (struct player *p)
 Spell failure adjustment by casting stat level (or whatever realm whatever - NRM) More...
 
int min_fail (struct player *p)
 Spell minimum failure casting stat level (or whatever realm whatever - NRM) More...
 
s16b spell_chance (int spell_index)
 Returns chance of failure for a spell. More...
 
void spell_learn (int spell_index)
 Learn the specified spell. More...
 
static int beam_chance (void)
 
bool spell_cast (int spell_index, int dir)
 Cast the specified spell. More...
 
bool spell_needs_aim (int spell_index)
 
static size_t append_random_value_string (char *buffer, size_t size, random_value *rv)
 
static void spell_append_value_info (int spell_index, char *p, size_t len)
 
void get_spell_info (int spell_index, char *p, size_t len)
 
static int spell_value_base_spell_power (void)
 
static int spell_value_base_player_level (void)
 
static int spell_value_base_dungeon_level (void)
 
static int spell_value_base_max_sight (void)
 
static int spell_value_base_food_faint (void)
 
static int spell_value_base_food_starve (void)
 
static int spell_value_base_weapon_damage (void)
 
expression_base_value_f spell_value_base_by_name (const char *name)
 

Variables

static const int adj_mag_fail [STAT_RANGE]
 Stat Table (INT/WIS) – Minimum failure rate (percentage) More...
 
static const int adj_mag_stat [STAT_RANGE]
 Stat Table (INT/WIS) – failure rate adjustment. More...
 

Detailed Description

Spell and prayer casting/praying.

Copyright (c) 1997 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

static size_t append_random_value_string ( char *  buffer,
size_t  size,
random_value rv 
)
static
static int beam_chance ( void  )
static

References player::lev, and player_has.

Referenced by spell_cast().

int fail_adjust ( struct player p)

Spell failure adjustment by casting stat level (or whatever realm whatever - NRM)

References adj_mag_stat, player::class, player_class::magic, class_magic::spell_realm, magic_realm::stat, player_state::stat_ind, and player::state.

Referenced by spell_chance().

void get_spell_info ( int  spell_index,
char *  p,
size_t  len 
)

References spell_append_value_info().

Referenced by spell_menu_display().

int min_fail ( struct player p)

Spell minimum failure casting stat level (or whatever realm whatever - NRM)

References adj_mag_fail, player::class, player_class::magic, class_magic::spell_realm, magic_realm::stat, player_state::stat_ind, and player::state.

Referenced by spell_chance().

const struct class_book* object_to_book ( const struct object obj)
void player_spells_free ( struct player p)

Free player spells.

References mem_free(), player::spell_flags, and player::spell_order.

Referenced by cleanup_player().

void player_spells_init ( struct player p)
static void spell_append_value_info ( int  spell_index,
char *  p,
size_t  len 
)
static
int spell_book_count_spells ( const struct object obj,
bool(*)(int spell)  tester 
)

Return the number of castable spells in the spellbook 'obj'.

References i, class_book::num_spells, object_to_book(), class_spell::sidx, and class_book::spells.

Referenced by obj_can_cast_from(), and obj_can_study().

const struct class_spell* spell_by_index ( int  index)
bool spell_cast ( int  spell_index,
int  dir 
)
s16b spell_chance ( int  spell_index)
int spell_collect_from_book ( const struct object obj,
int **  spells 
)

Collect spells from a book into the spells[] array, allocating appropriate memory.

References i, mem_zalloc(), class_book::num_spells, object_to_book(), class_spell::sidx, and class_book::spells.

Referenced by spell_menu_new().

void spell_learn ( int  spell_index)
bool spell_needs_aim ( int  spell_index)
bool spell_okay_list ( bool(*)(int spell)  spell_test,
const int  spells[],
int  n_spells 
)

True if at least one spell in spells[] is OK according to spell_test.

References i.

Referenced by spell_menu_new().

bool spell_okay_to_browse ( int  spell_index)

True if the spell is browsable.

References class_spell::slevel, and spell_by_index().

Referenced by textui_book_browse().

bool spell_okay_to_cast ( int  spell)

True if the spell is castable.

References PY_SPELL_LEARNED, and player::spell_flags.

Referenced by do_cmd_cast(), and obj_can_cast_from().

bool spell_okay_to_study ( int  spell_index)
expression_base_value_f spell_value_base_by_name ( const char *  name)
static int spell_value_base_dungeon_level ( void  )
static

References cave, and chunk::depth.

Referenced by spell_value_base_by_name().

static int spell_value_base_food_faint ( void  )
static

References PY_FOOD_FAINT.

Referenced by spell_value_base_by_name().

static int spell_value_base_food_starve ( void  )
static

References PY_FOOD_STARVE.

Referenced by spell_value_base_by_name().

static int spell_value_base_max_sight ( void  )
static
static int spell_value_base_player_level ( void  )
static

References player::lev.

Referenced by spell_value_base_by_name().

static int spell_value_base_spell_power ( void  )
static
static int spell_value_base_weapon_damage ( void  )
static

Variable Documentation

const int adj_mag_fail[STAT_RANGE]
static

Stat Table (INT/WIS) – Minimum failure rate (percentage)

Referenced by min_fail().

const int adj_mag_stat[STAT_RANGE]
static

Stat Table (INT/WIS) – failure rate adjustment.

Referenced by fail_adjust().