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-tval.h"
#include "obj-util.h"
#include "object.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.
void player_spells_free (struct player *p)
 Free player spells.
const class_bookobject_to_book (const struct object *obj)
 Get the spellbook structure from an object which is a book the player can cast from.
const class_spellspell_by_index (int index)
int spell_collect_from_book (const object_type *o_ptr, int **spells)
 Collect spells from a book into the spells[] array, allocating appropriate memory.
int spell_book_count_spells (const object_type *o_ptr, bool(*tester)(int spell))
 Return the number of castable spells in the spellbook 'o_ptr'.
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.
bool spell_okay_to_cast (int spell)
 True if the spell is castable.
bool spell_okay_to_study (int spell)
 True if the spell can be studied.
bool spell_okay_to_browse (int spell)
 True if the spell is browsable.
int fail_adjust (struct player *p)
 Spell failure adjustment by casting stat level (or whatever realm whatever - NRM)
int min_fail (struct player *p)
 Spell minimum failure casting stat level (or whatever realm whatever - NRM)
s16b spell_chance (int spell)
 Returns chance of failure for a spell.
void spell_learn (int spell)
 Learn the specified spell.
static int beam_chance (void)
bool spell_cast (int spell, int dir)
 Cast the specified spell.
bool spell_is_identify (int spell)
bool spell_needs_aim (int spell)
static size_t append_random_value_string (char *buffer, size_t size, random_value *rv)
static void spell_append_value_info (int spell, char *p, size_t len)
void get_spell_info (int spell, char *p, size_t len)
static int spell_value_base_monster_level (void)
static int spell_value_base_player_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)
expression_base_value_f spell_value_base_by_name (const char *name)

Variables

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

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,
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 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,
char *  p,
size_t  len 
)
static
int spell_book_count_spells ( const object_type o_ptr,
bool(*)(int spell)  tester 
)

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

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 class_spell* spell_by_index ( int  index)
bool spell_cast ( int  spell,
int  dir 
)
s16b spell_chance ( int  spell)
int spell_collect_from_book ( const object_type o_ptr,
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().

bool spell_is_identify ( int  spell)
void spell_learn ( int  spell)
bool spell_needs_aim ( int  spell)
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 FALSE, i, and TRUE.

Referenced by spell_menu_new().

bool spell_okay_to_browse ( int  spell)

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)
expression_base_value_f spell_value_base_by_name ( const char *  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_monster_level ( void  )
static
static int spell_value_base_player_level ( void  )
static

References player::lev.

Referenced by spell_value_base_by_name().

Variable Documentation

const byte adj_mag_fail[STAT_RANGE]

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

Referenced by min_fail().

const int adj_mag_stat[STAT_RANGE]

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

Referenced by fail_adjust().