Angband
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"

Functions

void log_obj (char *message)
 Log progress info to the object log. More...
 
static int object_power_calculation_TO_DAM (void)
 
static int object_power_calculation_DICE (void)
 
static int object_power_calculation_IS_EGO (void)
 
static int object_power_calculation_EXTRA_BLOWS (void)
 
static int object_power_calculation_EXTRA_SHOTS (void)
 
static int object_power_calculation_EXTRA_MIGHT (void)
 
static int object_power_calculation_BOW_MULTIPLIER (void)
 
static int object_power_calculation_BEST_SLAY (void)
 
static int object_power_calculation_SLAY_SLAY (void)
 
static int object_power_calculation_BRAND_BRAND (void)
 
static int object_power_calculation_SLAY_BRAND (void)
 
static int object_power_calculation_KILL_KILL (void)
 
static int object_power_calculation_ALL_SLAYS (void)
 
static int object_power_calculation_ALL_BRANDS (void)
 
static int object_power_calculation_ALL_KILLS (void)
 
static int object_power_calculation_TO_HIT (void)
 
static int object_power_calculation_AC (void)
 
static int object_power_calculation_TO_ARMOR (void)
 
static int object_power_calculation_TOTAL_ARMOR (void)
 
static int object_power_calculation_WEIGHT (void)
 
static int object_power_calculation_MODIFIER (void)
 
static int object_power_calculation_MOD_POWER (void)
 
static int object_power_calculation_MOD_TYPE_MULT (void)
 
static int object_power_calculation_MOD_MULT (void)
 
static int object_power_calculation_FLAG_POWER (void)
 
static int object_power_calculation_FLAG_TYPE_MULT (void)
 
static int object_power_calculation_NUM_SUSTAINS (void)
 
static int object_power_calculation_ALL_SUSTAINS (void)
 
static int object_power_calculation_NUM_PROTECTS (void)
 
static int object_power_calculation_ALL_PROTECTS (void)
 
static int object_power_calculation_NUM_MISC (void)
 
static int object_power_calculation_ALL_MISC (void)
 
static int object_power_calculation_IGNORE (void)
 
static int object_power_calculation_VULN (void)
 
static int object_power_calculation_RESIST (void)
 
static int object_power_calculation_IMM (void)
 
static int object_power_calculation_NUM_BASE_RES (void)
 
static int object_power_calculation_ALL_BASE_RES (void)
 
static int object_power_calculation_NUM_HIGH_RES (void)
 
static int object_power_calculation_ALL_HIGH_RES (void)
 
static int object_power_calculation_NUM_IMM (void)
 
static int object_power_calculation_ALL_IMM (void)
 
static int object_power_calculation_EFFECT_POWER (void)
 
expression_base_value_f power_calculation_by_name (const char *name)
 
static int run_power_calculation (struct power_calc *calc)
 

Overall object power calculations

More...
 
static void apply_op (int operation, int *current, int new)
 
static void collect_slay_brand_stats (const struct object *obj)
 Calculate stats on slays and brands up. More...
 
int object_power (const struct object *obj, bool verbose, ang_file *log_file)
 Run all the power calculations on an object to find its power. 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

struct power_calccalculations
 
static ang_fileobject_log
 

Helpers for power calculations

More...
 
static struct objectpower_obj
 

Individual object power calculations

More...
 
static int num_brands
 
static int num_slays
 
static int num_kills
 
static int best_power
 
static int iter
 

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.

Function Documentation

static void apply_op ( int  operation,
int current,
int  new 
)
static
static void collect_slay_brand_stats ( const struct object obj)
static
void log_obj ( char *  message)

Log progress info to the object log.

References file_putf().

Referenced by collect_slay_brand_stats(), and object_power().

int object_power ( const struct object obj,
bool  verbose,
ang_file log_file 
)
static int object_power_calculation_AC ( void  )
static

References object::ac.

Referenced by power_calculation_by_name().

static int object_power_calculation_ALL_BASE_RES ( void  )
static
static int object_power_calculation_ALL_BRANDS ( void  )
static
static int object_power_calculation_ALL_HIGH_RES ( void  )
static
static int object_power_calculation_ALL_IMM ( void  )
static
static int object_power_calculation_ALL_KILLS ( void  )
static
static int object_power_calculation_ALL_MISC ( void  )
static
static int object_power_calculation_ALL_PROTECTS ( void  )
static
static int object_power_calculation_ALL_SLAYS ( void  )
static
static int object_power_calculation_ALL_SUSTAINS ( void  )
static
static int object_power_calculation_BEST_SLAY ( void  )
static

References best_power, and MAX.

Referenced by power_calculation_by_name().

static int object_power_calculation_BOW_MULTIPLIER ( void  )
static
static int object_power_calculation_BRAND_BRAND ( void  )
static

References num_brands.

Referenced by power_calculation_by_name().

static int object_power_calculation_DICE ( void  )
static
static int object_power_calculation_EFFECT_POWER ( void  )
static
static int object_power_calculation_EXTRA_BLOWS ( void  )
static

References object::modifiers.

Referenced by power_calculation_by_name().

static int object_power_calculation_EXTRA_MIGHT ( void  )
static

References object::modifiers.

Referenced by power_calculation_by_name().

static int object_power_calculation_EXTRA_SHOTS ( void  )
static

References object::modifiers.

Referenced by power_calculation_by_name().

static int object_power_calculation_FLAG_POWER ( void  )
static
static int object_power_calculation_FLAG_TYPE_MULT ( void  )
static
static int object_power_calculation_IGNORE ( void  )
static
static int object_power_calculation_IMM ( void  )
static
static int object_power_calculation_IS_EGO ( void  )
static

References object::ego.

Referenced by power_calculation_by_name().

static int object_power_calculation_KILL_KILL ( void  )
static

References num_kills.

Referenced by power_calculation_by_name().

static int object_power_calculation_MOD_MULT ( void  )
static
static int object_power_calculation_MOD_POWER ( void  )
static
static int object_power_calculation_MOD_TYPE_MULT ( void  )
static
static int object_power_calculation_MODIFIER ( void  )
static

References iter, and object::modifiers.

Referenced by power_calculation_by_name().

static int object_power_calculation_NUM_BASE_RES ( void  )
static
static int object_power_calculation_NUM_HIGH_RES ( void  )
static
static int object_power_calculation_NUM_IMM ( void  )
static
static int object_power_calculation_NUM_MISC ( void  )
static
static int object_power_calculation_NUM_PROTECTS ( void  )
static
static int object_power_calculation_NUM_SUSTAINS ( void  )
static
static int object_power_calculation_RESIST ( void  )
static
static int object_power_calculation_SLAY_BRAND ( void  )
static

References num_brands, and num_slays.

Referenced by power_calculation_by_name().

static int object_power_calculation_SLAY_SLAY ( void  )
static

References num_slays.

Referenced by power_calculation_by_name().

static int object_power_calculation_TO_ARMOR ( void  )
static

References object::to_a.

Referenced by power_calculation_by_name().

static int object_power_calculation_TO_DAM ( void  )
static

References object::to_d.

Referenced by power_calculation_by_name().

static int object_power_calculation_TO_HIT ( void  )
static

References object::to_h.

Referenced by power_calculation_by_name().

static int object_power_calculation_TOTAL_ARMOR ( void  )
static

References object::ac, and object::to_a.

Referenced by power_calculation_by_name().

static int object_power_calculation_VULN ( void  )
static
static int object_power_calculation_WEIGHT ( void  )
static

References MAX, and object::weight.

Referenced by power_calculation_by_name().

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::known, object_value_base(), object_value_real(), tval_has_variable_power(), and value.

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

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

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, NULL, 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 make_object(), object_value(), player_outfit(), price_item(), store_carry(), and store_create_random().

expression_base_value_f power_calculation_by_name ( const char *  name)

References my_stricmp(), name, NULL, object_power_calculation_AC(), object_power_calculation_ALL_BASE_RES(), object_power_calculation_ALL_BRANDS(), object_power_calculation_ALL_HIGH_RES(), object_power_calculation_ALL_IMM(), object_power_calculation_ALL_KILLS(), object_power_calculation_ALL_MISC(), object_power_calculation_ALL_PROTECTS(), object_power_calculation_ALL_SLAYS(), object_power_calculation_ALL_SUSTAINS(), object_power_calculation_BEST_SLAY(), object_power_calculation_BOW_MULTIPLIER(), object_power_calculation_BRAND_BRAND(), object_power_calculation_DICE(), object_power_calculation_EFFECT_POWER(), object_power_calculation_EXTRA_BLOWS(), object_power_calculation_EXTRA_MIGHT(), object_power_calculation_EXTRA_SHOTS(), object_power_calculation_FLAG_POWER(), object_power_calculation_FLAG_TYPE_MULT(), object_power_calculation_IGNORE(), object_power_calculation_IMM(), object_power_calculation_IS_EGO(), object_power_calculation_KILL_KILL(), object_power_calculation_MOD_MULT(), object_power_calculation_MOD_POWER(), object_power_calculation_MOD_TYPE_MULT(), object_power_calculation_MODIFIER(), object_power_calculation_NUM_BASE_RES(), object_power_calculation_NUM_HIGH_RES(), object_power_calculation_NUM_IMM(), object_power_calculation_NUM_MISC(), object_power_calculation_NUM_PROTECTS(), object_power_calculation_NUM_SUSTAINS(), object_power_calculation_RESIST(), object_power_calculation_SLAY_BRAND(), object_power_calculation_SLAY_SLAY(), object_power_calculation_TO_ARMOR(), object_power_calculation_TO_DAM(), object_power_calculation_TO_HIT(), object_power_calculation_TOTAL_ARMOR(), object_power_calculation_VULN(), and object_power_calculation_WEIGHT().

Referenced by parse_object_power_expr().

static int run_power_calculation ( struct power_calc calc)
static


Overall object power calculations

Run an individual power calculation

Dice are used in power calculations sometimes as an easy way of encoding multiplication, so the MAXIMISE aspect is always used in their evaluation.

References power_calc::dice, dice_evaluate(), object_kind::kidx, poss_item::kidx, object::kind, MAXIMISE, poss_item::next, and power_calc::poss_items.

Referenced by object_power().

Variable Documentation

int best_power
static
struct power_calc* calculations
int iter
static
int num_brands
static
int num_kills
static
int num_slays
static
ang_file* object_log
static


Helpers for power calculations

struct object* power_obj
static


Individual object power calculations