static bool _create_arrows(void) { int item, slot; object_type forge; item_tester_hook = _create_ammo_p; if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) return FALSE; object_prep(&forge, lookup_kind(TV_ARROW, m_bonus(1, p_ptr->lev)+ 1)); forge.number = (byte)rand_range(5, 10); apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART); obj_identify(&forge); forge.discount = 99; msg_print("You make some ammo."); if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } slot = inven_carry(&forge); if (slot >= 0) autopick_alter_item(slot, FALSE); return TRUE; }
static void refuel_torch(object_type *j_ptr, object_type *o_ptr, int item) { bitflag f[OF_SIZE]; bitflag g[OF_SIZE]; /* Refuel */ j_ptr->timeout += o_ptr->timeout + 5; /* Message */ msg("You combine the torches."); /* Transfer the LIGHT flag if refuelling from a torch with it to one without it */ object_flags(o_ptr, f); object_flags(j_ptr, g); if (of_has(f, OF_LIGHT) && !of_has(g, OF_LIGHT)) { of_on(j_ptr->flags, OF_LIGHT); if (!j_ptr->ego && o_ptr->ego) j_ptr->ego = o_ptr->ego; msg("Your torch shines further!"); } /* Over-fuel message */ if (j_ptr->timeout >= FUEL_TORCH) { j_ptr->timeout = FUEL_TORCH; msg("Your torch is fully fueled."); } /* Refuel message */ else { msg("Your torch glows more brightly."); } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Redraw stuff */ p_ptr->redraw |= (PR_EQUIP); }
/********************************************************************** * Powers **********************************************************************/ static void _absorb_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Absorb Weapon"); break; case SPELL_DESC: var_set_string(res, "Destroys a single weapon, absorbing the essence of its power."); break; case SPELL_CAST: { object_type * o_ptr; int item; char o_name[MAX_NLEN]; var_set_bool(res, FALSE); item_tester_hook = object_is_melee_weapon; if (!get_item(&item, "Absorb which item? ", "You have nothing to absorb.", USE_INVEN | USE_FLOOR)) break; if (item >= 0) o_ptr = &inventory[item]; else o_ptr = &o_list[0 - item]; object_desc(o_name, o_ptr, OD_NAME_ONLY); msg_format("You absorb the power of %s!", o_name); _absorb(o_ptr); if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } var_set_bool(res, TRUE); break; } default: default_spell(cmd, res); break; } }
static void do_cmd_refill_torch(object_type *torch) { int item; object_type *o_ptr; item_tester_hook = _is_torch; if (!get_item(&item, "Refuel with which torch? ", "You have no extra torches.", USE_INVEN | USE_FLOOR)) return; if (item >= 0) o_ptr = &inventory[item]; else o_ptr = &o_list[0 - item]; energy_use = 50; torch->xtra4 += o_ptr->xtra4 + 5; msg_print("You combine the torches."); if (_lite_is_darkness(o_ptr) && torch->xtra4 > 0) { torch->xtra4 = 0; msg_print("Your torch has gone out!"); } else if (_lite_is_darkness(o_ptr) || _lite_is_darkness(torch)) { torch->xtra4 = 0; msg_print("Curiously, your torch does not light."); } else if (torch->xtra4 >= FUEL_TORCH) { torch->xtra4 = FUEL_TORCH; msg_print("Your torch is fully fueled."); } else msg_print("Your torch glows more brightly."); if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } p_ptr->update |= PU_TORCH; }
/* * Refill the players lamp (from the pack or floor) */ static void do_cmd_refill_lamp(object_type *lantern) { int item; object_type *o_ptr; item_tester_hook = item_tester_refill_lantern; if (!get_item(&item, "Refill with which flask? ", "You have no flasks of oil.", USE_INVEN | USE_FLOOR)) return; if (item >= 0) o_ptr = &inventory[item]; else o_ptr = &o_list[0 - item]; energy_use = 50; lantern->xtra4 += o_ptr->xtra4; msg_print("You fuel your lamp."); if ( _lite_is_darkness(o_ptr) && lantern->xtra4 > 0) { lantern->xtra4 = 0; msg_print("Your lamp has gone out!"); } else if (_lite_is_darkness(o_ptr) || _lite_is_darkness(lantern)) { lantern->xtra4 = 0; msg_print("Curiously, your lamp doesn't light."); } else if (lantern->xtra4 >= FUEL_LAMP) { lantern->xtra4 = FUEL_LAMP; msg_print("Your lamp is full."); } if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } p_ptr->update |= PU_TORCH; }
static bool _create_bolts(void) { int item, slot; object_type forge; item_tester_hook = _create_ammo_p; if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) return FALSE; /* Note: You won't ever get Steel Bolts this way since I:18:1 is shared with by Bolts and Steel Bolts and lookup_kind() picks the first match in k_info.txt. However, getting Steel from Bones/Junk would be a bit odd anyway ... */ object_prep(&forge, lookup_kind(TV_BOLT, m_bonus(1, p_ptr->lev)+ 1)); forge.number = (byte)rand_range(4, 8); apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART); obj_identify(&forge); forge.discount = 99; msg_print("You make some ammo."); if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } slot = inven_carry(&forge); if (slot >= 0) autopick_alter_item(slot, FALSE); return TRUE; }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt; int old_number; object_type *o_ptr; char o_name[80]; char out_val[160]; cptr q, s; /* Get an item */ q = "Destroy which item? "; s = "You have nothing to destroy."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; /* Describe the object */ old_number = o_ptr->number; o_ptr->number = amt; object_desc(o_name, o_ptr, TRUE, 3); o_ptr->number = old_number; /* Verify destruction */ if (verify_destroy) { sprintf(out_val, "Really destroy %s? ", o_name); if (!get_check(out_val)) return; } /* Take a turn */ p_ptr->energy_use = 100; /* Artifacts cannot be destroyed */ if (artifact_p(o_ptr)) { /* Message */ msg_format("You cannot destroy %s.", o_name); /* Don't mark id'ed objects */ if (object_known_p(o_ptr)) return; /* It has already been sensed */ if (o_ptr->ident & (IDENT_SENSE)) { /* Already sensed objects always get improved feelings */ if (cursed_p(o_ptr) || broken_p(o_ptr)) o_ptr->discount = INSCRIP_TERRIBLE; else o_ptr->discount = INSCRIP_SPECIAL; } else { /* Mark the object as indestructible */ o_ptr->discount = INSCRIP_INDESTRUCTIBLE; } /* Combine the pack */ p_ptr->notice |= (PN_COMBINE); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); p_ptr->redraw |= (PR_EQUIPPY); /* Done */ return; } /* Message */ msg_format("You destroy %s.", o_name); /* Eliminate the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt = 1; int old_number; bool force = FALSE; object_type *o_ptr; char o_name[MAX_NLEN]; char out_val[160]; cptr q, s; /* Hack -- force destruction */ if (command_arg > 0) force = TRUE; /* Get an item */ #ifdef JP q = "どのアイテムを壊しますか? "; s = "壊せるアイテムを持っていない。"; #else q = "Destroy which item? "; s = "You have nothing to destroy."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Verify unless quantity given */ if (!force && (!(auto_destroy && (object_value(o_ptr) < 1)))) { object_desc(o_name, o_ptr, OD_OMIT_PREFIX); /* Make a verification */ sprintf(out_val, #ifdef JP "本当に%sを壊しますか? [y/n/Auto]", #else "Really destroy %s? [y/n/Auto]", #endif o_name); msg_print(NULL); /* HACK : Add the line to message buffer */ message_add(out_val); p_ptr->window |= (PW_MESSAGE); window_stuff(); /* Get an acceptable answer */ while (TRUE) { char i; /* Prompt */ prt(out_val, 0, 0); i = inkey(); /* Erase the prompt */ prt("", 0, 0); if (i == 'y' || i == 'Y') { break; } if (i == ESCAPE || i == 'n' || i == 'N') { /* Cancel */ return; } if (i == 'A') { /* Add an auto-destroy preference line */ if (autopick_autoregister(o_ptr)) { /* Auto-destroy it */ autopick_alter_item(item, TRUE); } /* The object is already destroyed. */ return; } } /* while (TRUE) */ } /* See how many items */ if (o_ptr->number > 1) { /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; } /* Describe the object */ old_number = o_ptr->number; o_ptr->number = amt; object_desc(o_name, o_ptr, 0); o_ptr->number = old_number; /* Take a turn */ energy_use = 100; /* Can the player destroy the object? */ if (!can_player_destroy_object(o_ptr)) { /* Don't take a turn */ energy_use = 0; /* Message */ #ifdef JP msg_format("%sは破壊不可能だ。", o_name); #else msg_format("You cannot destroy %s.", o_name); #endif /* Done */ return; } /* Message */ #ifdef JP msg_format("%sを壊した。", o_name); #else msg_format("You destroy %s.", o_name); #endif sound(SOUND_DESTROY); if (high_level_book(o_ptr)) { bool gain_expr = FALSE; if (p_ptr->pclass == CLASS_WARRIOR) { gain_expr = TRUE; } else if (p_ptr->pclass == CLASS_PALADIN) { if (p_ptr->realm1 == REALM_LIFE) { if (o_ptr->tval != TV_LIFE_BOOK) gain_expr = TRUE; } else { if (o_ptr->tval == TV_LIFE_BOOK) gain_expr = TRUE; } } if (gain_expr && (p_ptr->exp < PY_MAX_EXP)) { s32b tester_exp = p_ptr->max_exp / 20; if (tester_exp > 10000) tester_exp = 10000; if (o_ptr->sval < 3) tester_exp /= 4; if (tester_exp < 1) tester_exp = 1; #ifdef JP msg_print("更に経験を積んだような気がする。"); #else msg_print("You feel more experienced."); #endif gain_exp(tester_exp * amt); } } /* Reduce the charges of rods/wands */ reduce_charges(o_ptr, amt); /* Eliminate the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* Absorb Magic */ static bool gain_magic(void) { int item; int pval; object_type *o_ptr; int idx; char o_name[MAX_NLEN]; item_tester_hook = item_tester_hook_recharge; if (!get_item(&item, "Gain power of which item? ", "You have nothing to gain power from.", (USE_INVEN | USE_FLOOR))) return (FALSE); if (item >= 0) o_ptr = &inventory[item]; else o_ptr = &o_list[0 - item]; if (!object_is_known(o_ptr)) { msg_print("You need to identify before absorbing."); return FALSE; } if (o_ptr->timeout) { msg_print("This item is still charging."); return FALSE; } idx = _find_idx(o_ptr->tval, o_ptr->sval); if (idx < 0) /* Bug? Tables need to be updated for every new device ... */ { msg_print("You can't eat that!"); return FALSE; } pval = o_ptr->pval; if (o_ptr->tval == TV_ROD) { p_ptr->magic_num2[idx] += o_ptr->number; if (p_ptr->magic_num2[idx] > 99) p_ptr->magic_num2[idx] = 99; } else { int num; for (num = o_ptr->number; num; num--) { int gain_num = pval; if (o_ptr->tval == TV_WAND) gain_num = (pval + num - 1) / num; if (p_ptr->magic_num2[idx]) gain_num = (gain_num + randint0(2))/2; p_ptr->magic_num2[idx] += gain_num; if (p_ptr->magic_num2[idx] > 99) p_ptr->magic_num2[idx] = 99; p_ptr->magic_num1[idx] += pval * _EATER_CHARGE; if (p_ptr->magic_num1[idx] > 99 * _EATER_CHARGE) p_ptr->magic_num1[idx] = 99 * _EATER_CHARGE; if (p_ptr->magic_num1[idx] > p_ptr->magic_num2[idx] * _EATER_CHARGE) p_ptr->magic_num1[idx] = p_ptr->magic_num2[idx] * _EATER_CHARGE; if (o_ptr->tval == TV_WAND) pval -= (pval + num - 1) / num; } } object_desc(o_name, o_ptr, 0); msg_format("You absorb magic of %s.", o_name); /* Eliminate the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -999); inven_item_describe(item); inven_item_optimize(item); } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -999); floor_item_describe(0 - item); floor_item_optimize(0 - item); } return TRUE; }
/* * Use an object the right way. * * There may be a BIG problem with any "effect" that can cause "changes" * to the inventory. For example, a "scroll of recharging" can cause * a wand/staff to "disappear", moving the inventory up. Luckily, the * scrolls all appear BEFORE the staffs/wands, so this is not a problem. * But, for example, a "staff of recharging" could cause MAJOR problems. * In such a case, it will be best to either (1) "postpone" the effect * until the end of the function, or (2) "change" the effect, say, into * giving a staff "negative" charges, or "turning a staff into a stick". * It seems as though a "rod of recharging" might in fact cause problems. * The basic problem is that the act of recharging (and destroying) an * item causes the inducer of that action to "move", causing "o_ptr" to * no longer point at the correct item, with horrifying results. */ void do_cmd_use(cmd_code code, cmd_arg args[]) { int item = args[0].item; object_type *o_ptr = object_from_item_idx(item); int effect; bool ident = FALSE, used = FALSE; bool was_aware = object_flavor_is_aware(o_ptr); int dir = 5; int px = p_ptr->px, py = p_ptr->py; int snd, boost, level; use_type use; int items_allowed = 0; /* Determine how this item is used. */ if (obj_is_rod(o_ptr)) { if (!obj_can_zap(o_ptr)) { msg("That rod is still charging."); return; } use = USE_TIMEOUT; snd = MSG_ZAP_ROD; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_wand(o_ptr)) { if (!obj_has_charges(o_ptr)) { msg("That wand has no charges."); return; } use = USE_CHARGE; snd = MSG_ZAP_ROD; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_staff(o_ptr)) { if (!obj_has_charges(o_ptr)) { msg("That staff has no charges."); return; } use = USE_CHARGE; snd = MSG_USE_STAFF; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_food(o_ptr)) { use = USE_SINGLE; snd = MSG_EAT; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_potion(o_ptr)) { use = USE_SINGLE; snd = MSG_QUAFF; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_scroll(o_ptr)) { /* Check player can use scroll */ if (!player_can_read()) return; use = USE_SINGLE; snd = MSG_GENERIC; items_allowed = USE_INVEN | USE_FLOOR; } else if (obj_is_activatable(o_ptr)) { if (!obj_can_activate(o_ptr)) { msg("That item is still charging."); return; } use = USE_TIMEOUT; snd = MSG_ACT_ARTIFACT; items_allowed = USE_EQUIP; } else { msg("The item cannot be used at the moment"); } /* Check if item is within player's reach. */ if (items_allowed == 0 || !item_is_available(item, NULL, items_allowed)) { msg("You cannot use that item from its current location."); return; } /* track the object used */ track_object(item); /* Figure out effect to use */ effect = object_effect(o_ptr); /* If the item requires a direction, get one (allow cancelling) */ if (obj_needs_aim(o_ptr)) dir = args[1].direction; /* Check for use if necessary, and execute the effect */ if ((use != USE_CHARGE && use != USE_TIMEOUT) || check_devices(o_ptr)) { int beam = beam_chance(o_ptr->tval); /* Special message for artifacts */ if (o_ptr->artifact) { msgt(snd, "You activate it."); if (o_ptr->artifact->effect_msg) activation_message(o_ptr, o_ptr->artifact->effect_msg); level = o_ptr->artifact->level; } else { /* Make a noise! */ sound(snd); level = o_ptr->kind->level; } /* A bit of a hack to make ID work better. -- Check for "obvious" effects beforehand. */ if (effect_obvious(effect)) object_flavor_aware(o_ptr); /* Boost damage effects if skill > difficulty */ boost = MAX(p_ptr->state.skills[SKILL_DEVICE] - level, 0); /* Do effect */ used = effect_do(effect, &ident, was_aware, dir, beam, boost); /* Quit if the item wasn't used and no knowledge was gained */ if (!used && (was_aware || !ident)) return; } /* If the item is a null pointer or has been wiped, be done now */ if (!o_ptr || !o_ptr->kind) return; if (ident) object_notice_effect(o_ptr); /* Food feeds the player */ if (o_ptr->tval == TV_FOOD || o_ptr->tval == TV_POTION) (void)set_food(p_ptr->food + o_ptr->pval[DEFAULT_PVAL]); /* Use the turn */ p_ptr->energy_use = 100; /* Mark as tried and redisplay */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); p_ptr->redraw |= (PR_INVEN | PR_EQUIP | PR_OBJECT); /* * If the player becomes aware of the item's function, then mark it as * aware and reward the player with some experience. Otherwise, mark * it as "tried". */ if (ident && !was_aware) { /* Object level */ int lev = o_ptr->kind->level; object_flavor_aware(o_ptr); if (o_ptr->tval == TV_ROD) object_notice_everything(o_ptr); player_exp_gain(p_ptr, (lev + (p_ptr->lev / 2)) / p_ptr->lev); p_ptr->notice |= PN_SQUELCH; } else if (used) { object_flavor_tried(o_ptr); } /* If there are no more of the item left, then we're done. */ if (!o_ptr->number) return; /* Chargeables act differently to single-used items when not used up */ if (used && use == USE_CHARGE) { /* Use a single charge */ o_ptr->pval[DEFAULT_PVAL]--; /* Describe charges */ if (item >= 0) inven_item_charges(item); else floor_item_charges(0 - item); } else if (used && use == USE_TIMEOUT) { /* Artifacts use their own special field */ if (o_ptr->artifact) o_ptr->timeout = randcalc(o_ptr->artifact->time, 0, RANDOMISE); else o_ptr->timeout += randcalc(o_ptr->kind->time, 0, RANDOMISE); } else if (used && use == USE_SINGLE) { /* Destroy a potion in the pack */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Destroy a potion on the floor */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } } /* Hack to make Glyph of Warding work properly */ if (cave->feat[py][px] == FEAT_GLYPH) { /* Push objects off the grid */ if (cave->o_idx[py][px]) push_object(py, px); } }
static void refill_lamp(object_type *j_ptr, object_type *o_ptr, int item) { /* Refuel */ j_ptr->timeout += o_ptr->timeout ? o_ptr->timeout : o_ptr->pval[DEFAULT_PVAL]; /* Message */ msg("You fuel your lamp."); /* Comment */ if (j_ptr->timeout >= FUEL_LAMP) { j_ptr->timeout = FUEL_LAMP; msg("Your lamp is full."); } /* Refilled from a lantern */ if (o_ptr->sval == SV_LIGHT_LANTERN) { /* Unstack if necessary */ if (o_ptr->number > 1) { object_type *i_ptr; object_type object_type_body; /* Get local object */ i_ptr = &object_type_body; /* Obtain a local object */ object_copy(i_ptr, o_ptr); /* Modify quantity */ i_ptr->number = 1; /* Remove fuel */ i_ptr->timeout = 0; /* Unstack the used item */ o_ptr->number--; p_ptr->total_weight -= i_ptr->weight; /* Carry or drop */ if (item >= 0) item = inven_carry(p_ptr, i_ptr); else drop_near(cave, i_ptr, 0, p_ptr->py, p_ptr->px, FALSE); } /* Empty a single lantern */ else { /* No more fuel */ o_ptr->timeout = 0; } /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* Redraw stuff */ p_ptr->redraw |= (PR_INVEN); } /* Refilled from a flask */ else { /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Redraw stuff */ p_ptr->redraw |= (PR_EQUIP); }
/* * Refill the player's lamp (from the pack or floor) */ void do_cmd_refuel_lamp(object_type *default_o_ptr, int default_item) { int item; object_type *o_ptr; object_type *j_ptr; cptr q, s; // use specified item if possible if (default_o_ptr != NULL) { o_ptr = default_o_ptr; item = default_item; } /* Get an item */ else { /* Restrict the choices */ item_tester_hook = item_tester_refuel_lantern; /* Get an item */ q = "Refill with which source of oil? "; s = "You have no sources of oil."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } } /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; /* Get the lantern */ j_ptr = &inventory[INVEN_LITE]; /* Refuel from a latern */ if (o_ptr->sval == SV_LIGHT_LANTERN) { j_ptr->timeout += o_ptr->timeout; } /* Refuel from a flask */ else { j_ptr->timeout += o_ptr->pval; } /* Message */ msg_print("You fuel your lamp."); /* Comment */ if (j_ptr->timeout >= FUEL_LAMP) { j_ptr->timeout = FUEL_LAMP; msg_print("Your lamp is full."); } /* Refilled from a latern */ if (o_ptr->sval == SV_LIGHT_LANTERN) { /* Unstack if necessary */ if (o_ptr->number > 1) { object_type *i_ptr; object_type object_type_body; /* Get local object */ i_ptr = &object_type_body; /* Obtain a local object */ object_copy(i_ptr, o_ptr); /* Modify quantity */ i_ptr->number = 1; /* Remove fuel */ i_ptr->timeout = 0; /* Unstack the used item */ o_ptr->number--; /* Carry or drop */ if (item >= 0) item = inven_carry(i_ptr); else drop_near(i_ptr, 0, p_ptr->py, p_ptr->px); } /* Empty a single latern */ else { /* No more fuel */ o_ptr->timeout = 0; } /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* Window stuff */ p_ptr->window |= (PW_INVEN); } /* Refilled from a flask */ else { /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } } /* Window stuff */ p_ptr->window |= (PW_EQUIP); // get another chance to identify the lamp ident_on_wield(j_ptr); }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt; int old_number; int old_charges = 0; object_type *o_ptr; char o_name[80]; char out_val[160]; cptr q, s; item_tester_hook = item_tester_hook_destroy; // Special case for prising Silmarils from the Iron Crown of Morgoth o_ptr = &o_list[cave_o_idx[p_ptr->py][p_ptr->px]]; if ((o_ptr->name1 >= ART_MORGOTH_1) && (o_ptr->name1 <= ART_MORGOTH_3)) { // Select the melee weapon o_ptr = &inventory[INVEN_WIELD]; // No weapon if (!o_ptr->k_idx) { msg_print("To prise a Silmaril from the crown, you would need to wield a weapon."); } // Wielding a weapon else { if (get_check("Will you try to prise a Silmaril from the Iron Crown? ")) { prise_silmaril(); /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; return; } } } /* Get an item */ q = "Destroy which item? "; s = "You have nothing to destroy."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } // Special case for Iron Crown of Morgoth, if it has Silmarils left if ((o_ptr->name1 >= ART_MORGOTH_1) && (o_ptr->name1 <= ART_MORGOTH_3)) { if (item >= 0) { msg_print("You would have to put it down first."); } else { /* No weapon */ if (!o_ptr->k_idx) { msg_print("To prise a Silmaril from the crown, you would need to wield a weapon."); } else { msg_print("You decide to try to prise out a Silmaril after all."); prise_silmaril(); /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; return; } } } /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; /* Describe the object */ old_number = o_ptr->number; /* Hack, state the correct number of charges to be destroyed if staff*/ if ((o_ptr->tval == TV_STAFF) && (amt < o_ptr->number)) { /*save the number of charges*/ old_charges = o_ptr->pval; /*distribute the charges*/ o_ptr->pval -= o_ptr->pval * amt / o_ptr->number; o_ptr->pval = old_charges - o_ptr->pval; } /*hack - make sure we get the right amount displayed*/ o_ptr->number = amt; /*now describe with correct amount*/ object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); /*reverse the hack*/ o_ptr->number = old_number; /* Check for known special items */ strnfmt(out_val, sizeof(out_val), "Really destroy %s? ", o_name); if (!get_check(out_val)) return; /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; /* Message */ msg_format("You destroy %s.", o_name); /*hack, restore the proper number of charges after the messages have printed * so the proper number of charges are destroyed*/ if (old_charges) o_ptr->pval = old_charges; /* Eliminate the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* * Refuel the players torch (from the pack or floor) */ static void do_cmd_refill_torch(void) { int item; object_type *o_ptr; object_type *j_ptr; cptr q, s; /* Restrict the choices */ item_tester_hook = item_tester_refill_torch; /* Get an item */ #ifdef JP q = "どの松明で明かりを強めますか? "; s = "他に松明がない。"; #else q = "Refuel with which torch? "; s = "You have no extra torches."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Take a partial turn */ energy_use = 50; /* Access the primary torch */ j_ptr = &inventory[INVEN_LITE]; /* Refuel */ j_ptr->xtra3 += o_ptr->xtra3 + 5; /* Message */ #ifdef JP msg_print("松明を結合した。"); #else msg_print("You combine the torches."); #endif /* Over-fuel message */ if (j_ptr->xtra3 >= FUEL_TORCH) { j_ptr->xtra3 = FUEL_TORCH; #ifdef JP msg_print("松明の寿命は十分だ。"); #else msg_print("Your torch is fully fueled."); #endif } /* Refuel message */ else { #ifdef JP msg_print("松明はいっそう明るく輝いた。"); #else msg_print("Your torch glows more brightly."); #endif } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); }
/* * Destroy an item */ void do_cmd_destroy(void) { int item, amt = 1; int old_number; bool force = FALSE; object_type *o_ptr; object_type forge; object_type *q_ptr = &forge; bool is_equipped = FALSE; char o_name[MAX_NLEN]; char out_val[MAX_NLEN+40]; cptr q, s; int mode = USE_INVEN | USE_FLOOR; if (p_ptr->pclass == CLASS_RUNE_KNIGHT) mode |= USE_EQUIP; if (p_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } /* Hack -- force destruction */ if (command_arg > 0) force = TRUE; /* Get an item */ q = "Destroy which item? "; s = "You have nothing to destroy."; if (!get_item(&item, q, s, mode)) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; is_equipped = equip_is_valid_slot(item); } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Hack for Rune Knight: They can destroy worn equipment, but only if it has the Sacrifice rune. get_item() is not smart enough to handle this restriction ... */ if (is_equipped && o_ptr->rune != RUNE_SACRIFICE) { msg_print("You must first remove that item before destroying it."); return; } /* Verify unless quantity given beforehand */ if (!force && (confirm_destroy || (object_value(o_ptr) > 0))) { object_desc(o_name, o_ptr, OD_OMIT_PREFIX); /* Make a verification */ sprintf(out_val, "Really destroy %s? [y/n/Auto]", o_name); msg_print(NULL); /* HACK : Add the line to message buffer */ message_add(out_val); p_ptr->window |= (PW_MESSAGE); window_stuff(); /* Get an acceptable answer */ while (TRUE) { char i; /* Prompt */ prt(out_val, 0, 0); i = inkey(); /* Erase the prompt */ prt("", 0, 0); if (i == 'y' || i == 'Y') { break; } if (i == ESCAPE || i == 'n' || i == 'N') { /* Cancel */ return; } if (i == 'A') { /* Add an auto-destroy preference line */ if (autopick_autoregister(o_ptr)) { /* Auto-destroy it */ autopick_alter_item(item, TRUE); } /* The object is already destroyed. */ return; } } /* while (TRUE) */ } /* See how many items */ if (o_ptr->number > 1) { /* Get a quantity */ amt = get_quantity(NULL, o_ptr->number); /* Allow user abort */ if (amt <= 0) return; } /* Describe the object */ old_number = o_ptr->number; o_ptr->number = amt; object_desc(o_name, o_ptr, 0); o_ptr->number = old_number; /* Take a turn */ energy_use = 100; /* Artifacts cannot be destroyed */ if (!can_player_destroy_object(o_ptr)) { energy_use = 0; /* Message */ msg_format("You cannot destroy %s.", o_name); /* Done */ return; } object_copy(q_ptr, o_ptr); stats_on_p_destroy(o_ptr, amt); if (prace_is_(RACE_MON_JELLY)) jelly_eat_object(o_ptr); else if (prace_is_(RACE_MON_SWORD) && object_is_melee_weapon(o_ptr)) sword_absorb_object(o_ptr); else if (prace_is_(RACE_MON_RING) && object_is_jewelry(o_ptr)) ring_absorb_object(o_ptr); else msg_format("You destroy %s.", o_name); if (o_ptr->rune == RUNE_SACRIFICE) { int add_hp = is_equipped ? p_ptr->mhp : p_ptr->mhp/3; int add_sp = is_equipped ? p_ptr->msp : p_ptr->msp/3; msg_print("You feel a surge of wondrous power enter your body."); p_ptr->chp = MIN(p_ptr->mhp, p_ptr->chp + add_hp); p_ptr->chp_frac = 0; p_ptr->csp = MIN(p_ptr->msp, p_ptr->csp + add_sp); p_ptr->csp_frac = 0; p_ptr->redraw |= (PR_MANA); p_ptr->window |= (PW_PLAYER); p_ptr->window |= (PW_SPELL); p_ptr->redraw |= (PR_HP); if (is_equipped) { blast_object(o_ptr); o_ptr->curse_flags = TRC_HEAVY_CURSE; } } else if (is_equipped) blast_object(o_ptr); sound(SOUND_DESTITEM); /* Reduce the charges of rods/wands */ reduce_charges(o_ptr, amt); /* Eliminate the item (from the pack) */ if (item >= 0) { if (!is_equipped) { inven_item_increase(item, -amt); inven_item_describe(item); inven_item_optimize(item); } } /* Eliminate the item (from the floor) */ else { floor_item_increase(0 - item, -amt); floor_item_describe(0 - item); floor_item_optimize(0 - item); } if ( p_ptr->pclass == CLASS_NECROMANCER && (q_ptr->tval == TV_LIFE_BOOK || q_ptr->tval == TV_CRUSADE_BOOK) ) { int sp = 0; int osp = p_ptr->csp; switch (q_ptr->sval) { case 0: sp = 10; break; case 1: sp = 25; break; case 2: sp = 100; break; case 3: sp = 666; break; } p_ptr->csp += sp; if (p_ptr->csp >= p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; } if (p_ptr->csp > osp) msg_print("You feel your head clear."); p_ptr->redraw |= (PR_MANA); } if (high_level_book(q_ptr)) { bool gain_expr = FALSE; if (p_ptr->prace == RACE_ANDROID) { } else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER)) { gain_expr = TRUE; } else if (p_ptr->pclass == CLASS_PALADIN) { if (is_good_realm(p_ptr->realm1)) { if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE; } else { if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE; } } if (gain_expr && (p_ptr->exp < PY_MAX_EXP)) { s32b tester_exp = p_ptr->max_exp / 20; if (tester_exp > 10000) tester_exp = 10000; if (q_ptr->sval < 3) tester_exp /= 4; if (tester_exp<1) tester_exp = 1; msg_print("You feel more experienced."); gain_exp(tester_exp * amt); } } if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK) { virtue_add(VIRTUE_UNLIFE, 1); virtue_add(VIRTUE_VITALITY, -1); } else if ( high_level_book(q_ptr) && (q_ptr->tval == TV_DEATH_BOOK || q_ptr->tval == TV_NECROMANCY_BOOK) ) { virtue_add(VIRTUE_UNLIFE, -1); virtue_add(VIRTUE_VITALITY, 1); } if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d) virtue_add(VIRTUE_ENCHANTMENT, -1); if (object_value_real(q_ptr) > 30000) virtue_add(VIRTUE_SACRIFICE, 2); else if (object_value_real(q_ptr) > 10000) virtue_add(VIRTUE_SACRIFICE, 1); if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0) virtue_add(VIRTUE_HARMONY, 1); if (equip_is_valid_slot(item)) calc_android_exp(); }
/* * Refill the players lamp (from the pack or floor) */ static void do_cmd_refill_lamp(void) { int item; object_type *o_ptr; object_type *j_ptr; cptr q, s; /* Restrict the choices */ item_tester_hook = item_tester_refill_lantern; /* Get an item */ q = "Refill with which source of oil? "; s = "You have no sources of oil."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Take a partial turn */ p_ptr->energy_use = 50; /* Get the lantern */ j_ptr = &inventory[INVEN_LIGHT]; /* Refuel */ j_ptr->pval += o_ptr->pval; /* Message */ msg_print("You fuel your lamp."); /* Comment */ if (j_ptr->pval >= FUEL_LAMP) { j_ptr->pval = FUEL_LAMP; msg_print("Your lamp is full."); } /* Use fuel from a lantern */ if (o_ptr->sval == SV_LIGHT_LANTERN) { /* No more fuel */ o_ptr->pval = 0; /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* Window stuff */ p_ptr->window |= (PW_INVEN); } /* Decrease the item (from the pack) */ else if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Window stuff */ p_ptr->window |= (PW_EQUIP); }
/* * Eat some food (from the pack or floor) */ void do_cmd_eat_food(void) { int item, lev; bool ident; object_type *o_ptr; cptr q, s; /* Restrict choices to food */ item_tester_tval = TV_FOOD; /* Get an item */ q = "Eat which item? "; s = "You have nothing to eat."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Sound */ sound(MSG_EAT); /* Take a turn */ p_ptr->energy_use = 100; /* Identity not known yet */ ident = FALSE; /* Object level */ lev = k_info[o_ptr->k_idx].level; /* Eat the food */ use_object(o_ptr, &ident); /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* We have tried it */ object_tried(o_ptr); /* The player is now aware of the object */ if (ident && !object_aware_p(o_ptr)) { object_aware(o_ptr); gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev); } /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Destroy a food in the pack */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Destroy a food on the floor */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* * Read a scroll (from the pack or floor). * * Certain scrolls can be "aborted" without losing the scroll. These * include scrolls with no effects but recharge or identify, which are * cancelled before use. XXX Reading them still takes a turn, though. */ void do_cmd_read_scroll(void) { int item, used_up, lev; bool ident; object_type *o_ptr; cptr q, s; /* Check some conditions */ if (p_ptr->blind) { msg_print("You can't see anything."); return; } if (no_lite()) { msg_print("You have no light to read by."); return; } if (p_ptr->confused) { msg_print("You are too confused!"); return; } /* Restrict choices to scrolls */ item_tester_tval = TV_SCROLL; /* Get an item */ q = "Read which scroll? "; s = "You have no scrolls to read."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Take a turn */ p_ptr->energy_use = 100; /* Not identified yet */ ident = FALSE; /* Object level */ lev = k_info[o_ptr->k_idx].level; /* Read the scroll */ used_up = use_object(o_ptr, &ident); /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* The item was tried */ object_tried(o_ptr); /* An identification was made */ if (ident && !object_aware_p(o_ptr)) { object_aware(o_ptr); gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev); } /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Hack -- allow certain scrolls to be "preserved" */ if (!used_up) return; /* Destroy a scroll in the pack */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Destroy a scroll on the floor */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* * Quaff a potion (from the pack or the floor) */ void do_cmd_quaff_potion(void) { int item, lev; bool ident; object_type *o_ptr; cptr q, s; /* Restrict choices to potions */ item_tester_tval = TV_POTION; /* Get an item */ q = "Quaff which potion? "; s = "You have no potions to quaff."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Sound */ sound(MSG_QUAFF); /* Take a turn */ p_ptr->energy_use = 100; /* Not identified yet */ ident = FALSE; /* Object level */ lev = k_info[o_ptr->k_idx].level; /* Quaff the potion */ use_object(o_ptr, &ident); /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* The item has been tried */ object_tried(o_ptr); /* An identification was made */ if (ident && !object_aware_p(o_ptr)) { object_aware(o_ptr); gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev); } /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Destroy a potion in the pack */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Destroy a potion on the floor */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } }
/* * Refuel the player's torch (from the pack or floor) */ void do_cmd_refuel_torch(object_type *default_o_ptr, int default_item) { int item; object_type *o_ptr; object_type *j_ptr; cptr q, s; // use specified item if possible if (default_o_ptr != NULL) { o_ptr = default_o_ptr; item = default_item; } /* Get an item */ else { /* Restrict the choices */ item_tester_hook = item_tester_refuel_torch; /* Get an item */ q = "Refuel with which torch? "; s = "You have no extra torches."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } } /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; /* Get the primary torch */ j_ptr = &inventory[INVEN_LITE]; /* Refuel */ j_ptr->timeout += o_ptr->timeout + 5; /* Message */ msg_print("You combine the torches."); /* Over-fuel message */ if (j_ptr->timeout >= FUEL_TORCH) { j_ptr->timeout = FUEL_TORCH; msg_print("Your torch is fully fueled."); } /* Refuel message */ else { msg_print("Your torch glows more brightly."); } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Window stuff */ p_ptr->window |= (PW_EQUIP); // get another chance to identify the torch ident_on_wield(j_ptr); }
/* * Refuel the players torch (from the pack or floor) */ static void do_cmd_refill_torch(void) { int item; object_type *o_ptr; object_type *j_ptr; cptr q, s; /* Restrict the choices */ item_tester_hook = item_tester_refill_torch; /* Get an item */ q = "Refuel with which torch? "; s = "You have no extra torches."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Take a partial turn */ p_ptr->energy_use = 50; /* Get the primary torch */ j_ptr = &inventory[INVEN_LIGHT]; /* Refuel */ j_ptr->pval += o_ptr->pval + 5; /* Message */ msg_print("You combine the torches."); /* Over-fuel message */ if (j_ptr->pval >= FUEL_TORCH) { j_ptr->pval = FUEL_TORCH; msg_print("Your torch is fully fueled."); } /* Refuel message */ else { msg_print("Your torch glows more brightly."); } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Window stuff */ p_ptr->window |= (PW_EQUIP); }
/* * Refill the players lamp (from the pack or floor) */ static void do_cmd_refill_lamp(void) { int item; int fuel; object_type *o_ptr; object_type *j_ptr; cptr q, s; /* Restrict the choices */ item_tester_hook = item_tester_refill_lantern; /* Get an item */ #ifdef JP q = "どの油つぼから注ぎますか? "; s = "油を補給するものがない。"; #else q = "Refill with which source of oil? "; s = "You have no sources of oil."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Take a partial turn */ energy_use = 50; /* Access the lantern */ j_ptr = &inventory[INVEN_LITE]; /* Lantern */ if (o_ptr->tval == TV_LITE && o_ptr->sval == SV_LITE_LANTERN) { fuel = o_ptr->xtra3; } /* Other (Flask of oil) */ else { fuel = o_ptr->pval; } /* Refuel */ j_ptr->xtra3 += fuel; /* Message */ #ifdef JP msg_print("ランプに油を注いだ。"); #else msg_print("You fuel your lamp."); #endif /* Comment */ if (j_ptr->xtra3 >= FUEL_LAMP) { j_ptr->xtra3 = FUEL_LAMP; #ifdef JP msg_print("ランプの油は一杯だ。"); #else msg_print("Your lamp is full."); #endif } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_describe(0 - item); floor_item_optimize(0 - item); } /* Recalculate torch */ p_ptr->update |= (PU_TORCH); }