/* * Hack -- load a screen dump from a file */ void do_cmd_load_screen(void) { s32b i, y, x; s32b wid, hgt; s32b len; byte a = 0; char c = ' '; bool okay = TRUE; PHYSFS_file *fff; char buf[1024]; /* Build the filename */ path_build(buf, 1024, TENGINE_DIR_USER, "dump.txt"); /* Append to the file */ fff = my_fopen(buf, "r"); /* Oops */ if (!fff) return; /* Retrieve the current screen size */ Term_get_size(&wid, &hgt); /* Enter "icky" mode */ character_icky++; /* Save the screen */ Term_save(); /* Clear the screen */ Term_clear(); /* Load the screen */ for (y = 0; okay; y++) { /* Get a line of data */ if (my_fgets(fff, buf, 1024)) okay = FALSE; /* Stop on blank line */ if (!buf[0]) break; /* Ignore off screen lines */ if (y >= hgt) continue; /* Get width */ len = strlen(buf); /* Truncate if it's longer than current screen width */ if (len > wid) len = wid; /* Show each row */ for (x = 0; x < len; x++) { /* Put the attr/char */ Term_draw(x, y, TERM_WHITE, buf[x]); } } /* Dump the screen */ for (y = 0; okay; y++) { /* Get a line of data */ if (my_fgets(fff, buf, 1024)) okay = FALSE; /* Stop on blank line */ if (!buf[0]) break; /* Ignore off screen lines */ if (y >= hgt) continue; /* Get width */ len = strlen(buf); /* Truncate if it's longer than current screen width */ if (len > wid) len = wid; /* Dump each row */ for (x = 0; x < len; x++) { /* Get the attr/char */ (void)(Term_what(x, y, &a, &c)); /* Look up the attr */ for (i = 0; i < 16; i++) { /* Use attr matches */ if (hack[i] == buf[x]) a = i; } /* Hack -- fake monochrome */ if (!use_color) a = TERM_WHITE; /* Put the attr/char */ Term_draw(x, y, a, c); } } /* Close it */ my_fclose(fff); /* Message */ msg_print("Screen dump loaded."); msg_print(NULL); /* Restore the screen */ Term_load(); /* Leave "icky" mode */ character_icky--; }
/* * Observe an item which has been *identify*-ed */ void do_cmd_observe(void) { int item; object_type *o_ptr; char o_name[MAX_NLEN]; cptr q, s; /* Get an item */ #ifdef JP q = "どのアイテムを調べますか? "; s = "調べられるアイテムがない。"; #else q = "Examine which item? "; s = "You have nothing to examine."; #endif if (!get_item(&item, q, s, (USE_EQUIP | 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]; } /* Require full knowledge */ if (!(o_ptr->ident & IDENT_MENTAL)) { #ifdef JP msg_print("このアイテムについて特に知っていることはない。"); #else msg_print("You have no special knowledge about that item."); #endif return; } /* Description */ object_desc(o_name, o_ptr, 0); /* Describe */ #ifdef JP msg_format("%sを調べている...", o_name); #else msg_format("Examining %s...", o_name); #endif /* Describe it fully */ if (!identify_fully_aux(o_ptr, TRUE)) #ifdef JP msg_print("特に変わったところはないようだ。"); #else msg_print("You see nothing special."); #endif }
/* * Places "streamers" of rock through dungeon * * Note that their are actually six different terrain features used * to represent streamers. Three each of magma and quartz, one for * basic vein, one with hidden gold, and one with known gold. The * hidden gold types are currently unused. */ void build_streamer(int feat, int chance) { int i, tx, ty; int y, x, dir; int dummy = 0; cave_type *c_ptr; feature_type *f_ptr; feature_type *streamer_ptr = &f_info[feat]; bool streamer_is_wall = have_flag(streamer_ptr->flags, FF_WALL) && !have_flag(streamer_ptr->flags, FF_PERMANENT); bool streamer_may_have_gold = have_flag(streamer_ptr->flags, FF_MAY_HAVE_GOLD); /* Hack -- Choose starting point */ y = rand_spread(cur_hgt / 2, cur_hgt / 6); x = rand_spread(cur_wid / 2, cur_wid / 6); /* Choose a random compass direction */ dir = ddd[randint0(8)]; /* Place streamer into dungeon */ while (dummy < SAFE_MAX_ATTEMPTS) { dummy++; /* One grid per density */ for (i = 0; i < DUN_STR_DEN; i++) { int d = DUN_STR_RNG; /* Pick a nearby grid */ while (1) { ty = rand_spread(y, d); tx = rand_spread(x, d); if (!in_bounds2(ty, tx)) continue; break; } /* Access the grid */ c_ptr = &cave[ty][tx]; f_ptr = &f_info[c_ptr->feat]; if (have_flag(f_ptr->flags, FF_MOVE) && (have_flag(f_ptr->flags, FF_WATER) || have_flag(f_ptr->flags, FF_LAVA))) continue; /* Do not convert permanent features */ if (have_flag(f_ptr->flags, FF_PERMANENT)) continue; /* Only convert "granite" walls */ if (streamer_is_wall) { if (!is_extra_grid(c_ptr) && !is_inner_grid(c_ptr) && !is_outer_grid(c_ptr) && !is_solid_grid(c_ptr)) continue; if (is_closed_door(c_ptr->feat)) continue; } if (c_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[m_list[c_ptr->m_idx].r_idx], 0))) { /* Delete the monster (if any) */ delete_monster(ty, tx); } if (c_ptr->o_idx && !have_flag(streamer_ptr->flags, FF_DROP)) { s16b this_o_idx, next_o_idx = 0; /* Scan all objects in the grid */ for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { /* Acquire object */ object_type *o_ptr = &o_list[this_o_idx]; /* Acquire next object */ next_o_idx = o_ptr->next_o_idx; /* Hack -- Preserve unknown artifacts */ if (object_is_fixed_artifact(o_ptr)) { /* Mega-Hack -- Preserve the artifact */ a_info[o_ptr->name1].cur_num = 0; if (cheat_peek) { char o_name[MAX_NLEN]; object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE)); msg_format("Artifact (%s) was deleted by streamer.", o_name); } } else if (o_ptr->name3) { /* Mega-Hack -- Preserve the artifact */ a_info[o_ptr->name3].cur_num = 0; if (cheat_peek) { char o_name[MAX_NLEN]; object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE)); msg_format("Artifact (%s) was deleted by streamer.", o_name); } } else if (cheat_peek && o_ptr->art_name) { msg_print("One of the random artifacts was deleted by streamer."); } } /* Delete objects */ delete_object(ty, tx); } /* Clear previous contents, add proper vein type */ c_ptr->feat = feat; /* Paranoia: Clear mimic field */ c_ptr->mimic = 0; if (streamer_may_have_gold) { /* Hack -- Add some known treasure */ if (one_in_(chance)) { cave_alter_feat(ty, tx, FF_MAY_HAVE_GOLD); } /* Hack -- Add some hidden treasure */ else if (one_in_(chance / 4)) { cave_alter_feat(ty, tx, FF_MAY_HAVE_GOLD); cave_alter_feat(ty, tx, FF_ENSECRET); } } } if (dummy >= SAFE_MAX_ATTEMPTS) { if (cheat_room) { msg_print("Warning! Could not place streamer!"); } return; } /* Advance the streamer */ y += ddy[dir]; x += ddx[dir]; /* Quit before leaving the dungeon */ if (!in_bounds(y, x)) break; } }
/* * 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); }
/* * Drop an item */ void do_cmd_drop(void) { int item, amt = 1; object_type *o_ptr; cptr q, s; /* Get an item */ #ifdef JP q = "どのアイテムを落としますか? "; s = "落とせるアイテムを持っていない。"; #else q = "Drop which item? "; s = "You have nothing to drop."; #endif if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) 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]; } /* Hack -- Cannot remove cursed items */ if ((item >= INVEN_WIELD) && cursed_p(o_ptr)) { /* Oops */ #ifdef JP msg_print("ふーむ、どうやら呪われているようだ。"); #else msg_print("Hmmm, it seems to be cursed."); #endif /* Nope */ return; } /* 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; } /* Take a partial turn */ energy_use = 50; /* Drop (some of) the item */ inven_drop(item, amt); p_ptr->redraw |= (PR_EQUIPPY); }
void save_char(int exit, int no_ask) { int i; int j; int flag; int error; vtype fnam; vtype temp; double version; struct stat buf; FILE *f1; char char_tmp; cave_type *c_ptr; flag = FALSE; if(!no_ask) { prt("Enter Filename:", 0, 0); if(!get_string(fnam, 0, 16, 60)) { /* Only return if exit TRUE, i.e. this is not a panic save */ if(exit) { return; } else { strcpy(fnam, "MORIACHR.SAV"); } } else if(strlen(fnam) == 0) { /* If get_string succeeded, but returned zero length */ strcpy(fnam, "MORIACHR.SAV"); } } else { strcpy(fnam, "MORIACHR.SAV"); } no_controlz(); /* Open the user's save file -JEW- */ f1 = fopen(fnam, "w"); if(f1 == NULL) { sprintf(temp, "Error creating %s", fnam); msg_print(temp); return; } flag = TRUE; clear_screen(0, 0); prt("Saving character...", 0, 0); put_qio(); version = CUR_VERSION; error = 0; error |= !fwrite((char *)&version, sizeof(version), 1, f1); error |= !fwrite((char *)&py, sizeof(py), 1, f1); error |= !fwrite((char *)&char_row, sizeof(char_row), 1, f1); error |= !fwrite((char *)&char_col, sizeof(char_col), 1, f1); error |= !fwrite((char *)&inven_ctr, sizeof(inven_ctr), 1, f1); error |= !fwrite((char *)&inven_weight, sizeof(inven_weight), 1, f1); error |= !fwrite((char *)&equip_ctr, sizeof(equip_ctr), 1, f1); error |= !fwrite((char *)&dun_level, sizeof(dun_level), 1, f1); error |= !fwrite((char *)&missile_ctr, sizeof(missile_ctr), 1, f1); error |= !fwrite((char *)&mon_tot_mult, sizeof(mon_tot_mult), 1, f1); error |= !fwrite((char *)&turn, sizeof(turn), 1, f1); error |= !fwrite((char *)inventory, sizeof(inventory), 1, f1); error |= !fwrite((char *)magic_spell[py.misc.pclass], sizeof(spell_type), 31, f1); error |= !fwrite((char *)&cur_height, sizeof(cur_height), 1, f1); error |= !fwrite((char *)&cur_width, sizeof(cur_width), 1, f1); error |= !fwrite((char *)&max_panel_rows, sizeof(max_panel_rows), 1, f1); error |= !fwrite((char *)&max_panel_cols, sizeof(max_panel_cols), 1, f1); for(i = 0; i < MAX_HEIGHT; ++i) { for(j = 0; j < MAX_WIDTH; ++j) { c_ptr = &cave[i][j]; char_tmp = c_ptr->fval | (c_ptr->fopen << 4) | (c_ptr->fm << 5) | (c_ptr->pl << 6) | (c_ptr->tl << 7); error |= !fwrite((char *)&c_ptr->cptr, sizeof(c_ptr->cptr), 1, f1); error |= !fwrite((char *)&c_ptr->tptr, sizeof(c_ptr->tptr), 1, f1); error |= !fwrite((char *)&char_tmp, sizeof(char_tmp), 1, f1); } } error |= !fwrite((char *)t_list, sizeof(t_list), 1, f1); error |= !fwrite((char *)&tcptr, sizeof(tcptr), 1, f1); error |= !fwrite((char *)object_ident, sizeof(object_ident), 1, f1); error |= !fwrite((char *)m_list, sizeof(m_list), 1, f1); error |= !fwrite((char *)&mfptr, sizeof(mfptr), 1, f1); error |= !fwrite((char *)&muptr, sizeof(muptr), 1, f1); error |= !fwrite((char *)store, sizeof(store), 1, f1); if(stat(fnam, &buf) == -1) { sprintf(temp, "Can not stat file %s", fnam); msg_print(temp); return; } error |= !fwrite((char *)&buf, sizeof(buf), 1, f1); error |= !fwrite((char *)norm_state, sizeof(norm_state), 1, f1); error |= !fwrite((char *)randes_state, sizeof(randes_state), 1, f1); error |= !fwrite((char *)&randes_seed, sizeof(randes_seed), 1, f1); error |= !fwrite((char *)town_state, sizeof(town_state), 1, f1); error |= !fwrite((char *)&town_seed, sizeof(town_seed), 1, f1); /* This indicates 'cheating' if it is a one */ error |= !fwrite((char *)&panic_save, sizeof(panic_save), 1, f1); error |= fclose(f1); character_saved = 1; if(!wizard1) { if(chmod(fnam, 0) == -1) { sprintf(temp, "Can not change file mode for %s", fnam); msg_print(temp); return; } } /* Make sure user can't touch save file for 5 seconds */ sleep(5); controlz(); if(error) { sprintf(temp, "Error writing to file %s", fnam); prt(temp, 0, 0); prt("Game not saved.", 0, 0); } else if(flag) { sprintf(temp, "Character saved. [Moria Version %lf]", CUR_VERSION); prt(temp, 0, 0); if(exit) { exit_game(); } } }
/* * Inscribe an object with a comment */ void do_cmd_inscribe(void) { int item; object_type *o_ptr; char o_name[MAX_NLEN]; char out_val[80]; cptr q, s; /* Get an item */ #ifdef JP q = "どのアイテムに銘を刻みますか? "; s = "銘を刻めるアイテムがない。"; #else q = "Inscribe which item? "; s = "You have nothing to inscribe."; #endif if (!get_item(&item, q, s, (USE_EQUIP | 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]; } /* Describe the activity */ object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP msg_format("%sに銘を刻む。", o_name); #else msg_format("Inscribing %s.", o_name); #endif msg_print(NULL); /* Start with nothing */ strcpy(out_val, ""); /* Use old inscription */ if (o_ptr->inscription) { /* Start with the old inscription */ strcpy(out_val, quark_str(o_ptr->inscription)); } /* Get a new inscription (possibly empty) */ #ifdef JP if (get_string("銘: ", out_val, 80)) #else if (get_string("Inscription: ", out_val, 80)) #endif { /* Auto flag inscription */ o_ptr->inscription = quark_add(out_val); /* Combine the pack */ p_ptr->notice |= (PN_COMBINE); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Updare stuff */ p_ptr->update |= (PU_BONUS); } }
static bool use_staff(object_type *o_ptr, bool *ident) { int py = p_ptr->py; int px = p_ptr->px; int k; bool use_charge = TRUE; /* Analyze the staff */ switch (o_ptr->sval) { case SV_STAFF_DARKNESS: { if (!p_ptr->resist_blind) { if (set_blind(p_ptr->blind + 3 + randint(5))) *ident = TRUE; } if (unlite_area(10, 3)) *ident = TRUE; break; } case SV_STAFF_SLOWNESS: { if (set_slow(p_ptr->slow + randint(30) + 15)) *ident = TRUE; break; } case SV_STAFF_HASTE_MONSTERS: { if (speed_monsters()) *ident = TRUE; break; } case SV_STAFF_SUMMONING: { for (k = 0; k < randint(4); k++) { if (summon_specific(py, px, p_ptr->depth, 0)) { *ident = TRUE; } } break; } case SV_STAFF_TELEPORTATION: { teleport_player(100); *ident = TRUE; break; } case SV_STAFF_IDENTIFY: { if (!ident_spell()) use_charge = FALSE; *ident = TRUE; break; } case SV_STAFF_REMOVE_CURSE: { if (remove_curse()) { if (!p_ptr->blind) { msg_print("Посох светится синим светом..."); } *ident = TRUE; } break; } case SV_STAFF_STARLITE: { if (!p_ptr->blind) { msg_print("Конец посоха ярко вспыхивает..."); } for (k = 0; k < 8; k++) lite_line(ddd[k]); *ident = TRUE; break; } case SV_STAFF_LITE: { if (lite_area(damroll(2, 8), 2)) *ident = TRUE; break; } case SV_STAFF_MAPPING: { map_area(); *ident = TRUE; break; } case SV_STAFF_DETECT_GOLD: { if (detect_treasure()) *ident = TRUE; if (detect_objects_gold()) *ident = TRUE; break; } case SV_STAFF_DETECT_ITEM: { if (detect_objects_normal()) *ident = TRUE; break; } case SV_STAFF_DETECT_TRAP: { if (detect_traps()) *ident = TRUE; break; } case SV_STAFF_DETECT_DOOR: { if (detect_doors()) *ident = TRUE; if (detect_stairs()) *ident = TRUE; break; } case SV_STAFF_DETECT_INVIS: { if (detect_monsters_invis()) *ident = TRUE; break; } case SV_STAFF_DETECT_EVIL: { if (detect_monsters_evil()) *ident = TRUE; break; } case SV_STAFF_CURE_LIGHT: { if (hp_player(randint(8))) *ident = TRUE; break; } case SV_STAFF_CURING: { if (set_blind(0)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_STAFF_HEALING: { if (hp_player(300)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_STAFF_THE_MAGI: { if (do_res_stat(A_INT)) *ident = TRUE; if (p_ptr->csp < p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; *ident = TRUE; msg_print("Ваша голова проясняется."); p_ptr->redraw |= (PR_MANA); p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1); } break; } case SV_STAFF_SLEEP_MONSTERS: { if (sleep_monsters()) *ident = TRUE; break; } case SV_STAFF_SLOW_MONSTERS: { if (slow_monsters()) *ident = TRUE; break; } case SV_STAFF_SPEED: { if (!p_ptr->fast) { if (set_fast(randint(30) + 15)) *ident = TRUE; } else { (void)set_fast(p_ptr->fast + 5); } break; } case SV_STAFF_PROBING: { probing(); *ident = TRUE; break; } case SV_STAFF_DISPEL_EVIL: { if (dispel_evil(60)) *ident = TRUE; break; } case SV_STAFF_POWER: { if (dispel_monsters(120)) *ident = TRUE; break; } case SV_STAFF_HOLINESS: { if (dispel_evil(120)) *ident = TRUE; k = 3 * p_ptr->lev; if (set_protevil(p_ptr->protevil + randint(25) + k)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_afraid(0)) *ident = TRUE; if (hp_player(50)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_STAFF_BANISHMENT: { if (!banishment()) use_charge = FALSE; *ident = TRUE; break; } case SV_STAFF_EARTHQUAKES: { earthquake(py, px, 10); *ident = TRUE; break; } case SV_STAFF_DESTRUCTION: { destroy_area(py, px, 15, TRUE); *ident = TRUE; break; } } return (use_charge); }
static bool aim_wand(object_type *o_ptr, bool *ident) { int lev, chance, dir, sval; /* Allow direction to be cancelled for free */ if (!get_aim_dir(&dir)) return (FALSE); /* Take a turn */ p_ptr->energy_use = 100; /* Not identified yet */ *ident = FALSE; /* Get the level */ lev = k_info[o_ptr->k_idx].level; /* Base chance of success */ chance = p_ptr->skill_dev; /* Confusion hurts skill */ if (p_ptr->confused) chance = chance / 2; /* High level objects are harder */ chance = chance - ((lev > 50) ? 50 : lev); /* Give everyone a (slight) chance */ if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0)) { chance = USE_DEVICE; } /* Roll for usage */ if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE)) { if (flush_failure) flush(); msg_print("Вы не смогли использовать палочку."); return (FALSE); } /* The wand is already empty! */ if (o_ptr->pval <= 0) { if (flush_failure) flush(); msg_print("В палочке кончились заряды."); o_ptr->ident |= (IDENT_EMPTY); p_ptr->notice |= (PN_COMBINE | PN_REORDER); p_ptr->window |= (PW_INVEN); return (FALSE); } /* Sound */ sound(MSG_ZAP); /* XXX Hack -- Extract the "sval" effect */ sval = o_ptr->sval; /* XXX Hack -- Wand of wonder can do anything before it */ if (sval == SV_WAND_WONDER) sval = rand_int(SV_WAND_WONDER); /* Analyze the wand */ switch (sval) { case SV_WAND_HEAL_MONSTER: { if (heal_monster(dir)) *ident = TRUE; break; } case SV_WAND_HASTE_MONSTER: { if (speed_monster(dir)) *ident = TRUE; break; } case SV_WAND_CLONE_MONSTER: { if (clone_monster(dir)) *ident = TRUE; break; } case SV_WAND_TELEPORT_AWAY: { if (teleport_monster(dir)) *ident = TRUE; break; } case SV_WAND_DISARMING: { if (disarm_trap(dir)) *ident = TRUE; break; } case SV_WAND_TRAP_DOOR_DEST: { if (destroy_door(dir)) *ident = TRUE; break; } case SV_WAND_STONE_TO_MUD: { if (wall_to_mud(dir)) *ident = TRUE; break; } case SV_WAND_LITE: { msg_print("Появляется коридор синего мерцающего света."); lite_line(dir); *ident = TRUE; break; } case SV_WAND_SLEEP_MONSTER: { if (sleep_monster(dir)) *ident = TRUE; break; } case SV_WAND_SLOW_MONSTER: { if (slow_monster(dir)) *ident = TRUE; break; } case SV_WAND_CONFUSE_MONSTER: { if (confuse_monster(dir, 10)) *ident = TRUE; break; } case SV_WAND_FEAR_MONSTER: { if (fear_monster(dir, 10)) *ident = TRUE; break; } case SV_WAND_DRAIN_LIFE: { if (drain_life(dir, 150)) *ident = TRUE; break; } case SV_WAND_POLYMORPH: { if (poly_monster(dir)) *ident = TRUE; break; } case SV_WAND_STINKING_CLOUD: { fire_ball(GF_POIS, dir, 12, 2); *ident = TRUE; break; } case SV_WAND_MAGIC_MISSILE: { fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(3, 4)); *ident = TRUE; break; } case SV_WAND_ACID_BOLT: { fire_bolt_or_beam(20, GF_ACID, dir, damroll(10, 8)); *ident = TRUE; break; } case SV_WAND_ELEC_BOLT: { fire_bolt_or_beam(20, GF_ELEC, dir, damroll(6, 6)); *ident = TRUE; break; } case SV_WAND_FIRE_BOLT: { fire_bolt_or_beam(20, GF_FIRE, dir, damroll(12, 8)); *ident = TRUE; break; } case SV_WAND_COLD_BOLT: { fire_bolt_or_beam(20, GF_COLD, dir, damroll(6, 8)); *ident = TRUE; break; } case SV_WAND_ACID_BALL: { fire_ball(GF_ACID, dir, 120, 2); *ident = TRUE; break; } case SV_WAND_ELEC_BALL: { fire_ball(GF_ELEC, dir, 64, 2); *ident = TRUE; break; } case SV_WAND_FIRE_BALL: { fire_ball(GF_FIRE, dir, 144, 2); *ident = TRUE; break; } case SV_WAND_COLD_BALL: { fire_ball(GF_COLD, dir, 96, 2); *ident = TRUE; break; } case SV_WAND_WONDER: { msg_print("Oops. Wand of wonder activated."); break; } case SV_WAND_DRAGON_FIRE: { fire_ball(GF_FIRE, dir, 200, 3); *ident = TRUE; break; } case SV_WAND_DRAGON_COLD: { fire_ball(GF_COLD, dir, 160, 3); *ident = TRUE; break; } case SV_WAND_DRAGON_BREATH: { switch (randint(5)) { case 1: { fire_ball(GF_ACID, dir, 200, 3); break; } case 2: { fire_ball(GF_ELEC, dir, 160, 3); break; } case 3: { fire_ball(GF_FIRE, dir, 200, 3); break; } case 4: { fire_ball(GF_COLD, dir, 160, 3); break; } default: { fire_ball(GF_POIS, dir, 120, 3); break; } } *ident = TRUE; break; } case SV_WAND_ANNIHILATION: { if (drain_life(dir, 250)) *ident = TRUE; break; } } return (TRUE); }
bool leprechaun_steal(int m_idx) { bool result = FALSE; monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; if ( !mon_save_p(m_ptr->r_idx, A_DEX) || (MON_CSLEEP(m_ptr) && !mon_save_p(m_ptr->r_idx, A_DEX))) { object_type loot = {0}; if (m_ptr->hold_o_idx && one_in_(2)) { object_copy(&loot, &o_list[m_ptr->hold_o_idx]); delete_object_idx(m_ptr->hold_o_idx); loot.held_m_idx = 0; } else if (m_ptr->drop_ct > m_ptr->stolen_ct) { if (get_monster_drop(m_idx, &loot)) { m_ptr->stolen_ct++; if (r_ptr->flags1 & RF1_UNIQUE) r_ptr->stolen_ct++; } } if (!loot.k_idx) { msg_print("There is nothing to steal!"); } else { char o_name[MAX_NLEN]; result = TRUE; object_desc(o_name, &loot, 0); if (mon_save_p(m_ptr->r_idx, A_DEX)) { msg_format("Oops! You drop %s.", o_name); drop_near(&loot, -1, py, px); } else if (loot.tval == TV_GOLD) { msg_format("You steal %d gold pieces worth of %s.", (int)loot.pval, o_name); sound(SOUND_SELL); p_ptr->au += loot.pval; stats_on_gold_find(loot.pval); p_ptr->redraw |= (PR_GOLD); if (prace_is_(RACE_MON_LEPRECHAUN)) p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA); } else if (!inven_carry_okay(&loot)) { msg_format("You have no room for %s.", o_name); drop_near(&loot, -1, py, px); } else { int slot = inven_carry(&loot); msg_format("You steal %s (%c).", o_name, index_to_label(slot)); autopick_alter_item(slot, TRUE); } } } return result; }
/** * Handle character death */ void death_screen(void) { const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Dump bones file */ make_bones(); /* Handle retirement */ if (p_ptr->total_winner) kingly(); /* Save dead player */ if (!old_save()) { msg_print("death save failed!"); message_flush(); } /* Get time of death */ #ifdef _WIN32_WCE { unsigned long fake_time(unsigned long *fake_time_t); fake_time(&death_time); } #else (void) time(&death_time); #endif /* Hack - Know everything upon death */ death_knowledge(); event_signal(EVENT_INVENTORY); event_signal(EVENT_EQUIPMENT); /* Handle stuff */ notice_stuff(); handle_stuff(); /* You are dead */ print_tomb(); /* Enter player in high score list */ enter_score(&death_time); /* Flush all input keys */ flush(); /* Flush messages */ msg_print(NULL); if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); do { menu_select(death_menu, 0); } while (!get_check("Do you want to quit? ")); }
/* * Interact with "macros" * * Note that the macro "action" must be defined before the trigger. * * Could use some helpful instructions on this page. XXX XXX XXX */ void do_cmd_macros(void) { s32b i; char tmp[1024]; char buf[1024]; s32b mode; /* Roguelike */ if (rogue_like_commands) { mode = KEYMAP_MODE_ROGUE; } /* Original */ else { mode = KEYMAP_MODE_ORIG; } /* Enter "icky" mode */ character_icky++; /* Save screen */ Term_save(); /* Process requests until done */ while (1) { /* Clear screen */ Term_clear(); /* Describe */ prt("Interact with Macros", 2, 0); /* Describe that action */ prt("Current action (if any) shown below:", 20, 0); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Selections */ prt("(1) Load a user pref file", 4, 5); #ifdef ALLOW_MACROS prt("(2) Append macros to a file", 5, 5); prt("(3) Query a macro", 6, 5); prt("(4) Create a macro", 7, 5); prt("(5) Remove a macro", 8, 5); prt("(6) Append keymaps to a file", 9, 5); prt("(7) Query a keymap", 10, 5); prt("(8) Create a keymap", 11, 5); prt("(9) Remove a keymap", 12, 5); prt("(0) Enter a new action", 13, 5); #endif /* ALLOW_MACROS */ /* Prompt */ prt("Command: ", 16, 0); /* Get a command */ i = inkey(); /* Leave */ if (i == ESCAPE) break; /* Load a 'macro' file */ else if (i == '1') { /* Prompt */ prt("Command: Load a user pref file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Process the given filename */ if (0 != process_pref_file(tmp)) { /* Prompt */ msg_print("Could not load file!"); } } #ifdef ALLOW_MACROS /* Save macros */ else if (i == '2') { /* Prompt */ prt("Command: Append macros to a file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Dump the macros */ (void)macro_dump(tmp); /* Prompt */ msg_print("Appended macros."); } /* Query a macro */ else if (i == '3') { s32b k; /* Prompt */ prt("Command: Query a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Acquire action */ k = macro_find_exact(buf); /* Nothing found */ if (k < 0) { /* Prompt */ msg_print("Found no macro."); } /* Found one */ else { /* Obtain the action */ strcpy(macro__buf, macro__act[k]); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Prompt */ msg_print("Found a macro."); } } /* Create a macro */ else if (i == '4') { /* Prompt */ prt("Command: Create a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Clear */ clear_from(20); /* Prompt */ prt("Action: ", 20, 0); /* Convert to text */ ascii_to_text(tmp, macro__buf); /* Get an encoded action */ if (askfor_aux(tmp, 80)) { /* Convert to ascii */ text_to_ascii(macro__buf, tmp); /* Link the macro */ macro_add(buf, macro__buf); /* Prompt */ msg_print("Added a macro."); } } /* Remove a macro */ else if (i == '5') { /* Prompt */ prt("Command: Remove a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Link the macro */ macro_add(buf, buf); /* Prompt */ msg_print("Removed a macro."); } /* Save keymaps */ else if (i == '6') { /* Prompt */ prt("Command: Append keymaps to a file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Dump the macros */ (void)keymap_dump(tmp); /* Prompt */ msg_print("Appended keymaps."); } /* Query a keymap */ else if (i == '7') { cptr act; /* Prompt */ prt("Command: Query a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Look up the keymap */ act = keymap_act[mode][(byte)(buf[0])]; /* Nothing found */ if (!act) { /* Prompt */ msg_print("Found no keymap."); } /* Found one */ else { /* Obtain the action */ strcpy(macro__buf, act); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Prompt */ msg_print("Found a keymap."); } } /* Create a keymap */ else if (i == '8') { /* Prompt */ prt("Command: Create a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Clear */ clear_from(20); /* Prompt */ prt("Action: ", 20, 0); /* Convert to text */ ascii_to_text(tmp, macro__buf); /* Get an encoded action */ if (askfor_aux(tmp, 80)) { /* Convert to ascii */ text_to_ascii(macro__buf, tmp); /* Free old keymap */ string_free(keymap_act[mode][(byte)(buf[0])]); /* Make new keymap */ keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf); /* Prompt */ msg_print("Added a keymap."); } } /* Remove a keymap */ else if (i == '9') { /* Prompt */ prt("Command: Remove a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Free old keymap */ string_free(keymap_act[mode][(byte)(buf[0])]); /* Make new keymap */ keymap_act[mode][(byte)(buf[0])] = NULL; /* Prompt */ msg_print("Removed a keymap."); } /* Enter a new action */ else if (i == '0') { /* Prompt */ prt("Command: Enter a new action", 16, 0); /* Go to the correct location */ Term_gotoxy(0, 22); /* Hack -- limit the value */ tmp[80] = '\0'; /* Get an encoded action */ if (!askfor_aux(buf, 80)) continue; /* Extract an action */ text_to_ascii(macro__buf, buf); } #endif /* ALLOW_MACROS */ /* Oops */ else { /* Oops */ bell(); } /* Flush messages */ msg_print(NULL); } /* Load screen */ Term_load(); /* Leave "icky" mode */ character_icky--; }
void macro_recorder_start() { msg_print("Starting macro recording, press this key again to stop. Note that if the action you want to record accepts the @ key, use it, it will remove your the need to inscribe stuff."); C_MAKE(macro_recorder_current, 1, char); macro_recorder_current[0] = '\0'; }
/* * Hack -- save a screen dump to a file */ void do_cmd_save_screen(void) { /* Do we use a special screendump function ? */ if (screendump_aux) { /* Dump the screen to a graphics file */ (*screendump_aux)(); } /* Dump the screen as text */ else { s32b y, x; s32b wid, hgt; byte a = 0; char c = ' '; PHYSFS_file *fff; char buf[1024]; /* Build the filename */ path_build(buf, 1024, TENGINE_DIR_USER, "dump.txt"); /* Append to the file */ fff = my_fopen(buf, "w"); /* Oops */ if (!fff) return; /* Retrieve the current screen size */ Term_get_size(&wid, &hgt); /* Enter "icky" mode */ character_icky++; /* Save the screen */ Term_save(); /* Dump the screen */ for (y = 0; y < hgt; y++) { /* Dump each row */ for (x = 0; x < wid; x++) { /* Get the attr/char */ (void)(Term_what(x, y, &a, &c)); /* Dump it */ buf[x] = c; } /* Terminate */ buf[x] = '\0'; /* End the row */ fprintf(fff, "%s\n", buf); } /* Skip a line */ fprintf(fff, "\n"); /* Dump the screen */ for (y = 0; y < hgt; y++) { /* Dump each row */ for (x = 0; x < wid; x++) { /* Get the attr/char */ (void)(Term_what(x, y, &a, &c)); /* Dump it */ buf[x] = hack[a & 0x0F]; } /* Terminate */ buf[x] = '\0'; /* End the row */ fprintf(fff, "%s\n", buf); } /* Skip a line */ fprintf(fff, "\n"); /* Close it */ my_fclose(fff); /* Message */ msg_print("Screen dump saved."); msg_print(NULL); /* Restore the screen */ Term_load(); /* Leave "icky" mode */ character_icky--; } }
/* * do_cmd_cast calls this function if the player's class * is 'imitator'. */ static bool use_mane(int spell) { int dir; int plev = p_ptr->lev; u32b mode = (PM_ALLOW_GROUP | PM_FORCE_PET); u32b u_mode = 0L; if (randint1(50+plev) < plev/10) u_mode = PM_ALLOW_UNIQUE; /* spell code */ switch (spell) { case MS_SHRIEK: msg_print("You make a high pitched shriek."); aggravate_monsters(0); break; case MS_XXX1: break; case MS_DISPEL: { int m_idx; if (!target_set(TARGET_KILL)) return FALSE; m_idx = cave[target_row][target_col].m_idx; if (!m_idx) break; if (!player_has_los_bold(target_row, target_col)) break; if (!projectable(py, px, target_row, target_col)) break; dispel_monster_status(m_idx); break; } case MS_ROCKET: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You fire a rocket."); fire_rocket(GF_ROCKET, dir, damage, 2); break; case MS_SHOOT: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You fire an arrow."); fire_bolt(GF_ARROW, dir, damage); break; case MS_XXX2: break; case MS_XXX3: break; case MS_BR_STORM: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe storm."); fire_ball(GF_STORM, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_ACID: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe acid."); fire_ball(GF_ACID, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_ELEC: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe lightning."); fire_ball(GF_ELEC, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_FIRE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe fire."); fire_ball(GF_FIRE, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_COLD: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe frost."); fire_ball(GF_COLD, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_POIS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe gas."); fire_ball(GF_POIS, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_NETHER: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe nether."); fire_ball(GF_NETHER, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_LITE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe light."); fire_ball(GF_LITE, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_DARK: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe darkness."); fire_ball(GF_DARK, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_CONF: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe confusion."); fire_ball(GF_CONFUSION, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_SOUND: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe sound."); fire_ball(GF_SOUND, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_CHAOS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe chaos."); fire_ball(GF_CHAOS, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_DISEN: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe disenchantment."); fire_ball(GF_DISENCHANT, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_NEXUS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe nexus."); fire_ball(GF_NEXUS, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_TIME: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe time."); fire_ball(GF_TIME, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_INERTIA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe inertia."); fire_ball(GF_INERT, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_GRAVITY: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe gravity."); fire_ball(GF_GRAVITY, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_SHARDS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe shards."); fire_ball(GF_SHARDS, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_PLASMA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe plasma."); fire_ball(GF_PLASMA, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_FORCE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe force."); fire_ball(GF_FORCE, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BR_MANA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe mana."); fire_ball(GF_MANA, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BALL_NUKE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a ball of radiation."); fire_ball(GF_NUKE, dir, damage, 2); break; case MS_BR_NUKE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe toxic waste."); fire_ball(GF_NUKE, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BALL_CHAOS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You invoke a raw Logrus."); fire_ball(GF_CHAOS, dir, damage, 4); break; case MS_BR_DISI: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You breathe disintegration."); fire_ball(GF_DISINTEGRATE, dir, damage, (plev > 35 ? -3 : -2)); break; case MS_BALL_ACID: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast an acid ball."); fire_ball(GF_ACID, dir, damage, 2); break; case MS_BALL_ELEC: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a lightning ball."); fire_ball(GF_ELEC, dir, damage, 2); break; case MS_BALL_FIRE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a fire ball."); fire_ball(GF_FIRE, dir, damage, 2); break; case MS_BALL_COLD: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a frost ball."); fire_ball(GF_COLD, dir, damage, 2); break; case MS_BALL_POIS: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a stinking cloud."); fire_ball(GF_POIS, dir, damage, 2); break; case MS_BALL_NETHER: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a nether ball."); fire_ball(GF_NETHER, dir, damage, 2); break; case MS_BALL_WATER: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You gesture fluidly."); fire_ball(GF_WATER, dir, damage, 4); break; case MS_BALL_MANA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You invoke a mana storm."); fire_ball(GF_MANA, dir, damage, 4); break; case MS_BALL_DARK: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You invoke a darkness storm."); fire_ball(GF_DARK, dir, damage, 4); break; case MS_DRAIN_MANA: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_DRAIN_MANA, dir, randint1(plev*3)+plev, 0); break; case MS_MIND_BLAST: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_MIND_BLAST, dir, damage, 0); break; case MS_BRAIN_SMASH: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_BRAIN_SMASH, dir, damage, 0); break; case MS_CAUSE_1: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_CAUSE_1, dir, damage, 0); break; case MS_CAUSE_2: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_CAUSE_2, dir, damage, 0); break; case MS_CAUSE_3: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_CAUSE_3, dir, damage, 0); break; case MS_CAUSE_4: if (!get_fire_dir(&dir)) return FALSE; fire_ball_hide(GF_CAUSE_4, dir, damage, 0); break; case MS_BOLT_ACID: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast an acid bolt."); fire_bolt(GF_ACID, dir, damage); break; case MS_BOLT_ELEC: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a lightning bolt."); fire_bolt(GF_ELEC, dir, damage); break; case MS_BOLT_FIRE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a fire bolt."); fire_bolt(GF_FIRE, dir, damage); break; case MS_BOLT_COLD: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a frost bolt."); fire_bolt(GF_COLD, dir, damage); break; case MS_STARBURST: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You invoke a starburst."); fire_ball(GF_LITE, dir, damage, 4); break; case MS_BOLT_NETHER: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a nether bolt."); fire_bolt(GF_NETHER, dir, damage); break; case MS_BOLT_WATER: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a water bolt."); fire_bolt(GF_WATER, dir, damage); break; case MS_BOLT_MANA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a mana bolt."); fire_bolt(GF_MANA, dir, damage); break; case MS_BOLT_PLASMA: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a plasma bolt."); fire_bolt(GF_PLASMA, dir, damage); break; case MS_BOLT_ICE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a ice bolt."); fire_bolt(GF_ICE, dir, damage); break; case MS_MAGIC_MISSILE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a magic missile."); fire_bolt(GF_MISSILE, dir, damage); break; case MS_SCARE: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a fearful illusion."); fear_monster(dir, plev+10); break; case MS_BLIND: if (!get_fire_dir(&dir)) return FALSE; confuse_monster(dir, plev * 2); break; case MS_CONF: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You cast a mesmerizing illusion."); confuse_monster(dir, plev * 2); break; case MS_SLOW: if (!get_fire_dir(&dir)) return FALSE; slow_monster(dir); break; case MS_SLEEP: if (!get_fire_dir(&dir)) return FALSE; sleep_monster(dir, plev*3); break; case MS_SPEED: (void)set_fast(randint1(20 + plev) + plev, FALSE); break; case MS_HAND_DOOM: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You invoke the Hand of Doom!"); fire_ball_hide(GF_HAND_DOOM, dir, 200, 0); break; case MS_HEAL: msg_print("You concentrate on your wounds!"); (void)hp_player(plev*6); (void)set_stun(0, TRUE); (void)set_cut(0, TRUE); break; case MS_INVULNER: msg_print("You cast a Globe of Invulnerability."); (void)set_invuln(randint1(7) + 7, FALSE); break; case MS_BLINK: if (mut_present(MUT_ASTRAL_GUIDE)) energy_use = 30; teleport_player(10, 0L); break; case MS_TELEPORT: if (mut_present(MUT_ASTRAL_GUIDE)) energy_use = 30; teleport_player(plev * 5, 0L); break; case MS_WORLD: world_player = TRUE; if (damage == 1 || damage == 2) msg_print("You yell 'The World! Time has stopped!'"); else if (damage == 3 || damage == 6) msg_print("You yell 'Time!'"); else msg_print("hek!"); msg_print(NULL); p_ptr->energy_need -= 1000 + (100 + randint1(200)+200)*TURNS_PER_TICK/10; p_ptr->redraw |= (PR_MAP); p_ptr->update |= (PU_MONSTERS); p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); handle_stuff(); break; case MS_SPECIAL: break; case MS_TELE_TO: { monster_type *m_ptr; monster_race *r_ptr; char m_name[80]; if (!target_set(TARGET_KILL)) return FALSE; if (!cave[target_row][target_col].m_idx) break; if (!player_has_los_bold(target_row, target_col)) break; if (!projectable(py, px, target_row, target_col)) break; m_ptr = &m_list[cave[target_row][target_col].m_idx]; r_ptr = &r_info[m_ptr->r_idx]; monster_desc(m_name, m_ptr, 0); if (r_ptr->flagsr & RFR_RES_TELE) { if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL)) { mon_lore_r(m_ptr, RFR_RES_TELE); msg_format("%s is unaffected!", m_name); break; } else if (r_ptr->level > randint1(100)) { mon_lore_r(m_ptr, RFR_RES_TELE); msg_format("%s resists!", m_name); break; } } msg_format("You command %s to return.", m_name); teleport_monster_to(cave[target_row][target_col].m_idx, py, px, 100, TELEPORT_PASSIVE); break; } case MS_TELE_AWAY: if (!get_fire_dir(&dir)) return FALSE; (void)fire_beam(GF_AWAY_ALL, dir, plev); break; case MS_TELE_LEVEL: { int target_m_idx; monster_type *m_ptr; monster_race *r_ptr; char m_name[80]; if (!target_set(TARGET_KILL)) return FALSE; target_m_idx = cave[target_row][target_col].m_idx; if (!target_m_idx) break; if (!player_has_los_bold(target_row, target_col)) break; if (!projectable(py, px, target_row, target_col)) break; m_ptr = &m_list[target_m_idx]; r_ptr = &r_info[m_ptr->r_idx]; monster_desc(m_name, m_ptr, 0); msg_format("You gesture at %^s's feet.", m_name); if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) || (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > plev + randint1(60))) { msg_format("%^s is unaffected!", m_name); } else teleport_level(target_m_idx); break; } case MS_PSY_SPEAR: if (!get_fire_dir(&dir)) return FALSE; else msg_print("You throw a psycho-spear."); fire_beam(GF_PSY_SPEAR, dir, damage); break; case MS_DARKNESS: msg_print("You gesture in shadow."); unlite_area(10, 3); break; case MS_MAKE_TRAP: if (!target_set(TARGET_KILL)) return FALSE; msg_print("You cast a spell and cackle evilly."); trap_creation(target_row, target_col); break; case MS_FORGET: msg_print("Nothing happens."); /* TODO: forget_spell(m_idx) ... */ break; case MS_RAISE_DEAD: msg_print("You cast a animate dead."); animate_dead(0, py, px); break; case MS_S_KIN: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon minions."); for (k = 0;k < 4; k++) { (void)summon_kin_player(plev, target_row, target_col, (PM_FORCE_PET | PM_ALLOW_GROUP)); } break; } case MS_S_CYBER: { int k; int max_cyber = (dun_level / 50) + randint1(3); if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon Cyberdemons!"); if (max_cyber > 4) max_cyber = 4; for (k = 0;k < max_cyber; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_CYBER, mode); break; } case MS_S_MONSTER: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon help."); for (k = 0;k < 1; k++) summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode)); break; } case MS_S_MONSTERS: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon monsters!"); for (k = 0;k < 6; k++) summon_specific(-1, target_row, target_col, plev, 0, (mode | u_mode)); break; } case MS_S_ANT: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon ants."); for (k = 0;k < 6; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_ANT, mode); break; } case MS_S_SPIDER: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon spiders."); for (k = 0;k < 6; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_SPIDER, mode); break; } case MS_S_HOUND: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon hounds."); for (k = 0;k < 4; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_HOUND, mode); break; } case MS_S_HYDRA: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon hydras."); for (k = 0;k < 4; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_HYDRA, mode); break; } case MS_S_ANGEL: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon angel!"); for (k = 0;k < 1; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_ANGEL, mode); break; } case MS_S_DEMON: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon a demon from the Courts of Chaos!"); for (k = 0;k < 1; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_DEMON, (mode | u_mode)); break; } case MS_S_UNDEAD: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon an undead adversary!"); for (k = 0;k < 1; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_UNDEAD, (mode | u_mode)); break; } case MS_S_DRAGON: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon dragon!"); for (k = 0;k < 1; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_DRAGON, (mode | u_mode)); break; } case MS_S_HI_UNDEAD: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon greater undead!"); for (k = 0;k < 6; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode)); break; } case MS_S_HI_DRAGON: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon ancient dragons!"); for (k = 0;k < 4; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_HI_DRAGON, (mode | u_mode)); break; } case MS_S_AMBERITE: { int k; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon Lords of Amber!"); for (k = 0;k < 4; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_AMBERITE, (mode | PM_ALLOW_UNIQUE)); break; } case MS_S_UNIQUE: { int k, count = 0; if (!target_set(TARGET_KILL)) return FALSE; msg_print("You summon special opponents!"); for (k = 0;k < 4; k++) if (summon_specific(-1, target_row, target_col, plev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE))) count++; for (k = count;k < 4; k++) summon_specific(-1, target_row, target_col, plev, SUMMON_HI_UNDEAD, (mode | u_mode)); break; } default: msg_print("hoge?"); } return TRUE; }
static bool zap_rod(object_type *o_ptr, bool *ident) { int chance, dir, lev; bool used_charge = TRUE; object_kind *k_ptr = &k_info[o_ptr->k_idx]; /* Get a direction (unless KNOWN not to need it) */ if ((o_ptr->sval >= SV_ROD_MIN_DIRECTION) || !object_aware_p(o_ptr)) { /* Get a direction, allow cancel */ if (!get_aim_dir(&dir)) return FALSE; } /* Take a turn */ p_ptr->energy_use = 100; /* Not identified yet */ *ident = FALSE; /* Extract the item level */ lev = k_info[o_ptr->k_idx].level; /* Base chance of success */ chance = p_ptr->skill_dev; /* Confusion hurts skill */ if (p_ptr->confused) chance = chance / 2; /* High level objects are harder */ chance = chance - ((lev > 50) ? 50 : lev); /* Give everyone a (slight) chance */ if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0)) { chance = USE_DEVICE; } /* Roll for usage */ if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE)) { if (flush_failure) flush(); msg_print("Вы не смогли использовать жезл."); return FALSE; } /* Still charging? */ if (o_ptr->timeout > (o_ptr->pval - k_ptr->pval)) { if (flush_failure) flush(); if (o_ptr->number == 1) msg_print("Жезл все еще заряжается."); else msg_print("Все жезлы все еще заряжаются."); return FALSE; } /* Sound */ sound(MSG_ZAP); /* Analyze the rod */ switch (o_ptr->sval) { case SV_ROD_DETECT_TRAP: { if (detect_traps()) *ident = TRUE; break; } case SV_ROD_DETECT_DOOR: { if (detect_doors()) *ident = TRUE; if (detect_stairs()) *ident = TRUE; break; } case SV_ROD_IDENTIFY: { *ident = TRUE; if (ident_spell()) used_charge = FALSE; break; } case SV_ROD_RECALL: { set_recall(); *ident = TRUE; break; } case SV_ROD_ILLUMINATION: { if (lite_area(damroll(2, 8), 2)) *ident = TRUE; break; } case SV_ROD_MAPPING: { map_area(); *ident = TRUE; break; } case SV_ROD_DETECTION: { detect_all(); *ident = TRUE; break; } case SV_ROD_PROBING: { probing(); *ident = TRUE; break; } case SV_ROD_CURING: { if (set_blind(0)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_ROD_HEALING: { if (hp_player(500)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_ROD_RESTORATION: { if (restore_level()) *ident = TRUE; if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_INT)) *ident = TRUE; if (do_res_stat(A_WIS)) *ident = TRUE; if (do_res_stat(A_DEX)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (do_res_stat(A_CHR)) *ident = TRUE; break; } case SV_ROD_SPEED: { if (!p_ptr->fast) { if (set_fast(randint(30) + 15)) *ident = TRUE; } else { (void)set_fast(p_ptr->fast + 5); } break; } case SV_ROD_TELEPORT_AWAY: { if (teleport_monster(dir)) *ident = TRUE; break; } case SV_ROD_DISARMING: { if (disarm_trap(dir)) *ident = TRUE; break; } case SV_ROD_LITE: { msg_print("Появляется коридор синего мерцающего света."); lite_line(dir); *ident = TRUE; break; } case SV_ROD_SLEEP_MONSTER: { if (sleep_monster(dir)) *ident = TRUE; break; } case SV_ROD_SLOW_MONSTER: { if (slow_monster(dir)) *ident = TRUE; break; } case SV_ROD_DRAIN_LIFE: { if (drain_life(dir, 150)) *ident = TRUE; break; } case SV_ROD_POLYMORPH: { if (poly_monster(dir)) *ident = TRUE; break; } case SV_ROD_ACID_BOLT: { fire_bolt_or_beam(10, GF_ACID, dir, damroll(12, 8)); *ident = TRUE; break; } case SV_ROD_ELEC_BOLT: { fire_bolt_or_beam(10, GF_ELEC, dir, damroll(6, 6)); *ident = TRUE; break; } case SV_ROD_FIRE_BOLT: { fire_bolt_or_beam(10, GF_FIRE, dir, damroll(16, 8)); *ident = TRUE; break; } case SV_ROD_COLD_BOLT: { fire_bolt_or_beam(10, GF_COLD, dir, damroll(10, 8)); *ident = TRUE; break; } case SV_ROD_ACID_BALL: { fire_ball(GF_ACID, dir, 120, 2); *ident = TRUE; break; } case SV_ROD_ELEC_BALL: { fire_ball(GF_ELEC, dir, 64, 2); *ident = TRUE; break; } case SV_ROD_FIRE_BALL: { fire_ball(GF_FIRE, dir, 144, 2); *ident = TRUE; break; } case SV_ROD_COLD_BALL: { fire_ball(GF_COLD, dir, 96, 2); *ident = TRUE; break; } } /* Drain the charge */ if (used_charge) o_ptr->timeout += k_ptr->pval; return TRUE; }
bool imitator_cast(bool revenge) { int n = 0, j; int chance; int minfail = 0; int plev = p_ptr->lev; monster_power spell; bool cast; if (p_ptr->confused) { msg_print("You are too confused!"); return TRUE; } if (!p_ptr->mane_num) { msg_print("You don't remember any action!"); return FALSE; } /* get power */ if (!get_mane_power(&n, revenge)) return FALSE; spell = monster_powers[p_ptr->mane_spell[n]]; /* Spell failure chance */ chance = spell.manefail; /* Reduce failure rate by "effective" level adjustment */ if (plev > spell.level) chance -= 3 * (plev - spell.level); /* Reduce failure rate by 1 stat and DEX adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2; if (spell.manedam) chance = chance * damage / spell.manedam; chance += p_ptr->to_m_chance; /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]]; /* Minimum failure rate */ if (chance < minfail) chance = minfail; /* Stunning makes spells harder */ if (p_ptr->stun > 50) chance += 25; else if (p_ptr->stun) chance += 15; /* Always a 5 percent chance of working */ if (chance > 95) chance = 95; /* Failed spell */ if (randint0(100) < chance) { if (flush_failure) flush(); msg_print("You failed to concentrate hard enough!"); sound(SOUND_FAIL); } else { sound(SOUND_ZAP); cast = use_mane(p_ptr->mane_spell[n]); if (!cast) return FALSE; } p_ptr->mane_num--; for (j = n; j < p_ptr->mane_num;j++) { p_ptr->mane_spell[j] = p_ptr->mane_spell[j+1]; p_ptr->mane_dam[j] = p_ptr->mane_dam[j+1]; } energy_use = 100; p_ptr->redraw |= PR_EFFECTS; p_ptr->window |= (PW_SPELL); return TRUE; }
static bool eat_food(object_type *o_ptr, bool *ident) { /* Analyze the food */ switch (o_ptr->sval) { case SV_FOOD_POISON: { if (!(p_ptr->resist_pois || p_ptr->oppose_pois)) { if (set_poisoned(p_ptr->poisoned + rand_int(10) + 10)) { *ident = TRUE; } } break; } case SV_FOOD_BLINDNESS: { if (!p_ptr->resist_blind) { if (set_blind(p_ptr->blind + rand_int(200) + 200)) { *ident = TRUE; } } break; } case SV_FOOD_PARANOIA: { if (!p_ptr->resist_fear) { if (set_afraid(p_ptr->afraid + rand_int(10) + 10)) { *ident = TRUE; } } break; } case SV_FOOD_CONFUSION: { if (!p_ptr->resist_confu) { if (set_confused(p_ptr->confused + rand_int(10) + 10)) { *ident = TRUE; } } break; } case SV_FOOD_HALLUCINATION: { if (!p_ptr->resist_chaos) { if (set_image(p_ptr->image + rand_int(250) + 250)) { *ident = TRUE; } } break; } case SV_FOOD_PARALYSIS: { if (!p_ptr->free_act) { if (set_paralyzed(p_ptr->paralyzed + rand_int(10) + 10)) { *ident = TRUE; } } break; } case SV_FOOD_WEAKNESS: { take_hit(damroll(6, 6), "отравленная еда"); (void)do_dec_stat(A_STR); *ident = TRUE; break; } case SV_FOOD_SICKNESS: { take_hit(damroll(6, 6), "отравленная еда"); (void)do_dec_stat(A_CON); *ident = TRUE; break; } case SV_FOOD_STUPIDITY: { take_hit(damroll(8, 8), "отравленная еда"); (void)do_dec_stat(A_INT); *ident = TRUE; break; } case SV_FOOD_NAIVETY: { take_hit(damroll(8, 8), "отравленная еда"); (void)do_dec_stat(A_WIS); *ident = TRUE; break; } case SV_FOOD_UNHEALTH: { take_hit(damroll(10, 10), "отравленная еда"); (void)do_dec_stat(A_CON); *ident = TRUE; break; } case SV_FOOD_DISEASE: { take_hit(damroll(10, 10), "отравленная еда"); (void)do_dec_stat(A_STR); *ident = TRUE; break; } case SV_FOOD_CURE_POISON: { if (set_poisoned(0)) *ident = TRUE; break; } case SV_FOOD_CURE_BLINDNESS: { if (set_blind(0)) *ident = TRUE; break; } case SV_FOOD_CURE_PARANOIA: { if (set_afraid(0)) *ident = TRUE; break; } case SV_FOOD_CURE_CONFUSION: { if (set_confused(0)) *ident = TRUE; break; } case SV_FOOD_CURE_SERIOUS: { if (hp_player(damroll(4, 8))) *ident = TRUE; break; } case SV_FOOD_RESTORE_STR: { if (do_res_stat(A_STR)) *ident = TRUE; break; } case SV_FOOD_RESTORE_CON: { if (do_res_stat(A_CON)) *ident = TRUE; break; } case SV_FOOD_RESTORING: { if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_INT)) *ident = TRUE; if (do_res_stat(A_WIS)) *ident = TRUE; if (do_res_stat(A_DEX)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (do_res_stat(A_CHR)) *ident = TRUE; break; } case SV_FOOD_RATION: case SV_FOOD_BISCUIT: case SV_FOOD_JERKY: case SV_FOOD_SLIME_MOLD: { msg_print("Вкусно!"); *ident = TRUE; break; } case SV_FOOD_WAYBREAD: { msg_print("Очень вкусно!"); (void)set_poisoned(0); (void)hp_player(damroll(4, 8)); *ident = TRUE; break; } case SV_FOOD_PINT_OF_ALE: case SV_FOOD_PINT_OF_WINE: { msg_print("Вкусно!"); *ident = TRUE; break; } } /* Food can feed the player */ (void)set_food(p_ptr->food + o_ptr->pval); return (TRUE); }
int get_char(char *fnam) { int i; int j; FILE *f1; int error; vtype temp; double version; #ifdef USG struct stat buf; struct stat buf2; #else struct stat lbuf; struct stat buf; struct stat buf2; #endif char char_tmp; char char_tmp_array[3]; cave_type *c_ptr; long age; clear_screen(0, 0); no_controlz(); #ifdef USG /* No symbolic links */ if(stat(fnam, &buf) == -1) { sprintf(temp, "Cannot stat file &s", fnam); prt(temp, 0, 0); exit_game(); } #else if((lstat(fnam, &lbuf) == -1) || (stat(fnam, &buf) == -1)) { sprintf(temp, "Cannot stat file %s", fnam); prt(temp, 0, 0); exit_game(); } #endif #ifdef USG /* No symbolic links */ #else if(lbuf.st_ino != buf.st_ino) { sprintf(temp, "Cannot restore from symbolic link %s", fnam); prt(temp, 0, 0); exit_game(); } #endif if(buf.st_nlink != 1) { sprintf(temp, "Too many links to file %s", fnam); prt(temp, 0, 0); exit_game(); } if(chmod(fnam, (IREAD | IWRITE)) == -1) { sprintf(temp, "Can not change file mode for %s", fnam); prt(temp, 0, 0); } f1 = fopen(fnam, "r"); if(f1 == NULL) { sprintf(temp, "Cannot open file %s for reading", fnam); prt(temp, 0, 0); exit_game(); } prt("Restoring Character...", 0, 0); put_qio(); error = 0; error |= !fread((char *)&version, sizeof(version), 1, f1); error |= !fread((char *)&py, sizeof(py), 1, f1); error |= !fread((char *)&char_row, sizeof(char_row), 1, f1); error |= !fread((char *)&char_col, sizeof(char_col), 1, f1); error |= !fread((char *)&inven_ctr, sizeof(inven_ctr), 1, f1); error |= !fread((char *)&inven_weight, sizeof(inven_weight), 1, f1); error |= !fread((char *)&equip_ctr, sizeof(equip_ctr), 1, f1); error |= !fread((char *)&dun_level, sizeof(dun_level), 1, f1); error |= !fread((char *)&missile_ctr, sizeof(missile_ctr), 1, f1); error |= !fread((char *)&mon_tot_mult, sizeof(mon_tot_mult), 1, f1); error |= !fread((char *)&turn, sizeof(turn), 1, f1); error |= !fread((char *)inventory, sizeof(inventory), 1, f1); error |= !fread((char *)magic_spell[py.misc.pclass], sizeof(spell_type), 31, f1); error |= !fread((char *)&cur_height, sizeof(cur_height), 1, f1); error |= !fread((char *)&cur_width, sizeof(cur_width), 1, f1); error |= !fread((char *)&max_panel_rows, sizeof(max_panel_rows), 1, f1); error |= !fread((char *)&max_panel_cols, sizeof(max_panel_cols), 1, f1); for(i = 0; i < MAX_HEIGHT; ++i) { for(j = 0; j < MAX_WIDTH; ++j) { c_ptr = &cave[i][j]; error |= !fread((char *)&c_ptr->cptr, sizeof(c_ptr->cptr), 1, f1); error |= !fread((char *)&c_ptr->tptr, sizeof(c_ptr->tptr), 1, f1); error |= !fread((char *)&char_tmp, sizeof(char_tmp), 1, f1); c_ptr->fval = char_tmp & 0xF; c_ptr->fopen = (char_tmp >> 4) & 0x1; c_ptr->fm = (char_tmp >> 5) & 0x1; c_ptr->pl = (char_tmp >> 6) & 0x1; c_ptr->tl = (char_tmp >> 7) & 0x1; } } error |= !fread((char *)t_list, sizeof(t_list), 1, f1); error |= !fread((char *)&tcptr, sizeof(tcptr), 1, f1); error |= !fread((char *)object_ident, sizeof(object_ident), 1, f1); error |= !fread((char *)m_list, sizeof(m_list), 1, f1); error |= !fread((char *)&mfptr, sizeof(mfptr), 1, f1); error |= !fread((char *)&muptr, sizeof(muptr), 1, f1); if(version == 4.83) { /* insult_cur was a byte in 4.83, but is now a short */ for(i = 0; i < MAX_STORES; ++i) { error |= !fread((char *)&store[i].store_open, sizeof(short), 1, f1); /* This is different */ error |= !fread((char *)&char_tmp, sizeof(char), 1, f1); store[i].insult_cur = (short)char_tmp; error |= !fread((char *)&store[i].owner, sizeof(char), 1, f1); error |= !fread((char *)&store[i].store_ctr, sizeof(char), 1, f1); /* * Quick compatibility hack for a local vax ignore three bytes of * fill character */ error |= !fread((char *)char_tmp_array, sizeof(char), 3, f1); error |= !fread((char *)store[i].store_inven, sizeof(inven_record), STORE_INVEN_MAX, f1); } } else { error |= !fread((char *)store, sizeof(store), 1, f1); } error |= !fread((char *)&buf2, sizeof(buf2), 1, f1); error |= !fread((char *)norm_state, sizeof(norm_state), 1, f1); error |= !fread((char *)randes_state, sizeof(randes_state), 1, f1); error |= !fread((char *)&randes_seed, sizeof(randes_seed), 1, f1); error |= !fread((char *)town_state, sizeof(town_state), 1, f1); error |= !fread((char *)&town_seed, sizeof(town_seed), 1, f1); if(version >= 4.87) { error |= !fread((char *)&panic_save, sizeof(panic_save), 1, f1); } error |= fclose(f1); controlz(); if(buf.st_atime >= (buf2.st_atime + 5)) { sprintf(temp, "File %s has been touched, sorry.", fnam); prt(temp, 0, 0); exit_game(); } if(error) { sprintf(temp, "Error reading in file %s", fnam); prt(temp, 0, 0); exit_game(); } /* * Rotate store inventory, depending on how old the save file is foreach day * or fraction thereof old, call store_maint once must do this before delete * file */ if(stat(fnam, &buf2) == -1) { sprintf(temp, "Cannot stat file %s?", fnam); prt(temp, 0, 0); } else { /* Age in seconds */ age = (long)buf2.st_atime - (long)buf.st_atime; /* Age in days */ age = (age / 86400) + 1; for(i = 0; i < age; ++i) { store_maint(); } } if(unlink(fnam) == -1) { sprintf(temp, "Cannot delete file %s", fnam); prt(temp, 0, 0); exit_game(); } if(panic_save == 1) { sprintf(temp, "This game is from a panic save. Score will not be added to scoreboard."); msg_print(temp); /* Make sure player will see message before change_name is called */ msg_print(" "); } /* * Reidentify objects. * Very inefficient, should write new routine perhaps? */ for(i = 0; i < MAX_OBJECTS; ++i) { if(object_ident[i] == TRUE) { identify(object_list[i]); } } /* * In case restoring a dead character, this can happen if a signal is caught * after a character's hit points go below zero, but before the game ends */ if(py.misc.chp <= -1) { prt("Your character has already died.", 23, 0); strcpy(died_from, "Unknown."); death = 1; } return FALSE; }
/* * Activate a wielded object. Wielded objects never stack. * And even if they did, activatable objects never stack. * * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated. * But one could, for example, easily make an activatable "Ring of Plasma". * * Note that it always takes a turn to activate an artifact, even if * the user hits "escape" at the "direction" prompt. */ static bool activate_object(object_type *o_ptr, bool *ident) { int k, dir, i, chance, rod; char o_name[80]; /* Get the basic name of the object */ rod = object_desc(o_name, sizeof(o_name), o_ptr, FALSE, 0, PAD_IMEN); /* Check the recharge */ if (o_ptr->timeout) { msg_format("Он%s светится и затухает...", (rod == ROD_M ? "" : rod == ROD_F ? "а" : rod == ROD_N ? "о" : "и")); return FALSE; } /* Activate the artifact */ message(MSG_ZAP, 0, "Вы активируете его..."); /* Artifacts */ if (o_ptr->name1) { artifact_type *a_ptr = &a_info[o_ptr->name1]; switch (a_ptr->activation) { case ACT_ILLUMINATION: { msg_format("%s озаряется чистым светом...", o_name); lite_area(damroll(2, 15), 3); break; } case ACT_MAGIC_MAP: { msg_format("%s ярко сверкает...", o_name); map_area(); break; } case ACT_CLAIRVOYANCE: { msg_format("%s светится глубоким зеленым...", o_name); wiz_lite(); (void)detect_traps(); (void)detect_doors(); (void)detect_stairs(); break; } case ACT_PROT_EVIL: { msg_format("%s издает протяжный стон...", o_name); k = 3 * p_ptr->lev; (void)set_protevil(p_ptr->protevil + randint(25) + k); break; } case ACT_DISP_EVIL: { msg_format("%s заполняет подземелье добром...", o_name); dispel_evil(p_ptr->lev * 5); break; } case ACT_HASTE2: { msg_format("%s ярко светится...", o_name); if (!p_ptr->fast) { (void)set_fast(randint(75) + 75); } else { (void)set_fast(p_ptr->fast + 5); } break; } case ACT_FIRE3: { msg_format("%s светится глубоким красным...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_FIRE, dir, 120, 3); break; } case ACT_FROST5: { msg_format("%s светится ярко-белым...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_COLD, dir, 200, 3); break; } case ACT_ELEC2: { msg_format("%s светится глубоким синим...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_ELEC, dir, 250, 3); break; } case ACT_BIZZARE: { msg_format("%s светится черным...", o_name); if (!get_aim_dir(&dir)) return FALSE; ring_of_power(dir); break; } case ACT_STAR_BALL: { msg_format("%s окружается молнией...", o_name); for (i = 0; i < 8; i++) fire_ball(GF_ELEC, ddd[i], 150, 3); break; } case ACT_RAGE_BLESS_RESIST: { msg_format("%s светится всеми цветами...", o_name); (void)hp_player(30); (void)set_afraid(0); (void)set_shero(p_ptr->shero + randint(50) + 50); (void)set_blessed(p_ptr->blessed + randint(50) + 50); (void)set_oppose_acid(p_ptr->oppose_acid + randint(50) + 50); (void)set_oppose_elec(p_ptr->oppose_elec + randint(50) + 50); (void)set_oppose_fire(p_ptr->oppose_fire + randint(50) + 50); (void)set_oppose_cold(p_ptr->oppose_cold + randint(50) + 50); (void)set_oppose_pois(p_ptr->oppose_pois + randint(50) + 50); break; } case ACT_HEAL2: { msg_format("%s светится ярким белым...", o_name); msg_print("Вы чувствуете себя намного лучше..."); (void)hp_player(1000); (void)set_cut(0); break; } case ACT_PHASE: { msg_format("%s искривляет пространство вокруг вас...", o_name); teleport_player(10); break; } case ACT_BANISHMENT: { msg_format("%s светится угрожающим синим...", o_name); if (!banishment()) return FALSE; break; } case ACT_TRAP_DOOR_DEST: { msg_format("%s светится ярко-красным...", o_name); destroy_doors_touch(); break; } case ACT_DETECT: { msg_format("%s светится лучистым белым...", o_name); msg_print("Изображение формируется в вашей голове..."); detect_all(); break; } case ACT_HEAL1: { msg_format("%s светится спокойным синим...", o_name); msg_print("Вы чувствуете теплое покалывание..."); (void)hp_player(500); (void)set_cut(0); break; } case ACT_RESIST: { msg_format("%s светится цветами радуги...", o_name); (void)set_oppose_acid(p_ptr->oppose_acid + randint(20) + 20); (void)set_oppose_elec(p_ptr->oppose_elec + randint(20) + 20); (void)set_oppose_fire(p_ptr->oppose_fire + randint(20) + 20); (void)set_oppose_cold(p_ptr->oppose_cold + randint(20) + 20); (void)set_oppose_pois(p_ptr->oppose_pois + randint(20) + 20); break; } case ACT_SLEEP: { msg_format("%s светится ярко-синим...", o_name); sleep_monsters_touch(); break; } case ACT_RECHARGE1: { msg_format("%s светится ярко-желтым...", o_name); recharge(60); break; } case ACT_TELEPORT: { msg_format("%s распрямляет пространство вокруг вас...", o_name); teleport_player(100); break; } case ACT_RESTORE_LIFE: { msg_format("%s светится спокойным красным...", o_name); restore_level(); break; } case ACT_MISSILE: { msg_format("%s ярко горит...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_MISSILE, dir, damroll(2, 6)); break; } case ACT_FIRE1: { msg_format("%s покрывается пламенем...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_FIRE, dir, damroll(9, 8)); break; } case ACT_FROST1: { msg_format("%s излучает холод...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_COLD, dir, damroll(6, 8)); break; } case ACT_LIGHTNING_BOLT: { msg_format("%s сыплет искрамиs...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_ELEC, dir, damroll(4, 8)); break; } case ACT_ACID1: { msg_format("%s покрывается кислотой...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_ACID, dir, damroll(5, 8)); break; } case ACT_ARROW: { msg_format("%s покрывается шипами...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_ARROW, dir, 150); break; } case ACT_HASTE1: { msg_format("%s светится ярко-зеленым...", o_name); if (!p_ptr->fast) { (void)set_fast(randint(20) + 20); } else { (void)set_fast(p_ptr->fast + 5); } break; } case ACT_REM_FEAR_POIS: { msg_format("%s вспыхивает синим...", o_name); (void)set_afraid(0); (void)set_poisoned(0); break; } case ACT_STINKING_CLOUD: { msg_format("%s светится ядовито-зеленым...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_POIS, dir, 12, 3); break; } case ACT_FROST2: { msg_format("%s покрывается инеем...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_COLD, dir, 48, 2); break; } case ACT_FROST4: { msg_format("%s горит бледно-синим...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_COLD, dir, damroll(12, 8)); break; } case ACT_FROST3: { msg_format("%s светится насыщенным синим...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_COLD, dir, 100, 2); break; } case ACT_FIRE2: { msg_format("%s пылает огнем...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_ball(GF_FIRE, dir, 72, 2); break; } case ACT_DRAIN_LIFE2: { msg_format("%s светится черным...", o_name); if (!get_aim_dir(&dir)) return FALSE; drain_life(dir, 120); break; } case ACT_STONE_TO_MUD: { msg_format("%s пульсирует...", o_name); if (!get_aim_dir(&dir)) return FALSE; wall_to_mud(dir); break; } case ACT_MASS_BANISHMENT: { msg_format("%s издает протяжную ноту...", o_name); (void)mass_banishment(); break; } case ACT_CURE_WOUNDS: { msg_format("%s светится глубоким фиолетовым...", o_name); hp_player(damroll(4, 8)); (void)set_cut((p_ptr->cut / 2) - 50); break; } case ACT_TELE_AWAY: { msg_format("%s вспыхивает глубоким красным...", o_name); if (!get_aim_dir(&dir)) return FALSE; teleport_monster(dir); break; } case ACT_WOR: { msg_format("%s светится мягким белым...", o_name); set_recall(); break; } case ACT_CONFUSE: { msg_format("%s светится странными цветами...", o_name); if (!get_aim_dir(&dir)) return FALSE; confuse_monster(dir, 20); break; } case ACT_IDENTIFY: { msg_format("%s вспыхивает желтым...", o_name); if (!ident_spell()) return FALSE; break; } case ACT_PROBE: { msg_format("%s ярко загорается...", o_name); probing(); break; } case ACT_DRAIN_LIFE1: { msg_format("%s горит белым...", o_name); if (!get_aim_dir(&dir)) return FALSE; drain_life(dir, 90); break; } case ACT_FIREBRAND: { msg_format("%s светится огненно-красным...", o_name); (void)brand_bolts(); break; } case ACT_STARLIGHT: { msg_format("%s вспыхивает светом тысячи звезд...", o_name); for (k = 0; k < 8; k++) strong_lite_line(ddd[k]); break; } case ACT_MANA_BOLT: { msg_format("%s светится белым...", o_name); if (!get_aim_dir(&dir)) return FALSE; fire_bolt(GF_MANA, dir, damroll(12, 8)); break; } case ACT_BERSERKER: { msg_format("%s горит яростью...", o_name); set_shero(p_ptr->shero + randint(50) + 50); break; } } /* Set the recharge time */ if (a_ptr->randtime) o_ptr->timeout = a_ptr->time + (byte)randint(a_ptr->randtime); else o_ptr->timeout = a_ptr->time; /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Done */ return FALSE; } /* Hack -- Dragon Scale Mail can be activated as well */ if (o_ptr->tval == TV_DRAG_ARMOR) { /* Get a direction for breathing (or abort) */ if (!get_aim_dir(&dir)) return FALSE; /* Branch on the sub-type */ switch (o_ptr->sval) { case SV_DRAGON_BLUE: { msg_print("Вы дышите молнией."); fire_ball(GF_ELEC, dir, 100, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_WHITE: { msg_print("Вы дышите холодом."); fire_ball(GF_COLD, dir, 110, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_BLACK: { msg_print("Вы дышите кислотой."); fire_ball(GF_ACID, dir, 130, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_GREEN: { msg_print("Вы дышите ядовитым газом."); fire_ball(GF_POIS, dir, 150, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_RED: { msg_print("Вы дышите огнем."); fire_ball(GF_FIRE, dir, 200, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_MULTIHUED: { chance = rand_int(5); msg_format("Вы дышите %s.", ((chance == 1) ? "молнией" : ((chance == 2) ? "холодом" : ((chance == 3) ? "кислотой" : ((chance == 4) ? "ядовитым газом" : "огнем"))))); fire_ball(((chance == 1) ? GF_ELEC : ((chance == 2) ? GF_COLD : ((chance == 3) ? GF_ACID : ((chance == 4) ? GF_POIS : GF_FIRE)))), dir, 250, 2); o_ptr->timeout = rand_int(225) + 225; break; } case SV_DRAGON_BRONZE: { msg_print("Вы дышите контузией."); fire_ball(GF_CONFUSION, dir, 120, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_GOLD: { msg_print("Вы дышите звуком."); fire_ball(GF_SOUND, dir, 130, 2); o_ptr->timeout = rand_int(450) + 450; break; } case SV_DRAGON_CHAOS: { chance = rand_int(2); msg_format("Вы дышите %s.", ((chance == 1 ? "хаосом" : "антимагией"))); fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT), dir, 220, 2); o_ptr->timeout = rand_int(300) + 300; break; } case SV_DRAGON_LAW: { chance = rand_int(2); msg_format("Вы дышите %s.", ((chance == 1 ? "звуком" : "осколками"))); fire_ball((chance == 1 ? GF_SOUND : GF_SHARD), dir, 230, 2); o_ptr->timeout = rand_int(300) + 300; break; } case SV_DRAGON_BALANCE: { chance = rand_int(4); msg_format("Вы дышите %s.", ((chance == 1) ? "хаосом" : ((chance == 2) ? "антимагией" : ((chance == 3) ? "звуком" : "осколками")))); fire_ball(((chance == 1) ? GF_CHAOS : ((chance == 2) ? GF_DISENCHANT : ((chance == 3) ? GF_SOUND : GF_SHARD))), dir, 250, 2); o_ptr->timeout = rand_int(300) + 300; break; } case SV_DRAGON_SHINING: { chance = rand_int(2); msg_format("Вы дышите %s.", ((chance == 0 ? "светом" : "темнотой"))); fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, 2); o_ptr->timeout = rand_int(300) + 300; break; } case SV_DRAGON_POWER: { msg_print("Вы дышите элементами."); fire_ball(GF_MISSILE, dir, 300, 2); o_ptr->timeout = rand_int(300) + 300; break; } } /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Success */ return FALSE; } /* Hack -- some Rings can be activated for double resist and element ball */ if (o_ptr->tval == TV_RING) { /* Get a direction for firing (or abort) */ if (!get_aim_dir(&dir)) return FALSE; /* Branch on the sub-type */ switch (o_ptr->sval) { case SV_RING_ACID: { fire_ball(GF_ACID, dir, 70, 2); set_oppose_acid(p_ptr->oppose_acid + randint(20) + 20); o_ptr->timeout = rand_int(50) + 50; break; } case SV_RING_FLAMES: { fire_ball(GF_FIRE, dir, 80, 2); set_oppose_fire(p_ptr->oppose_fire + randint(20) + 20); o_ptr->timeout = rand_int(50) + 50; break; } case SV_RING_ICE: { fire_ball(GF_COLD, dir, 75, 2); set_oppose_cold(p_ptr->oppose_cold + randint(20) + 20); o_ptr->timeout = rand_int(50) + 50; break; } case SV_RING_LIGHTNING: { fire_ball(GF_ELEC, dir, 85, 2); set_oppose_elec(p_ptr->oppose_elec + randint(20) + 20); o_ptr->timeout = rand_int(50) + 50; break; } } /* Window stuff */ p_ptr->window |= (PW_EQUIP); /* Success */ return FALSE; } /* Mistake */ msg_print("Oops. That object cannot be activated."); /* Not used up */ return (FALSE); }
/* * 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); }
static bool quaff_potion(object_type *o_ptr, bool *ident) { /* Analyze the potion */ switch (o_ptr->sval) { case SV_POTION_WATER: case SV_POTION_APPLE_JUICE: case SV_POTION_SLIME_MOLD: { msg_print("Вы утолили жажду."); *ident = TRUE; break; } case SV_POTION_SLOWNESS: { if (set_slow(p_ptr->slow + randint(25) + 15)) *ident = TRUE; break; } case SV_POTION_SALT_WATER: { msg_print("Вя-а-а! Вас стошнило!"); (void)set_food(PY_FOOD_STARVE - 1); (void)set_poisoned(0); (void)set_paralyzed(p_ptr->paralyzed + 4); *ident = TRUE; break; } case SV_POTION_POISON: { if (!(p_ptr->resist_pois || p_ptr->oppose_pois)) { if (set_poisoned(p_ptr->poisoned + rand_int(15) + 10)) { *ident = TRUE; } } break; } case SV_POTION_BLINDNESS: { if (!p_ptr->resist_blind) { if (set_blind(p_ptr->blind + rand_int(100) + 100)) { *ident = TRUE; } } break; } case SV_POTION_CONFUSION: { if (!p_ptr->resist_confu) { if (set_confused(p_ptr->confused + rand_int(20) + 15)) { *ident = TRUE; } } break; } case SV_POTION_SLEEP: { if (!p_ptr->free_act) { if (set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4)) { *ident = TRUE; } } break; } case SV_POTION_LOSE_MEMORIES: { if (!p_ptr->hold_life && (p_ptr->exp > 0)) { msg_print("Ваша жизнь меркнет."); lose_exp(p_ptr->exp / 4); *ident = TRUE; } break; } case SV_POTION_RUINATION: { msg_print("Ваши нервы и мускулы кажутся слабыми и безжизненными!"); take_hit(damroll(10, 10), "зельем Ослабевания"); (void)dec_stat(A_DEX, 25, TRUE); (void)dec_stat(A_WIS, 25, TRUE); (void)dec_stat(A_CON, 25, TRUE); (void)dec_stat(A_STR, 25, TRUE); (void)dec_stat(A_CHR, 25, TRUE); (void)dec_stat(A_INT, 25, TRUE); *ident = TRUE; break; } case SV_POTION_DEC_STR: { if (do_dec_stat(A_STR)) *ident = TRUE; break; } case SV_POTION_DEC_INT: { if (do_dec_stat(A_INT)) *ident = TRUE; break; } case SV_POTION_DEC_WIS: { if (do_dec_stat(A_WIS)) *ident = TRUE; break; } case SV_POTION_DEC_DEX: { if (do_dec_stat(A_DEX)) *ident = TRUE; break; } case SV_POTION_DEC_CON: { if (do_dec_stat(A_CON)) *ident = TRUE; break; } case SV_POTION_DEC_CHR: { if (do_dec_stat(A_CHR)) *ident = TRUE; break; } case SV_POTION_DETONATIONS: { msg_print("Массивные взрывы сотрясают ваше тело!"); take_hit(damroll(50, 20), "зельем взрыва"); (void)set_stun(p_ptr->stun + 75); (void)set_cut(p_ptr->cut + 5000); *ident = TRUE; break; } case SV_POTION_DEATH: { msg_print("Чувство Смерти протекает сквозь вас..."); take_hit(5000, "зельем Смерти"); *ident = TRUE; break; } case SV_POTION_INFRAVISION: { if (set_tim_infra(p_ptr->tim_infra + 100 + randint(100))) { *ident = TRUE; } break; } case SV_POTION_DETECT_INVIS: { if (set_tim_invis(p_ptr->tim_invis + 12 + randint(12))) { *ident = TRUE; } break; } case SV_POTION_SLOW_POISON: { if (set_poisoned(p_ptr->poisoned / 2)) *ident = TRUE; break; } case SV_POTION_CURE_POISON: { if (set_poisoned(0)) *ident = TRUE; break; } case SV_POTION_BOLDNESS: { if (set_afraid(0)) *ident = TRUE; break; } case SV_POTION_SPEED: { if (!p_ptr->fast) { if (set_fast(randint(25) + 15)) *ident = TRUE; } else { (void)set_fast(p_ptr->fast + 5); } break; } case SV_POTION_RESIST_HEAT: { if (set_oppose_fire(p_ptr->oppose_fire + randint(10) + 10)) { *ident = TRUE; } break; } case SV_POTION_RESIST_COLD: { if (set_oppose_cold(p_ptr->oppose_cold + randint(10) + 10)) { *ident = TRUE; } break; } case SV_POTION_HEROISM: { if (hp_player(10)) *ident = TRUE; if (set_afraid(0)) *ident = TRUE; if (set_hero(p_ptr->hero + randint(25) + 25)) *ident = TRUE; break; } case SV_POTION_BERSERK_STRENGTH: { if (hp_player(30)) *ident = TRUE; if (set_afraid(0)) *ident = TRUE; if (set_shero(p_ptr->shero + randint(25) + 25)) *ident = TRUE; break; } case SV_POTION_CURE_LIGHT: { if (hp_player(damroll(2, 8))) *ident = TRUE; if (set_blind(0)) *ident = TRUE; if (set_cut(p_ptr->cut - 10)) *ident = TRUE; break; } case SV_POTION_CURE_SERIOUS: { if (hp_player(damroll(4, 8))) *ident = TRUE; if (set_blind(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_cut((p_ptr->cut / 2) - 50)) *ident = TRUE; break; } case SV_POTION_CURE_CRITICAL: { if (hp_player(damroll(6, 8))) *ident = TRUE; if (set_blind(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_POTION_HEALING: { if (hp_player(300)) *ident = TRUE; if (set_blind(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_POTION_STAR_HEALING: { if (hp_player(1200)) *ident = TRUE; if (set_blind(0)) *ident = TRUE; if (set_confused(0)) *ident = TRUE; if (set_poisoned(0)) *ident = TRUE; if (set_stun(0)) *ident = TRUE; if (set_cut(0)) *ident = TRUE; break; } case SV_POTION_LIFE: { msg_print("Чуство Жизни протекает в вас!"); restore_level(); (void)set_poisoned(0); (void)set_blind(0); (void)set_confused(0); (void)set_image(0); (void)set_stun(0); (void)set_cut(0); (void)do_res_stat(A_STR); (void)do_res_stat(A_CON); (void)do_res_stat(A_DEX); (void)do_res_stat(A_WIS); (void)do_res_stat(A_INT); (void)do_res_stat(A_CHR); /* Recalculate max. hitpoints */ update_stuff(); hp_player(5000); *ident = TRUE; break; } case SV_POTION_RESTORE_MANA: { if (p_ptr->csp < p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; msg_print("Ваша голова проясняется."); p_ptr->redraw |= (PR_MANA); p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1); *ident = TRUE; } break; } case SV_POTION_RESTORE_EXP: { if (restore_level()) *ident = TRUE; break; } case SV_POTION_RES_STR: { if (do_res_stat(A_STR)) *ident = TRUE; break; } case SV_POTION_RES_INT: { if (do_res_stat(A_INT)) *ident = TRUE; break; } case SV_POTION_RES_WIS: { if (do_res_stat(A_WIS)) *ident = TRUE; break; } case SV_POTION_RES_DEX: { if (do_res_stat(A_DEX)) *ident = TRUE; break; } case SV_POTION_RES_CON: { if (do_res_stat(A_CON)) *ident = TRUE; break; } case SV_POTION_RES_CHR: { if (do_res_stat(A_CHR)) *ident = TRUE; break; } case SV_POTION_INC_STR: { if (do_inc_stat(A_STR)) *ident = TRUE; break; } case SV_POTION_INC_INT: { if (do_inc_stat(A_INT)) *ident = TRUE; break; } case SV_POTION_INC_WIS: { if (do_inc_stat(A_WIS)) *ident = TRUE; break; } case SV_POTION_INC_DEX: { if (do_inc_stat(A_DEX)) *ident = TRUE; break; } case SV_POTION_INC_CON: { if (do_inc_stat(A_CON)) *ident = TRUE; break; } case SV_POTION_INC_CHR: { if (do_inc_stat(A_CHR)) *ident = TRUE; break; } case SV_POTION_AUGMENTATION: { if (do_inc_stat(A_STR)) *ident = TRUE; if (do_inc_stat(A_INT)) *ident = TRUE; if (do_inc_stat(A_WIS)) *ident = TRUE; if (do_inc_stat(A_DEX)) *ident = TRUE; if (do_inc_stat(A_CON)) *ident = TRUE; if (do_inc_stat(A_CHR)) *ident = TRUE; break; } case SV_POTION_ENLIGHTENMENT: { msg_print("Изображение подземелья формируется у вас в голове..."); wiz_lite(); *ident = TRUE; break; } case SV_POTION_STAR_ENLIGHTENMENT: { msg_print("Вы чувствуете себя просвещенным..."); message_flush(); wiz_lite(); (void)do_inc_stat(A_INT); (void)do_inc_stat(A_WIS); (void)detect_traps(); (void)detect_doors(); (void)detect_stairs(); (void)detect_treasure(); (void)detect_objects_gold(); (void)detect_objects_normal(); identify_pack(); self_knowledge(); *ident = TRUE; break; } case SV_POTION_SELF_KNOWLEDGE: { msg_print("Вы познаете себя немного лучше..."); message_flush(); self_knowledge(); *ident = TRUE; break; } case SV_POTION_EXPERIENCE: { if (p_ptr->exp < PY_MAX_EXP) { s32b ee = (p_ptr->exp / 2) + 10; if (ee > 100000L) ee = 100000L; msg_print("Вы чувствуете себя более опытным."); gain_exp(ee); *ident = TRUE; } break; } } return (TRUE); }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(void) { int i, item, slot; object_type forge; object_type *q_ptr; object_type *o_ptr; cptr act; char o_name[MAX_NLEN]; cptr q, s; bool newrace = FALSE; /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ #ifdef JP q = "どれを装備しますか? "; s = "装備可能なアイテムがない。"; #else q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; #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]; } /* Check the slot */ slot = wield_slot(o_ptr); /* Where is the item now */ if (slot == INVEN_WIELD) { #ifdef JP act = "を打撃用に装備した"; #else act = "You are wielding"; #endif } else if (slot == INVEN_BOW) { #ifdef JP act = "を射撃用に装備した"; #else act = "You are shooting with"; #endif } else if (slot == INVEN_LITE) { #ifdef JP act = "を光源にした"; #else act = "Your light source is"; #endif } else { #ifdef JP act = "を装備した"; #else act = "You are wearing"; #endif } if ((o_ptr->tval == TV_RING) && inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx) { /* Restrict the choices */ item_tester_tval = TV_RING; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの指輪と取り替えますか?"; s = "おっと。"; #else q = "Replace which ring? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } if (slot == INVEN_WIELD) { if (is_two_handed()) { /* Restrict the choices */ item_tester_hook = item_tester_hook_melee_weapon; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの武器と取り替えますか?"; s = "おっと。"; #else q = "Replace which weapon? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } else if (inventory[slot].k_idx) { /* Confirm doing two handed combat */ #ifdef JP if (get_check("二刀流を行いますか?")) #else if (get_check("Do you want to do two handed combat?")) #endif { slot = INVEN_ARM; } } } /* Prevent wielding into a cursed slot */ if (cursed_p(&inventory[slot])) { /* Describe it */ object_desc(o_name, &inventory[slot], OD_OMIT_PREFIX | OD_NAME_ONLY); /* Message */ #ifdef JP msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name ); #else msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); #endif /* Cancel the command */ return; } if (cursed_p(o_ptr) && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE))) { char dummy[512]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "本当に%s{呪われている}を使いますか?", o_name); #else sprintf(dummy, "Really use the %s {cursed}? ", o_name); #endif if (!get_check(dummy)) return; } #if 0 if ((o_ptr->name1 == ART_STONEMASK) && object_known_p(o_ptr) && (p_ptr->prace != RACE_VAMPIRE)) { char dummy[MAX_NLEN+80]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name); #else msg_format("%s will transforms you into a vampire permanently when equiped.", o_name); sprintf(dummy, "Do you become a vampire?"); #endif if (!get_check(dummy)) return; } #endif /* Check if completed a quest */ for (i = 0; i < max_quests; i++) { if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) && (quest[i].status == QUEST_STATUS_TAKEN) && (quest[i].k_idx == o_ptr->name1)) { quest[i].status = QUEST_STATUS_COMPLETED; quest[i].complev = (byte)p_ptr->lev; #ifdef JP msg_print("クエストを達成した!"); #else msg_print("You completed your quest!"); #endif sound(SOUND_LEVEL); /* (Sound substitute) No quest sound */ msg_print(NULL); } } /* Take a turn */ energy_use = 100; /* Get local object */ q_ptr = &forge; /* Obtain local object */ object_copy(q_ptr, o_ptr); /* Modify quantity */ q_ptr->number = 1; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } /* Access the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Wear the new stuff */ object_copy(o_ptr, q_ptr); /* Player touches it */ o_ptr->marked |= OM_TOUCHED; /* Forget stack */ o_ptr->next_o_idx = 0; /* Forget location */ o_ptr->iy = o_ptr->ix = 0; /* Increase the weight */ p_ptr->total_weight += q_ptr->weight; /* Increment the equip counter by hand */ equip_cnt++; /* Describe the result */ object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP msg_format("%s(%c)%s。", o_name, index_to_label(slot), act ); #else msg_format("%s %s (%c).", act, o_name, index_to_label(slot)); #endif sound(SOUND_WIELD); /* Cursed! */ if (cursed_p(o_ptr)) { /* Warn the player */ #ifdef JP msg_print("うわ! すさまじく冷たい!"); #else msg_print("Oops! It feels deathly cold!"); #endif sound(SOUND_CURSED); /* Note the curse */ o_ptr->ident |= (IDENT_SENSE); } #if 0 /* if you weild stonemask, you morph into vampire */ if ((o_ptr->name1 == ART_STONEMASK) && (!is_undead())) { p_ptr->prace = RACE_VAMPIRE; newrace = TRUE; #ifdef JP msg_format("あなたは吸血鬼に変化した!"); #else msg_format("You polymorphed into a vampire!"); #endif } #endif if (newrace) { rp_ptr = &race_info[p_ptr->prace]; /* Experience factor */ calc_expfact(); /* Get new height and weight */ get_ahw(FALSE); check_experience(); /* Hitdice */ p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp; do_cmd_rerate(TRUE); p_ptr->redraw |= (PR_BASIC); p_ptr->update |= (PU_BONUS); handle_stuff(); /* Load an autopick preference file */ autopick_load_pref(FALSE); lite_spot(py, px); } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Recalculate mana */ p_ptr->update |= (PU_MANA); p_ptr->redraw |= (PR_EQUIPPY); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER | PW_STATS); }
static bool read_scroll(object_type *o_ptr, bool *ident) { int py = p_ptr->py; int px = p_ptr->px; int k; bool used_up = TRUE; /* Analyze the scroll */ switch (o_ptr->sval) { case SV_SCROLL_DARKNESS: { if (!p_ptr->resist_blind) { (void)set_blind(p_ptr->blind + 3 + randint(5)); } if (unlite_area(10, 3)) *ident = TRUE; break; } case SV_SCROLL_AGGRAVATE_MONSTER: { msg_print("Вы слышите громкий противный звук."); aggravate_monsters(0); *ident = TRUE; break; } case SV_SCROLL_CURSE_ARMOR: { if (curse_armor()) *ident = TRUE; break; } case SV_SCROLL_CURSE_WEAPON: { if (curse_weapon()) *ident = TRUE; break; } case SV_SCROLL_SUMMON_MONSTER: { for (k = 0; k < randint(3); k++) { if (summon_specific(py, px, p_ptr->depth, 0)) { *ident = TRUE; } } break; } case SV_SCROLL_SUMMON_UNDEAD: { for (k = 0; k < randint(3); k++) { if (summon_specific(py, px, p_ptr->depth, SUMMON_UNDEAD)) { *ident = TRUE; } } break; } case SV_SCROLL_TRAP_CREATION: { if (trap_creation()) *ident = TRUE; break; } case SV_SCROLL_PHASE_DOOR: { teleport_player(10); *ident = TRUE; break; } case SV_SCROLL_TELEPORT: { teleport_player(100); *ident = TRUE; break; } case SV_SCROLL_TELEPORT_LEVEL: { (void)teleport_player_level(); *ident = TRUE; break; } case SV_SCROLL_WORD_OF_RECALL: { set_recall(); *ident = TRUE; break; } case SV_SCROLL_IDENTIFY: { *ident = TRUE; if (!ident_spell()) used_up = FALSE; break; } case SV_SCROLL_STAR_IDENTIFY: { *ident = TRUE; if (!identify_fully()) used_up = FALSE; break; } case SV_SCROLL_REMOVE_CURSE: { if (remove_curse()) { msg_print("Вы чувствуете, как кто-то присматривает за вами."); *ident = TRUE; } break; } case SV_SCROLL_STAR_REMOVE_CURSE: { remove_all_curse(); *ident = TRUE; break; } case SV_SCROLL_ENCHANT_ARMOR: { *ident = TRUE; if (!enchant_spell(0, 0, 1)) used_up = FALSE; break; } case SV_SCROLL_ENCHANT_WEAPON_TO_HIT: { if (!enchant_spell(1, 0, 0)) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_ENCHANT_WEAPON_TO_DAM: { if (!enchant_spell(0, 1, 0)) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_STAR_ENCHANT_ARMOR: { if (!enchant_spell(0, 0, randint(3) + 2)) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_STAR_ENCHANT_WEAPON: { if (!enchant_spell(randint(3), randint(3), 0)) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_RECHARGING: { if (!recharge(60)) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_LIGHT: { if (lite_area(damroll(2, 8), 2)) *ident = TRUE; break; } case SV_SCROLL_MAPPING: { map_area(); *ident = TRUE; break; } case SV_SCROLL_DETECT_GOLD: { if (detect_treasure()) *ident = TRUE; if (detect_objects_gold()) *ident = TRUE; break; } case SV_SCROLL_DETECT_ITEM: { if (detect_objects_normal()) *ident = TRUE; break; } case SV_SCROLL_DETECT_TRAP: { if (detect_traps()) *ident = TRUE; break; } case SV_SCROLL_DETECT_DOOR: { if (detect_doors()) *ident = TRUE; if (detect_stairs()) *ident = TRUE; break; } case SV_SCROLL_DETECT_INVIS: { if (detect_monsters_invis()) *ident = TRUE; break; } case SV_SCROLL_SATISFY_HUNGER: { if (set_food(PY_FOOD_MAX - 1)) *ident = TRUE; break; } case SV_SCROLL_BLESSING: { if (set_blessed(p_ptr->blessed + randint(12) + 6)) *ident = TRUE; break; } case SV_SCROLL_HOLY_CHANT: { if (set_blessed(p_ptr->blessed + randint(24) + 12)) *ident = TRUE; break; } case SV_SCROLL_HOLY_PRAYER: { if (set_blessed(p_ptr->blessed + randint(48) + 24)) *ident = TRUE; break; } case SV_SCROLL_MONSTER_CONFUSION: { if (p_ptr->confusing == 0) { msg_print("Ваши руки начинают светиться."); p_ptr->confusing = TRUE; *ident = TRUE; } break; } case SV_SCROLL_PROTECTION_FROM_EVIL: { k = 3 * p_ptr->lev; if (set_protevil(p_ptr->protevil + randint(25) + k)) *ident = TRUE; break; } case SV_SCROLL_RUNE_OF_PROTECTION: { warding_glyph(); *ident = TRUE; break; } case SV_SCROLL_TRAP_DOOR_DESTRUCTION: { if (destroy_doors_touch()) *ident = TRUE; break; } case SV_SCROLL_STAR_DESTRUCTION: { destroy_area(py, px, 15, TRUE); *ident = TRUE; break; } case SV_SCROLL_DISPEL_UNDEAD: { if (dispel_undead(60)) *ident = TRUE; break; } case SV_SCROLL_BANISHMENT: { if (!banishment()) used_up = FALSE; *ident = TRUE; break; } case SV_SCROLL_MASS_BANISHMENT: { (void)mass_banishment(); *ident = TRUE; break; } case SV_SCROLL_ACQUIREMENT: { acquirement(py, px, 1, TRUE); *ident = TRUE; break; } case SV_SCROLL_STAR_ACQUIREMENT: { acquirement(py, px, randint(2) + 1, TRUE); *ident = TRUE; break; } } return (used_up); }
/* * 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); } }
void banish_evil_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Banish Evil"); break; case SPELL_DESC: var_set_string(res, "Attempts to remove a single evil opponent."); break; case SPELL_GAIN_MUT: msg_print("You feel a holy wrath fill you."); break; case SPELL_LOSE_MUT: msg_print("You no longer feel a holy wrath."); break; case SPELL_MUT_DESC: var_set_string(res, "You can send evil creatures directly to Hell."); break; case SPELL_CAST: { int dir = 0; int x, y; cave_type *c_ptr; monster_type *m_ptr; monster_race *r_ptr; if (!get_rep_dir2(&dir)) { var_set_bool(res, FALSE); break; } var_set_bool(res, TRUE); y = py + ddy[dir]; x = px + ddx[dir]; c_ptr = &cave[y][x]; if (!c_ptr->m_idx) { msg_print("You sense no evil there!"); break; } m_ptr = &m_list[c_ptr->m_idx]; r_ptr = &r_info[m_ptr->r_idx]; if ((r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags1 & RF1_QUESTOR) && !(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena && !p_ptr->inside_quest && (r_ptr->level < randint1(p_ptr->lev+50)) && !(m_ptr->mflag2 & MFLAG2_NOGENO)) { /* Delete the monster, rather than killing it. */ delete_monster_idx(c_ptr->m_idx); msg_print("The evil creature vanishes in a puff of sulfurous smoke!"); } else { msg_print("Your invocation is ineffectual!"); if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO; } break; } default: default_spell(cmd, res); break; } }
/* * Remove the inscription from an object * XXX Mention item (when done)? */ void do_cmd_uninscribe(void) { int item; object_type *o_ptr; cptr q, s; /* Get an item */ #ifdef JP q = "どのアイテムの銘を消しますか? "; s = "銘を消せるアイテムがない。"; #else q = "Un-inscribe which item? "; s = "You have nothing to un-inscribe."; #endif if (!get_item(&item, q, s, (USE_EQUIP | 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]; } /* Nothing to remove */ if (!o_ptr->inscription) { #ifdef JP msg_print("このアイテムには消すべき銘がない。"); #else msg_print("That item had no inscription to remove."); #endif return; } /* Message */ #ifdef JP msg_print("銘を消した。"); #else msg_print("Inscription removed."); #endif /* Remove the incription */ o_ptr->inscription = 0; /* Combine the pack */ p_ptr->notice |= (PN_COMBINE); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); /* Update stuff */ p_ptr->update |= (PU_BONUS); }
/* * Set "p_ptr->food", notice observable changes * * The "p_ptr->food" variable can get as large as 20000, allowing the * addition of the most "filling" item, Elvish Waybread, which adds * 7500 food units, without overflowing the 32767 maximum limit. * * Perhaps we should disturb the player with various messages, * especially messages about hunger status changes. XXX XXX XXX * * Digestion of food is handled in "dungeon.c", in which, normally, * the player digests about 20 food units per 100 game turns, more * when "fast", more when "regenerating", less with "slow digestion", * but when the player is "gorged", he digests 100 food units per 10 * game turns, or a full 1000 food units per 100 game turns. * * Note that the player's speed is reduced by 10 units while gorged, * so if the player eats a single food ration (5000 food units) when * full (15000 food units), he will be gorged for (5000/100)*10 = 500 * game turns, or 500/(100/5) = 25 player turns (if nothing else is * affecting the player speed). */ bool set_food(int v) { int old_aux, new_aux; bool notice = FALSE; /* Hack -- Force good values */ v = MIN(v, PY_FOOD_UPPER); v = MAX(v, 0); /* Fainting / Starving */ if (p_ptr->food < PY_FOOD_FAINT) { old_aux = 0; } /* Weak */ else if (p_ptr->food < PY_FOOD_WEAK) { old_aux = 1; } /* Hungry */ else if (p_ptr->food < PY_FOOD_ALERT) { old_aux = 2; } /* Normal */ else if (p_ptr->food < PY_FOOD_FULL) { old_aux = 3; } /* Full */ else if (p_ptr->food < PY_FOOD_MAX) { old_aux = 4; } /* Gorged */ else { old_aux = 5; } /* Fainting / Starving */ if (v < PY_FOOD_FAINT) { new_aux = 0; } /* Weak */ else if (v < PY_FOOD_WEAK) { new_aux = 1; } /* Hungry */ else if (v < PY_FOOD_ALERT) { new_aux = 2; } /* Normal */ else if (v < PY_FOOD_FULL) { new_aux = 3; } /* Full */ else if (v < PY_FOOD_MAX) { new_aux = 4; } /* Gorged */ else { new_aux = 5; } /* Food increase */ if (new_aux > old_aux) { /* Describe the state */ switch (new_aux) { /* Weak */ case 1: { msg_print("You are still weak."); break; } /* Hungry */ case 2: { msg_print("You are still hungry."); break; } /* Normal */ case 3: { msg_print("You are no longer hungry."); break; } /* Full */ case 4: { msg_print("You are full!"); break; } /* Bloated */ case 5: { message(MSG_HUNGRY, 0, "You have gorged yourself!"); break; } } /* Change */ notice = TRUE; } /* Food decrease */ else if (new_aux < old_aux) { /* Describe the state */ switch (new_aux) { /* Fainting / Starving */ case 0: { sound(MSG_NOTICE); message(MSG_PARALYZED, 0, "You are getting faint from hunger!"); break; } /* Weak */ case 1: { sound(MSG_NOTICE); message(MSG_HUNGRY, 0, "You are getting weak from hunger!"); break; } /* Hungry */ case 2: { sound(MSG_HUNGRY); message(MSG_HUNGRY, 0, "You are getting hungry."); break; } /* Normal */ case 3: { sound(MSG_NOTICE); msg_print("You are no longer full."); break; } /* Full */ case 4: { sound(MSG_NOTICE); msg_print("You are no longer gorged."); break; } } /* Change */ notice = TRUE; } /* Use the value */ p_ptr->food = v; /* Nothing to notice */ if (!notice) return (FALSE); /* Disturb */ if (disturb_state) disturb(0, 0); /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Redraw hunger */ p_ptr->redraw |= (PR_STATUS|PR_HP); /* Handle stuff */ handle_stuff(); /* Result */ return (TRUE); }
static void _shatter_device_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, T("Shatter Device", "")); break; case SPELL_DESC: var_set_string(res, T("Destroy a magical device in your inventory for various effects.", "")); break; case SPELL_CAST: { int item; object_type *o_ptr; var_set_bool(res, FALSE); item_tester_hook = item_tester_hook_recharge; if (!get_item(&item, "Shatter which device?", "You have nothing to shatter.", USE_INVEN)) return; o_ptr = &inventory[item]; var_set_bool(res, TRUE); if (_object_is_(o_ptr, TV_STAFF, SV_STAFF_DESTRUCTION)) { if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), 4 * p_ptr->lev)) msg_print("The dungeon collapses..."); else msg_print("The dungeon trembles."); } else if ( _object_is_(o_ptr, TV_STAFF, SV_STAFF_HEALING) || _object_is_(o_ptr, TV_ROD, SV_ROD_HEALING) || _object_is_(o_ptr, TV_ROD, SV_ROD_RESTORATION) ) { msg_print("You feel life flow through your body!"); restore_level(); (void)set_poisoned(0, TRUE); (void)set_blind(0, TRUE); (void)set_confused(0, TRUE); (void)set_image(0, TRUE); (void)set_stun(0, TRUE); (void)set_cut(0, TRUE); (void)do_res_stat(A_STR); (void)do_res_stat(A_CON); (void)do_res_stat(A_DEX); (void)do_res_stat(A_WIS); (void)do_res_stat(A_INT); (void)do_res_stat(A_CHR); update_stuff(); hp_player(5000); } else if (_object_is_(o_ptr, TV_ROD, SV_ROD_TELEPORT_AWAY)) { banish_monsters(p_ptr->lev * 4); } else { project(0, 5, py, px, k_info[o_ptr->k_idx].level * 16, _object_dam_type(o_ptr), PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1); } inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); break; } default: default_spell(cmd, res); break; } }
/* * Interact with "colors" */ void do_cmd_colors(void) { s32b i; PHYSFS_file *fff; char tmp[160]; char buf[1024]; /* Enter "icky" mode */ character_icky++; /* Save the screen */ Term_save(); /* Interact until done */ while (1) { /* Clear screen */ Term_clear(); /* Ask for a choice */ prt("Interact with Colors", 2, 0); /* Give some choices */ prt("(1) Load a user pref file", 4, 5); #ifdef ALLOW_COLORS prt("(2) Dump colors", 5, 5); prt("(3) Modify colors", 6, 5); # ifdef SUPPORT_GAMMA prt("(4) Gamma correction", 7, 5); # endif /* SUPPORT_GAMMA */ #endif /* Prompt */ prt("Command: ", 8, 0); /* Prompt */ i = inkey(); /* Done */ if (i == ESCAPE) break; /* Load a 'pref' file */ if (i == '1') { /* Prompt */ prt("Command: Load a user pref file", 8, 0); /* Prompt */ prt("File: ", 10, 0); /* Default file */ strnfmt(tmp, 160, "user-%s.prf", ANGBAND_SYS); /* Query */ if (!askfor_aux(tmp, 70)) continue; /* Process the given filename */ (void)process_pref_file(tmp); /* Mega-Hack -- react to changes */ Term_xtra(TERM_XTRA_REACT, 0); /* Mega-Hack -- redraw */ Term_redraw(); } #ifdef ALLOW_COLORS /* Dump colors */ else if (i == '2') { /* Prompt */ prt("Command: Dump colors", 8, 0); /* Prompt */ prt("File: ", 10, 0); /* Default filename */ strnfmt(tmp, 160, "user-%s.prf", ANGBAND_SYS); /* Get a filename */ if (!askfor_aux(tmp, 70)) continue; /* Build the filename */ path_build(buf, 1024, TENGINE_DIR_USER, tmp); /* Append to the file */ fff = my_fopen(buf, "a"); /* Failure */ if (!fff) continue; /* Start dumping */ fprintf(fff, "\n\n"); fprintf(fff, "# Color redefinitions\n\n"); /* Dump colors */ for (i = 0; i < 256; i++) { s32b kv = angband_color_table[i][0]; s32b rv = angband_color_table[i][1]; s32b gv = angband_color_table[i][2]; s32b bv = angband_color_table[i][3]; cptr name = "unknown"; /* Skip non-entries */ if (!kv && !rv && !gv && !bv) continue; /* Extract the color name */ name = color_names[i]; /* Dump a comment */ fprintf(fff, "# Color '%s'\n", name); /* Dump the monster attr/char info */ fprintf(fff, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n", i, kv, rv, gv, bv); } /* All done */ fprintf(fff, "\n\n\n\n"); /* Close */ my_fclose(fff); /* Message */ msg_print("Dumped color redefinitions."); } /* Edit colors */ else if (i == '3') { static byte a = 0; /* Prompt */ prt("Command: Modify colors", 8, 0); /* Hack -- query until done */ while (1) { cptr name; /* Clear */ clear_from(10); /* Exhibit the normal colors */ for (i = 0; i < 16; i++) { /* Exhibit this color */ Term_putstr(i*4, 20, -1, a, "###"); /* Exhibit all colors */ Term_putstr(i*4, 22, -1, i, format("%3d", i)); } /* Describe the color */ name = ((color_names[a]) ? color_names[a] : "undefined"); /* Describe the color */ Term_putstr(5, 10, -1, TERM_WHITE, format("Color = %d, Name = %s", a, name)); /* Label the Current values */ Term_putstr(5, 12, -1, TERM_WHITE, format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x", angband_color_table[a][0], angband_color_table[a][1], angband_color_table[a][2], angband_color_table[a][3])); /* Prompt */ Term_putstr(0, 14, -1, TERM_WHITE, "Command (n/N/k/K/r/R/g/G/b/B): "); /* Get a command */ i = inkey(); /* All done */ if (i == ESCAPE) break; /* Analyze */ if (i == 'n') a = (byte)(a + 1); if (i == 'N') a = (byte)(a - 1); if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1); if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1); if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1); if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1); if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1); if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1); if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1); if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1); /* Hack -- react to changes */ Term_xtra(TERM_XTRA_REACT, 0); /* Hack -- redraw */ Term_redraw(); } } # ifdef SUPPORT_GAMMA /* Gamma correction */ else if (i == '4') { s32b gamma; /* Prompt */ prt("Command: Gamma correction", 8, 0); /* gamma_val isn't set - assume 1.0 */ if (gamma_val == 0) gamma = 10; /* It's set - convert to usual notation (times 10) */ else gamma = 2560 / gamma_val; /* Hack -- query until done */ while (1) { /* Clear */ clear_from(10); /* Exhibit the normal colors */ for (i = 0; i < 16; i++) { /* Exhibit all colors */ Term_putstr(i*4, 22, -1, i, format("%3d", i)); } /* Describe the gamma */ Term_putstr(5, 10, -1, TERM_WHITE, format("Gamma = %d.%d", gamma / 10, gamma % 10)); /* Prompt */ Term_putstr(0, 12, -1, TERM_WHITE, "Command (g/G): "); /* Get a command */ i = inkey(); /* All done */ if (i == ESCAPE) break; /* Analyze */ if (i == 'g') gamma = (byte)(gamma + 1); else if (i == 'G') gamma = (byte)(gamma - 1); else continue; /* Force limits ([1.0, 2.5]) */ if (gamma < 10) gamma = 10; if (gamma > 25) gamma = 25; /* Hack - 1.0 means no correction */ if (gamma == 10) gamma_val = 0; /* otherwise, calculate gamma_val */ else gamma_val = 2560 / gamma; /* Hack -- react to changes */ Term_xtra(TERM_XTRA_REACT, 0); /* Hack -- redraw */ Term_redraw(); } } # endif /* SUPPORT_GAMMA */ #endif /* Unknown option */ else { bell(); } /* Flush messages */ msg_print(NULL); } /* Restore the screen */ Term_load(); /* Leave "icky" mode */ character_icky--; }