X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fobject2.c;h=7c2be2aeb25294113903e2d5f79f2152940b9cd8;hb=1cb863682cba91dc9928eef55e7ef552e4d1651f;hp=453d629ce42a04fd730e68d41d54fbda52467e29;hpb=628198121ab9c54dcffb6a1d83dae10cf3dcdd7f;p=hengband%2Fhengband.git diff --git a/src/object2.c b/src/object2.c index 453d629ce..7c2be2aeb 100644 --- a/src/object2.c +++ b/src/object2.c @@ -13,14 +13,20 @@ #include "angband.h" #include "util.h" +#include "world.h" +#include "term.h" #include "object.h" +#include "cmd-dump.h" +#include "cmd-spell.h" #include "spells.h" #include "dungeon.h" #include "floor.h" #include "grid.h" +#include "objectkind.h" #include "object-boost.h" +#include "object-ego.h" #include "object-flavor.h" #include "object-hook.h" #include "object-curse.h" @@ -30,8 +36,12 @@ #include "player-status.h" #include "player-move.h" #include "player-effects.h" +#include "player-class.h" +#include "player-personality.h" #include "monster.h" #include "monsterrace-hook.h" +#include "object-ego.h" +#include "view-mainwindow.h" /*! * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks @@ -46,18 +56,18 @@ void excise_object_idx(OBJECT_IDX o_idx) OBJECT_IDX prev_o_idx = 0; /* Object */ - j_ptr = ¤t_floor_ptr->o_list[o_idx]; + j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; - if (j_ptr->held_m_idx) + if (OBJECT_IS_HELD_MONSTER(j_ptr)) { monster_type *m_ptr; - m_ptr = ¤t_floor_ptr->m_list[j_ptr->held_m_idx]; + m_ptr = &p_ptr->current_floor_ptr->m_list[j_ptr->held_m_idx]; /* Scan all objects in the grid */ for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; if (this_o_idx == o_idx) @@ -75,7 +85,7 @@ void excise_object_idx(OBJECT_IDX o_idx) object_type *k_ptr; /* Previous object */ - k_ptr = ¤t_floor_ptr->o_list[prev_o_idx]; + k_ptr = &p_ptr->current_floor_ptr->o_list[prev_o_idx]; /* Remove from list */ k_ptr->next_o_idx = next_o_idx; @@ -100,13 +110,13 @@ void excise_object_idx(OBJECT_IDX o_idx) POSITION y = j_ptr->iy; POSITION x = j_ptr->ix; - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; /* Scan all objects in the grid */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; if (this_o_idx == o_idx) @@ -124,7 +134,7 @@ void excise_object_idx(OBJECT_IDX o_idx) object_type *k_ptr; /* Previous object */ - k_ptr = ¤t_floor_ptr->o_list[prev_o_idx]; + k_ptr = &p_ptr->current_floor_ptr->o_list[prev_o_idx]; /* Remove from list */ k_ptr->next_o_idx = next_o_idx; @@ -158,10 +168,10 @@ void delete_object_idx(OBJECT_IDX o_idx) excise_object_idx(o_idx); /* Object */ - j_ptr = ¤t_floor_ptr->o_list[o_idx]; + j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; /* Dungeon floor */ - if (!(j_ptr->held_m_idx)) + if (!OBJECT_IS_HELD_MONSTER(j_ptr)) { POSITION y, x; y = j_ptr->iy; @@ -171,7 +181,7 @@ void delete_object_idx(OBJECT_IDX o_idx) object_wipe(j_ptr); /* Count objects */ - o_cnt--; + p_ptr->current_floor_ptr->o_cnt--; } @@ -188,20 +198,20 @@ void delete_object(POSITION y, POSITION x) OBJECT_IDX this_o_idx, next_o_idx = 0; /* Refuse "illegal" locations */ - if (!in_bounds(y, x)) return; + if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return; - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; /* Scan all objects in the grid */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; object_wipe(o_ptr); /* Count objects */ - o_cnt--; + p_ptr->current_floor_ptr->o_cnt--; } /* Objects are gone */ @@ -228,9 +238,9 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2) if (i1 == i2) return; /* Repair objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < p_ptr->current_floor_ptr->o_max; i++) { - o_ptr = ¤t_floor_ptr->o_list[i]; + o_ptr = &p_ptr->current_floor_ptr->o_list[i]; /* Skip "dead" objects */ if (!o_ptr->k_idx) continue; @@ -242,14 +252,12 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2) o_ptr->next_o_idx = i2; } } - o_ptr = ¤t_floor_ptr->o_list[i1]; + o_ptr = &p_ptr->current_floor_ptr->o_list[i1]; - if (o_ptr->held_m_idx) + if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - - /* Acquire monster */ - m_ptr = ¤t_floor_ptr->m_list[o_ptr->held_m_idx]; + m_ptr = &p_ptr->current_floor_ptr->m_list[o_ptr->held_m_idx]; /* Repair monster */ if (m_ptr->hold_o_idx == i1) @@ -269,7 +277,7 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2) x = o_ptr->ix; /* Acquire grid */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; /* Repair grid */ if (g_ptr->o_idx == i1) @@ -280,7 +288,7 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2) } /* Structure copy */ - current_floor_ptr->o_list[i2] = current_floor_ptr->o_list[i1]; + p_ptr->current_floor_ptr->o_list[i2] = p_ptr->current_floor_ptr->o_list[i1]; /* Wipe the hole */ object_wipe(o_ptr); @@ -330,22 +338,19 @@ void compact_objects(int size) cur_dis = 5 * (20 - cnt); /* Examine the objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < p_ptr->current_floor_ptr->o_max; i++) { - o_ptr = ¤t_floor_ptr->o_list[i]; + o_ptr = &p_ptr->current_floor_ptr->o_list[i]; - /* Skip dead objects */ - if (!o_ptr->k_idx) continue; + if (!OBJECT_IS_VALID(o_ptr)) continue; /* Hack -- High level objects start out "immune" */ if (k_info[o_ptr->k_idx].level > cur_lev) continue; - if (o_ptr->held_m_idx) + if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - - /* Acquire monster */ - m_ptr = ¤t_floor_ptr->m_list[o_ptr->held_m_idx]; + m_ptr = &p_ptr->current_floor_ptr->m_list[o_ptr->held_m_idx]; y = m_ptr->fy; x = m_ptr->fx; @@ -383,92 +388,21 @@ void compact_objects(int size) /* Excise dead objects (backwards!) */ - for (i = o_max - 1; i >= 1; i--) + for (i = p_ptr->current_floor_ptr->o_max - 1; i >= 1; i--) { - o_ptr = ¤t_floor_ptr->o_list[i]; + o_ptr = &p_ptr->current_floor_ptr->o_list[i]; /* Skip real objects */ if (o_ptr->k_idx) continue; /* Move last object into open hole */ - compact_objects_aux(o_max - 1, i); - - /* Compress "o_max" */ - o_max--; - } -} - - -/*! - * @brief グローバルオブジェクト配列を初期化する / - * Delete all the items when player leaves the level - * @note we do NOT visually reflect these (irrelevant) changes - * @details - * Hack -- we clear the "g_ptr->o_idx" field for every grid, - * and the "m_ptr->next_o_idx" field for every monster, since - * we know we are clearing every object. Technically, we only - * clear those fields for grids/monsters containing objects, - * and we clear it once for every such object. - * @return なし - */ -void wipe_o_list(void) -{ - int i; - - /* Delete the existing objects */ - for (i = 1; i < o_max; i++) - { - object_type *o_ptr = ¤t_floor_ptr->o_list[i]; - - /* Skip dead objects */ - if (!o_ptr->k_idx) continue; - - /* Mega-Hack -- preserve artifacts */ - if (!character_dungeon || preserve_mode) - { - /* Hack -- Preserve unknown artifacts */ - if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr)) - { - /* Mega-Hack -- Preserve the artifact */ - a_info[o_ptr->name1].cur_num = 0; - } - } - - if (o_ptr->held_m_idx) - { - monster_type *m_ptr; - m_ptr = ¤t_floor_ptr->m_list[o_ptr->held_m_idx]; - - /* Hack -- see above */ - m_ptr->hold_o_idx = 0; - } - - /* Dungeon */ - else - { - grid_type *g_ptr; + compact_objects_aux(p_ptr->current_floor_ptr->o_max - 1, i); - /* Access location */ - POSITION y = o_ptr->iy; - POSITION x = o_ptr->ix; - - /* Access grid */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; - - /* Hack -- see above */ - g_ptr->o_idx = 0; - } - object_wipe(o_ptr); + /* Compress "p_ptr->current_floor_ptr->o_max" */ + p_ptr->current_floor_ptr->o_max--; } - - /* Reset "o_max" */ - o_max = 1; - - /* Reset "o_cnt" */ - o_cnt = 0; } - /*! * @brief グローバルオブジェクト配列から空きを取得する / * Acquires and returns the index of a "free" object. @@ -482,16 +416,16 @@ OBJECT_IDX o_pop(void) OBJECT_IDX i; /* Initial allocation */ - if (o_max < current_floor_ptr->max_o_idx) + if (p_ptr->current_floor_ptr->o_max < current_world_ptr->max_o_idx) { /* Get next space */ - i = o_max; + i = p_ptr->current_floor_ptr->o_max; /* Expand object array */ - o_max++; + p_ptr->current_floor_ptr->o_max++; /* Count objects */ - o_cnt++; + p_ptr->current_floor_ptr->o_cnt++; /* Use this object */ return (i); @@ -499,16 +433,16 @@ OBJECT_IDX o_pop(void) /* Recycle dead objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < p_ptr->current_floor_ptr->o_max; i++) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[i]; + o_ptr = &p_ptr->current_floor_ptr->o_list[i]; /* Skip live objects */ if (o_ptr->k_idx) continue; /* Count objects */ - o_cnt++; + p_ptr->current_floor_ptr->o_cnt++; /* Use this object */ return (i); @@ -516,11 +450,15 @@ OBJECT_IDX o_pop(void) /* Warn the player (except during dungeon creation) */ - if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!")); + if (current_world_ptr->character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!")); return (0); } +/* + * Hack -- function hook to restrict "get_obj_num_prep()" function + */ +bool(*get_obj_num_hook)(KIND_OBJECT_IDX k_idx); /*! * @brief オブジェクト生成テーブルに生成制約を加える / @@ -576,7 +514,7 @@ static errr get_obj_num_prep(void) * Note that if no objects are "appropriate", then this function will\n * fail, and return zero, but this should *almost* never happen.\n */ -OBJECT_IDX get_obj_num(DEPTH level) +OBJECT_IDX get_obj_num(DEPTH level, BIT_FLAGS mode) { int i, j, p; KIND_OBJECT_IDX k_idx; @@ -614,8 +552,7 @@ OBJECT_IDX get_obj_num(DEPTH level) /* Access the actual kind */ k_ptr = &k_info[k_idx]; - /* Hack -- prevent embedded chests */ - if (opening_chest && (k_ptr->tval == TV_CHEST)) continue; + if ((mode & AM_FORBID_CHEST) && (k_ptr->tval == TV_CHEST)) continue; /* Accept */ table[i].prob3 = table[i].prob2; @@ -694,7 +631,6 @@ OBJECT_IDX get_obj_num(DEPTH level) return (table[i].index); } - /*! * @brief オブジェクトを鑑定済にする / * Known is true when the "attributes" of an object are "known". @@ -754,7 +690,7 @@ void object_aware(object_type *o_ptr) q_ptr->number = 1; object_desc(o_name, q_ptr, OD_NAME_ONLY); - do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name); + exe_write_diary(p_ptr, NIKKI_HANMEI, 0, o_name); } } @@ -2074,7 +2010,7 @@ void apply_magic_weapon(object_type *o_ptr, DEPTH level, int power) if (power > 1) { if (one_in_(30) || (power > 2)) /* power > 2 is debug only */ - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); else /* Special Ego-item */ o_ptr->name2 = EGO_DIGGING; @@ -2106,7 +2042,7 @@ void apply_magic_weapon(object_type *o_ptr, DEPTH level, int power) { if (one_in_(40) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } while (1) @@ -2265,7 +2201,7 @@ void apply_magic_weapon(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE); @@ -2284,7 +2220,7 @@ void apply_magic_weapon(object_type *o_ptr, DEPTH level, int power) { if (power > 2) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } @@ -2371,7 +2307,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) case TV_DRAG_ARMOR: { if (one_in_(50) || (power > 2)) /* power > 2 is debug only */ - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } @@ -2403,7 +2339,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } @@ -2491,7 +2427,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } @@ -2537,7 +2473,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE); @@ -2564,7 +2500,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE); @@ -2595,7 +2531,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } while (1) @@ -2671,7 +2607,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } while (1) @@ -2749,7 +2685,7 @@ static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power) { if (one_in_(20) || (power > 2)) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); break; } o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE); @@ -3098,7 +3034,7 @@ static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power) { o_ptr->pval = MIN(o_ptr->pval, 4); /* Randart amulet */ - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); } else if ((power == 2) && one_in_(2)) { @@ -3430,7 +3366,7 @@ static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power) { o_ptr->pval = MIN(o_ptr->pval, 4); /* Randart amulet */ - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); } else if ((power == 2) && one_in_(2)) { @@ -3633,7 +3569,7 @@ static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power) if (power > 2) /* power > 2 is debug only */ { - create_artifact(o_ptr, FALSE); + become_random_artifact(o_ptr, FALSE); } else if ((power == 2) || ((power == 1) && one_in_(3))) { @@ -3726,7 +3662,7 @@ static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power) r_ptr = &r_info[i]; - check = (current_floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - current_floor_ptr->dun_level) : 0; + check = (p_ptr->current_floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - p_ptr->current_floor_ptr->dun_level) : 0; /* Ignore dead monsters */ if (!r_ptr->rarity) continue; @@ -3772,11 +3708,11 @@ static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power) /* Pick a random non-unique monster race */ while (1) { - i = get_mon_num(current_floor_ptr->dun_level); + i = get_mon_num(p_ptr->current_floor_ptr->dun_level); r_ptr = &r_info[i]; - check = (current_floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - current_floor_ptr->dun_level) : 0; + check = (p_ptr->current_floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - p_ptr->current_floor_ptr->dun_level) : 0; /* Ignore dead monsters */ if (!r_ptr->rarity) continue; @@ -3840,7 +3776,7 @@ static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power) o_ptr->pval = randint1(obj_level); if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6; - o_ptr->xtra3 = current_floor_ptr->dun_level + 5; + o_ptr->xtra3 = p_ptr->current_floor_ptr->dun_level + 5; /* Never exceed "difficulty" of 55 to 59 */ if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5); @@ -3996,7 +3932,7 @@ void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode) a_ptr->cur_num = 1; /* Hack -- Memorize location of artifact in saved floors */ - if (character_dungeon) + if (current_world_ptr->character_dungeon) a_ptr->floor_id = p_ptr->floor_id; /* Extract the other fields */ @@ -4295,7 +4231,7 @@ void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode) * @return 生成に成功したらTRUEを返す。 * @details * This routine plays nasty games to generate the "special artifacts".\n - * This routine uses "current_floor_ptr->object_level" for the "generation level".\n + * This routine uses "p_ptr->current_floor_ptr->object_level" for the "generation level".\n * We assume that the given object has been "wiped".\n */ bool make_object(object_type *j_ptr, BIT_FLAGS mode) @@ -4308,7 +4244,7 @@ bool make_object(object_type *j_ptr, BIT_FLAGS mode) prob = ((mode & AM_GOOD) ? 10 : 1000); /* Base level for the object */ - base = ((mode & AM_GOOD) ? (current_floor_ptr->object_level + 10) : current_floor_ptr->object_level); + base = ((mode & AM_GOOD) ? (p_ptr->current_floor_ptr->object_level + 10) : p_ptr->current_floor_ptr->object_level); /* Generate a special object, or a normal object */ @@ -4327,7 +4263,7 @@ bool make_object(object_type *j_ptr, BIT_FLAGS mode) if (get_obj_num_hook) get_obj_num_prep(); /* Pick a random object */ - k_idx = get_obj_num(base); + k_idx = get_obj_num(base, mode); /* Restricted objects */ if (get_obj_num_hook) @@ -4347,7 +4283,7 @@ bool make_object(object_type *j_ptr, BIT_FLAGS mode) } /* Apply magic (allow artifacts) */ - apply_magic(j_ptr, current_floor_ptr->object_level, mode); + apply_magic(j_ptr, p_ptr->current_floor_ptr->object_level, mode); /* Hack -- generate multiple spikes/missiles */ switch (j_ptr->tval) @@ -4378,7 +4314,7 @@ bool make_object(object_type *j_ptr, BIT_FLAGS mode) * @return 生成に成功したらTRUEを返す。 * @details * This routine plays nasty games to generate the "special artifacts".\n - * This routine uses "current_floor_ptr->object_level" for the "generation level".\n + * This routine uses "p_ptr->current_floor_ptr->object_level" for the "generation level".\n * This routine requires a clean floor grid destination.\n */ void place_object(POSITION y, POSITION x, BIT_FLAGS mode) @@ -4386,17 +4322,17 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode) OBJECT_IDX o_idx; /* Acquire grid */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; + grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; object_type forge; object_type *q_ptr; /* Paranoia -- check bounds */ - if (!in_bounds(y, x)) return; + if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return; /* Require floor space */ - if (!cave_drop_bold(y, x)) return; + if (!cave_drop_bold(p_ptr->current_floor_ptr, y, x)) return; /* Avoid stacking on other objects */ if (g_ptr->o_idx) return; @@ -4413,7 +4349,7 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode) if (o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; /* Structure Copy */ object_copy(o_ptr, q_ptr); @@ -4439,6 +4375,8 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode) } +OBJECT_SUBTYPE_VALUE coin_type; /* Hack -- force coin type */ + /*! * @brief 生成階に応じた財宝オブジェクトの生成を行う。 * Make a treasure object @@ -4453,12 +4391,12 @@ bool make_gold(object_type *j_ptr) s32b base; /* Hack -- Pick a Treasure variety */ - i = ((randint1(current_floor_ptr->object_level + 2) + 2) / 2) - 1; + i = ((randint1(p_ptr->current_floor_ptr->object_level + 2) + 2) / 2) - 1; /* Apply "extra" magic */ if (one_in_(GREAT_OBJ)) { - i += randint1(current_floor_ptr->object_level + 1); + i += randint1(p_ptr->current_floor_ptr->object_level + 1); } /* Hack -- Creeping Coins only generate "themselves" */ @@ -4495,17 +4433,17 @@ void place_gold(POSITION y, POSITION x) OBJECT_IDX o_idx; /* Acquire grid */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; + grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; object_type forge; object_type *q_ptr; /* Paranoia -- check bounds */ - if (!in_bounds(y, x)) return; + if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return; /* Require floor space */ - if (!cave_drop_bold(y, x)) return; + if (!cave_drop_bold(p_ptr->current_floor_ptr, y, x)) return; /* Avoid stacking on other objects */ if (g_ptr->o_idx) return; @@ -4522,7 +4460,7 @@ void place_gold(POSITION y, POSITION x) if (o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; object_copy(o_ptr, q_ptr); /* Save location */ @@ -4543,12 +4481,12 @@ void place_gold(POSITION y, POSITION x) * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。 * Let an object fall to the ground at or near a location. * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ - * @param chance ドロップの成功率(%) + * @param chance ドロップの消滅率(%) * @param y 配置したいフロアのY座標 * @param x 配置したいフロアのX座標 * @return 生成に成功したらオブジェクトのIDを返す。 * @details - * The initial location is assumed to be "in_bounds()".\n + * The initial location is assumed to be "in_bounds(p_ptr->current_floor_ptr, )".\n *\n * This function takes a parameter "chance". This is the percentage\n * chance that the item will "disappear" instead of drop. If the object\n @@ -4597,7 +4535,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION #else msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)")); + if (current_world_ptr->wizard) msg_print(_("(破損)", "(breakage)")); /* Failure */ return (0); @@ -4631,17 +4569,16 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION ty = y + dy; tx = x + dx; - /* Skip illegal grids */ - if (!in_bounds(ty, tx)) continue; + if (!in_bounds(p_ptr->current_floor_ptr, ty, tx)) continue; /* Require line of projection */ - if (!projectable(y, x, ty, tx)) continue; + if (!projectable(p_ptr->current_floor_ptr, y, x, ty, tx)) continue; /* Obtain grid */ - g_ptr = ¤t_floor_ptr->grid_array[ty][tx]; + g_ptr = &p_ptr->current_floor_ptr->grid_array[ty][tx]; /* Require floor space */ - if (!cave_drop_bold(ty, tx)) continue; + if (!cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) continue; /* No objects */ k = 0; @@ -4650,7 +4587,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Check for possible combination */ @@ -4697,7 +4634,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); + if (current_world_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); /* Failure */ return (0); @@ -4711,14 +4648,14 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION ty = rand_spread(by, 1); tx = rand_spread(bx, 1); - if (!in_bounds(ty, tx)) continue; + if (!in_bounds(p_ptr->current_floor_ptr, ty, tx)) continue; /* Bounce to that location */ by = ty; bx = tx; /* Require floor space */ - if (!cave_drop_bold(by, bx)) continue; + if (!cave_drop_bold(p_ptr->current_floor_ptr, by, bx)) continue; flag = TRUE; } @@ -4728,12 +4665,12 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION { int candidates = 0, pick; - for (ty = 1; ty < current_floor_ptr->height - 1; ty++) + for (ty = 1; ty < p_ptr->current_floor_ptr->height - 1; ty++) { - for (tx = 1; tx < current_floor_ptr->width - 1; tx++) + for (tx = 1; tx < p_ptr->current_floor_ptr->width - 1; tx++) { /* A valid space found */ - if (cave_drop_bold(ty, tx)) candidates++; + if (cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) candidates++; } } @@ -4746,7 +4683,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); + if (current_world_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); /* Mega-Hack -- preserve artifacts */ if (preserve_mode) @@ -4766,11 +4703,11 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /* Choose a random one */ pick = randint1(candidates); - for (ty = 1; ty < current_floor_ptr->height - 1; ty++) + for (ty = 1; ty < p_ptr->current_floor_ptr->height - 1; ty++) { - for (tx = 1; tx < current_floor_ptr->width - 1; tx++) + for (tx = 1; tx < p_ptr->current_floor_ptr->width - 1; tx++) { - if (cave_drop_bold(ty, tx)) + if (cave_drop_bold(p_ptr->current_floor_ptr, ty, tx)) { pick--; @@ -4787,13 +4724,13 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION } - g_ptr = ¤t_floor_ptr->grid_array[by][bx]; + g_ptr = &p_ptr->current_floor_ptr->grid_array[by][bx]; /* Scan objects in that grid for combination */ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - o_ptr = ¤t_floor_ptr->o_list[this_o_idx]; + o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx]; next_o_idx = o_ptr->next_o_idx; /* Check for combination */ @@ -4819,7 +4756,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)")); + if (current_world_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)")); /* Hack -- Preserve artifacts */ if (object_is_fixed_artifact(j_ptr)) @@ -4835,10 +4772,10 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION if (!done) { /* Structure copy */ - object_copy(¤t_floor_ptr->o_list[o_idx], j_ptr); + object_copy(&p_ptr->current_floor_ptr->o_list[o_idx], j_ptr); /* Access new object */ - j_ptr = ¤t_floor_ptr->o_list[o_idx]; + j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; /* Locate */ j_ptr->iy = by; @@ -4862,7 +4799,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /* Mega-Hack -- no message if "dropped" by player */ /* Message when an object falls under the player */ - if (chance && player_bold(by, bx)) + if (chance && player_bold(p_ptr, by, bx)) { msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet.")); } @@ -4872,7 +4809,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION /*! * @brief 魔道具の使用回数の残量を示すメッセージを表示する / - * Describe the charges on an item in the p_ptr->inventory_list. + * Describe the charges on an item in the inventory. * @param item 残量を表示したいプレイヤーのアイテム所持スロット * @return なし */ @@ -4913,7 +4850,7 @@ void inven_item_charges(INVENTORY_IDX item) /*! * @brief アイテムの残り所持数メッセージを表示する / - * Describe an item in the p_ptr->inventory_list. + * Describe an item in the inventory. * @param item 残量を表示したいプレイヤーのアイテム所持スロット * @return なし */ @@ -4942,9 +4879,25 @@ void inven_item_describe(INVENTORY_IDX item) } +void vary_item(INVENTORY_IDX item, ITEM_NUMBER num) +{ + if (item >= 0) + { + inven_item_increase(item, num); + inven_item_describe(item); + inven_item_optimize(item); + } + else + { + floor_item_increase(0 - item, num); + floor_item_describe(0 - item); + floor_item_optimize(0 - item); + } +} + /*! * @brief アイテムを増減させ残り所持数メッセージを表示する / - * Increase the "number" of an item in the p_ptr->inventory_list + * Increase the "number" of an item in the inventory * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット * @param num 増やしたい量 * @return なし @@ -4981,10 +4934,10 @@ void inven_item_increase(INVENTORY_IDX item, ITEM_NUMBER num) { if ((item == INVEN_RARM) || (item == INVEN_LARM)) { - if (!has_melee_weapon(INVEN_RARM + INVEN_LARM - item)) + if (!has_melee_weapon(p_ptr, INVEN_RARM + INVEN_LARM - item)) { /* Clear all temporary elemental brands */ - set_ele_attack(0, 0); + set_ele_attack(p_ptr, 0, 0); } } } @@ -4993,7 +4946,7 @@ void inven_item_increase(INVENTORY_IDX item, ITEM_NUMBER num) /*! * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する / - * Erase an p_ptr->inventory_list slot if it has no more items + * Erase an inventory slot if it has no more items * @param item 消去したいプレイヤーのアイテム所持スロット * @return なし */ @@ -5013,7 +4966,7 @@ void inven_item_optimize(INVENTORY_IDX item) int i; /* One less item */ - inven_cnt--; + p_ptr->inven_cnt--; /* Slide everything down */ for (i = item; i < INVEN_PACK; i++) @@ -5032,7 +4985,7 @@ void inven_item_optimize(INVENTORY_IDX item) else { /* One less item */ - equip_cnt--; + p_ptr->equip_cnt--; /* Erase the empty slot */ object_wipe(&p_ptr->inventory_list[item]); @@ -5054,7 +5007,7 @@ void inven_item_optimize(INVENTORY_IDX item) */ void floor_item_charges(INVENTORY_IDX item) { - object_type *o_ptr = ¤t_floor_ptr->o_list[item]; + object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[item]; /* Require staff/wand */ if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return; @@ -5095,7 +5048,7 @@ void floor_item_charges(INVENTORY_IDX item) */ void floor_item_describe(INVENTORY_IDX item) { - object_type *o_ptr = ¤t_floor_ptr->o_list[item]; + object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[item]; GAME_TEXT o_name[MAX_NLEN]; object_desc(o_name, o_ptr, 0); @@ -5126,7 +5079,7 @@ void floor_item_describe(INVENTORY_IDX item) */ void floor_item_increase(INVENTORY_IDX item, ITEM_NUMBER num) { - object_type *o_ptr = ¤t_floor_ptr->o_list[item]; + object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[item]; /* Apply */ num += o_ptr->number; @@ -5151,7 +5104,7 @@ void floor_item_increase(INVENTORY_IDX item, ITEM_NUMBER num) */ void floor_item_optimize(INVENTORY_IDX item) { - object_type *o_ptr = ¤t_floor_ptr->o_list[item]; + object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[item]; /* Paranoia -- be sure it exists */ if (!o_ptr->k_idx) return; @@ -5174,7 +5127,7 @@ bool inven_carry_okay(object_type *o_ptr) int j; /* Empty slot? */ - if (inven_cnt < INVEN_PACK) return (TRUE); + if (p_ptr->inven_cnt < INVEN_PACK) return (TRUE); /* Similar slot? */ for (j = 0; j < INVEN_PACK; j++) @@ -5280,13 +5233,13 @@ bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr) /*! * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン / - * Add an item to the players p_ptr->inventory_list, and return the slot used. + * Add an item to the players inventory, and return the slot used. * @param o_ptr 拾うオブジェクトの構造体参照ポインタ * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。 * @details - * If the new item can combine with an existing item in the p_ptr->inventory_list,\n + * If the new item can combine with an existing item in the inventory,\n * it will do so, using "object_similar()" and "object_absorb()", else,\n - * the item will be placed into the "proper" location in the p_ptr->inventory_list.\n + * the item will be placed into the "proper" location in the inventory.\n *\n * This function can be used to "over-fill" the player's pack, but only\n * once, and such an action must trigger the "overflow" code immediately.\n @@ -5296,7 +5249,7 @@ bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr) * combined. This may be tricky. See "dungeon.c" for info.\n *\n * Note that this code must remove any location/stack information\n - * from the object once it is placed into the p_ptr->inventory_list.\n + * from the object once it is placed into the inventory.\n */ s16b inven_carry(object_type *o_ptr) { @@ -5329,7 +5282,7 @@ s16b inven_carry(object_type *o_ptr) } } - if (inven_cnt > INVEN_PACK) return (-1); + if (p_ptr->inven_cnt > INVEN_PACK) return (-1); /* Find an empty slot */ for (j = 0; j <= INVEN_PACK; j++) @@ -5392,7 +5345,7 @@ s16b inven_carry(object_type *o_ptr) p_ptr->total_weight += (j_ptr->number * j_ptr->weight); /* Count the items */ - inven_cnt++; + p_ptr->inven_cnt++; p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER); p_ptr->window |= (PW_INVEN); @@ -5411,7 +5364,7 @@ s16b inven_carry(object_type *o_ptr) * Note that only one item at a time can be wielded per slot.\n * Note that taking off an item when "full" may cause that item\n * to fall to the ground.\n - * Return the p_ptr->inventory_list slot into which the item is placed.\n + * Return the inventory slot into which the item is placed.\n */ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt) { @@ -5434,8 +5387,6 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt) /* Verify */ if (amt > o_ptr->number) amt = o_ptr->number; q_ptr = &forge; - - /* Obtain a local object */ object_copy(q_ptr, o_ptr); /* Modify quantity */ @@ -5489,7 +5440,7 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt) /*! * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン / - * Drop (some of) a non-cursed p_ptr->inventory_list/equipment item + * Drop (some of) a non-cursed inventory/equipment item * @param item 所持テーブルのID * @param amt 落としたい個数 * @return なし @@ -5542,10 +5493,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) /* Drop it near the player */ (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x); - /* Modify, Describe, Optimize */ - inven_item_increase(item, -amt); - inven_item_describe(item); - inven_item_optimize(item); + vary_item(item, -amt); } @@ -5556,7 +5504,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt) * @details * Note special handling of the "overflow" slot */ -void combine_pack(void) +void combine_pack(player_type *owner_ptr) { int i, j, k; object_type *o_ptr; @@ -5570,7 +5518,7 @@ void combine_pack(void) /* Combine the pack (backwards) */ for (i = INVEN_PACK; i > 0; i--) { - o_ptr = &p_ptr->inventory_list[i]; + o_ptr = &owner_ptr->inventory_list[i]; /* Skip empty items */ if (!o_ptr->k_idx) continue; @@ -5580,7 +5528,7 @@ void combine_pack(void) { int max_num; - j_ptr = &p_ptr->inventory_list[j]; + j_ptr = &owner_ptr->inventory_list[j]; /* Skip empty items */ if (!j_ptr->k_idx) continue; @@ -5603,17 +5551,17 @@ void combine_pack(void) object_absorb(j_ptr, o_ptr); /* One object is gone */ - inven_cnt--; + owner_ptr->inven_cnt--; /* Slide everything down */ for (k = i; k < INVEN_PACK; k++) { /* Structure copy */ - p_ptr->inventory_list[k] = p_ptr->inventory_list[k+1]; + owner_ptr->inventory_list[k] = owner_ptr->inventory_list[k+1]; } /* Erase the "final" slot */ - object_wipe(&p_ptr->inventory_list[k]); + object_wipe(&owner_ptr->inventory_list[k]); } else { @@ -5641,7 +5589,7 @@ void combine_pack(void) } } - p_ptr->window |= (PW_INVEN); + owner_ptr->window |= (PW_INVEN); /* Take note */ combined = TRUE; @@ -5677,7 +5625,7 @@ void reorder_pack(void) for (i = 0; i < INVEN_PACK; i++) { /* Mega-Hack -- allow "proper" over-flow */ - if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break; + if ((i == INVEN_PACK) && (p_ptr->inven_cnt == INVEN_PACK)) break; o_ptr = &p_ptr->inventory_list[i]; @@ -5791,7 +5739,7 @@ void display_koff(KIND_OBJECT_IDX k_idx) } /* Print spells */ - print_spells(0, spells, num, 2, 0, use_realm); + print_spells(p_ptr, 0, spells, num, 2, 0, use_realm); } }