Angband
Macros | Functions | Variables
wiz-debug.c File Reference

Debug mode commands. More...

#include "angband.h"
#include "cave.h"
#include "cmds.h"
#include "effects.h"
#include "game-input.h"
#include "grafmode.h"
#include "init.h"
#include "mon-lore.h"
#include "mon-make.h"
#include "mon-util.h"
#include "monster.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-knowledge.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-power.h"
#include "obj-slays.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "object.h"
#include "player-calcs.h"
#include "player-timed.h"
#include "player-util.h"
#include "project.h"
#include "target.h"
#include "trap.h"
#include "ui-command.h"
#include "ui-event.h"
#include "ui-display.h"
#include "ui-help.h"
#include "ui-input.h"
#include "ui-map.h"
#include "ui-menu.h"
#include "ui-prefs.h"
#include "ui-target.h"
#include "wizard.h"

Macros

#define WIZ_CREATE_ALL_MENU_ITEM   -9999
 
#define WIZ_TWEAK(attribute)
 
#define TEST_ROLL   100000
 

Functions

static void proj_display (struct menu *m, int type, bool cursor, int row, int col, int wid)
 
static void wiz_proj_demo (void)
 
static s16b get_idx_from_name (char *s)
 This is a nice utility function; it determines if a (NULL-terminated) string consists of only digits (starting with a non-zero digit). More...
 
static void do_cmd_wiz_hack_nick (void)
 Display in sequence the squares at n grids from the player, as measured by the noise and scent algorithms; n goes from 1 to max flow depth. More...
 
static void prt_binary (const bitflag *flags, int offset, int row, int col, char ch, int num)
 Output part of a bitflag set in binary format. More...
 
static void do_cmd_keylog (void)
 This ugly piece of code exists to figure out what keycodes the user has been generating. More...
 
static void do_cmd_wiz_bamf (void)
 Teleport to the requested target. More...
 
static void do_cmd_wiz_change_aux (void)
 Aux function for "do_cmd_wiz_change()". More...
 
static void do_cmd_wiz_change (void)
 Change player stats, gold and experience. More...
 
static void wiz_display_item (const struct object *obj, bool all)
 Wizard routines for creating objects and modifying them. More...
 
static void get_art_name (char *buf, int max, int a_idx)
 Build an "artifact name" and transfer it into a buffer. More...
 
static struct objectwiz_create_item_object_from_kind (struct object_kind *kind)
 Create an instance of an object of a given kind. More...
 
static struct objectwiz_create_item_object_from_artifact (struct artifact *art)
 Create an instance of an artifact. More...
 
static void wiz_create_item_drop_object (struct object *obj)
 Drop an object near the player in a manner suitable for debugging. More...
 
static void wiz_create_item_all_items (bool create_artifacts)
 Drop all possible artifacts or objects by the player. More...
 
static void wiz_create_item_subdisplay (struct menu *m, int oid, bool cursor, int row, int col, int width)
 Artifact or object kind selection. More...
 
static bool wiz_create_item_subaction (struct menu *m, const ui_event *e, int oid)
 
static void wiz_create_item_display (struct menu *m, int oid, bool cursor, int row, int col, int width)
 Object base kind selection. More...
 
static bool wiz_create_item_action (struct menu *m, const ui_event *e, int oid)
 
static void wiz_create_item (bool art)
 Choose and create an instance of an artifact or object kind. More...
 
static void wiz_tweak_item (struct object *obj)
 Tweak an item - make it ego or artifact, give values for modifiers, to_a, to_h or to_d. More...
 
static void wiz_reroll_item (struct object *obj)
 Apply magic to an item or turn it into an artifact. More...
 
static void wiz_statistics (struct object *obj, int level)
 Try to create an item again. More...
 
static void wiz_quantity_item (struct object *obj, bool carried)
 Change the quantity of an item. More...
 
static void wiz_tweak_curse (struct object *obj)
 Tweak the cursed status of an object. More...
 
static void do_cmd_wiz_play (void)
 Play with an item. More...
 
void wiz_cheat_death (void)
 What happens when you cheat death. More...
 
static void do_cmd_wiz_cure_all (void)
 Cure everything instantly. More...
 
static void do_cmd_wiz_jump (void)
 Go to any level. More...
 
static void do_cmd_wiz_learn (int lev)
 Become aware of all object flavors. More...
 
static void do_cmd_rerate (void)
 Hack – Rerate Hitpoints. More...
 
static void do_cmd_wiz_summon (int num)
 Summon some creatures. More...
 
static void do_cmd_wiz_named (struct monster_race *r, bool slp)
 Summon a creature of the specified type. More...
 
static void do_cmd_wiz_zap (int d)
 Delete all nearby monsters. More...
 
static void do_cmd_wiz_query (void)
 Query square flags - needs alteration if list-square-flags.h changes. More...
 
static void do_cmd_wiz_features (void)
 Query terrain - needs alteration if terrain types change. More...
 
static void wiz_test_kind (int tval)
 Create lots of items. More...
 
static void do_cmd_wiz_help (void)
 Display the debug commands help file. More...
 
static void do_cmd_wiz_advance (void)
 Advance the player to level 50 with max stats and other bonuses. More...
 
void do_cmd_wiz_effect (void)
 Prompt for an effect and perform it. More...
 
void get_debug_command (void)
 Main switch for processing debug commands. More...
 

Variables

static const menu_iter proj_iter
 
static bool choose_artifact = false
 Object creation code. More...
 
static const region wiz_create_item_area = { 0, 0, 0, 0 }
 
static menu_iter wiz_create_item_submenu
 
static const menu_iter wiz_create_item_menu
 

Detailed Description

Debug mode commands.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

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 TEST_ROLL   100000

Referenced by wiz_statistics().

#define WIZ_CREATE_ALL_MENU_ITEM   -9999
#define WIZ_TWEAK (   attribute)
Value:
do {\
p = "Enter new '" #attribute "' setting: ";\
strnfmt(tmp_val, sizeof(tmp_val), "%d", obj->attribute);\
if (!get_string(p, tmp_val, 6)) return;\
obj->attribute = atoi(tmp_val);\
} while (0)
bool get_string(const char *prompt, char *buf, size_t len)
Prompt for a string from the user.
Definition: game-input.c:49
size_t strnfmt(char *buf, size_t max, const char *fmt,...)
Do a vstrnfmt (see above) into a buffer of a given size.
Definition: z-form.c:613
const char ** p[]
Definition: name.c:40
static void wiz_display_item(const struct object *obj, bool all)
Wizard routines for creating objects and modifying them.
Definition: wiz-debug.c:434
similar monsters monsters spiders hydrae demons dragons true
Definition: list-summon-types.h:30

Referenced by wiz_tweak_item().

Function Documentation

static void do_cmd_keylog ( void  )
static

This ugly piece of code exists to figure out what keycodes the user has been generating.

References anykey(), buf, keypress::code, i, keylog, KEYLOG_SIZE, KEYPRESS_NULL, keypress_to_text(), log_i, log_size, keypress::mods, prt(), screen_load(), screen_save(), and strnfmt().

Referenced by get_debug_command().

static void do_cmd_rerate ( void  )
static
static void do_cmd_wiz_advance ( void  )
static
static void do_cmd_wiz_bamf ( void  )
static

Teleport to the requested target.

References cave, effect_simple(), msg, NULL, source_player(), square_ispassable(), target_get(), TARGET_LOOK, and target_set_interactive().

Referenced by get_debug_command().

static void do_cmd_wiz_change ( void  )
static

Change player stats, gold and experience.

References do_cmd_redraw(), and do_cmd_wiz_change_aux().

Referenced by get_debug_command().

static void do_cmd_wiz_change_aux ( void  )
static
static void do_cmd_wiz_cure_all ( void  )
static
void do_cmd_wiz_effect ( void  )
static void do_cmd_wiz_features ( void  )
static
static void do_cmd_wiz_hack_nick ( void  )
static

Display in sequence the squares at n grids from the player, as measured by the noise and scent algorithms; n goes from 1 to max flow depth.

References cave, COLOUR_RED, COLOUR_YELLOW, format(), get_com(), heatmap::grids, i, chunk::noise, term::offset_x, offset_x, term::offset_y, offset_y, print_rel(), prt(), prt_map(), player::px, player::py, chunk::scent, SCREEN_HGT, SCREEN_WID, square_in_bounds_fully(), square_ispassable(), and Term.

Referenced by get_debug_command().

static void do_cmd_wiz_help ( void  )
static

Display the debug commands help file.

References buf, NULL, screen_load(), screen_save(), show_file(), and strnfmt().

Referenced by get_debug_command().

static void do_cmd_wiz_jump ( void  )
static

Go to any level.

optionally choosing level generation algorithm

References CMD_HOLD, cmdq_push(), player::depth, dungeon_change_level(), get_check(), get_string(), angband_constants::max_depth, msg, player::noscore, NOSCORE_JUMPING, strnfmt(), and z_info.

Referenced by get_debug_command().

static void do_cmd_wiz_learn ( int  lev)
static

Become aware of all object flavors.

References object_kind::aware, i, k_info, angband_constants::k_max, object_kind::level, msg, object_kind::name, and z_info.

Referenced by get_debug_command().

static void do_cmd_wiz_named ( struct monster_race r,
bool  slp 
)
static

Summon a creature of the specified type.

References cave, i, place_new_monster(), player::px, player::py, scatter(), and square_isempty().

Referenced by get_debug_command().

static void do_cmd_wiz_play ( void  )
static

Play with an item.

Options include:

  • Output statistics (via wiz_roll_item)
  • Reroll item (via wiz_reroll_item)
  • Change properties (via wiz_tweak_item)
  • Change the number of items (via wiz_quantity_item)

References player::depth, get_com(), get_item(), msg, player_upkeep::notice, NULL, object_is_carried(), PN_COMBINE, PR_EQUIP, PR_INVEN, PU_BONUS, PU_INVEN, player_upkeep::redraw, screen_load(), screen_save(), player_upkeep::update, player::upkeep, USE_EQUIP, USE_FLOOR, USE_INVEN, USE_QUIVER, wiz_display_item(), wiz_quantity_item(), wiz_reroll_item(), wiz_statistics(), wiz_tweak_curse(), and wiz_tweak_item().

Referenced by get_debug_command().

static void do_cmd_wiz_query ( void  )
static
static void do_cmd_wiz_summon ( int  num)
static

Summon some creatures.

References effect_simple(), i, NULL, num, and source_player().

Referenced by get_debug_command().

static void do_cmd_wiz_zap ( int  d)
static
static void get_art_name ( char *  buf,
int  max,
int  a_idx 
)
static
void get_debug_command ( void  )
static s16b get_idx_from_name ( char *  s)
static

This is a nice utility function; it determines if a (NULL-terminated) string consists of only digits (starting with a non-zero digit).

References NULL.

Referenced by do_cmd_wiz_effect(), and get_debug_command().

static void proj_display ( struct menu m,
int  type,
bool  cursor,
int  row,
int  col,
int  wid 
)
static
static void prt_binary ( const bitflag flags,
int  offset,
int  row,
int  col,
char  ch,
int  num 
)
static

Output part of a bitflag set in binary format.

References COLOUR_BLUE, COLOUR_WHITE, flag, FLAG_START, num, of_has, and Term_putch().

Referenced by wiz_display_item().

void wiz_cheat_death ( void  )
static void wiz_create_item ( bool  art)
static
static bool wiz_create_item_action ( struct menu m,
const ui_event e,
int  oid 
)
static
static void wiz_create_item_all_items ( bool  create_artifacts)
static

Drop all possible artifacts or objects by the player.

Parameters
create_artifactsWhen true, all artifacts will be created; when false, all regular objects will be created.

References a_info, angband_constants::a_max, object_kind::base, i, k_info, angband_constants::k_max, kf_has, object_kind::kind_flags, object_base::name, NULL, wiz_create_item_drop_object(), wiz_create_item_object_from_artifact(), wiz_create_item_object_from_kind(), and z_info.

Referenced by wiz_create_item_action().

static void wiz_create_item_display ( struct menu m,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
static void wiz_create_item_drop_object ( struct object obj)
static

Drop an object near the player in a manner suitable for debugging.

Parameters
objThe object to drop.

References cave, player::depth, drop_near(), NULL, object::origin, object::origin_depth, player::px, and player::py.

Referenced by wiz_create_item_all_items(), and wiz_create_item_subaction().

static struct object* wiz_create_item_object_from_artifact ( struct artifact art)
static

Create an instance of an artifact.

Parameters
artThe artifact to instantiate.
Returns
An object that represents the artifact.

References artifact::alloc_min, object::artifact, copy_artifact_data(), artifact::created, lookup_kind(), artifact::name, NULL, object_new(), object_prep(), RANDOMISE, artifact::sval, and artifact::tval.

Referenced by wiz_create_item_all_items(), and wiz_create_item_subaction().

static struct object* wiz_create_item_object_from_kind ( struct object_kind kind)
static

Create an instance of an object of a given kind.

Parameters
kindThe base type of object to instantiate.
Returns
An object of the provided object type.

References apply_magic(), player::depth, make_gold(), object_kind::name, object_new(), object_prep(), RANDOMISE, and tval_is_money_k().

Referenced by wiz_create_item_all_items(), and wiz_create_item_subaction().

static bool wiz_create_item_subaction ( struct menu m,
const ui_event e,
int  oid 
)
static
static void wiz_create_item_subdisplay ( struct menu m,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
static void wiz_display_item ( const struct object obj,
bool  all 
)
static

Wizard routines for creating objects and modifying them.

This has been rewritten to make the whole procedure of debugging objects much easier and more comfortable.

Here are the low-level functions

  • wiz_display_item() display an item's debug-info
  • wiz_create_itemtype() specify tval and sval (type and subtype of object)
  • wiz_tweak_item() specify pval, +AC, +tohit, +todam Note that the wizard can leave this function anytime, thus accepting the default-values for the remaining values. pval comes first now, since it is most important.
  • wiz_reroll_item() apply some magic to the item or turn it into an artifact.
  • wiz_roll_item() Get some statistics about the rarity of an item: We create a lot of fake items and see if they are of the same type (tval and sval), then we compare pval and +AC. If the fake-item is better or equal it is counted. Note that cursed items that are better or equal (absolute values) are counted, too. HINT: This is very useful for balancing the game!
  • wiz_quantity_item() change the quantity of an item, but be sane about it.

And now the high-level functions

Note – You do not have to specify "pval" and other item-properties directly. Just apply magic until you are satisfied with the item.

Note – For some items (such as wands, staffs, some rings, etc), you must apply magic, or you will get "broken" or "uncharged" objects.

Note – Redefining artifacts via "do_cmd_wiz_play()" may destroy the artifact. Be careful.

Hack – this function will allow you to create multiple artifacts. This "feature" may induce crashes or other nasty effects. Display an item's properties

References object::ac, artifact::aidx, object::artifact, buf, object::dd, object::ds, object::ego, ego_item::eidx, object::flags, format(), object_kind::kidx, object::kind, object::known, object::number, object_desc(), object_flags(), object_flags_known(), object_value(), ODESC_FULL, ODESC_PREFIX, ODESC_SPOIL, OF_SIZE, prt(), prt_binary(), object::pval, object::sval, Term_clear(), object::timeout, object::to_a, object::to_d, object::to_h, object::tval, and object::weight.

Referenced by do_cmd_wiz_play(), wiz_reroll_item(), wiz_statistics(), and wiz_tweak_item().

static void wiz_proj_demo ( void  )
static
static void wiz_quantity_item ( struct object obj,
bool  carried 
)
static
static void wiz_reroll_item ( struct object obj)
static
static void wiz_statistics ( struct object obj,
int  level 
)
static

Try to create an item again.

Output some statistics. -Bernd-

The statistics are correct now. We acquire a clean grid, and then repeatedly place an object in this grid, copying it into an item holder, and then deleting the object. We fiddle with the artifact counter flags to prevent weirdness. We use the items to collect statistics on item creation relative to the initial item.

References object::artifact, cave, artifact::created, player::depth, EVENT_INPUT_FLUSH, EVENT_MESSAGE_FLUSH, event_signal(), EVT_NONE, format(), get_com(), i, inkey(), inkey_scan, make_object(), object::modifiers, msg, NULL, OBJ_MOD_MAX, object_delete(), prt(), SCAN_INSTANT, object::sval, Term_fresh(), TEST_ROLL, object::to_a, object::to_d, object::to_h, object::tval, keypress::type, and wiz_display_item().

Referenced by do_cmd_wiz_play().

static void wiz_test_kind ( int  tval)
static
static void wiz_tweak_curse ( struct object obj)
static

Tweak the cursed status of an object.

Parameters
objis the object to curse or decurse

Referenced by do_cmd_wiz_play().

static void wiz_tweak_item ( struct object obj)
static

Variable Documentation

bool choose_artifact = false
static
const menu_iter proj_iter
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL
}
static void proj_display(struct menu *m, int type, bool cursor, int row, int col, int wid)
Definition: wiz-debug.c:58
NULL
Definition: list-summon-types.h:18
const region wiz_create_item_area = { 0, 0, 0, 0 }
static
const menu_iter wiz_create_item_menu
static
Initial value:
=
{
NULL
}
static bool wiz_create_item_action(struct menu *m, const ui_event *e, int oid)
Definition: wiz-debug.c:746
NULL
Definition: list-summon-types.h:18
static void wiz_create_item_display(struct menu *m, int oid, bool cursor, int row, int col, int width)
Object base kind selection.
Definition: wiz-debug.c:728
menu_iter wiz_create_item_submenu
static
Initial value:
=
{
NULL
}
static void wiz_create_item_subdisplay(struct menu *m, int oid, bool cursor, int row, int col, int width)
Artifact or object kind selection.
Definition: wiz-debug.c:645
NULL
Definition: list-summon-types.h:18
static bool wiz_create_item_subaction(struct menu *m, const ui_event *e, int oid)
Definition: wiz-debug.c:674