Angband
Macros | Functions | Variables
player-timed.c File Reference

Timed effects handling. More...

#include "angband.h"
#include "cave.h"
#include "datafile.h"
#include "init.h"
#include "mon-util.h"
#include "obj-knowledge.h"
#include "player-calcs.h"
#include "player-timed.h"
#include "player-util.h"
#include "list-player-timed.h"

Macros

#define TMD(a, b, c)   { #a, b, c },
 
#define TMD(a, b, c)   #a,
 

Functions

static bool set_stun (struct player *p, int v)
 The "stun" and "cut" statuses need to be handled by special functions of their own, as they are more complex than the ones handled by the generic code. More...
 
static bool set_cut (struct player *p, int v)
 Set "player->timed[TMD_CUT]", notice observable changes. More...
 
int timed_name_to_idx (const char *name)
 
void player_fix_scramble (struct player *p)
 Undo scrambled stats when effect runs out. More...
 
bool player_set_timed (struct player *p, int idx, int v, bool notify)
 Set a timed effect. More...
 
bool player_inc_check (struct player *p, int idx, bool lore)
 Check whether a timed effect will affect the player. More...
 
bool player_inc_timed (struct player *p, int idx, int v, bool notify, bool check)
 Increase the timed effect idx by v. More...
 
bool player_dec_timed (struct player *p, int idx, int v, bool notify)
 Decrease the timed effect idx by v. More...
 
bool player_clear_timed (struct player *p, int idx, bool notify)
 Clear the timed effect idx. More...
 
bool player_set_food (struct player *p, int v)
 Set "player->food", notice observable changes. More...
 
static enum parser_error parse_player_timed_name (struct parser *p)
 
static enum parser_error parse_player_timed_desc (struct parser *p)
 
static enum parser_error parse_player_timed_begin_message (struct parser *p)
 
static enum parser_error parse_player_timed_end_message (struct parser *p)
 
static enum parser_error parse_player_timed_increase_message (struct parser *p)
 
static enum parser_error parse_player_timed_decrease_message (struct parser *p)
 
static enum parser_error parse_player_timed_message_type (struct parser *p)
 
static enum parser_error parse_player_timed_fail (struct parser *p)
 
static struct parserinit_parse_player_timed (void)
 
static errr run_parse_player_timed (struct parser *p)
 
static errr finish_parse_player_timed (struct parser *p)
 
static void cleanup_player_timed (void)
 

Variables

struct timed_effect_data timed_effects [TMD_MAX]
 
static const char * list_timed_effect_names []
 List of timed effect names. More...
 
struct file_parser player_timed_parser
 

Detailed Description

Timed effects handling.

Copyright (c) 1997 Ben Harrison Copyright (c) 2007 Andi Sidwell

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 TMD (   a,
  b,
 
)    { #a, b, c },
#define TMD (   a,
  b,
 
)    #a,

Function Documentation

static void cleanup_player_timed ( void  )
static
static errr finish_parse_player_timed ( struct parser p)
static

References parser_destroy().

static struct parser* init_parse_player_timed ( void  )
static
static enum parser_error parse_player_timed_begin_message ( struct parser p)
static
static enum parser_error parse_player_timed_decrease_message ( struct parser p)
static
static enum parser_error parse_player_timed_desc ( struct parser p)
static
static enum parser_error parse_player_timed_end_message ( struct parser p)
static
static enum parser_error parse_player_timed_fail ( struct parser p)
static
static enum parser_error parse_player_timed_increase_message ( struct parser p)
static
static enum parser_error parse_player_timed_message_type ( struct parser p)
static
static enum parser_error parse_player_timed_name ( struct parser p)
static
bool player_clear_timed ( struct player p,
int  idx,
bool  notify 
)

Clear the timed effect idx.

Mention this if notify is true.

References player_set_timed(), and TMD_MAX.

Referenced by do_cmd_wiz_cure_all(), effect_handler_CURE(), and wiz_cheat_death().

bool player_dec_timed ( struct player p,
int  idx,
int  v,
bool  notify 
)

Decrease the timed effect idx by v.

Mention this if notify is true.

References player_set_timed(), player::timed, and TMD_MAX.

Referenced by decrease_timeouts(), and effect_handler_TIMED_DEC().

void player_fix_scramble ( struct player p)

Undo scrambled stats when effect runs out.

References i, player::stat_cur, player::stat_map, STAT_MAX, and player::stat_max.

Referenced by player_set_timed().

bool player_inc_check ( struct player p,
int  idx,
bool  lore 
)
bool player_inc_timed ( struct player p,
int  idx,
int  v,
bool  notify,
bool  check 
)
bool player_set_food ( struct player p,
int  v 
)

Set "player->food", notice observable changes.

The "player->food" variable can get as large as 20000, allowing the addition of the most "filling" item, Elvish Waybread, which adds 7500 food units, without overflowing the 32767 maximum limit.

Perhaps we should disturb the player with various messages, especially messages about hunger status changes. XXX XXX XXX

Digestion of food is handled in "dungeon.c", in which, normally, the player digests about 20 food units per 100 game turns, more when "fast", more when "regenerating", less with "slow digestion".

References disturb(), player::food, handle_stuff(), MAX, MIN, msg, msgt(), PR_STATUS, PU_BONUS, PY_FOOD_ALERT, PY_FOOD_FAINT, PY_FOOD_FULL, PY_FOOD_MAX, PY_FOOD_WEAK, player_upkeep::redraw, player_upkeep::update, and player::upkeep.

Referenced by do_cmd_wiz_cure_all(), effect_handler_NOURISH(), effect_handler_SET_NOURISH(), process_world(), and wiz_cheat_death().

bool player_set_timed ( struct player p,
int  idx,
int  v,
bool  notify 
)
static errr run_parse_player_timed ( struct parser p)
static
static bool set_cut ( struct player p,
int  v 
)
static

Set "player->timed[TMD_CUT]", notice observable changes.

Note the special code to only notice "range" changes.

References disturb(), handle_stuff(), msgt(), PR_STATUS, PU_BONUS, player_upkeep::redraw, player::timed, TMD_CUT_BAD, TMD_CUT_DEEP, TMD_CUT_GRAZE, TMD_CUT_LIGHT, TMD_CUT_NASTY, TMD_CUT_NONE, TMD_CUT_SEVERE, player_upkeep::update, and player::upkeep.

Referenced by player_set_timed().

static bool set_stun ( struct player p,
int  v 
)
static

The "stun" and "cut" statuses need to be handled by special functions of their own, as they are more complex than the ones handled by the generic code.

Set "player->timed[TMD_STUN]", notice observable changes.

Note the special code to only notice "range" changes.

References disturb(), handle_stuff(), msgt(), PR_STATUS, PU_BONUS, player_upkeep::redraw, player::timed, player_upkeep::update, and player::upkeep.

Referenced by player_set_timed().

int timed_name_to_idx ( const char *  name)

References i, my_stricmp(), and N_ELEMENTS.

Referenced by effect_param().

Variable Documentation

const char* list_timed_effect_names[]
static

List of timed effect names.

Referenced by parse_player_timed_name().

struct file_parser player_timed_parser
Initial value:
= {
"player timed effects",
}
static void cleanup_player_timed(void)
Definition: player-timed.c:762
static struct parser * init_parse_player_timed(void)
Definition: player-timed.c:736
static errr finish_parse_player_timed(struct parser *p)
Definition: player-timed.c:756
static errr run_parse_player_timed(struct parser *p)
Definition: player-timed.c:751
struct timed_effect_data timed_effects[TMD_MAX]

Referenced by describe_effect(), and unset_spells().