Angband
Data Structures | Enumerations | Functions | Variables
obj-power.c File Reference

calculation of object power and value More...

#include "angband.h"
#include "obj-curse.h"
#include "obj-gear.h"
#include "obj-knowledge.h"
#include "obj-power.h"
#include "obj-slays.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "init.h"
#include "effects.h"
#include "monster.h"

Data Structures

struct  archery
 

Object power data and assumptions

More...
 
struct  flag_set
 Set the weightings of flag types: More...
 
struct  element_set
 Similar data for elements. More...
 
struct  element_powers
 Power data for elements. More...
 

Enumerations

enum  { T_LRES, T_HRES }
 

Functions

void log_obj (char *message)
 Log progress info to the object log. More...
 
static int bow_multiplier (const struct object *obj)
 

Object power calculations

More...
 
static int to_damage_power (const struct object *obj)
 To damage power. More...
 
static int damage_dice_power (const struct object *obj)
 Damage dice power or equivalent. More...
 
static int ammo_damage_power (const struct object *obj, int p)
 Add ammo damage for launchers, get multiplier and rescale. More...
 
static int launcher_ammo_damage_power (const struct object *obj, int p)
 Add launcher bonus for ego ammo, multiply for launcher and rescale. More...
 
static int extra_blows_power (const struct object *obj, int p)
 Add power for extra blows. More...
 
static int extra_shots_power (const struct object *obj, int p)
 Add power for extra shots - note that we cannot handle negative shots. More...
 
static int extra_might_power (const struct object *obj, int p, int mult)
 Add power for extra might. More...
 
static s32b slay_power (const struct object *obj, int p, int verbose, int dice_pwr)
 Calculate the rating for a given slay combination. More...
 
static int rescale_bow_power (const struct object *obj, int p)
 Melee weapons assume MAX_BLOWS per turn, so we must divide by MAX_BLOWS to get equal ratings for launchers. More...
 
static int to_hit_power (const struct object *obj, int p)
 Add power for +to_hit. More...
 
static int ac_power (const struct object *obj, int p)
 Add power for base AC and adjust for weight. More...
 
static int to_ac_power (const struct object *obj, int p)
 Add power for +to_ac. More...
 
static int jewelry_power (const struct object *obj, int p)
 Add base power for jewelry. More...
 
static int modifier_power (const struct object *obj, int p)
 Add power for modifiers. More...
 
static int flags_power (const struct object *obj, int p, int verbose, ang_file *log_file)
 Add power for non-derived flags (derived flags have flag_power 0) More...
 
static int element_power (const struct object *obj, int p)
 Add power for elemental properties. More...
 
static int effects_power (const struct object *obj, int p)
 Add power for effect. More...
 
static int curse_power (const struct object *obj, int p, int verbose, ang_file *log_file)
 Add power for curses. More...
 
s32b object_power (const struct object *obj, bool verbose, ang_file *log_file)
 Evaluate the object's overall power level. More...
 
static int object_value_base (const struct object *obj)
 

Object pricing

More...
 
int object_value_real (const struct object *obj, int qty)
 Return the real price of a known (or partly known) item. More...
 
int object_value (const struct object *obj, int qty)
 Return the price of an item including plusses (and charges). More...
 

Variables

static struct archery archery []
 
static struct flag_set flag_sets []
 
static struct element_set element_sets []
 
static struct element_powers el_powers []
 
static s16b ability_power [25]
 Boost ratings for combinations of ability bonuses We go up to +24 here - anything higher is inhibited N.B. More...
 
static ang_fileobject_log
 

Detailed Description

calculation of object power and value

Copyright (c) 2001 Chris Carr, Chris Robertson Revised in 2009-11 by Chris Carr, Peter Denison

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.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
T_LRES 
T_HRES 

Function Documentation

◆ ac_power()

static int ac_power ( const struct object obj,
int  p 
)
static

Add power for base AC and adjust for weight.

References object::ac, BASE_AC_POWER, BASE_ARMOUR_POWER, format(), i, log_obj(), p, object::to_a, and object::weight.

Referenced by object_power().

◆ ammo_damage_power()

static int ammo_damage_power ( const struct object obj,
int  p 
)
static

Add ammo damage for launchers, get multiplier and rescale.

References archery::ammo_dam, DAMAGE_POWER, format(), kf_has, object::kind, object_kind::kind_flags, log_obj(), slot_by_name(), and wield_slot().

Referenced by object_power().

◆ bow_multiplier()

static int bow_multiplier ( const struct object obj)
static


Object power calculations

Calculate the multiplier we'll get with a given bow type.

References format(), log_obj(), object::pval, and object::tval.

Referenced by object_power().

◆ curse_power()

static int curse_power ( const struct object obj,
int  p,
int  verbose,
ang_file log_file 
)
static

◆ damage_dice_power()

static int damage_dice_power ( const struct object obj)
static

◆ effects_power()

static int effects_power ( const struct object obj,
int  p 
)
static

Add power for effect.

References object::activation, format(), object::kind, log_obj(), p, activation::power, and object_kind::power.

Referenced by object_power().

◆ element_power()

static int element_power ( const struct object obj,
int  p 
)
static

◆ extra_blows_power()

static int extra_blows_power ( const struct object obj,
int  p 
)
static

Add power for extra blows.

References DAMAGE_POWER, format(), INHIBIT_BLOWS, INHIBIT_POWER, log_obj(), MAX_BLOWS, object::modifiers, NONWEAP_DAMAGE, and p.

Referenced by object_power().

◆ extra_might_power()

static int extra_might_power ( const struct object obj,
int  p,
int  mult 
)
static

Add power for extra might.

References format(), INHIBIT_MIGHT, INHIBIT_POWER, log_obj(), object::modifiers, and p.

Referenced by object_power().

◆ extra_shots_power()

static int extra_shots_power ( const struct object obj,
int  p 
)
static

Add power for extra shots - note that we cannot handle negative shots.

References format(), INHIBIT_POWER, INHIBIT_SHOTS, log_obj(), object::modifiers, and p.

Referenced by object_power().

◆ flags_power()

static int flags_power ( const struct object obj,
int  p,
int  verbose,
ang_file log_file 
)
static

◆ jewelry_power()

static int jewelry_power ( const struct object obj,
int  p 
)
static

Add base power for jewelry.

References BASE_JEWELRY_POWER, format(), log_obj(), p, and tval_is_jewelry().

Referenced by object_power().

◆ launcher_ammo_damage_power()

static int launcher_ammo_damage_power ( const struct object obj,
int  p 
)
static

Add launcher bonus for ego ammo, multiply for launcher and rescale.

References DAMAGE_POWER, object::ego, format(), archery::launch_dam, archery::launch_mult, log_obj(), MAX_BLOWS, p, object::tval, and tval_is_ammo().

Referenced by object_power().

◆ log_obj()

void log_obj ( char *  message)

◆ modifier_power()

static int modifier_power ( const struct object obj,
int  p 
)
static

◆ object_power()

s32b object_power ( const struct object obj,
bool  verbose,
ang_file log_file 
)

◆ object_value()

int object_value ( const struct object obj,
int  qty 
)

Return the price of an item including plusses (and charges).

This function returns the "value" of the given item (qty one).

Never notice unknown bonuses or properties, including curses, since that would give the player information they did not have.

References object::kind, object::known, object_flavor_is_aware(), object_value_base(), object_value_real(), tval_can_have_flavor_k(), tval_has_variable_power(), and value.

Referenced by do_cmd_sell(), earlier_object(), kind_info(), price_item(), store_carry(), store_will_buy(), and wiz_display_item().

◆ object_value_base()

static int object_value_base ( const struct object obj)
static


Object pricing

Return the "value" of an "unknown" item Make a guess at the value of non-aware items

References object_kind::cost, object::kind, object_flavor_is_aware(), and object::tval.

Referenced by object_value().

◆ object_value_real()

int object_value_real ( const struct object obj,
int  qty 
)

Return the real price of a known (or partly known) item.

Wand and staffs get cost for each charge.

Wearable items (weapons, launchers, jewelry, lights, armour) and ammo are priced according to their power rating. All ammo, and normal (non-ego) torches are scaled down by AMMO_RESCALER to reflect their impermanence.

References AMMO_RESCALER, ANGBAND_DIR_USER, buf, object_kind::cost, object::ego, file_close(), file_open(), file_putf(), object::flags, FTYPE_TEXT, object::kind, log_file, MODE_APPEND, MODE_WRITE, msg, object_kind::name, object::number, object_power(), of_has, path_build(), obj_property::power, object::pval, SGN, tval_can_have_charges(), tval_has_variable_power(), tval_is_ammo(), tval_is_light(), and value.

Referenced by black_market_ok(), do_cmd_sell(), make_object(), mass_produce(), object_value(), player_outfit(), price_item(), store_carry(), and store_create_random().

◆ rescale_bow_power()

static int rescale_bow_power ( const struct object obj,
int  p 
)
static

Melee weapons assume MAX_BLOWS per turn, so we must divide by MAX_BLOWS to get equal ratings for launchers.

References format(), log_obj(), MAX_BLOWS, p, slot_by_name(), and wield_slot().

Referenced by object_power().

◆ slay_power()

static s32b slay_power ( const struct object obj,
int  p,
int  verbose,
int  dice_pwr 
)
static

◆ to_ac_power()

static int to_ac_power ( const struct object obj,
int  p 
)
static

Add power for +to_ac.

References format(), HIGH_TO_AC, INHIBIT_AC, INHIBIT_POWER, log_obj(), p, object::to_a, TO_AC_POWER, and VERYHIGH_TO_AC.

Referenced by object_power().

◆ to_damage_power()

static int to_damage_power ( const struct object obj)
static

◆ to_hit_power()

static int to_hit_power ( const struct object obj,
int  p 
)
static

Add power for +to_hit.

References format(), log_obj(), p, object::to_h, and TO_HIT_POWER.

Referenced by object_power().

Variable Documentation

◆ ability_power

s16b ability_power[25]
static
Initial value:
=
{0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8,
12, 16, 20, 24, 30, 36, 42, 48, 56, 64,
74, 84, 96, 110}

Boost ratings for combinations of ability bonuses We go up to +24 here - anything higher is inhibited N.B.

Not all stats count equally towards this total

Referenced by modifier_power().

◆ archery

struct archery archery[]
static
Initial value:
= {
{TV_SHOT, 10, 9, 4},
{TV_ARROW, 12, 9, 5},
{TV_BOLT, 14, 9, 7}
}

◆ el_powers

struct element_powers el_powers[]
static
Initial value:
= {
{ "acid", T_LRES, 3, -6, 5, 38 },
{ "electricity", T_LRES, 1, -6, 6, 35 },
{ "fire", T_LRES, 3, -6, 6, 40 },
{ "cold", T_LRES, 1, -6, 6, 37 },
{ "poison", T_HRES, 0, 0, 28, 0 },
{ "light", T_HRES, 0, 0, 6, 0 },
{ "dark", T_HRES, 0, 0, 16, 0 },
{ "sound", T_HRES, 0, 0, 14, 0 },
{ "shards", T_HRES, 0, 0, 8, 0 },
{ "nexus", T_HRES, 0, 0, 15, 0 },
{ "nether", T_HRES, 0, 0, 20, 0 },
{ "chaos", T_HRES, 0, 0, 20, 0 },
{ "disenchantment", T_HRES, 0, 0, 20, 0 }
}
Definition: obj-power.c:79
Definition: obj-power.c:78

Referenced by element_power().

◆ element_sets

struct element_set element_sets[]
static
Initial value:
= {
{ T_LRES, 3, 6, INHIBIT_POWER, 4, 0, "immunities" },
{ T_LRES, 1, 1, 10, 4, 0, "low resists" },
{ T_HRES, 1, 2, 10, 9, 0, "high resists" },
}
Definition: obj-power.c:79
#define INHIBIT_POWER
Some constants used in randart generation and power calculation.
Definition: obj-power.h:53
Definition: obj-power.c:78

Referenced by element_power().

◆ flag_sets

struct flag_set flag_sets[]
static
Initial value:
= {
{ OFT_SUST, 1, 10, 5, 0, "sustains" },
{ OFT_PROT, 3, 15, 4, 0, "protections" },
{ OFT_MISC, 1, 25, 8, 0, "misc abilities" }
}
Definition: obj-properties.h:84
Definition: obj-properties.h:85
Definition: obj-properties.h:86

Referenced by flags_power().

◆ object_log

ang_file* object_log
static