void gray_mage_cast_spell(void) { _slot_info_ptr slot_ptr; /* Blind is OK!!! */ if (p_ptr->confused) { msg_print("You are too confused!"); return; } slot_ptr = _choose("Cast", _ALLOW_EXCHANGE | _SHOW_INFO); if (slot_ptr) { magic_type *spell_ptr = _get_spell_info(slot_ptr->realm, slot_ptr->spell); int cost = calculate_cost(spell_ptr->smana); int fail = calculate_fail_rate(spell_ptr->slevel, spell_ptr->sfail, p_ptr->stat_ind[A_INT]); if (spell_ptr->slevel > p_ptr->lev) /* Experience Drain? */ { msg_format("You need to be level %d to use that spell.", spell_ptr->slevel); return; } if (cost > p_ptr->csp) { msg_print("You do not have enough mana to cast this spell."); return; } p_ptr->csp -= cost; energy_use = 100; if (randint0(100) < fail) { if (flush_failure) flush(); cmsg_format(TERM_VIOLET, "You failed to cast %s!", do_spell(slot_ptr->realm, slot_ptr->spell, SPELL_NAME)); if (demigod_is_(DEMIGOD_ATHENA)) p_ptr->csp += cost/2; spell_stats_on_fail_old(slot_ptr->realm, slot_ptr->spell); sound(SOUND_FAIL); do_spell(slot_ptr->realm, slot_ptr->spell, SPELL_FAIL); } else { if (!do_spell(slot_ptr->realm, slot_ptr->spell, SPELL_CAST)) { /* Canceled */ p_ptr->csp += cost; energy_use = 0; return; } sound(SOUND_ZAP); spell_stats_on_cast_old(slot_ptr->realm, slot_ptr->spell); } } p_ptr->redraw |= PR_MANA; p_ptr->window |= PW_SPELL; }
/* * Apply abilities to be granted this level */ void apply_level_abilities(s32b level) { s32b z, i; /***** Apply each descriptors abilities, in order *****/ for (z = 1; z <= flag_max_key(&p_ptr->descriptors); z++) { player_descriptor *d_ptr = &descriptor_info[flag_get(&p_ptr->descriptors, z)]; /* Check all the */ for (i = 0; i < d_ptr->abilities.size; i++) { flag_node *n = &d_ptr->abilities.node[i]; if (n->flags & FLAG_FLAG_USED) { if (flag_get(&d_ptr->abilities, n->key) == level) { if ((level > 1) && (!ab_info[n->key].acquired)) cmsg_format(TERM_L_GREEN, "You have learned the ability '%s'.", ab_info[n->key].name); ab_info[n->key].acquired = TRUE; } } } } }
int doc_display_help_aux(cptr file_name, cptr topic, rect_t display) { int rc = _OK; FILE *fp = NULL; char path[1024]; char caption[1024]; doc_ptr doc = NULL; int top = 0; /* Check for file_name#topic from a lazy client */ if (!topic) { cptr pos = strchr(file_name, '#'); if (pos) { string_ptr name = string_copy_sn(file_name, pos - file_name); int result = doc_display_help_aux(string_buffer(name), pos + 1, display); string_free(name); return result; } } sprintf(caption, "Help file '%s'", file_name); path_build(path, sizeof(path), ANGBAND_DIR_HELP, file_name); fp = my_fopen(path, "r"); if (!fp) { cmsg_format(TERM_VIOLET, "Cannot open '%s'.", file_name); msg_print(NULL); return _OK; } doc = doc_alloc(MIN(80, display.cx)); doc_read_file(doc, fp); my_fclose(fp); if (topic) { doc_pos_t pos = doc_find_bookmark(doc, topic); if (doc_pos_is_valid(pos)) top = pos.y; } rc = doc_display_aux(doc, caption, top, display); doc_free(doc); return rc; }
/* A special fetch(), that places item in player's inventory */ static bool _whip_fetch(int dir, int rng) { int ty, tx; cave_type *c_ptr; object_type *o_ptr; char o_name[MAX_NLEN]; /* Use a target */ if (dir == 5 && target_okay()) { tx = target_col; ty = target_row; if (distance(py, px, ty, tx) > rng) { msg_print("You can't fetch something that far away!"); return FALSE; } c_ptr = &cave[ty][tx]; /* We need an item to fetch */ if (!c_ptr->o_idx) { msg_print("There is no object at this place."); return TRUE; /* didn't work, but charge the player energy anyway */ } /* Fetching from a vault is OK */ /* Line of sight is required */ if (!player_has_los_bold(ty, tx)) { msg_print("You have no direct line of sight to that location."); return FALSE; } else if (!projectable(py, px, ty, tx)) { msg_print("You have no direct line of sight to that location."); return FALSE; } } else { /* Use a direction */ ty = py; /* Where to drop the item */ tx = px; do { ty += ddy[dir]; tx += ddx[dir]; c_ptr = &cave[ty][tx]; if ((distance(py, px, ty, tx) > MAX_RANGE) || !in_bounds(ty, tx) || !cave_have_flag_bold(ty, tx, FF_PROJECT)) { return TRUE; /* didn't work, but charge the player energy anyway */ } } while (!c_ptr->o_idx); } o_ptr = &o_list[c_ptr->o_idx]; if (o_ptr->weight > p_ptr->lev * 15) { msg_print("The object is too heavy."); return TRUE; /* didn't work, but charge the player energy anyway */ } object_desc(o_name, o_ptr, OD_NAME_ONLY); /* Get the object */ if (!inven_carry_okay(o_ptr)) { cmsg_format(TERM_VIOLET, "You fail to fetch %^s since your pack is full.", o_name); /* Leave the object where it is */ } else { msg_format("You skillfully crack your whip and fetch %^s.", o_name); py_pickup_aux(c_ptr->o_idx); } return TRUE; }