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-gear.h"
#include "obj-knowledge.h"
#include "obj-util.h"
#include "player-calcs.h"
#include "player-timed.h"
#include "player-util.h"
#include "list-player-flags.h"
#include "list-player-timed.h"

Macros

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

Functions

int timed_name_to_idx (const char *name)
 
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_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 enum parser_error parse_player_timed_grade (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)
 
static void player_scramble_stats (struct player *p)
 

Utilities for more complex or anomolous effects

More...
 
static void player_fix_scramble (struct player *p)
 Undo scrambled stats when effect runs out. More...
 
bool player_timed_grade_eq (struct player *p, int idx, char *match)
 Return true if the player timed effect matches the given string. More...
 
bool player_set_timed (struct player *p, int idx, int v, bool notify)
 

Setting, increasing, decreasing and clearing timed effects

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

Variables

int PY_FOOD_MAX
 Player food values. More...
 
int PY_FOOD_FULL
 
int PY_FOOD_HUNGRY
 
int PY_FOOD_WEAK
 
int PY_FOOD_FAINT
 
int PY_FOOD_STARVE
 
const char * list_player_flag_names []
 

Parsing functions for player_timed.txt

More...
 
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

◆ PF

#define PF (   a,
  b,
 
)    #a,

◆ TMD [1/2]

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

◆ TMD [2/2]

#define TMD (   a,
  b,
 
)    #a,

Function Documentation

◆ cleanup_player_timed()

static void cleanup_player_timed ( void  )
static

◆ finish_parse_player_timed()

static errr finish_parse_player_timed ( struct parser p)
static

References parser_destroy().

◆ init_parse_player_timed()

static struct parser* init_parse_player_timed ( void  )
static

◆ parse_player_timed_decrease_message()

static enum parser_error parse_player_timed_decrease_message ( struct parser p)
static

◆ parse_player_timed_desc()

static enum parser_error parse_player_timed_desc ( struct parser p)
static

◆ parse_player_timed_end_message()

static enum parser_error parse_player_timed_end_message ( struct parser p)
static

◆ parse_player_timed_fail()

static enum parser_error parse_player_timed_fail ( struct parser p)
static

◆ parse_player_timed_grade()

static enum parser_error parse_player_timed_grade ( struct parser p)
static

◆ parse_player_timed_increase_message()

static enum parser_error parse_player_timed_increase_message ( struct parser p)
static

◆ parse_player_timed_message_type()

static enum parser_error parse_player_timed_message_type ( struct parser p)
static

◆ parse_player_timed_name()

static enum parser_error parse_player_timed_name ( struct parser p)
static

◆ player_clear_timed()

bool player_clear_timed ( struct player p,
int  idx,
bool  notify 
)

◆ player_dec_timed()

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(), effect_handler_TIMED_DEC(), and process_world().

◆ player_fix_scramble()

static void player_fix_scramble ( struct player p)
static

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

◆ player_inc_check()

bool player_inc_check ( struct player p,
int  idx,
bool  lore 
)

◆ player_inc_timed()

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

◆ player_scramble_stats()

static void player_scramble_stats ( struct player p)
static


Utilities for more complex or anomolous effects

Swap stats at random to temporarily scramble the player's stats.

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

Referenced by player_set_timed().

◆ player_set_timed()

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

◆ player_timed_grade_eq()

bool player_timed_grade_eq ( struct player p,
int  idx,
char *  match 
)

Return true if the player timed effect matches the given string.

References timed_grade::grade, timed_effect_data::grade, timed_grade::max, timed_grade::name, timed_grade::next, streq, and player::timed.

Referenced by calc_bonuses(), decrease_timeouts(), process_player(), and process_world().

◆ run_parse_player_timed()

static errr run_parse_player_timed ( struct parser p)
static

◆ timed_name_to_idx()

int timed_name_to_idx ( const char *  name)

References i, my_stricmp(), and N_ELEMENTS.

Referenced by effect_subtype().

Variable Documentation

◆ list_player_flag_names

const char* list_player_flag_names[]
Initial value:
= {
#define PF(a, b, c)
NULL
}


Parsing functions for player_timed.txt

Referenced by parse_player_timed_fail().

◆ list_timed_effect_names

const char* list_timed_effect_names[]
static

List of timed effect names.

Referenced by parse_player_timed_name().

◆ player_timed_parser

struct file_parser player_timed_parser
Initial value:
= {
"player timed effects",
}
static void cleanup_player_timed(void)
Definition: player-timed.c:287
static struct parser * init_parse_player_timed(void)
Definition: player-timed.c:261
static errr finish_parse_player_timed(struct parser *p)
Definition: player-timed.c:281
static errr run_parse_player_timed(struct parser *p)
Definition: player-timed.c:276

◆ PY_FOOD_FAINT

int PY_FOOD_FAINT

◆ PY_FOOD_FULL

int PY_FOOD_FULL

◆ PY_FOOD_HUNGRY

int PY_FOOD_HUNGRY

◆ PY_FOOD_MAX

int PY_FOOD_MAX

Player food values.

Referenced by calc_bonuses(), parse_player_timed_grade(), and wiz_cheat_death().

◆ PY_FOOD_STARVE

int PY_FOOD_STARVE

◆ PY_FOOD_WEAK

int PY_FOOD_WEAK

◆ timed_effects

struct timed_effect_data timed_effects[TMD_MAX]