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-spell.h"
#include "mon-summon.h"
#include "mon-util.h"
#include "obj-chest.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-identify.h"
#include "obj-ignore.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-power.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"
#include "target.h"
#include "trap.h"
#include "list-stats.h"
#include "list-effects.h"

Data Structures

struct  effect_handler_context_s
struct  effect_kind
 Structure for effects. More...
struct  breath_info
 Element info - can be improved NRM. More...

Macros

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

Typedefs

typedef struct
effect_handler_context_s 
effect_handler_context_t
typedef bool(* effect_handler_f )(effect_handler_context_t *)

Functions

int effect_calculate_value (effect_handler_context_t *context, bool use_boost)
static bool project_aimed (int typ, int dir, int dam, int flg)
 Apply the project() function in a direction, or at a target.
static bool project_touch (int dam, int typ, bool aware)
 Apply the project() function to grids the player is touching.
bool effect_handler_RANDOM (effect_handler_context_t *context)
 Dummy effect, to tell the effect code to pick one of the next context->value.base effects at random.
bool effect_handler_DAMAGE (effect_handler_context_t *context)
 Deal damage from the current monster to the player.
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.
bool effect_handler_MON_HEAL_HP (effect_handler_context_t *context)
 Monster self-healing.
bool effect_handler_NOURISH (effect_handler_context_t *context)
 Feed the player.
bool effect_handler_CRUNCH (effect_handler_context_t *context)
bool effect_handler_CURE (effect_handler_context_t *context)
 Cure a player status condition.
bool effect_handler_TIMED_SET (effect_handler_context_t *context)
 Set a (positive or negative) player status condition.
bool effect_handler_TIMED_INC (effect_handler_context_t *context)
 Extend a (positive or negative) player status condition.
bool effect_handler_MON_TIMED_INC (effect_handler_context_t *context)
 Extend a (positive or negative) monster status condition.
bool effect_handler_TIMED_DEC (effect_handler_context_t *context)
 Reduce a (positive or negative) player status condition.
bool effect_handler_SET_NOURISH (effect_handler_context_t *context)
 Make the player, um, lose food.
bool effect_handler_CONFUSING (effect_handler_context_t *context)
bool effect_handler_RUNE (effect_handler_context_t *context)
 Create a "glyph of warding".
bool effect_handler_RESTORE_STAT (effect_handler_context_t *context)
 Restore a stat.
bool effect_handler_DRAIN_STAT (effect_handler_context_t *context)
 Drain a stat temporarily.
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.
bool effect_handler_GAIN_STAT (effect_handler_context_t *context)
 Gain a stat point.
bool effect_handler_RESTORE_EXP (effect_handler_context_t *context)
 Restores any drained experience; message suppressed if context->p1 is set.
bool effect_handler_GAIN_EXP (effect_handler_context_t *context)
bool effect_handler_LOSE_EXP (effect_handler_context_t *context)
bool effect_handler_DRAIN_MANA (effect_handler_context_t *context)
 Drain mana from the player, healing the caster.
bool effect_handler_RESTORE_MANA (effect_handler_context_t *context)
static void uncurse_object (object_type *o_ptr)
static int remove_curse_aux (bool heavy)
bool remove_curse (void)
bool remove_all_curse (void)
bool effect_handler_REMOVE_CURSE (effect_handler_context_t *context)
 Will need revamping with curses - NRM.
bool effect_handler_REMOVE_ALL_CURSE (effect_handler_context_t *context)
 Will need revamping with curses - NRM.
bool effect_handler_RECALL (effect_handler_context_t *context)
 Set word of recall as appropriate.
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.
bool effect_handler_DETECT_TRAPS (effect_handler_context_t *context)
 Detect traps around the player.
bool effect_handler_DETECT_DOORS (effect_handler_context_t *context)
 Detect doors around the player.
bool effect_handler_DETECT_STAIRS (effect_handler_context_t *context)
 Detect stairs around the player.
bool effect_handler_DETECT_GOLD (effect_handler_context_t *context)
 Detect buried gold around the player.
bool effect_handler_SENSE_OBJECTS (effect_handler_context_t *context)
 Sense objects around the player.
bool effect_handler_DETECT_OBJECTS (effect_handler_context_t *context)
 Detect objects around the player.
bool effect_handler_DETECT_VISIBLE_MONSTERS (effect_handler_context_t *context)
 Detect visible monsters around the player.
bool effect_handler_DETECT_INVISIBLE_MONSTERS (effect_handler_context_t *context)
 Detect invisible monsters around the player.
bool effect_handler_DETECT_EVIL (effect_handler_context_t *context)
 Detect evil monsters around the player.
bool effect_handler_CREATE_STAIRS (effect_handler_context_t *context)
 Create stairs at the player location.
bool effect_handler_DISENCHANT (effect_handler_context_t *context)
 Apply disenchantment to the player's stuff.
static bool item_tester_hook_weapon (const object_type *o_ptr)
static bool item_tester_hook_armour (const object_type *o_ptr)
static bool enchant_score (s16b *score, bool is_artifact)
 Tries to increase an items bonus score, if possible.
static bool enchant_curse (object_type *o_ptr, bool is_artifact)
 Tries to uncurse a cursed item, if possible.
static bool enchant2 (object_type *o_ptr, s16b *score)
 Helper function for enchant() which tries to do the two things that enchanting an item does, namely increasing its bonuses and breaking curses.
bool enchant (object_type *o_ptr, int n, int eflag)
 Enchant an item.
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.
void brand_object (object_type *obj, const char *name)
 Brand weapons (or ammo)
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.
static bool item_tester_unknown (const object_type *o_ptr)
bool effect_handler_IDENTIFY (effect_handler_context_t *context)
 Identify an unknown item.
bool effect_handler_IDENTIFY_PACK (effect_handler_context_t *context)
 Identify everything worn or carried by the player.
static bool item_tester_hook_recharge (const struct object *obj)
bool effect_handler_RECHARGE (effect_handler_context_t *context)
 Recharge a wand or staff from the pack or on the floor.
bool effect_handler_PROJECT_LOS (effect_handler_context_t *context)
 Apply a "project()" directly to all viewable monsters.
bool effect_handler_ACQUIRE (effect_handler_context_t *context)
bool effect_handler_AGGRAVATE (effect_handler_context_t *context)
 Wake up all monsters, and speed up "los" monsters.
bool effect_handler_SUMMON (effect_handler_context_t *context)
 Summon context->value monsters of context->p1 type.
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


bool effect_handler_MASS_BANISH (effect_handler_context_t *context)
 Delete all nearby (non-unique) monsters.
bool effect_handler_PROBE (effect_handler_context_t *context)
bool effect_handler_THRUST_AWAY (effect_handler_context_t *context)
 Thrust the player or a monster away from the source of a projection.
bool effect_handler_TELEPORT (effect_handler_context_t *context)
 Teleport player or monster up to context->value.base grids away.
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.
bool effect_handler_TELEPORT_LEVEL (effect_handler_context_t *context)
 Teleport the player one level up or down (random when legal)
bool effect_handler_DESTRUCTION (effect_handler_context_t *context)
 The destruction effect.
bool effect_handler_EARTHQUAKE (effect_handler_context_t *context)
 Induce an earthquake of the radius context->p2 centred on the instigator.
bool effect_handler_ENLIGHTENMENT (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)
bool effect_handler_DARKEN_AREA (effect_handler_context_t *context)
 Call darkness around the player Affect all monsters in the projection radius (context->p2)
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.
bool effect_handler_BREATH (effect_handler_context_t *context)
 Breathe an element Stop if we hit a monster or the player, act as a ball (for now) Allow target mode to pass over monsters Affect grids, objects, and monsters context->p1 is element, context->p2 radius.
bool effect_handler_SWARM (effect_handler_context_t *context)
 Cast multiple non-jumping ball spells at the same target.
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.
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.
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)
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)
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.
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)
bool effect_handler_ALTER (effect_handler_context_t *context)
 Cast an alter spell Affect objects and grids (not monsters)
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.
bool effect_handler_TOUCH (effect_handler_context_t *context)
 Affect adjacent grids (radius 1 ball attack)
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.
bool effect_handler_CURSE_ARMOR (effect_handler_context_t *context)
 Curse the player's armor.
bool effect_handler_CURSE_WEAPON (effect_handler_context_t *context)
 Curse the player's weapon.
bool effect_handler_BRAND_WEAPON (effect_handler_context_t *context)
 Brand the current weapon.
static bool item_tester_hook_ammo (const object_type *obj)
bool effect_handler_BRAND_AMMO (effect_handler_context_t *context)
 Brand some (non-magical) ammo.
static bool item_tester_hook_bolt (const struct object *obj)
bool effect_handler_BRAND_BOLTS (effect_handler_context_t *context)
 Enchant some (non-magical) bolts.
bool effect_handler_BIZARRE (effect_handler_context_t *context)
 One Ring activation.
bool effect_handler_WONDER (effect_handler_context_t *context)
 The "wonder" effect.
bool effect_handler_TRAP_DOOR (effect_handler_context_t *context)
bool effect_handler_TRAP_PIT (effect_handler_context_t *context)
bool effect_handler_TRAP_PIT_SPIKES (effect_handler_context_t *context)
bool effect_handler_TRAP_PIT_POISON (effect_handler_context_t *context)
bool effect_handler_TRAP_RUNE_SUMMON (effect_handler_context_t *context)
bool effect_handler_TRAP_RUNE_TELEPORT (effect_handler_context_t *context)
bool effect_handler_TRAP_SPOT_FIRE (effect_handler_context_t *context)
bool effect_handler_TRAP_SPOT_ACID (effect_handler_context_t *context)
bool effect_handler_TRAP_DART_SLOW (effect_handler_context_t *context)
bool effect_handler_TRAP_DART_LOSE_STR (effect_handler_context_t *context)
bool effect_handler_TRAP_DART_LOSE_DEX (effect_handler_context_t *context)
bool effect_handler_TRAP_DART_LOSE_CON (effect_handler_context_t *context)
bool effect_handler_TRAP_GAS_BLIND (effect_handler_context_t *context)
bool effect_handler_TRAP_GAS_CONFUSE (effect_handler_context_t *context)
bool effect_handler_TRAP_GAS_POISON (effect_handler_context_t *context)
bool effect_handler_TRAP_GAS_SLEEP (effect_handler_context_t *context)
void free_effect (struct effect *source)
 Free all the effects in a structure.
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 (const char *type)
 Translate a string to an effect parameter index.
bool effect_do (struct effect *effect, bool *ident, bool aware, int dir, int beam, int boost)
 Do an effect, given an object.
void effect_simple (int index, 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.

Variables

static struct breath_info elements []
static const char * desc_stat_pos []
 Array of stat adjectives.
static const char * desc_stat_neg []
 Array of stat opposite adjectives.
static const int enchant_table [16]
 Used by the enchant() function (chance of failure)
static struct effect_kind effects []
 Useful things about effects.
static const char * effect_names []

Detailed Description

Handler and auxiliary functions for every effect in the game.

Copyright (c) 2007 Andi Sidwell Copyright (c) 2014 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

#define EFFECT (   x,
  a,
  b,
 
)    { EF_##x, a, b, F(x), d },
#define EFFECT (   x,
  a,
  b,
 
)    #x,
#define ENCH_TOAC   0x04
#define ENCH_TODAM   0x02
#define ENCH_TOHIT   0x01

Bit flags for the enchant() function.

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

#define F (   x)    effect_handler_##x
#define STAT (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    f,
#define STAT (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    g,

Typedef Documentation

typedef bool(* effect_handler_f)(effect_handler_context_t *)

Function Documentation

void brand_object ( object_type obj,
const char *  name 
)
bool effect_aim ( struct effect effect)
int effect_calculate_value ( effect_handler_context_t context,
bool  use_boost 
)
const char* effect_desc ( struct effect effect)
bool effect_do ( struct effect effect,
bool ident,
bool  aware,
int  dir,
int  beam,
int  boost 
)

Do an effect, given an object.

Boost is the extent to which skill surpasses difficulty, used as % boost. It ranges from 0 to 138.

Note that no effect ever sets *ident to FALSE

References effect::dice, dice_roll(), effect_valid(), FALSE, effect_kind::handler, effect_handler_context_s::ident, effect::index, msg, effect::next, effect::params, randint0, and value.

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

bool effect_handler_ACQUIRE ( effect_handler_context_t context)
bool effect_handler_AGGRAVATE ( effect_handler_context_t context)

Wake up all monsters, and speed up "los" monsters.

Possibly the los test should be from the aggravating monster, rather than automatically the player - NRM

References cave, cave_monster(), cave_monster_max(), monster::cdis, FALSE, monster::fx, monster::fy, i, effect_handler_context_s::ident, monster::m_timed, angband_constants::max_sight, mon_clear_timed(), chunk::mon_current, mon_inc_timed(), MON_TMD_FLG_NOMESSAGE, MON_TMD_FLG_NOTIFY, msg, player_has_los_bold(), monster::race, TRUE, and z_info.

bool effect_handler_ALTER ( effect_handler_context_t context)
bool effect_handler_ALTER_REALITY ( effect_handler_context_t context)
bool effect_handler_BALL ( effect_handler_context_t context)
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(), monster_race::flags, get_com(), i, effect_handler_context_s::ident, PR_MONLIST, monster::race, randint1, player_upkeep::redraw, rf_has, take_hit(), TRUE, and player::upkeep.

Referenced by effect_handler_WONDER().

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)

References effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, project_aimed(), PROJECT_BEAM, PROJECT_KILL, and TRUE.

Referenced by effect_handler_BOLT_OR_BEAM(), and effect_handler_WONDER().

bool effect_handler_BIZARRE ( effect_handler_context_t context)
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)

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

Referenced by effect_handler_BOLT_OR_BEAM(), and effect_handler_WONDER().

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::p1, project_aimed(), PROJECT_AWARE, PROJECT_KILL, PROJECT_STOP, and TRUE.

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().

bool effect_handler_BRAND_AMMO ( effect_handler_context_t context)
bool effect_handler_BRAND_BOLTS ( effect_handler_context_t context)
bool effect_handler_BRAND_WEAPON ( effect_handler_context_t context)
bool effect_handler_BREATH ( effect_handler_context_t context)

Breathe an element Stop if we hit a monster or the player, act as a ball (for now) Allow target mode to pass over monsters Affect grids, objects, and monsters context->p1 is element, context->p2 radius.

References breath_dam(), cave, cave_monster(), ddx, ddy, desc, effect_handler_context_s::dir, effect_calculate_value(), elements, monster_race::flags, monster::hp, effect_handler_context_s::ident, chunk::mon_current, msgt(), effect_handler_context_s::p1, effect_handler_context_s::p2, project(), PROJECT_GRID, PROJECT_ITEM, PROJECT_KILL, PROJECT_PLAY, PROJECT_STOP, player::px, player::py, monster::race, rf_has, target_get(), target_okay(), TRUE, monster::tx, monster::ty, and type.

bool effect_handler_CONFUSING ( effect_handler_context_t context)
bool effect_handler_CREATE_STAIRS ( effect_handler_context_t context)
bool effect_handler_CRUNCH ( effect_handler_context_t context)
bool effect_handler_CURE ( effect_handler_context_t context)

Cure a player status condition.

References effect_handler_context_s::ident, effect_handler_context_s::p1, player_clear_timed(), TRUE, and type.

bool effect_handler_CURSE_ARMOR ( effect_handler_context_t context)
bool effect_handler_CURSE_WEAPON ( effect_handler_context_t context)
bool effect_handler_DAMAGE ( effect_handler_context_t context)

Deal damage from the current monster to the player.

References cave, cave_monster(), effect_calculate_value(), FALSE, MDESC_DIED_FROM, chunk::mon_current, monster_desc(), take_hit(), and TRUE.

bool effect_handler_DARKEN_AREA ( effect_handler_context_t context)

Call darkness around the player Affect all monsters in the projection radius (context->p2)

References effect_calculate_value(), FALSE, effect_handler_context_s::ident, light_room(), msg, effect_handler_context_s::p2, project(), PROJECT_GRID, PROJECT_KILL, player::px, player::py, player::timed, TRUE, and void().

bool effect_handler_DEEP_DESCENT ( effect_handler_context_t context)
bool effect_handler_DESTRUCTION ( effect_handler_context_t context)
bool effect_handler_DETECT_DOORS ( effect_handler_context_t context)

Detect doors 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, cave_k, random::dice, FALSE, square::feat, chunk::height, effect_handler_context_s::ident, square::info, msg, place_closed_door(), player::px, player::py, random::sides, sqinfo_on, square_in_bounds_fully(), square_isdoor(), square_issecretdoor(), square_light_spot(), chunk::squares, TRUE, effect_handler_context_s::value, and chunk::width.

bool effect_handler_DETECT_EVIL ( effect_handler_context_t context)
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, FALSE, chunk::height, effect_handler_context_s::ident, square::info, msg, effect_handler_context_s::p1, player::px, player::py, random::sides, sqinfo_on, square_hasgoldvein(), square_in_bounds_fully(), square_light_spot(), chunk::squares, TRUE, effect_handler_context_s::value, and chunk::width.

bool effect_handler_DETECT_INVISIBLE_MONSTERS ( effect_handler_context_t context)
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, FALSE, chunk::height, effect_handler_context_s::ident, ignore_item_ok(), MARK_SEEN, object::marked, msg, object::next, player::px, player::py, random::sides, square_light_spot(), square_object(), TRUE, effect_handler_context_s::value, and chunk::width.

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, cave_k, random::dice, FALSE, square::feat, chunk::height, effect_handler_context_s::ident, square::info, msg, player::px, player::py, random::sides, sqinfo_on, square_in_bounds_fully(), square_isstairs(), square_light_spot(), chunk::squares, stairs, TRUE, effect_handler_context_s::value, and chunk::width.

bool effect_handler_DETECT_TRAPS ( effect_handler_context_t context)
bool effect_handler_DETECT_VISIBLE_MONSTERS ( effect_handler_context_t context)
bool effect_handler_DISENCHANT ( effect_handler_context_t context)
bool effect_handler_DRAIN_MANA ( effect_handler_context_t context)
bool effect_handler_DRAIN_STAT ( effect_handler_context_t context)
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, cave_monster(), damroll(), ddx_ddd, ddy_ddd, delete_monster(), player::depth, distance(), FALSE, FLAG_END, monster_race::flags, flags_test(), monster::fx, monster::fy, monster::hp, i, effect_handler_context_s::ident, square::info, MDESC_STANDARD, square::mon, mon_clear_timed(), chunk::mon_current, MON_TMD_FLG_NOMESSAGE, monster_desc(), monster_swap(), msg, object_pile_free(), effect_handler_context_s::p2, player_inc_timed(), PR_HEALTH, PR_ITEMLIST, PR_MONLIST, PU_FORGET_FLOW, PU_FORGET_VIEW, PU_MONSTERS, PU_UPDATE_FLOW, 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_in_bounds_fully(), square_isempty(), square_iswarded(), square_light_spot(), square_monster(), square_object(), chunk::squares, take_hit(), TRUE, player_upkeep::update, player::upkeep, and void().

Referenced by effect_handler_WONDER().

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_TODAM, ENCH_TOHIT, enchant_spell(), effect_handler_context_s::ident, effect_handler_context_s::p1, randcalc(), RANDOMISE, TRUE, effect_handler_context_s::value, and value.

bool effect_handler_ENLIGHTENMENT ( effect_handler_context_t context)
bool effect_handler_GAIN_EXP ( effect_handler_context_t context)
bool effect_handler_GAIN_STAT ( effect_handler_context_t context)

Gain a stat point.

The stat index is context->p1.

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

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, TRUE, player::upkeep, effect_handler_context_s::value, and value.

bool effect_handler_IDENTIFY ( effect_handler_context_t context)
bool effect_handler_IDENTIFY_PACK ( effect_handler_context_t context)

Identify everything worn or carried by the player.

References do_ident_item(), player::gear, effect_handler_context_s::ident, object::next, object_is_known(), and TRUE.

bool effect_handler_LIGHT_AREA ( effect_handler_context_t context)
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)

References effect_handler_context_s::dir, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, project_aimed(), PROJECT_BEAM, PROJECT_GRID, PROJECT_KILL, and TRUE.

Referenced by effect_handler_WONDER().

bool effect_handler_LOSE_EXP ( effect_handler_context_t context)
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_neg, effect_handler_context_s::ident, msgt(), effect_handler_context_s::p1, player_stat_dec(), randint0, STAT_MAX, and TRUE.

bool effect_handler_MAP_AREA ( effect_handler_context_t context)

Map an area around the player.

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

References cave, cave_k, ddx_ddd, ddy_ddd, random::dice, square::feat, chunk::height, i, effect_handler_context_s::ident, square::info, player::px, player::py, random::sides, sqinfo_on, square_in_bounds_fully(), square_isinteresting(), square_isno_map(), square_light_spot(), square_seemslikewall(), chunk::squares, TRUE, effect_handler_context_s::value, and chunk::width.

bool effect_handler_MASS_BANISH ( effect_handler_context_t context)
bool effect_handler_MON_HEAL_HP ( effect_handler_context_t context)
bool effect_handler_MON_TIMED_INC ( effect_handler_context_t context)
bool effect_handler_NOURISH ( effect_handler_context_t context)
bool effect_handler_PROBE ( effect_handler_context_t context)
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 effect_handler_context_s::aware, cave, cave_monster(), cave_monster_max(), effect_calculate_value(), FALSE, monster::fx, monster::fy, i, effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_has_los_bold(), project(), PROJECT_AWARE, PROJECT_HIDE, PROJECT_JUMP, PROJECT_KILL, monster::race, and TRUE.

Referenced by effect_handler_WONDER().

bool effect_handler_RANDOM ( effect_handler_context_t context)

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

References TRUE.

bool effect_handler_RECALL ( effect_handler_context_t context)
bool effect_handler_RECHARGE ( effect_handler_context_t context)
bool effect_handler_REMOVE_ALL_CURSE ( effect_handler_context_t context)

Will need revamping with curses - NRM.

References effect_handler_context_s::ident, remove_all_curse(), and TRUE.

bool effect_handler_REMOVE_CURSE ( effect_handler_context_t context)

Will need revamping with curses - NRM.

References effect_handler_context_s::ident, msg, remove_curse(), player::timed, and TRUE.

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(), TRUE, update_stuff(), and player::upkeep.

bool effect_handler_RESTORE_MANA ( effect_handler_context_t context)
bool effect_handler_RESTORE_STAT ( effect_handler_context_t context)
bool effect_handler_RUNE ( effect_handler_context_t context)
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, FALSE, chunk::height, effect_handler_context_s::ident, MARK_AWARE, MARK_UNAWARE, object::marked, msg, object::next, player::px, player::py, random::sides, square_light_spot(), square_object(), TRUE, effect_handler_context_s::value, and chunk::width.

bool effect_handler_SET_NOURISH ( effect_handler_context_t context)

Make the player, um, lose food.

Or gain it.

References effect_calculate_value(), FALSE, effect_handler_context_s::ident, player_set_food(), and TRUE.

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.

References ddx, ddy, effect_calculate_value(), i, effect_handler_context_s::ident, effect_handler_context_s::p1, project(), PROJECT_BEAM, PROJECT_GRID, PROJECT_KILL, player::px, player::py, TRUE, monster::tx, and monster::ty.

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.

References ddx, ddy, effect_calculate_value(), i, effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, project(), PROJECT_GRID, PROJECT_ITEM, PROJECT_KILL, PROJECT_STOP, player::px, player::py, TRUE, monster::tx, and monster::ty.

bool effect_handler_SUMMON ( effect_handler_context_t context)
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::p1, effect_handler_context_s::p2, project(), PROJECT_GRID, PROJECT_ITEM, PROJECT_KILL, PROJECT_STOP, PROJECT_THRU, player::px, player::py, target_get(), target_okay(), TRUE, monster::tx, monster::ty, and effect_handler_context_s::value.

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 random::base, cave, cave_monster(), distance(), FALSE, monster::fx, monster::fy, handle_stuff(), i, effect_handler_context_s::ident, square::info, monster::midx, chunk::mon_current, monster_swap(), msg, effect_handler_context_s::p1, effect_handler_context_s::p2, player::px, player::py, monster::race, rand_spread, sound(), sqinfo_off, square_in_bounds_fully(), square_isempty(), square_isno_teleport(), square_isvault(), square_iswarded(), chunk::squares, TRUE, player::upkeep, and effect_handler_context_s::value.

bool effect_handler_TELEPORT_LEVEL ( effect_handler_context_t context)
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, monster::midx, chunk::mon_current, monster_swap(), 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(), TRUE, and player::upkeep.

bool effect_handler_THRUST_AWAY ( effect_handler_context_t context)

Thrust the player or a monster away from the source of a projection.

Monsters and players can be pushed past monsters or players weaker than they are. If set, context->p1 and context->p2 act as y and x coordinates

References cave, cave_monster(), ddx_ddd, ddy_ddd, effect_calculate_value(), FALSE, monster::fx, monster::fy, get_angle_to_grid, i, square::info, player::lev, monster_race::level, monster_race::mexp, square::mon, chunk::mon_current, monster_swap(), msg, effect_handler_context_s::p1, effect_handler_context_s::p2, player::px, player::py, monster::race, randint0, sqinfo_off, square_ispassable(), square_isprojectable(), square_monster(), chunk::squares, target_get(), and TRUE.

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(), FALSE, effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_dec_timed(), player::timed, and TRUE.

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(), FALSE, effect_handler_context_s::ident, effect_handler_context_s::p1, effect_handler_context_s::p2, player_inc_timed(), player::timed, and TRUE.

bool effect_handler_TIMED_SET ( effect_handler_context_t context)

Set a (positive or negative) player status condition.

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

bool effect_handler_TOUCH ( effect_handler_context_t context)

Affect adjacent grids (radius 1 ball attack)

References effect_calculate_value(), FALSE, effect_handler_context_s::ident, effect_handler_context_s::p1, project_touch(), and TRUE.

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.

References effect_handler_context_s::aware, effect_calculate_value(), effect_handler_context_s::ident, effect_handler_context_s::p1, project_touch(), and TRUE.

bool effect_handler_TRAP_DART_LOSE_CON ( effect_handler_context_t context)
bool effect_handler_TRAP_DART_LOSE_DEX ( effect_handler_context_t context)
bool effect_handler_TRAP_DART_LOSE_STR ( effect_handler_context_t context)
bool effect_handler_TRAP_DART_SLOW ( effect_handler_context_t context)
bool effect_handler_TRAP_DOOR ( effect_handler_context_t context)
bool effect_handler_TRAP_GAS_BLIND ( effect_handler_context_t context)

References msg, player_inc_timed(), randint0, TRUE, and void().

bool effect_handler_TRAP_GAS_CONFUSE ( effect_handler_context_t context)

References msg, player_inc_timed(), randint0, TRUE, and void().

bool effect_handler_TRAP_GAS_POISON ( effect_handler_context_t context)

References msg, player_inc_timed(), randint0, TRUE, and void().

bool effect_handler_TRAP_GAS_SLEEP ( effect_handler_context_t context)

References msg, player_inc_timed(), randint0, TRUE, and void().

bool effect_handler_TRAP_PIT ( effect_handler_context_t context)
bool effect_handler_TRAP_PIT_POISON ( effect_handler_context_t context)
bool effect_handler_TRAP_PIT_SPIKES ( effect_handler_context_t context)
bool effect_handler_TRAP_RUNE_SUMMON ( effect_handler_context_t context)
bool effect_handler_TRAP_RUNE_TELEPORT ( effect_handler_context_t context)
bool effect_handler_TRAP_SPOT_ACID ( effect_handler_context_t context)
bool effect_handler_TRAP_SPOT_FIRE ( effect_handler_context_t context)
bool effect_handler_WONDER ( effect_handler_context_t context)

The "wonder" effect.

This spell should become more useful (more controlled) as the player gains experience levels. Thus, add 1/5 of the player's level to the die roll. This eliminates the worst effects later on, while keeping the results quite random. It also allows some potent effects only at high level

References effect_handler_context_s::aware, random::base, effect_handler_context_s::beam, effect_handler_context_s::boost, random::dice, effect_handler_context_s::dir, effect_handler_context_s::effect, effect_calculate_value(), effect_handler_BALL(), effect_handler_BANISH(), effect_handler_BEAM(), effect_handler_BOLT(), effect_handler_BOLT_OR_BEAM(), effect_handler_EARTHQUAKE(), effect_handler_LINE(), effect_handler_PROJECT_LOS(), effect_simple(), FALSE, effect_handler_context_s::ident, player::lev, mem_free(), mem_zalloc(), msg, random::sides, TRUE, and value.

const char* effect_info ( struct effect effect)
effect_index effect_lookup ( const char *  name)

References EF_MAX, effect_names, i, N_ELEMENTS, and streq.

Referenced by do_cmd_wiz_effect().

int effect_param ( const char *  type)
void effect_simple ( int  index,
const char *  dice_string,
int  p1,
int  p2,
int  p3,
bool ident 
)
bool effect_valid ( struct effect effect)
bool enchant ( object_type o_ptr,
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(), FALSE, i, 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, TRUE, tval_is_ammo(), player_upkeep::update, and player::upkeep.

Referenced by brand_object(), and enchant_spell().

static bool enchant2 ( object_type o_ptr,
s16b score 
)
static

Helper function for enchant() which tries to do the two things that enchanting an item does, namely increasing its bonuses and breaking curses.

Returns
true if a bonus was increased or a curse was broken

References object::artifact, enchant_curse(), enchant_score(), FALSE, and TRUE.

Referenced by enchant().

static bool enchant_curse ( object_type o_ptr,
bool  is_artifact 
)
static

Tries to uncurse a cursed item, if possible.

Returns
true if a curse was broken

References cursed_p(), FALSE, object::flags, msg, of_has, randint0, TRUE, and uncurse_object().

Referenced by enchant2().

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, FALSE, randint0, randint1, and TRUE.

Referenced by enchant2().

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.

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

Referenced by effect_handler_ENCHANT().

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_ego(), cleanup_mon_spell(), cleanup_object(), cleanup_trap(), and effect_simple().

static bool item_tester_hook_ammo ( const object_type obj)
static

References tval_is_ammo().

Referenced by effect_handler_BRAND_AMMO().

static bool item_tester_hook_armour ( const object_type o_ptr)
static

References tval_is_armor().

Referenced by enchant_spell().

static bool item_tester_hook_bolt ( const struct object obj)
static

References object::tval.

Referenced by effect_handler_BRAND_BOLTS().

static bool item_tester_hook_recharge ( const struct object obj)
static

References FALSE, TRUE, and tval_can_have_charges().

Referenced by effect_handler_RECHARGE().

static bool item_tester_hook_weapon ( const object_type o_ptr)
static

References tval_is_weapon().

Referenced by enchant_spell().

static bool item_tester_unknown ( const object_type o_ptr)
static

References FALSE, object_is_known(), and TRUE.

Referenced by effect_handler_IDENTIFY().

static bool project_aimed ( int  typ,
int  dir,
int  dam,
int  flg 
)
static
static bool project_touch ( int  dam,
int  typ,
bool  aware 
)
static

Apply the project() function to grids the player is touching.

References project(), PROJECT_AWARE, PROJECT_HIDE, PROJECT_KILL, player::px, and player::py.

Referenced by effect_handler_TOUCH(), and effect_handler_TOUCH_AWARE().

bool remove_all_curse ( void  )
bool remove_curse ( void  )

References FALSE, and remove_curse_aux().

Referenced by effect_handler_REMOVE_CURSE().

static int remove_curse_aux ( bool  heavy)
static
static void uncurse_object ( object_type o_ptr)
static

Variable Documentation

const char* desc_stat_neg[]
static
Initial value:
{
#define STAT(a, b, c, d, e, f, g, h)
}

Array of stat opposite adjectives.

Referenced by effect_handler_DRAIN_STAT(), effect_handler_LOSE_RANDOM_STAT(), and effect_handler_RESTORE_STAT().

const char* desc_stat_pos[]
static
Initial value:
{
#define STAT(a, b, c, d, e, f, g, h)
}

Array of stat adjectives.

Referenced by effect_handler_GAIN_STAT().

const char* effect_names[]
static

Referenced by effect_lookup().

struct effect_kind effects[]
static

Useful things about effects.

struct breath_info elements[]
static
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().