Angband
Data Structures | Macros | Typedefs | Functions | Variables
effects.c File Reference

Handler and auxiliary functions for every effect in the game. More...

#include "angband.h"
#include "cave.h"
#include "effects.h"
#include "game-input.h"
#include "generate.h"
#include "init.h"
#include "mon-desc.h"
#include "mon-lore.h"
#include "mon-make.h"
#include "mon-msg.h"
#include "mon-predicate.h"
#include "mon-spell.h"
#include "mon-summon.h"
#include "mon-util.h"
#include "mon-timed.h"
#include "obj-chest.h"
#include "obj-curse.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-knowledge.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-power.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-calcs.h"
#include "player-history.h"
#include "player-spell.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"
#include "source.h"
#include "target.h"
#include "trap.h"
#include "list-effects.h"

Data Structures

struct  effect_handler_context_s
 

Structures and helper functions for effects

More...
 
struct  effect_kind
 Structure for effects. More...
 

Macros

#define ENCH_TOHIT   0x01
 Bit flags for the enchant() function. More...
 
#define ENCH_TODAM   0x02
 
#define ENCH_TOBOTH   0x03
 
#define ENCH_TOAC   0x04
 
#define F(x)   effect_handler_##x
 
#define EFFECT(x, a, b, c, d, e)   { EF_##x, a, b, F(x), e },
 
#define EFFECT(x, a, b, c, d, e)   #x,
 

Typedefs

typedef struct effect_handler_context_s effect_handler_context_t
 

Structures and helper functions for effects

More...
 
typedef bool(* effect_handler_f) (effect_handler_context_t *)
 

Functions

static const char * desc_stat (int stat, bool positive)
 Stat adjectives. More...
 
int effect_calculate_value (effect_handler_context_t *context, bool use_boost)
 
static void get_target (struct source origin, int dir, int *ty, int *tx, int *flags)
 
static bool project_aimed (struct source origin, int typ, int dir, int dam, int flg, const struct object *obj)
 Apply the project() function in a direction, or at a target. More...
 
static bool project_touch (int dam, int rad, int typ, bool aware, const struct object *obj)
 Apply the project() function to grids around the player. More...
 
static bool item_tester_uncursable (const struct object *obj)
 Selects items that have at least one removable curse. More...
 
static void remove_object_curse (struct object *obj, int index, bool message)
 Removes an individual curse from an object. More...
 
static bool uncurse_object (struct object *obj, int strength, char *dice_string)
 Attempts to remove a curse from an object. More...
 
static bool item_tester_unknown (const struct object *obj)
 Selects items that have at least one unknown rune. More...
 
static bool item_tester_hook_weapon (const struct object *obj)
 Hook to specify "weapon". More...
 
static bool item_tester_hook_armour (const struct object *obj)
 Hook to specify "armour". More...
 
static bool enchant_score (s16b *score, bool is_artifact)
 Tries to increase an items bonus score, if possible. More...
 
static bool enchant2 (struct object *obj, s16b *score)
 Helper function for enchant() which tries increasing an item's bonuses. More...
 
bool enchant (struct object *obj, int n, int eflag)
 Enchant an item. More...
 
bool enchant_spell (int num_hit, int num_dam, int num_ac)
 Enchant an item (in the inventory or on the floor) Note that "num_ac" requires armour, else weapon Returns true if attempted, false if cancelled. More...
 
void brand_object (struct object *obj, const char *name)
 Brand weapons (or ammo) More...
 
static bool item_tester_hook_recharge (const struct object *obj)
 Hook for "get_item()". More...
 
static bool item_tester_hook_ammo (const struct object *obj)
 Hook to specify "ammo". More...
 
static bool item_tester_hook_bolt (const struct object *obj)
 Hook to specify bolts. More...
 
bool effect_handler_RANDOM (effect_handler_context_t *context)
 

Effect handlers

More...
 
bool effect_handler_DAMAGE (effect_handler_context_t *context)
 Deal damage from the current monster or trap to the player. More...
 
bool effect_handler_HEAL_HP (effect_handler_context_t *context)
 Heal the player by a given percentage of their wounds, or a minimum amount, whichever is larger. More...
 
bool effect_handler_MON_HEAL_HP (effect_handler_context_t *context)
 Monster self-healing. More...
 
bool effect_handler_MON_HEAL_KIN (effect_handler_context_t *context)
 Monster healing of kin. More...
 
bool effect_handler_NOURISH (effect_handler_context_t *context)
 Feed the player. More...
 
bool effect_handler_CRUNCH (effect_handler_context_t *context)
 
bool effect_handler_CURE (effect_handler_context_t *context)
 Cure a player status condition. More...
 
bool effect_handler_TIMED_SET (effect_handler_context_t *context)
 Set a (positive or negative) player status condition. More...
 
bool effect_handler_TIMED_INC (effect_handler_context_t *context)
 Extend a (positive or negative) player status condition. More...
 
bool effect_handler_TIMED_INC_NO_RES (effect_handler_context_t *context)
 Extend a (positive or negative) player status condition unresistably. More...
 
bool effect_handler_MON_TIMED_INC (effect_handler_context_t *context)
 Extend a (positive or negative) monster status condition. More...
 
bool effect_handler_TIMED_DEC (effect_handler_context_t *context)
 Reduce a (positive or negative) player status condition. More...
 
bool effect_handler_SET_NOURISH (effect_handler_context_t *context)
 Make the player, um, lose food. More...
 
bool effect_handler_CONFUSING (effect_handler_context_t *context)
 
bool effect_handler_RUNE (effect_handler_context_t *context)
 Create a "glyph of warding". More...
 
bool effect_handler_RESTORE_STAT (effect_handler_context_t *context)
 Restore a stat. More...
 
bool effect_handler_DRAIN_STAT (effect_handler_context_t *context)
 Drain a stat temporarily. More...
 
bool effect_handler_LOSE_RANDOM_STAT (effect_handler_context_t *context)
 Lose a stat point permanently, in a stat other than the one specified in context->p1. More...
 
bool effect_handler_GAIN_STAT (effect_handler_context_t *context)
 Gain a stat point. More...
 
bool effect_handler_RESTORE_EXP (effect_handler_context_t *context)
 Restores any drained experience; message suppressed if context->p1 is set. More...
 
bool effect_handler_GAIN_EXP (effect_handler_context_t *context)
 
bool effect_handler_LOSE_EXP (effect_handler_context_t *context)
 
bool effect_handler_DRAIN_LIGHT (effect_handler_context_t *context)
 Drain some light from the player's light source, if possible. More...
 
bool effect_handler_DRAIN_MANA (effect_handler_context_t *context)
 Drain mana from the player, healing the caster. More...
 
bool effect_handler_RESTORE_MANA (effect_handler_context_t *context)
 
bool effect_handler_REMOVE_CURSE (effect_handler_context_t *context)
 Attempt to uncurse an object. More...
 
bool effect_handler_RECALL (effect_handler_context_t *context)
 Set word of recall as appropriate. More...
 
bool effect_handler_DEEP_DESCENT (effect_handler_context_t *context)
 
bool effect_handler_ALTER_REALITY (effect_handler_context_t *context)
 
bool effect_handler_MAP_AREA (effect_handler_context_t *context)
 Map an area around the player. More...
 
bool effect_handler_DETECT_TRAPS (effect_handler_context_t *context)
 Detect traps around the player. More...
 
bool effect_handler_DETECT_DOORS (effect_handler_context_t *context)
 Detect doors around the player. More...
 
bool effect_handler_DETECT_STAIRS (effect_handler_context_t *context)
 Detect stairs around the player. More...
 
bool effect_handler_DETECT_GOLD (effect_handler_context_t *context)
 Detect buried gold around the player. More...
 
bool effect_handler_SENSE_OBJECTS (effect_handler_context_t *context)
 Sense objects around the player. More...
 
bool effect_handler_DETECT_OBJECTS (effect_handler_context_t *context)
 Detect objects around the player. More...
 
bool effect_handler_DETECT_VISIBLE_MONSTERS (effect_handler_context_t *context)
 Detect visible monsters around the player. More...
 
bool effect_handler_DETECT_INVISIBLE_MONSTERS (effect_handler_context_t *context)
 Detect invisible monsters around the player. More...
 
bool effect_handler_IDENTIFY (effect_handler_context_t *context)
 Identify an unknown rune of an item. More...
 
bool effect_handler_DETECT_EVIL (effect_handler_context_t *context)
 Detect evil monsters around the player. More...
 
bool effect_handler_CREATE_STAIRS (effect_handler_context_t *context)
 Create stairs at the player location. More...
 
bool effect_handler_DISENCHANT (effect_handler_context_t *context)
 Apply disenchantment to the player's stuff. More...
 
bool effect_handler_ENCHANT (effect_handler_context_t *context)
 Enchant an item (in the inventory or on the floor) Note that armour, to hit or to dam is controlled by context->p1. More...
 
bool effect_handler_RECHARGE (effect_handler_context_t *context)
 Recharge a wand or staff from the pack or on the floor. More...
 
bool effect_handler_PROJECT_LOS (effect_handler_context_t *context)
 Apply a "project()" directly to all viewable monsters. More...
 
bool effect_handler_PROJECT_LOS_AWARE (effect_handler_context_t *context)
 Just like PROJECT_LOS except the player's awareness of an object using this effect is relevant. More...
 
bool effect_handler_ACQUIRE (effect_handler_context_t *context)
 
bool effect_handler_WAKE (effect_handler_context_t *context)
 Wake up all monsters in line of sight. More...
 
bool effect_handler_SUMMON (effect_handler_context_t *context)
 Summon context->value monsters of context->p1 type. More...
 
bool effect_handler_BANISH (effect_handler_context_t *context)
 

Delete all non-unique monsters of a given "type" from the level

Warning - this function assumes that the entered monster symbol is an ASCII

character, which may not be true in the future - NRM

More...
 
bool effect_handler_MASS_BANISH (effect_handler_context_t *context)
 Delete all nearby (non-unique) monsters. More...
 
bool effect_handler_PROBE (effect_handler_context_t *context)
 Probe nearby monsters. More...
 
bool effect_handler_THRUST_AWAY (effect_handler_context_t *context)
 Thrust the player or a monster away from the source of a projection. More...
 
bool effect_handler_TELEPORT (effect_handler_context_t *context)
 Teleport player or monster up to context->value.base grids away. More...
 
bool effect_handler_TELEPORT_TO (effect_handler_context_t *context)
 Teleport player to a grid near the given location Setting context->p1 and context->p2 treats them as y and x coordinates. More...
 
bool effect_handler_TELEPORT_LEVEL (effect_handler_context_t *context)
 Teleport the player one level up or down (random when legal) More...
 
bool effect_handler_RUBBLE (effect_handler_context_t *context)
 The rubble effect. More...
 
bool effect_handler_DESTRUCTION (effect_handler_context_t *context)
 The destruction effect. More...
 
bool effect_handler_EARTHQUAKE (effect_handler_context_t *context)
 Induce an earthquake of the radius context->p2 centred on the instigator. More...
 
bool effect_handler_LIGHT_LEVEL (effect_handler_context_t *context)
 
bool effect_handler_LIGHT_AREA (effect_handler_context_t *context)
 Call light around the player Affect all monsters in the projection radius (context->p2) More...
 
bool effect_handler_DARKEN_AREA (effect_handler_context_t *context)
 Call darkness around the player Affect all monsters in the projection radius (context->p2) More...
 
bool effect_handler_SPOT (effect_handler_context_t *context)
 Project from the player's grid at the player, act as a ball Affect the player, grids, objects, and monsters. More...
 
bool effect_handler_BALL (effect_handler_context_t *context)
 Cast a ball spell Stop if we hit a monster or the player, act as a ball Allow target mode to pass over monsters Affect grids, objects, and monsters. More...
 
bool effect_handler_BREATH (effect_handler_context_t *context)
 Breathe an element, in a cone from the breather Affect grids, objects, and monsters context->p1 is element, context->p2 degrees of arc, context->p3 radius. More...
 
bool effect_handler_SWARM (effect_handler_context_t *context)
 Cast multiple non-jumping ball spells at the same target. More...
 
bool effect_handler_STAR (effect_handler_context_t *context)
 Cast a line spell in every direction Stop if we hit a monster, act as a ball Affect grids, objects, and monsters. More...
 
bool effect_handler_STAR_BALL (effect_handler_context_t *context)
 Cast a ball spell in every direction Stop if we hit a monster, act as a ball Affect grids, objects, and monsters. More...
 
bool effect_handler_BOLT (effect_handler_context_t *context)
 Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) More...
 
bool effect_handler_BEAM (effect_handler_context_t *context)
 Cast a beam spell Pass through monsters, as a beam Affect monsters (not grids or objects) More...
 
bool effect_handler_BOLT_OR_BEAM (effect_handler_context_t *context)
 Cast a bolt spell, or rarely, a beam spell context->p2 is any adjustment to the regular beam chance context->p3 being set means to divide by the adjustment instead of adding. More...
 
bool effect_handler_LINE (effect_handler_context_t *context)
 Cast a line spell Pass through monsters, as a beam Affect monsters and grids (not objects) More...
 
bool effect_handler_ALTER (effect_handler_context_t *context)
 Cast an alter spell Affect objects and grids (not monsters) More...
 
bool effect_handler_BOLT_STATUS (effect_handler_context_t *context)
 Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) Like BOLT, but only identifies on noticing an effect. More...
 
bool effect_handler_BOLT_STATUS_DAM (effect_handler_context_t *context)
 Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) The same as BOLT_STATUS, but done as a separate function to aid descriptions. More...
 
bool effect_handler_BOLT_AWARE (effect_handler_context_t *context)
 Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) Notice stuff based on awareness of the effect. More...
 
bool effect_handler_TOUCH (effect_handler_context_t *context)
 Affect adjacent grids (radius 1 ball attack) More...
 
bool effect_handler_TOUCH_AWARE (effect_handler_context_t *context)
 Affect adjacent grids (radius 1 ball attack) Notice stuff based on awareness of the effect. More...
 
bool effect_handler_CURSE_ARMOR (effect_handler_context_t *context)
 Curse the player's armor. More...
 
bool effect_handler_CURSE_WEAPON (effect_handler_context_t *context)
 Curse the player's weapon. More...
 
bool effect_handler_BRAND_WEAPON (effect_handler_context_t *context)
 Brand the current weapon. More...
 
bool effect_handler_BRAND_AMMO (effect_handler_context_t *context)
 Brand some (non-magical) ammo. More...
 
bool effect_handler_BRAND_BOLTS (effect_handler_context_t *context)
 Enchant some (non-magical) bolts. More...
 
bool effect_handler_BIZARRE (effect_handler_context_t *context)
 One Ring activation. More...
 
bool effect_handler_WONDER (effect_handler_context_t *context)
 The "wonder" effect. More...
 
void free_effect (struct effect *source)
 Free all the effects in a structure. More...
 
bool effect_valid (struct effect *effect)
 
bool effect_aim (struct effect *effect)
 
const char * effect_info (struct effect *effect)
 
const char * effect_desc (struct effect *effect)
 
effect_index effect_lookup (const char *name)
 
int effect_param (int index, const char *type)
 Translate a string to an effect parameter index. More...
 
bool effect_do (struct effect *effect, struct source origin, struct object *obj, bool *ident, bool aware, int dir, int beam, int boost)
 

Execution of effects

More...
 
void effect_simple (int index, struct source origin, const char *dice_string, int p1, int p2, int p3, bool *ident)
 Perform a single effect with a simple dice string and parameters Calling with ident a valid pointer will (depending on effect) give success information; ident = NULL will ignore this. More...
 

Variables

static const int enchant_table [16]
 Used by the enchant() function (chance of failure) More...
 
static const struct effect_kind effects []
 

Properties of effects

More...
 
static const char * effect_names []
 

Detailed Description

Handler and auxiliary functions for every effect in the game.

Copyright (c) 2007 Andi Sidwell Copyright (c) 2016 Ben Semmler, 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

◆ EFFECT [1/2]

#define EFFECT (   x,
  a,
  b,
  c,
  d,
 
)    { EF_##x, a, b, F(x), e },

◆ EFFECT [2/2]

#define EFFECT (   x,
  a,
  b,
  c,
  d,
 
)    #x,

◆ ENCH_TOAC

#define ENCH_TOAC   0x04

◆ ENCH_TOBOTH

#define ENCH_TOBOTH   0x03

◆ ENCH_TODAM

#define ENCH_TODAM   0x02

◆ ENCH_TOHIT

#define ENCH_TOHIT   0x01

Bit flags for the enchant() function.

Referenced by brand_object(), effect_handler_ENCHANT(), effect_param(), enchant(), and enchant_spell().

◆ F

#define F (   x)    effect_handler_##x

Typedef Documentation

◆ effect_handler_context_t


Structures and helper functions for effects

◆ effect_handler_f

typedef bool(* effect_handler_f) (effect_handler_context_t *)

Function Documentation

◆ brand_object()

void brand_object ( struct object obj,
const char *  name 
)

◆ desc_stat()

static const char* desc_stat ( int  stat,
bool  positive 
)
static

◆ effect_aim()

bool effect_aim ( struct effect effect)

◆ effect_calculate_value()

int effect_calculate_value ( effect_handler_context_t context,
bool  use_boost 
)

◆ effect_desc()

const char* effect_desc ( struct effect effect)

◆ effect_do()

bool effect_do ( struct effect effect,
struct source  origin,
struct object obj,
bool *  ident,
bool  aware,
int  dir,
int  beam,
int  boost 
)


Execution of effects

Execute an effect chain.

Parameters
effectis the effect chain
originis the origin of the effect (player, monster etc.)
objis the object making the effect happen (or NULL)
identwill be updated if the effect is identifiable (NB: no effect ever sets *ident to false)
awareindicates whether the player is aware of the effect already
diris the direction the effect will go in
beamis the base chance out of 100 that a BOLT_OR_BEAM effect will beam
boostis the extent to which skill surpasses difficulty, used as % boost. It ranges from 0 to 138.

References effect_handler_context_s::aware, effect_handler_context_s::beam, effect_handler_context_s::boost, effect::dice, dice_roll(), effect_handler_context_s::dir, effect_valid(), effect_kind::handler, effect_handler_context_s::ident, effect::index, msg, effect::next, NULL, effect_handler_context_s::obj, effect_handler_context_s::origin, effect::params, randint0, effect_handler_context_s::value, and void().

Referenced by do_curse_effect(), do_mon_spell(), effect_simple(), hit_trap(), spell_cast(), and use_aux().

◆ effect_handler_ACQUIRE()

bool effect_handler_ACQUIRE ( effect_handler_context_t context)

◆ effect_handler_ALTER()

bool effect_handler_ALTER ( effect_handler_context_t context)

◆ effect_handler_ALTER_REALITY()

bool effect_handler_ALTER_REALITY ( effect_handler_context_t context)

◆ effect_handler_BALL()

bool effect_handler_BALL ( effect_handler_context_t context)

◆ effect_handler_BANISH()

bool effect_handler_BANISH ( effect_handler_context_t context)

Delete all non-unique monsters of a given "type" from the level

Warning - this function assumes that the entered monster symbol is an ASCII

character, which may not be true in the future - NRM

References cave, cave_monster(), cave_monster_max(), monster_race::d_char, delete_monster_idx(), get_com(), i, effect_handler_context_s::ident, monster_is_unique(), PR_MONLIST, monster::race, randint1, player_upkeep::redraw, take_hit(), and player::upkeep.

Referenced by effect_handler_WONDER().

◆ effect_handler_BEAM()

bool effect_handler_BEAM ( effect_handler_context_t context)

◆ effect_handler_BIZARRE()

bool effect_handler_BIZARRE ( effect_handler_context_t context)

◆ effect_handler_BOLT()

bool effect_handler_BOLT ( effect_handler_context_t context)

◆ effect_handler_BOLT_AWARE()

bool effect_handler_BOLT_AWARE ( effect_handler_context_t context)

Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) Notice stuff based on awareness of the effect.

References effect_handler_context_s::aware, effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::obj, effect_handler_context_s::origin, effect_handler_context_s::p1, project_aimed(), PROJECT_AWARE, PROJECT_KILL, and PROJECT_STOP.

◆ effect_handler_BOLT_OR_BEAM()

bool effect_handler_BOLT_OR_BEAM ( effect_handler_context_t context)

Cast a bolt spell, or rarely, a beam spell context->p2 is any adjustment to the regular beam chance context->p3 being set means to divide by the adjustment instead of adding.

References effect_handler_context_s::beam, effect_handler_BEAM(), effect_handler_BOLT(), effect_handler_context_s::p2, effect_handler_context_s::p3, and randint0.

Referenced by effect_handler_WONDER().

◆ effect_handler_BOLT_STATUS()

bool effect_handler_BOLT_STATUS ( effect_handler_context_t context)

Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) Like BOLT, but only identifies on noticing an effect.

References effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::obj, effect_handler_context_s::origin, effect_handler_context_s::p1, project_aimed(), PROJECT_KILL, and PROJECT_STOP.

◆ effect_handler_BOLT_STATUS_DAM()

bool effect_handler_BOLT_STATUS_DAM ( effect_handler_context_t context)

Cast a bolt spell Stop if we hit a monster, as a bolt Affect monsters (not grids or objects) The same as BOLT_STATUS, but done as a separate function to aid descriptions.

References effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::obj, effect_handler_context_s::origin, effect_handler_context_s::p1, project_aimed(), PROJECT_KILL, and PROJECT_STOP.

◆ effect_handler_BRAND_AMMO()

bool effect_handler_BRAND_AMMO ( effect_handler_context_t context)

◆ effect_handler_BRAND_BOLTS()

bool effect_handler_BRAND_BOLTS ( effect_handler_context_t context)

◆ effect_handler_BRAND_WEAPON()

bool effect_handler_BRAND_WEAPON ( effect_handler_context_t context)

◆ effect_handler_BREATH()

bool effect_handler_BREATH ( effect_handler_context_t context)

◆ effect_handler_CONFUSING()

bool effect_handler_CONFUSING ( effect_handler_context_t context)

◆ effect_handler_CREATE_STAIRS()

bool effect_handler_CREATE_STAIRS ( effect_handler_context_t context)

◆ effect_handler_CRUNCH()

bool effect_handler_CRUNCH ( effect_handler_context_t context)

◆ effect_handler_CURE()

bool effect_handler_CURE ( effect_handler_context_t context)

◆ effect_handler_CURSE_ARMOR()

bool effect_handler_CURSE_ARMOR ( effect_handler_context_t context)

◆ effect_handler_CURSE_WEAPON()

bool effect_handler_CURSE_WEAPON ( effect_handler_context_t context)

◆ effect_handler_DAMAGE()

bool effect_handler_DAMAGE ( effect_handler_context_t context)

◆ effect_handler_DARKEN_AREA()

bool effect_handler_DARKEN_AREA ( effect_handler_context_t context)

◆ effect_handler_DEEP_DESCENT()

bool effect_handler_DEEP_DESCENT ( effect_handler_context_t context)

◆ effect_handler_DESTRUCTION()

bool effect_handler_DESTRUCTION ( effect_handler_context_t context)

◆ effect_handler_DETECT_DOORS()

bool effect_handler_DETECT_DOORS ( effect_handler_context_t context)

◆ effect_handler_DETECT_EVIL()

bool effect_handler_DETECT_EVIL ( effect_handler_context_t context)

◆ effect_handler_DETECT_GOLD()

bool effect_handler_DETECT_GOLD ( effect_handler_context_t context)

Detect buried gold around the player.

The height to detect above and below the player is context->value.dice, the width either side of the player context->value.sides, and setting context->p1 to 1 suppresses messages.

References effect_handler_context_s::aware, cave, random::dice, chunk::height, effect_handler_context_s::ident, msg, effect_handler_context_s::p1, player::px, player::py, random::sides, square_hasgoldvein(), square_in_bounds_fully(), square_light_spot(), square_memorize(), effect_handler_context_s::value, and chunk::width.

◆ effect_handler_DETECT_INVISIBLE_MONSTERS()

bool effect_handler_DETECT_INVISIBLE_MONSTERS ( effect_handler_context_t context)

◆ effect_handler_DETECT_OBJECTS()

bool effect_handler_DETECT_OBJECTS ( effect_handler_context_t context)

Detect objects around the player.

The height to detect above and below the player is context->value.dice, the width either side of the player context->value.sides

References effect_handler_context_s::aware, cave, random::dice, chunk::height, effect_handler_context_s::ident, ignore_item_ok(), msg, effect_handler_context_s::obj, PR_ITEMLIST, player::px, player::py, player_upkeep::redraw, random::sides, square_know_pile(), square_object(), player::upkeep, effect_handler_context_s::value, and chunk::width.

◆ effect_handler_DETECT_STAIRS()

bool effect_handler_DETECT_STAIRS ( effect_handler_context_t context)

Detect stairs around the player.

The height to detect above and below the player is context->value.dice, the width either side of the player context->value.sides.

References effect_handler_context_s::aware, cave, random::dice, chunk::height, effect_handler_context_s::ident, msg, player::px, player::py, random::sides, square_in_bounds_fully(), square_isstairs(), square_light_spot(), square_memorize(), stairs, effect_handler_context_s::value, and chunk::width.

◆ effect_handler_DETECT_TRAPS()

bool effect_handler_DETECT_TRAPS ( effect_handler_context_t context)

◆ effect_handler_DETECT_VISIBLE_MONSTERS()

bool effect_handler_DETECT_VISIBLE_MONSTERS ( effect_handler_context_t context)

◆ effect_handler_DISENCHANT()

bool effect_handler_DISENCHANT ( effect_handler_context_t context)

◆ effect_handler_DRAIN_LIGHT()

bool effect_handler_DRAIN_LIGHT ( effect_handler_context_t context)

◆ effect_handler_DRAIN_MANA()

bool effect_handler_DRAIN_MANA ( effect_handler_context_t context)

◆ effect_handler_DRAIN_STAT()

bool effect_handler_DRAIN_STAT ( effect_handler_context_t context)

◆ effect_handler_EARTHQUAKE()

bool effect_handler_EARTHQUAKE ( effect_handler_context_t context)

Induce an earthquake of the radius context->p2 centred on the instigator.

This will turn some walls into floors and some floors into walls.

The player will take damage and jump into a safe grid if possible, otherwise, he will tunnel through the rubble instantaneously.

Monsters will take damage, and jump into a safe grid if possible, otherwise they will be buried in the rubble, disappearing from the level in the same way that they do when banished.

Note that players and monsters (except eaters of walls and passers through walls) will never occupy the same grid as a wall (or door).

References cave, damroll(), ddx_ddd, ddy_ddd, delete_monster(), player::depth, distance(), FLAG_END, monster_race::flags, flags_test(), monster::hp, i, effect_handler_context_s::ident, square::info, MDESC_STANDARD, square::mon, mon_clear_timed(), MON_TMD_FLG_NOMESSAGE, monster_desc(), monster_swap(), msg, effect_handler_context_s::origin, origin_get_loc(), effect_handler_context_s::p2, player_inc_timed(), PR_HEALTH, PR_ITEMLIST, PR_MONLIST, PU_MONSTERS, PU_UPDATE_VIEW, player::px, player::py, monster::race, randint0, randint1, player_upkeep::redraw, rf_has, RF_SIZE, sqinfo_off, square_changeable(), square_earthquake(), square_excise_pile(), square_forget(), square_in_bounds_fully(), square_isbright(), square_isempty(), square_iswarded(), square_light_spot(), square_monster(), chunk::squares, take_hit(), player_upkeep::update, player::upkeep, void(), loc::x, and loc::y.

Referenced by effect_handler_WONDER().

◆ effect_handler_ENCHANT()

bool effect_handler_ENCHANT ( effect_handler_context_t context)

Enchant an item (in the inventory or on the floor) Note that armour, to hit or to dam is controlled by context->p1.

Work on incorporating enchant_spell() has been postponed...NRM

References player::depth, ENCH_TOAC, ENCH_TOBOTH, ENCH_TODAM, ENCH_TOHIT, enchant_spell(), effect_handler_context_s::ident, effect_handler_context_s::p1, randcalc(), RANDOMISE, and effect_handler_context_s::value.

◆ effect_handler_GAIN_EXP()

bool effect_handler_GAIN_EXP ( effect_handler_context_t context)

◆ effect_handler_GAIN_STAT()

bool effect_handler_GAIN_STAT ( effect_handler_context_t context)

Gain a stat point.

The stat index is context->p1.

References desc_stat(), effect_handler_context_s::ident, msg, effect_handler_context_s::p1, and player_stat_inc().

◆ effect_handler_HEAL_HP()

bool effect_handler_HEAL_HP ( effect_handler_context_t context)

Heal the player by a given percentage of their wounds, or a minimum amount, whichever is larger.

context->value.base should be the minimum, and context->value.m_bonus the percentage

References random::base, player::chp, player::chp_frac, effect_handler_context_s::ident, random::m_bonus, player::mhp, msg, num, PR_HP, player_upkeep::redraw, player::upkeep, and effect_handler_context_s::value.

◆ effect_handler_IDENTIFY()

bool effect_handler_IDENTIFY ( effect_handler_context_t context)

◆ effect_handler_LIGHT_AREA()

bool effect_handler_LIGHT_AREA ( effect_handler_context_t context)

◆ effect_handler_LIGHT_LEVEL()

bool effect_handler_LIGHT_LEVEL ( effect_handler_context_t context)

◆ effect_handler_LINE()

bool effect_handler_LINE ( effect_handler_context_t context)

◆ effect_handler_LOSE_EXP()

bool effect_handler_LOSE_EXP ( effect_handler_context_t context)

◆ effect_handler_LOSE_RANDOM_STAT()

bool effect_handler_LOSE_RANDOM_STAT ( effect_handler_context_t context)

Lose a stat point permanently, in a stat other than the one specified in context->p1.

References desc_stat(), effect_handler_context_s::ident, msgt(), effect_handler_context_s::p1, player_stat_dec(), randint1, and STAT_MAX.

◆ effect_handler_MAP_AREA()

bool effect_handler_MAP_AREA ( effect_handler_context_t context)

◆ effect_handler_MASS_BANISH()

bool effect_handler_MASS_BANISH ( effect_handler_context_t context)

Delete all nearby (non-unique) monsters.

The radius of effect is context->p2 if passed, otherwise the player view radius.

References cave, cave_monster(), cave_monster_max(), monster::cdis, delete_monster_idx(), i, effect_handler_context_s::ident, angband_constants::max_sight, monster_is_unique(), effect_handler_context_s::p2, PR_MONLIST, monster::race, randint1, player_upkeep::redraw, take_hit(), player::upkeep, and z_info.

◆ effect_handler_MON_HEAL_HP()

bool effect_handler_MON_HEAL_HP ( effect_handler_context_t context)

◆ effect_handler_MON_HEAL_KIN()

bool effect_handler_MON_HEAL_KIN ( effect_handler_context_t context)

◆ effect_handler_MON_TIMED_INC()

bool effect_handler_MON_TIMED_INC ( effect_handler_context_t context)

◆ effect_handler_NOURISH()

bool effect_handler_NOURISH ( effect_handler_context_t context)

◆ effect_handler_PROBE()

bool effect_handler_PROBE ( effect_handler_context_t context)

◆ effect_handler_PROJECT_LOS()

bool effect_handler_PROJECT_LOS ( effect_handler_context_t context)

Apply a "project()" directly to all viewable monsters.

If context->p2 is set, the effect damage boost is applied. This is a hack - NRM

Note that affected monsters are NOT auto-tracked by this usage.

References cave, cave_monster(), cave_monster_max(), effect_calculate_value(), monster::fx, monster::fy, i, effect_handler_context_s::ident, effect_handler_context_s::obj, effect_handler_context_s::p1, effect_handler_context_s::p2, project(), PROJECT_HIDE, PROJECT_JUMP, PROJECT_KILL, monster::race, source_player(), square_isview(), and void().

Referenced by effect_handler_WONDER().

◆ effect_handler_PROJECT_LOS_AWARE()

bool effect_handler_PROJECT_LOS_AWARE ( effect_handler_context_t context)

◆ effect_handler_RANDOM()

bool effect_handler_RANDOM ( effect_handler_context_t context)


Effect handlers

Dummy effect, to tell the effect code to pick one of the next context->value.base effects at random.

◆ effect_handler_RECALL()

bool effect_handler_RECALL ( effect_handler_context_t context)

◆ effect_handler_RECHARGE()

bool effect_handler_RECHARGE ( effect_handler_context_t context)

◆ effect_handler_REMOVE_CURSE()

bool effect_handler_REMOVE_CURSE ( effect_handler_context_t context)

◆ effect_handler_RESTORE_EXP()

bool effect_handler_RESTORE_EXP ( effect_handler_context_t context)

Restores any drained experience; message suppressed if context->p1 is set.

References player::exp, effect_handler_context_s::ident, player::max_exp, msg, effect_handler_context_s::p1, player_exp_gain(), and update_stuff().

◆ effect_handler_RESTORE_MANA()

bool effect_handler_RESTORE_MANA ( effect_handler_context_t context)

◆ effect_handler_RESTORE_STAT()

bool effect_handler_RESTORE_STAT ( effect_handler_context_t context)

◆ effect_handler_RUBBLE()

bool effect_handler_RUBBLE ( effect_handler_context_t context)

◆ effect_handler_RUNE()

bool effect_handler_RUNE ( effect_handler_context_t context)

◆ effect_handler_SENSE_OBJECTS()

bool effect_handler_SENSE_OBJECTS ( effect_handler_context_t context)

Sense objects around the player.

The height to sense above and below the player is context->value.dice, the width either side of the player context->value.sides

References effect_handler_context_s::aware, cave, random::dice, chunk::height, effect_handler_context_s::ident, msg, effect_handler_context_s::obj, PR_ITEMLIST, player::px, player::py, player_upkeep::redraw, random::sides, square_object(), square_sense_pile(), player::upkeep, effect_handler_context_s::value, and chunk::width.

◆ effect_handler_SET_NOURISH()

bool effect_handler_SET_NOURISH ( effect_handler_context_t context)

Make the player, um, lose food.

Or gain it.

References effect_calculate_value(), effect_handler_context_s::ident, player_set_food(), and void().

◆ effect_handler_SPOT()

bool effect_handler_SPOT ( effect_handler_context_t context)

◆ effect_handler_STAR()

bool effect_handler_STAR ( effect_handler_context_t context)

◆ effect_handler_STAR_BALL()

bool effect_handler_STAR_BALL ( effect_handler_context_t context)

◆ effect_handler_SUMMON()

bool effect_handler_SUMMON ( effect_handler_context_t context)

◆ effect_handler_SWARM()

bool effect_handler_SWARM ( effect_handler_context_t context)

Cast multiple non-jumping ball spells at the same target.

Targets absolute coordinates instead of a specific monster, so that the death of the monster doesn't change the target's location.

References ddx, ddy, effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, random::m_bonus, num, effect_handler_context_s::obj, effect_handler_context_s::p1, effect_handler_context_s::p2, project(), PROJECT_GRID, PROJECT_ITEM, PROJECT_KILL, PROJECT_STOP, PROJECT_THRU, player::px, player::py, source_player(), target_get(), target_okay(), monster::tx, monster::ty, and effect_handler_context_s::value.

◆ effect_handler_TELEPORT()

bool effect_handler_TELEPORT ( effect_handler_context_t context)

Teleport player or monster up to context->value.base grids away.

If no spaces are readily available, the distance may increase. Try very hard to move the player/monster at least a quarter that distance. Setting context->p2 allows monsters to teleport the player away. Setting context->p1 and context->p2 treats them as y and x coordinates and teleports the monster from that grid.

References ABS, random::base, cave, cave_monster(), distance(), angband_constants::dungeon_hgt, angband_constants::dungeon_wid, equip_learn_flag(), monster::fx, monster::fy, handle_stuff(), chunk::height, effect_handler_context_s::ident, square::info, MAX, mem_free(), mem_zalloc(), source::monster, monster_swap(), msg, NULL, one_in_, effect_handler_context_s::origin, effect_handler_context_s::p1, effect_handler_context_s::p2, player_of_has(), player::px, player::py, randint0, sound(), sqinfo_off, square_isempty(), square_isno_teleport(), square_isvault(), square_iswarded(), chunk::squares, effect_handler_context_s::value, source::what, source::which, chunk::width, and z_info.

◆ effect_handler_TELEPORT_LEVEL()

bool effect_handler_TELEPORT_LEVEL ( effect_handler_context_t context)

◆ effect_handler_TELEPORT_TO()

bool effect_handler_TELEPORT_TO ( effect_handler_context_t context)

Teleport player to a grid near the given location Setting context->p1 and context->p2 treats them as y and x coordinates.

This function is slightly obsessive about correctness. This function allows teleporting into vaults (!)

References cave, cave_monster(), effect_handler_context_s::dir, monster::fx, monster::fy, handle_stuff(), effect_handler_context_s::ident, square::info, source::monster, monster_swap(), effect_handler_context_s::origin, effect_handler_context_s::p1, effect_handler_context_s::p2, player::px, player::py, rand_spread, sound(), sqinfo_off, square_in_bounds_fully(), square_isempty(), chunk::squares, target_get(), target_okay(), source::what, and source::which.

◆ effect_handler_THRUST_AWAY()

bool effect_handler_THRUST_AWAY ( effect_handler_context_t context)

◆ effect_handler_TIMED_DEC()

bool effect_handler_TIMED_DEC ( effect_handler_context_t context)

Reduce a (positive or negative) player status condition.

If context->p2 is set, decrease by the current value / context->p2

References effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_dec_timed(), player::timed, and void().

◆ effect_handler_TIMED_INC()

bool effect_handler_TIMED_INC ( effect_handler_context_t context)

Extend a (positive or negative) player status condition.

If context->p2 is set, increase by that amount if the status exists already

References effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_inc_timed(), and player::timed.

◆ effect_handler_TIMED_INC_NO_RES()

bool effect_handler_TIMED_INC_NO_RES ( effect_handler_context_t context)

Extend a (positive or negative) player status condition unresistably.

If context->p2 is set, increase by that amount if the status exists already

References effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_inc_timed(), and player::timed.

◆ effect_handler_TIMED_SET()

bool effect_handler_TIMED_SET ( effect_handler_context_t context)

Set a (positive or negative) player status condition.

References effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, and player_set_timed().

◆ effect_handler_TOUCH()

bool effect_handler_TOUCH ( effect_handler_context_t context)

◆ effect_handler_TOUCH_AWARE()

bool effect_handler_TOUCH_AWARE ( effect_handler_context_t context)

◆ effect_handler_WAKE()

bool effect_handler_WAKE ( effect_handler_context_t context)

◆ effect_handler_WONDER()

bool effect_handler_WONDER ( effect_handler_context_t context)

◆ effect_info()

const char* effect_info ( struct effect effect)

◆ effect_lookup()

effect_index effect_lookup ( const char *  name)

◆ effect_param()

int effect_param ( int  index,
const char *  type 
)

◆ effect_simple()

void effect_simple ( int  index,
struct source  origin,
const char *  dice_string,
int  p1,
int  p2,
int  p3,
bool *  ident 
)

◆ effect_valid()

bool effect_valid ( struct effect effect)

◆ enchant()

bool enchant ( struct object obj,
int  n,
int  eflag 
)

Enchant an item.

Revamped! Now takes item pointer, number of times to try enchanting, and a flag of what to try enchanting. Artifacts resist enchantment some of the time. Also, any enchantment attempt (even unsuccessful) kicks off a parallel attempt to uncurse a cursed item.

Note that an item can technically be enchanted all the way to +15 if you wait a very, very, long time. Going from +9 to +10 only works about 5% of the time, and from +10 to +11 only about 1% of the time.

Note that this function can now be used on "piles" of items, and the larger the pile, the lower the chance of success.

Returns
true if the item was changed in some way

References ENCH_TOAC, ENCH_TODAM, ENCH_TOHIT, enchant2(), i, object::known, player_upkeep::notice, object::number, PN_COMBINE, PR_EQUIP, PR_INVEN, PU_BONUS, PU_INVEN, randint0, player_upkeep::redraw, object::to_a, object::to_d, object::to_h, tval_is_ammo(), player_upkeep::update, and player::upkeep.

Referenced by brand_object(), and enchant_spell().

◆ enchant2()

static bool enchant2 ( struct object obj,
s16b score 
)
static

Helper function for enchant() which tries increasing an item's bonuses.

Returns
true if a bonus was increased

References object::artifact, enchant_score(), and true.

Referenced by enchant().

◆ enchant_score()

static bool enchant_score ( s16b score,
bool  is_artifact 
)
static

Tries to increase an items bonus score, if possible.

Returns
true if the bonus was increased

References enchant_table, randint0, and randint1.

Referenced by enchant2().

◆ enchant_spell()

bool enchant_spell ( int  num_hit,
int  num_dam,
int  num_ac 
)

Enchant an item (in the inventory or on the floor) Note that "num_ac" requires armour, else weapon Returns true if attempted, false if cancelled.

Enchanting with the TOBOTH flag will try to enchant both to_hit and to_dam with the same flag. This may not be the most desirable behavior (ACB).

References ENCH_TOAC, ENCH_TOBOTH, ENCH_TODAM, ENCH_TOHIT, enchant(), EVENT_INPUT_FLUSH, event_signal(), get_item(), item_tester_hook_armour(), item_tester_hook_weapon(), msg, object::number, effect_handler_context_s::obj, object_desc(), object_is_carried(), ODESC_BASE, USE_EQUIP, USE_FLOOR, USE_INVEN, and USE_QUIVER.

Referenced by effect_handler_ENCHANT().

◆ free_effect()

void free_effect ( struct effect source)

Free all the effects in a structure.

Parameters
sourcethe effects being freed

References effect::dice, dice_free(), mem_free(), and effect::next.

Referenced by cleanup_act(), cleanup_class(), cleanup_curse(), cleanup_ego(), cleanup_mon_spell(), cleanup_object(), and cleanup_trap().

◆ get_target()

static void get_target ( struct source  origin,
int  dir,
int ty,
int tx,
int flags 
)
static

◆ item_tester_hook_ammo()

static bool item_tester_hook_ammo ( const struct object obj)
static

Hook to specify "ammo".

References tval_is_ammo().

Referenced by effect_handler_BRAND_AMMO().

◆ item_tester_hook_armour()

static bool item_tester_hook_armour ( const struct object obj)
static

Hook to specify "armour".

References tval_is_armor().

Referenced by enchant_spell().

◆ item_tester_hook_bolt()

static bool item_tester_hook_bolt ( const struct object obj)
static

Hook to specify bolts.

References object::tval.

Referenced by effect_handler_BRAND_BOLTS().

◆ item_tester_hook_recharge()

static bool item_tester_hook_recharge ( const struct object obj)
static

Hook for "get_item()".

Determine if something is rechargable.

References tval_can_have_charges().

Referenced by effect_handler_RECHARGE().

◆ item_tester_hook_weapon()

static bool item_tester_hook_weapon ( const struct object obj)
static

Hook to specify "weapon".

References tval_is_weapon().

Referenced by enchant_spell().

◆ item_tester_uncursable()

static bool item_tester_uncursable ( const struct object obj)
static

Selects items that have at least one removable curse.

References angband_constants::curse_max, object::curses, i, object::known, curse_data::power, and z_info.

Referenced by effect_handler_REMOVE_CURSE().

◆ item_tester_unknown()

static bool item_tester_unknown ( const struct object obj)
static

Selects items that have at least one unknown rune.

References false, and object_runes_known().

Referenced by effect_handler_IDENTIFY().

◆ project_aimed()

static bool project_aimed ( struct source  origin,
int  typ,
int  dir,
int  dam,
int  flg,
const struct object obj 
)
static

◆ project_touch()

static bool project_touch ( int  dam,
int  rad,
int  typ,
bool  aware,
const struct object obj 
)
static

◆ remove_object_curse()

static void remove_object_curse ( struct object obj,
int  index,
bool  message 
)
static

Removes an individual curse from an object.

References angband_constants::curse_max, curses, object::curses, format(), i, index, mem_free(), msg, curse::name, NULL, curse_data::power, curse_data::timeout, and z_info.

Referenced by uncurse_object().

◆ uncurse_object()

static bool uncurse_object ( struct object obj,
int  strength,
char *  dice_string 
)
static

Variable Documentation

◆ effect_names

const char* effect_names[]
static

Referenced by effect_lookup().

◆ effects

const struct effect_kind effects[]
static


Properties of effects

Useful things about effects.

◆ enchant_table

const int enchant_table[16]
static
Initial value:
=
{
0, 10, 20, 40, 80,
160, 280, 400, 550, 700,
800, 900, 950, 970, 990,
1000
}

Used by the enchant() function (chance of failure)

Referenced by enchant_score().