Crossfire Server, Branches 1.12  R18729
weapon_improver.c File Reference
#include <global.h>
#include <ob_methods.h>
#include <ob_types.h>
#include <sounds.h>
#include <sproto.h>
+ Include dependency graph for weapon_improver.c:

Go to the source code of this file.

Macros

#define IMPROVE_CHA   9
 
#define IMPROVE_CON   7
 
#define IMPROVE_DAMAGE   2
 
#define IMPROVE_DEX   6
 
#define IMPROVE_ENCHANT   4
 
#define IMPROVE_INT   10
 
#define IMPROVE_POW   11
 
#define IMPROVE_PREPARE   1
 
#define IMPROVE_STR   5
 
#define IMPROVE_WEIGHT   3
 
#define IMPROVE_WIS   8
 

Functions

static int check_item (object *op, const char *item)
 
static int check_sacrifice (object *op, const object *improver)
 
static void eat_item (object *op, const char *item, uint32 nrof)
 
static int improve_weapon (object *op, object *improver, object *weapon)
 
static int improve_weapon_stat (object *op, object *improver, object *weapon, signed char *stat, int sacrifice_count, const char *statname)
 
void init_type_weapon_improver (void)
 
static int prepare_weapon (object *op, object *improver, object *weapon)
 
static method_ret weapon_improver_type_apply (ob_methods *context, object *op, object *applier, int aflags)
 

Detailed Description

The implementation of the Weapon Improver class of objects.

Definition in file weapon_improver.c.

Macro Definition Documentation

#define IMPROVE_CHA   9

Increase charisma bonus.

Definition at line 237 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_CON   7

Increase constitution bonus.

Definition at line 235 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_DAMAGE   2

Increase damage.

Definition at line 230 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_DEX   6

Increase dexterity bonus.

Definition at line 234 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_ENCHANT   4

Increase magic.

Definition at line 232 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_INT   10

Increase intelligence bonus.

Definition at line 238 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_POW   11

Increase power bonus.

Definition at line 239 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_PREPARE   1

Prepare the weapon.

Definition at line 229 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_STR   5

Increase strength bonus.

Definition at line 233 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_WEIGHT   3

Decrease weight.

Definition at line 231 of file weapon_improver.c.

Referenced by improve_weapon().

#define IMPROVE_WIS   8

Increase wisdom bonus.

Definition at line 236 of file weapon_improver.c.

Referenced by improve_weapon().

Function Documentation

static int check_item ( object op,
const char *  item 
)
static

Counts suitable items with specified archetype name. Will not consider unpaid/cursed items.

Parameters
opobject just before the bottom of the pile, others will be checked through object->below.
itemwhat archetype to check for.
Returns
count of matching items.
Todo:
couldn't item be a shared string, and == be used instead of strcmp? The op = op->below is weird - what is it's NULL?

Definition at line 99 of file weapon_improver.c.

References obj::arch, obj::below, FLAG_CURSED, FLAG_DAMNED, FLAG_UNPAID, archt::name, obj::nrof, and QUERY_FLAG.

Referenced by check_sacrifice().

+ Here is the caller graph for this function:

static int check_sacrifice ( object op,
const object improver 
)
static

Returns how many items of type improver->slaying there are under op. Will display a message if none found, and 1 if improver->slaying is NULL.

Parameters
opitem just below the bottom of the pile.
improversacrifice object.
Returns
count of matching items.
Todo:
weird logic? use shared string directly, improver isn't really useful.

Definition at line 172 of file weapon_improver.c.

References check_item(), draw_ext_info_format(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, and obj::slaying.

Referenced by improve_weapon().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void eat_item ( object op,
const char *  item,
uint32  nrof 
)
static

This removes 'nrof' items with specified archetype. op is typically the player, which is only really used to determine what space to look at. Modified to only eat 'nrof' of objects.

Parameters
opitem at the bottom to check.
itemarchetype to look for.
nrofcount to remove.
Todo:
couldn't item be a shared string, and use == instead of strcmp? also, the remove logic is wrong - op->nrof will be 0 after decreat_ob_nr in the 2nd case.

Definition at line 137 of file weapon_improver.c.

References obj::arch, obj::below, decrease_ob_nr(), archt::name, and obj::nrof.

Referenced by improve_weapon().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int improve_weapon ( object op,
object improver,
object weapon 
)
static

Does the dirty job for 'improve weapon' scroll, prepare or add something. This is the new improve weapon code.

Checks if weapon was prepared, if enough potions on the floor, ...

We are hiding extra information about the weapon in the level and last_eat numbers for an object. Hopefully this won't break anything ?? level == max improve last_eat == current improve

Parameters
opplayer improving.
improverthe scroll that was read.
weaponwepaon to improve.
Returns
1 if weapon was improved, 0 if not enough sacrifice, weapon not prepared, ...

Definition at line 343 of file weapon_improver.c.

References AP_UNAPPLY, apply_special(), liv::Cha, check_sacrifice(), check_weapon_power(), liv::Con, obj::contr, liv::dam, decrease_ob, liv::Dex, draw_ext_info(), draw_ext_info_format(), eat_item(), FLAG_APPLIED, IMPROVE_CHA, IMPROVE_CON, IMPROVE_DAMAGE, IMPROVE_DEX, IMPROVE_ENCHANT, IMPROVE_INT, IMPROVE_POW, IMPROVE_PREPARE, IMPROVE_STR, improve_weapon_stat(), IMPROVE_WEIGHT, IMPROVE_WIS, liv::Int, pl::item_power, obj::item_power, Settings::item_power_factor, obj::last_eat, obj::level, llevError, LOG(), obj::magic, MAX_WEAPON_ITEM_POWER, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, NDI_UNIQUE, PLAYER, liv::Pow, prepare_weapon(), QUERY_FLAG, settings, obj::slaying, liv::sp, obj::stats, liv::Str, obj::type, obj::weight, and liv::Wis.

Referenced by weapon_improver_type_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int improve_weapon_stat ( object op,
object improver,
object weapon,
signed char *  stat,
int  sacrifice_count,
const char *  statname 
)
static

Actually improves the weapon, and tells user. Won't test anything.

Parameters
opplayer improving.
improverscroll used to improve.
weaponimproved weapon.
statwhat statistic to improve.
sacrifice_counthow much to improve stat by.
statnamename of stat to display to player.
Returns
1.

Definition at line 208 of file weapon_improver.c.

References decrease_ob, draw_ext_info(), draw_ext_info_format(), fix_object(), obj::last_eat, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, and NDI_UNIQUE.

Referenced by improve_weapon().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void init_type_weapon_improver ( void  )

Initializer for the WEAPON_IMPROVER object type.

Definition at line 44 of file weapon_improver.c.

References register_apply(), WEAPON_IMPROVER, and weapon_improver_type_apply().

Referenced by register_all_ob_types().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int prepare_weapon ( object op,
object improver,
object weapon 
)
static

This does the prepare weapon scroll.

Checks for sacrifice, and so on. Will inform the player of failures or success.

Parameters
opplayer using the scroll.
improverimprovement scroll.
weaponweapon to improve.
Returns
1 if weapon was prepared, 0 else.

Definition at line 255 of file weapon_improver.c.

References draw_ext_info(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, and NDI_UNIQUE.

Referenced by improve_weapon().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static method_ret weapon_improver_type_apply ( ob_methods context,
object op,
object applier,
int  aflags 
)
static

Attempts to apply weapon_improver.

Parameters
contextThe method context
opThe weapon_improver to apply
applierThe object attempting to apply the weapon_improver. Ignored unless a player
aflagsSpecial flags (always apply/unapply)
Returns
The return value is METHOD_OK unless it fails to apply.

Definition at line 57 of file weapon_improver.c.

References BOW, draw_ext_info(), esrv_update_item(), find_marked_object(), FLAG_WIZCAST, get_map_flags(), improve_weapon(), obj::map, METHOD_ERROR, METHOD_OK, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, NDI_UNIQUE, P_NO_MAGIC, PLAYER, QUERY_FLAG, obj::type, UPD_FLAGS, UPD_NAME, UPD_NROF, WEAPON, obj::x, and obj::y.

Referenced by init_type_weapon_improver().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: