Macros | Functions
obj-make.h File Reference

Object generation functions. More...

#include "cave.h"

Go to the source code of this file.


#define NO_MINIMUM   255
 Define a value for minima which will be ignored (a replacement for 0, because 0 and some small negatives are valid values). More...


void ego_apply_magic (struct object *obj, int level)
 Apply generation magic to an ego-item. More...
void copy_artifact_data (struct object *obj, const struct artifact *art)
 Copy artifact data to a normal object. More...
bool make_fake_artifact (struct object *obj, const struct artifact *artifact)
 Create a fake artifact directly from a blank object. More...
void object_prep (struct object *obj, struct object_kind *kind, int lev, aspect rand_aspect)
 Wipe an object clean and make it a standard object of the specified kind. More...
int apply_magic (struct object *obj, int lev, bool okay, bool good, bool great, bool extra_roll)
 Applying magic to an object, which includes creating ego-items, and applying random bonuses,. More...
bool kind_is_good (const struct object_kind *kind)
 Hack – determine if a template is "good". More...
struct object_kindget_obj_num (int level, bool good, int tval)
 Choose an object kind given a dungeon level to choose it for. More...
struct objectmake_object (struct chunk *c, int lev, bool good, bool great, bool extra_roll, s32b *value, int tval)
 Attempt to make an object. More...
void acquirement (struct loc grid, int level, int num, bool great)
 Scatter some objects near the player. More...
struct object_kindmoney_kind (const char *name, int value)
 Get a money kind by name, or level-appropriate. More...
struct objectmake_gold (int lev, char *coin_type)
 Make a money object. More...

Detailed Description

Object generation functions.

Copyright (c) 1987-2007 Angband contributors

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


#define NO_MINIMUM   255

Define a value for minima which will be ignored (a replacement for 0, because 0 and some small negatives are valid values).

Referenced by ego_apply_minima().

Function Documentation

◆ acquirement()

void acquirement ( struct loc  grid,
int  level,
int  num,
bool  great 

Scatter some objects near the player.

References cave, player::depth, drop_near(), make_object(), object::origin, and object::origin_depth.

Referenced by effect_handler_ACQUIRE(), and get_debug_command().

◆ apply_magic()

int apply_magic ( struct object obj,
int  lev,
bool  allow_artifacts,
bool  good,
bool  great,
bool  extra_roll 

Applying magic to an object, which includes creating ego-items, and applying random bonuses,.

The good argument forces the item to be at least good, and the great argument does likewise. Setting allow_artifacts to true allows artifacts to be created here.

If good or great are not set, then the lev argument controls the quality of item.

Returns 0 if a normal object, 1 if a good object, 2 if an ego item, 3 if an artifact.

References apply_curse(), apply_magic_armour(), apply_magic_weapon(), ego_apply_minima(), i, lookup_sval(), make_artifact(), make_ego_item(), object::modifiers, one_in_, pick_chest_traps(), object::pval, randint0, object::sval, object::tval, tval_is_armor(), tval_is_chest(), tval_is_ring(), tval_is_weapon(), and tval_is_wearable().

Referenced by make_object(), mon_create_drop(), mon_create_mimicked_object(), store_create_random(), wiz_create_item_object_from_kind(), wiz_reroll_item(), and wiz_test_kind().

◆ copy_artifact_data()

void copy_artifact_data ( struct object obj,
const struct artifact art 

◆ ego_apply_magic()

void ego_apply_magic ( struct object obj,
int  level 

◆ get_obj_num()

struct object_kind* get_obj_num ( int  level,
bool  good,
int  tval 

Choose an object kind given a dungeon level to choose it for.

If tval = 0, we can choose an object of any type. Otherwise we can only choose one of the given tval.

References binary_search_probtable(), get_obj_num_by_kind(), angband_constants::great_obj, angband_constants::k_max, MAX, angband_constants::max_obj_depth, MIN, obj_alloc, obj_alloc_great, objkind_byid(), one_in_, randint0, randint1, value, and z_info.

Referenced by make_object(), store_create_random(), and test_get_obj_num_basic().

◆ kind_is_good()

bool kind_is_good ( const struct object_kind kind)

Hack – determine if a template is "good".

Note that this test only applies to the object kind, so it is possible to choose a kind which is "good", and then later cause the actual object to be cursed. We do explicitly forbid objects which are known to be boring or which start out somewhat damaged.

References kf_has, object_kind::kind_flags, MINIMISE, randcalc(), object_kind::to_a, object_kind::to_d, object_kind::to_h, and object_kind::tval.

Referenced by alloc_init_objects().

◆ make_fake_artifact()

bool make_fake_artifact ( struct object obj,
const struct artifact artifact 

Create a fake artifact directly from a blank object.

This function is used for describing artifacts, and for creating them for debugging.

Since this is now in no way marked as fake, we must make sure this function is never used to create an actual game object

References object::artifact, copy_artifact_data(), lookup_kind(), MAXIMISE, object_prep(), artifact::sval, and artifact::tval.

Referenced by artifact_power(), desc_art_fake(), get_artifact_display_name(), get_artifact_name(), and spoil_artifact().

◆ make_gold()

struct object* make_gold ( int  lev,
char *  coin_type 

Make a money object.

levthe dungeon level
coin_typethe name of the type of money object to make
a pointer to the newly minted cash (cannot fail)

References player::depth, mem_zalloc(), money_kind(), object_prep(), one_in_, OPT, object::pval, rand_spread, randint0, RANDOMISE, and value.

Referenced by mon_create_drop(), mon_create_mimicked_object(), place_gold(), wiz_create_item_object_from_kind(), and wiz_test_kind().

◆ make_object()

struct object* make_object ( struct chunk c,
int  lev,
bool  good,
bool  great,
bool  extra_roll,
s32b value,
int  tval 

Attempt to make an object.

cis the current dungeon level.
levis the creation level of the object (not necessarily == depth).
goodis whether the object is to be good
greatis whether the object is to be great
extra_rollis whether we get an extra roll in apply_magic()
valueis the value to be returned to the calling function
tvalis the desired tval, or 0 if we allow any tval
a pointer to the newly allocated object, or NULL on failure.

References object_kind::alloc_min, apply_magic(), object_kind::base, object::curses, chunk::depth, object_kind::gen_mult_prob, get_obj_num(), object::kind, make_artifact_special(), object_base::max_stack, object::number, obj_kind_can_browse(), object_new(), object_prep(), object_value_real(), one_in_, randcalc(), randint1, RANDOMISE, object_kind::stack_size, and tval_is_book_k().

Referenced by acquirement(), chest_death(), effect_handler_CREATE_ARROWS(), mon_create_drop(), place_object(), and wiz_statistics().

◆ money_kind()

struct object_kind* money_kind ( const char *  name,
int  value 

Get a money kind by name, or level-appropriate.

References lookup_kind(), angband_constants::max_depth, num_money_types, streq, money::type, and z_info.

Referenced by make_gold(), and melee_effect_handler_EAT_GOLD().

◆ object_prep()

void object_prep ( struct object obj,
struct object_kind kind,
int  lev,
aspect  rand_aspect 

Wipe an object clean and make it a standard object of the specified kind.

References object_kind::ac, object::ac, object_kind::base, object_kind::brands, object::brands, object_kind::charge, copy_brands(), copy_curses(), copy_slays(), object_kind::curses, object_kind::dd, object::dd, angband_constants::default_lamp, object_kind::ds, object::ds, object_kind::effect, object::effect, object_base::el_info, object_kind::el_info, object::el_info, ELEM_MAX, element_info::flags, object_base::flags, object_kind::flags, object::flags, angband_constants::fuel_torch, i, object::kind, object_kind::modifiers, object::modifiers, object::number, OBJ_MOD_MAX, of_copy, of_has, object_kind::pval, object::pval, randcalc(), element_info::res_level, object_kind::slays, object::slays, object_kind::sval, object::sval, object_kind::time, object::time, object::timeout, object_kind::to_a, object::to_a, object_kind::to_d, object::to_d, object_kind::to_h, object::to_h, object_kind::tval, object::tval, tval_can_have_charges(), tval_is_edible(), tval_is_fuel(), tval_is_launcher(), tval_is_light(), tval_is_potion(), object_kind::weight, object::weight, and z_info.

Referenced by desc_obj_fake(), display_object_kind_recall(), get_art_name(), kind_info(), make_artifact_special(), make_fake_artifact(), make_gold(), make_object(), melee_effect_handler_EAT_GOLD(), mon_create_drop(), mon_create_mimicked_object(), player_outfit(), store_create_item(), store_create_random(), test_breakage_chance(), test_obj_can_refill(), wiz_create_item_object_from_artifact(), wiz_create_item_object_from_kind(), wiz_reroll_item(), wiz_test_kind(), and wiz_tweak_item().