Ticket #749 (new task)

Opened 14 months ago

Last modified 8 months ago

A uniform way to access player knowledge of player state

Reported by: stefanor@… Owned by:
Milestone: 3.1.3 Keywords: cleanup
Cc:

Description

In the trunk at the time of writing, you can examine a red worm mass to find out if you are wearing unidentified fire resistance equipment. There's currently code in files.c to extract known resistances, but it's interwoven with the code for displaying the ability tables and thus of no use. One solution (stolen from Crawl) is to add a bool known_only parameter to calc_bonuses; I'd like a second opinion before implementing this. Side benefit: we can get rid of p_ptr->state.dis_to_h and friends.

Attachments

Change History

Changed 14 months ago by Kenneth 'Bessarion' Boyd

The resistance, etc. booleans are all computed fields; there's no savefile effect from adding more fields. What's painful is using record fields instead of arrays.

Zaiband 3.0.10 alpha is going to handle this (as part of the ID-inference code) by explicitly tracking the known boolean status. The initial field conversion in player_type was to:

s16b stat_use[A_MAX];	/**< Current modified stats */
s16b stat_top[A_MAX];	/**< Maximal modified stats */

/*** Extracted fields ***/

s16b stat_add[A_MAX];	/**< Equipment stat bonuses */
s16b stat_ind[A_MAX];	/**< Indexes into stat tables */

bool immune[MAX_IMMUNE];	/**< Immunity list */
bool resist[MAX_RESIST];	/**< Resistance list */
bool sustain[A_MAX];/**< Keep strength, etc. (cf. stat_index enumeration) */

with supporting new enum in defines.h

/**
 * Indexes of the various boolean resists/specials
 *
 * \sa
 */
enum resist_index {[[BR]]
	r_acid = 0,	/**< Resist acid */
	r_elec,		/**< Resist lightning */
	r_fire,		/**< Resist fire */
	r_cold,		/**< Resist cold */
	r_pois,		/**< Resist poison */

	r_fear,		/**< Resist fear */
	r_lite,		/**< Resist light */
	r_dark,		/**< Resist darkness */
	r_blind,	/**< Resist blindness */
	r_confu,	/**< Resist confusion */
	r_sound,	/**< Resist sound */
	r_shard,	/**< Resist shards */
	r_nexus,	/**< Resist nexus */
	r_nethr,	/**< Resist nether */
	r_chaos,	/**< Resist chaos */
	r_disen,	/**< Resist disenchant */

	p_slow_digest,	/**< Slower digestion */
	p_ffall,	/**< Feather falling */
	p_lite,		/**< Permanent light */
	p_regenerate,	/**< Regeneration */
	p_telepathy,	/**< Telepathy */
	p_see_inv,	/**< See invisible */
	p_free_act,	/**< Free action */
	p_hold_life,	/**< Hold life */

	p_impact,	/**< Earthquake blows */
	p_aggravate,	/**< Aggravate monsters */
	p_teleport,	/**< Random teleporting */
	p_exp_drain,	/**< Experience draining */

	p_bless_blade	/* Blessed blade */
};

/**
 * total number of various boolean resists/specials
 *
 * \sa ::resist_index
 */
#define MAX_RESIST (p_bless_blade+1)

/**
 * total number of various boolean immunities
 *
 * \sa ::resist_index
 */
#define MAX_IMMUNE (r_cold+1)

This change did incur some source code size bloat.

I'm indifferent as to whether to use a known-only boolean parameter, or just explicitly store the known state of the flags as well. (Zaiband is going to go with explicitly storing the known state of the flags, but that may not be reasonable for V).

Changed 14 months ago by takkaria

some of the work done in r1174

Changed 8 months ago by takkaria

  • milestone changed from 3.1.1 beta to 3.1.2 beta

Changed 8 months ago by magnate

  • keywords cleanup added

Add/Change #749 (A uniform way to access player knowledge of player state)

Author



Action
as new
Next status will be 'confirmed'
 
Note: See TracTickets for help on using tickets.