Ejemplo n.º 1
0
void rage_mage_gain_spell(void)
{
    int item;

    if (p_ptr->blind || no_lite())
    {
        msg_print("You cannot see!");
        return;
    }

    if (p_ptr->confused)
    {
        msg_print("You are too confused!");
        return;
    }
    
    if (!p_ptr->new_spells)
    {
        msg_print("You cannot learn any new techniques!");
        return;
    }

    msg_format("You can learn %d new technique%s.", p_ptr->new_spells, (p_ptr->new_spells == 1 ? "" : "s"));
    msg_print(NULL);

    item_tester_tval = TV_RAGE_BOOK;
    if (get_item(&item, "Study which book?", "You have no books that you can read.", USE_INVEN))
    {
        int book = inventory[item].sval;
        if (_gain_spell(book))
        {
            char o_name[MAX_NLEN];
            int old_amt = inventory[item].number;

            inventory[item].number = 1;
            object_desc(o_name, &inventory[item], 0);
            inventory[item].number = old_amt;
            
            msg_format("%^s is destroyed.", o_name);
            inven_item_increase(item, -1);
            inven_item_describe(item);
            inven_item_optimize(item);
            
            energy_use = 100;
        }
    }
}
Ejemplo n.º 2
0
/* Monster Fear */
bool fear_process_m(int m_idx)
{
    monster_type *m_ptr = &m_list[m_idx];
    if (MON_MONFEAR(m_ptr) && !MON_CSLEEP(m_ptr))
    {
        if (fear_save_m(m_ptr))
        {
            bool recovered = FALSE;
            if (fear_save_m(m_ptr))
            {
                set_monster_monfear(m_idx, 0);
                recovered = TRUE;
            }
            else
            {
            monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];

                recovered = set_monster_monfear(m_idx,
                    MON_MONFEAR(m_ptr) - randint1(r_ptr->level / 20 + 1));
            }

            if (recovered && is_seen(m_ptr))
            {
                char m_name[80];
                char m_poss[80];

                monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
                monster_desc(m_name, m_ptr, 0);

                msg_format("%^s recovers %s courage.", m_name, m_poss);
            }
        }
        else if (one_in_(3) && !fear_save_m(m_ptr))
        {
            if (is_seen(m_ptr))
            {
                char m_name[80];
                monster_desc(m_name, m_ptr, 0);
                msg_format("%^s is scared stiff!", m_name);
            }
            return FALSE;
        }
    }
    return TRUE;
}
Ejemplo n.º 3
0
bool target_set_closest(int mode)
{
	int y, x, m_idx;
	monster_type *m_ptr;
	char m_name[80];
	bool visibility;

	/* Cancel old target */
	target_set_monster(0);

	/* Get ready to do targetting */
	target_set_interactive_prepare(mode);

	/* Find the first monster in the queue */
	y = temp_y[0];
	x = temp_x[0];
	m_idx = cave_m_idx[y][x];

	/* If nothing was prepared, then return */
  	if (temp_n < 1)
	{
		msg_print("No Available Target.");
		return FALSE;
	}

	/* Target the monster, if possible */
	if ((m_idx <= 0) || !target_able(m_idx))
	{
		msg_print("No Available Target.");
		return FALSE;
	}

	/* Target the monster */
	m_ptr = &mon_list[m_idx];
	monster_desc(m_name, sizeof(m_name), m_ptr, 0x00);
	if (!(mode & TARGET_QUIET))
		msg_format("%^s is targeted.", m_name);
	Term_fresh();

	/* Set up target information */
	monster_race_track(m_ptr->r_idx);
	health_track(cave_m_idx[y][x]);
	target_set_monster(m_idx);

	/* Visual cue */
	Term_get_cursor(&visibility);
	(void)Term_set_cursor(TRUE);
	move_cursor_relative(y, x);
	Term_redraw_section(x, y, x, y);

	/* TODO: what's an appropriate amount of time to spend highlighting */
	Term_xtra(TERM_XTRA_DELAY, 150);
	(void)Term_set_cursor(visibility);

	return TRUE;
}
Ejemplo n.º 4
0
void sword_absorb_object(object_type *o_ptr)
{
    if (object_is_melee_weapon(o_ptr))
    {
        char o_name[MAX_NLEN];
        object_desc(o_name, o_ptr, OD_NAME_ONLY);
        msg_format("You attempt to drain power from %s.", o_name);
        _absorb(o_ptr);
    }
}
Ejemplo n.º 5
0
static void _gain_level(int new_level) {
    int tier = _find_tier(p_ptr->current_r_idx);
    if (tier < 0 || tier == _MAX_TIERS - 1) return;
    if (p_ptr->lev >= _tiers[tier + 1].level)
    {
        p_ptr->current_r_idx = _random(_tiers[tier+1].r_ids);
        msg_format("You have evolved into a %s.", _mon_name(p_ptr->current_r_idx));
        p_ptr->redraw |= PR_MAP;
    }
}
Ejemplo n.º 6
0
/**
 * Notice things about an object that would be noticed in time.
 */
static void object_notice_after_time(void)
{
	int i;
	int flag;

	object_type *o_ptr;
	char o_name[80];

	bitflag f[OF_SIZE], timed_mask[OF_SIZE];

	flags_init(timed_mask, OF_SIZE, OF_NOTICE_TIMED_MASK, FLAG_END);

	/* Check every item the player is wearing */
	for (i = INVEN_WIELD; i < ALL_INVEN_TOTAL; i++)
	{
		o_ptr = &p_ptr->inventory[i];

		if (!o_ptr->k_idx || object_is_known(o_ptr)) continue;

		/* Check for timed notice flags */
		object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
		object_flags(o_ptr, f);
		of_inter(f, timed_mask);

		for (flag = of_next(f, FLAG_START); flag != FLAG_END; flag = of_next(f, flag + 1))
		{
			if (!of_has(o_ptr->known_flags, flag))
			{
				/* Message */
				if (!streq(msgs[flag], ""))
					msg_format(msgs[flag], o_name);

				/* Notice the flag */
				object_notice_flag(o_ptr, flag);

				if (object_is_jewelry(o_ptr) &&
					 (!object_effect(o_ptr) || object_effect_is_known(o_ptr)))
				{
					/* XXX this is a small hack, but jewelry with anything noticeable really is obvious */
					/* XXX except, wait until learn activation if that is only clue */
					object_flavor_aware(o_ptr);
					object_check_for_ident(o_ptr);
				}
			}
			else
			{
				/* Notice the flag is absent */
				object_notice_flag(o_ptr, flag);
			}
		}

		/* XXX Is this necessary? */
		object_check_for_ident(o_ptr);
	}
}
Ejemplo n.º 7
0
/*
 * Hack -- Rerate Hitpoints
 */
void do_cmd_rerate(bool display)
{
	int percent;

	/* Rerate */
	do_cmd_rerate_aux();

	percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
		(2 * p_ptr->hitdie +
		((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));


	/* Update and redraw hitpoints */
	p_ptr->update |= (PU_HP);
	p_ptr->redraw |= (PR_HP);

	/* Window stuff */
	p_ptr->window |= (PW_PLAYER);

	/* Handle stuff */
	handle_stuff();

	/* Message */
	if (display)
	{
#ifdef JP
		msg_format("現在の体力ランクは %d/100 です。", percent);
#else
		msg_format("Your life rate is %d/100 now.", percent);
#endif
		p_ptr->knowledge |= KNOW_HPRATE;
	}
	else
	{
#ifdef JP
		msg_print("体力ランクが変わった。");
#else
		msg_print("Life rate is changed.");
#endif
		p_ptr->knowledge &= ~(KNOW_HPRATE);
	}
}
Ejemplo n.º 8
0
/*!
 * @brief キャラクタダンプを作って BUFに保存
 * @param dumpbuf 伝送内容バッファ
 * @return エラーコード
 */
static errr make_dump(BUF* dumpbuf)
{
	char		buf[1024];
	FILE *fff;
	char file_name[1024];

	/* Open a new file */
	fff = my_fopen_temp(file_name, 1024);
	if (!fff)
	{
#ifdef JP
		msg_format("一時ファイル %s を作成できませんでした。", file_name);
#else
		msg_format("Failed to create temporary file %s.", file_name);
#endif
		msg_print(NULL);
		return 1;
	}

	/* 一旦一時ファイルを作る。通常のダンプ出力と共通化するため。 */
	(void)make_character_dump(fff);

	/* Close the file */
	my_fclose(fff);

	/* Open for read */
	fff = my_fopen(file_name, "r");

	while (fgets(buf, 1024, fff))
	{
		(void)buf_sprintf(dumpbuf, "%s", buf);
	}

	/* Close the file */
	my_fclose(fff);

	/* Remove the file */
	fd_kill(file_name);

	/* Success */
	return (0);
}
Ejemplo n.º 9
0
bool rune_add(object_type *o_ptr, int which, bool prompt)	/* Birthing needs access to this ... */
{
	char o_name[MAX_NLEN];

	if (!which) return FALSE;

	object_desc(o_name, o_ptr, 0);

	/* For now, the restriction is one rune per object.  I'm using flags in case we change our mind ... */
	if (o_ptr->rune_flags)
	{
		msg_format("%^s already has an attached rune.", o_name);
		return FALSE;
	}

	if (prompt)
	{
		if (!get_check(
				format("Really add %^s to %^s?", 
					rune_desc(which), o_name))) return FALSE;
	}

	o_ptr->rune_flags = which;

	/* Runes protect objects from the elements */
	add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
	add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
	add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
	add_flag(o_ptr->art_flags, TR_IGNORE_COLD);

	/* Some runes can be completely handled by existing flags */
	if (which == RUNE_DESTRUCTION)
		add_flag(o_ptr->art_flags, TR_FORCE_WEAPON);

	if (which == RUNE_REFLECTION)
		add_flag(o_ptr->art_flags, TR_REFLECT);

	msg_format("%^s gleams.", o_name);
	p_ptr->update |= PU_BONUS;

	return TRUE;
}
Ejemplo n.º 10
0
static bool _memorize_form(int r_idx)
{
    int           i;
    monster_race *r_ptr = &r_info[r_idx];

    if (_is_memorized(r_idx))
    {
        msg_format("You already know this form (%s).", r_name + r_ptr->name);
        return FALSE;
    }

    i = _choose_new_slot(r_idx);
    if (i >= 0 && i < _MAX_FORMS)
    {
        _forms[i] = r_idx;
        msg_format("You have learned this form (%s).", r_name + r_ptr->name);
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 11
0
static void _set_current_r_idx(int r_idx)
{
    if (r_idx == p_ptr->current_r_idx)
        return;

    disturb(1, 0);
    if (r_idx == MON_MIMIC && p_ptr->current_r_idx)
        msg_format("You stop mimicking %s.", r_name + r_info[p_ptr->current_r_idx].name);
    possessor_set_current_r_idx(r_idx);
    if (r_idx != MON_MIMIC)
        msg_format("You start mimicking %s.", r_name + r_info[p_ptr->current_r_idx].name);
    /* Mimics shift forms often enough to be annoying if shapes
       have dramatically different body types (e.g. dragons vs humanoids).
       Inscribe gear with @mimic to autoequip on shifing. */
    equip_shuffle("@mimic1");
    equip_shuffle("@mimic2");
    equip_shuffle("@mimic3");
    equip_shuffle("@mimic4");
    equip_shuffle("@mimic");
}
/* Make a real level */
static bool level_gen(cptr *why)
{
    int level_height, level_width;

    if ((always_small_levels || ironman_small_levels ||
        (one_in_(SMALL_LEVEL) && small_levels) ||
         (d_info[dungeon_type].flags1 & DF1_BEGINNER) ||
        (d_info[dungeon_type].flags1 & DF1_SMALLEST)) &&
        !(d_info[dungeon_type].flags1 & DF1_BIG))
    {
        if (cheat_room)
            msg_print("A 'small' dungeon level.");

        if (d_info[dungeon_type].flags1 & DF1_SMALLEST)
        {
            level_height = 1;
            level_width = 1;
        }
        else if (d_info[dungeon_type].flags1 & DF1_BEGINNER)
        {
            level_height = 2;
            level_width = 2;
        }
        else
        {
            do
            {
                level_height = randint1(MAX_HGT/SCREEN_HGT);
                level_width = randint1(MAX_WID/SCREEN_WID);
            }
            while (level_height + level_width > MAX_HGT/SCREEN_HGT + MAX_WID/SCREEN_WID - 2);
        }

        cur_hgt = level_height * SCREEN_HGT;
        cur_wid = level_width * SCREEN_WID;

        if (cheat_room)
          msg_format("X:%d, Y:%d.", cur_wid, cur_hgt);
    }
    else
    {
        /* Big dungeon */
        cur_hgt = MAX_HGT;
        cur_wid = MAX_WID;
    }

    /* Make a dungeon */
    if (!cave_gen())
    {
        *why = "could not place player";
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 13
0
/* Player and monster swap places */
bool player_monster_swap(monster_type *m_ptr)
{
	char m_name[80];
	cave_type *c_ptr;

	if (!m_ptr) return FALSE;

	if (has_flag(m_ptr, FLAG_NO_PUSHBACK)) return FALSE;

	c_ptr = &cave[m_ptr->fy][m_ptr->fx];

	m_ptr->csleep = 0;

	/* Extract monster name (or "it") */
	monster_desc(m_name, m_ptr, 0);

	/* Auto-Recall if possible and visible */
	if (m_ptr->ml) monster_race_track(m_ptr->r_idx, m_ptr->ego);

	/* Track a new monster */
	if (m_ptr->ml) health_track(c_ptr->m_idx);

	/* displace? */
	if (cave_floor_bold(p_ptr->py, p_ptr->px) ||
		monst_can_pass_square(m_ptr, p_ptr->py, p_ptr->px, NULL))
	{
		msg_format("You push past %s.", m_name);
		m_ptr->fy = p_ptr->py;
		m_ptr->fx = p_ptr->px;
		cave[p_ptr->py][p_ptr->px].m_idx = c_ptr->m_idx;
		c_ptr->m_idx = 0;
		update_mon(cave[p_ptr->py][p_ptr->px].m_idx, TRUE);
		return TRUE;
	}
	else
	{
		msg_format("%^s is in your way!", m_name);
		energy_use = 0;
		return FALSE;
	}
}
Ejemplo n.º 14
0
void vampire_take_light_damage(int amt)
{
    if (!fear_save_p(amt))
    {
        msg_print("You fear the light!");
        fear_add_p(FEAR_SCARED);
    }

    if (randint1(p_ptr->chp) < amt && !res_save_default(RES_LITE))
    {
        int k = 0;
        cptr act = NULL;

        switch (randint1(12))
        {
        case 1: case 2: case 3: case 4: case 5:
            msg_print("You feel your unlife force diminish.");
            lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
            break;

        case 6: case 7: case 8: case 9:
            switch (randint1(6))
            {
                case 1: k = A_STR; act = "strong"; break;
                case 2: k = A_INT; act = "bright"; break;
                case 3: k = A_WIS; act = "wise"; break;
                case 4: k = A_DEX; act = "agile"; break;
                case 5: k = A_CON; act = "hale"; break;
                case 6: k = A_CHR; act = "confident"; break;
            }
            msg_format("You're not as %s as you used to be.", act);
            p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
            if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
            break;

        case 10:
            msg_print("You're not as powerful as you used to be.");
            for (k = 0; k < 6; k++)
            {
                p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
                if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
            }
            break;

        case 11: case 12:
            if (disenchant_player())
                msg_print("You feel diminished!");
            break;
        }

        p_ptr->update |= PU_BONUS;
    }
}
Ejemplo n.º 15
0
static bool snipe_concentrate(void)
{
    if ((int)p_ptr->concent < (2 + (p_ptr->lev + 5) / 10)) p_ptr->concent++;

    msg_format("You concentrate deeply. (lvl %d)", p_ptr->concent);
    reset_concent = FALSE;

    p_ptr->update |= PU_BONUS;
    p_ptr->redraw |= PR_STATUS;
    p_ptr->update |= PU_MONSTERS;
    return TRUE;
}
Ejemplo n.º 16
0
/*
 * Hack -- Rerate Hitpoints
 */
void do_cmd_rerate(void)
{
	int min_value, max_value, i, j, percent;

	min_value = (PY_MAX_LEVEL * 3 * (p_ptr->hitdie - 1)) / 8;
	min_value += PY_MAX_LEVEL;

	max_value = (PY_MAX_LEVEL * 5 * (p_ptr->hitdie - 1)) / 8;
	max_value += PY_MAX_LEVEL;

	p_ptr->player_hp[0] = p_ptr->hitdie;

	/* Rerate */
	while (1)
	{
		/* Collect values */
		for (i = 1; i < PY_MAX_LEVEL; i++)
		{
			/* Add in racial hit dice */
			j = randint1(rp_ptr->r_mhp);
			p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + j;

			/* If class hit dice is non zero - add it on */
			if (cp_ptr->c_mhp)
			{
				p_ptr->player_hp[i] += randint1(cp_ptr->c_mhp);
			}
		}

		/* Legal values */
		if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
		    (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
	}

	percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
		(2 * p_ptr->hitdie +
		((PY_MAX_LEVEL - 1) * (p_ptr->hitdie + 1))));


	/* Update and redraw hitpoints */
	p_ptr->update |= (PU_HP);
	p_ptr->redraw |= (PR_HP);

	/* Window stuff */
	p_ptr->window |= (PW_PLAYER);

	/* Handle stuff */
	handle_stuff();

	/* Message */
	msg_format("Current Life Rating is %d/100.", percent);
}
Ejemplo n.º 17
0
/**********************************************************************
 * Powers
 **********************************************************************/
static void _absorb_spell(int cmd, variant *res)
{
    switch (cmd)
    {
    case SPELL_NAME:
        var_set_string(res, "Absorb Weapon");
        break;
    case SPELL_DESC:
        var_set_string(res, "Destroys a single weapon, absorbing the essence of its power.");
        break;
    case SPELL_CAST:
    {
        object_type * o_ptr;
        int item;
        char o_name[MAX_NLEN];

        var_set_bool(res, FALSE);
        item_tester_hook = object_is_melee_weapon;

        if (!get_item(&item, "Absorb which item? ", "You have nothing to absorb.", USE_INVEN | USE_FLOOR)) break;

        if (item >= 0)
            o_ptr = &inventory[item];
        else
            o_ptr = &o_list[0 - item];

        object_desc(o_name, o_ptr, OD_NAME_ONLY);
        msg_format("You absorb the power of %s!", o_name);
        _absorb(o_ptr);

        if (item >= 0)
        {
            inven_item_increase(item, -1);
            inven_item_describe(item);
            inven_item_optimize(item);
        }
        else
        {
            floor_item_increase(0 - item, -1);
            floor_item_describe(0 - item);
            floor_item_optimize(0 - item);
        }
        

        var_set_bool(res, TRUE);
        break;
    }
    default:
        default_spell(cmd, res);
        break;
    }
}
Ejemplo n.º 18
0
/*
 * Describe an item in the inventory.
 */
void item_describe(s32b item)
{
	object_type *o_ptr = get_object(item);
	char o_name[80];

	if (!o_ptr) return;

	/* Get a description */
	object_desc(o_name, o_ptr, TRUE, 3);

	/* Print a message */
	msg_format("%s %s.", (item < 0) ? "You see":"You have", o_name);
}
Ejemplo n.º 19
0
/*
 * Inquire whether the player wishes to squelch items similar to an object
 *
 * Returns whether the item is now squelched.
 */
bool squelch_interactive(const object_type *o_ptr)
{
	char out_val[70];

	if (squelch_tval(o_ptr->tval))
	{
		char sval_name[50];

		/* Obtain plural form without a quantity */
		object_desc(sval_name, sizeof sval_name, o_ptr,
					ODESC_BASE | ODESC_PLURAL);
		/* XXX Eddie while correct in a sense, to squelch all torches on torch of brightness you get the message "Ignore Wooden Torches of Brightness in future? " */
		strnfmt(out_val, sizeof out_val, "Ignore %s in future? ",
				sval_name);

		if (!artifact_p(o_ptr) || !object_flavor_is_aware(o_ptr))
		{
			if (get_check(out_val))
			{
				object_squelch_flavor_of(o_ptr);
				msg_format("Ignoring %s from now on.", sval_name);
				return TRUE;
			}
		}
		/* XXX Eddie need to add generalized squelching, e.g. con rings with pval < 3 */
		if (!object_is_jewelry(o_ptr) || (squelch_level_of(o_ptr) != SQUELCH_BAD))
			return FALSE;
	}

	if (object_was_sensed(o_ptr) || object_was_worn(o_ptr) || object_is_known_not_artifact(o_ptr))
	{
		byte value = squelch_level_of(o_ptr);
		int type = squelch_type_of(o_ptr);

/* XXX Eddie on pseudoed cursed artifact, only showed {cursed}, asked to ignore artifacts */
		if ((value != SQUELCH_MAX) && ((value == SQUELCH_BAD) || !object_is_jewelry(o_ptr)))
		{

			strnfmt(out_val, sizeof out_val, "Ignore all %s that are %s in future? ",
				quality_choices[type].name, quality_values[value].name);

			if (get_check(out_val))
			{
				squelch_level[type] = value;
				return TRUE;
			}
		}

	}
	return FALSE;
}
Ejemplo n.º 20
0
bool duelist_issue_challenge(void)
{
    bool result = FALSE;
    int m_idx = 0;

    if (target_set(TARGET_MARK))
    {
        msg_flag = FALSE; /* Bug ... we get an extra -more- prompt after target_set() ... */
        if (target_who > 0)
            m_idx = target_who;
        else
            m_idx = cave[target_row][target_col].m_idx;
    }

    if (m_idx)
    {
        if (m_idx == p_ptr->duelist_target_idx)
            msg_format("%^s has already been challenged.", duelist_current_challenge());
        else
        {
            /* of course, we must first set the target index before duelist_current_challenge()
               will return the correct text */
            p_ptr->duelist_target_idx = m_idx;
            msg_format("You challenge %s to a duel!", duelist_current_challenge());
            set_monster_csleep(m_idx, 0);
            set_hostile(&m_list[m_idx]);
            result = TRUE;
        }
    }
    else if (p_ptr->duelist_target_idx)
    {
        p_ptr->duelist_target_idx = 0;
        msg_print("You cancel your current challenge!");
    }

    p_ptr->redraw |= PR_STATUS;
    return result;
}
Ejemplo n.º 21
0
bool jelly_eat_object(object_type *o_ptr)
{
    char o_name[MAX_NLEN];
    object_type copy = *o_ptr;
    copy.number = 1;
    object_desc(o_name, &copy, OD_COLOR_CODED);
    set_food(MIN(PY_FOOD_FULL - 1, p_ptr->food + o_ptr->weight * 50));
    msg_format("You assimilate %s into your gelatinous frame.", o_name);
    /* TODO: Consider giving timed benefits based on what is absorbed.
       For example, TR_RES_FIRE might give temp fire resistance and 
       TR_SPEED might give temporary haste.
    */
    return TRUE;
}
Ejemplo n.º 22
0
/*
 * Go to any level
 */
static void do_cmd_wiz_jump(void)
{
	/* Ask for level */
	if (p_ptr->command_arg <= 0)
	{
		char	ppp[80];

		char	tmp_val[160];

		/* Prompt */
		sprintf(ppp, "Jump to level (0-%d): ", MAX_DEPTH-1);

		/* Default */
		sprintf(tmp_val, "%d", p_ptr->depth);

		/* Ask for a level */
		if (!get_string(ppp, tmp_val, 10)) return;

		/* Extract request */
		p_ptr->command_arg = atoi(tmp_val);
	}

	/* Paranoia */
	if (p_ptr->command_arg < 0) p_ptr->command_arg = 0;

	/* Paranoia */
	if (p_ptr->command_arg > MAX_DEPTH - 1) p_ptr->command_arg = MAX_DEPTH - 1;

	/* Accept request */
	msg_format("You jump to dungeon level %d.", p_ptr->command_arg);

	if (autosave_l) do_cmd_save_game(TRUE);

	/* Change level */
	p_ptr->depth = p_ptr->command_arg;
	leaving_quest = p_ptr->inside_quest;

	/* Leaving an 'only once' quest marks it as failed */
	if (leaving_quest &&
		(quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
		(quest[leaving_quest].status == QUEST_STATUS_TAKEN))
	{
		quest[leaving_quest].status = QUEST_STATUS_FAILED;
	}

	p_ptr->inside_quest = 0;

	/* Leaving */
	p_ptr->leaving = TRUE;
}
Ejemplo n.º 23
0
/* Is the player capable of studying? */
bool player_can_study(void)
{
	if (!player_can_cast())
		return FALSE;

	if (!p_ptr->new_spells)
	{
		cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer");
		msg_format("You cannot learn any new %ss!", p);
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 24
0
/*
 * Check to see if the player can use a rod/wand/staff/activatable object.
 */
static int check_devices(object_type *o_ptr)
{
	int fail;
	const char *msg;
	const char *what = NULL;

	/* Get the right string */
	switch (o_ptr->tval)
	{
		case TV_ROD:   msg = "zap the rod";   break;
		case TV_WAND:  msg = "use the wand";  what = "wand";  break;
		case TV_STAFF: msg = "use the staff"; what = "staff"; break;
		default:       msg = "activate it";  break;
	}

	/* Figure out how hard the item is to use */
	fail = get_use_device_chance(o_ptr);

	/* Roll for usage */
	if (randint1(1000) < fail)
	{
		flush();
		msg_format("You failed to %s properly.", msg);
		return FALSE;
	}

	/* Notice empty staffs */
	if (what && o_ptr->pval <= 0)
	{
		flush();
		msg_format("The %s has no charges left.", what);
		o_ptr->ident |= (IDENT_EMPTY);
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 25
0
/*
 * Turns a simple pet into a faithful companion
 */
void do_cmd_companion()
{
	monster_type *m_ptr;
	s32b ii, jj;

	if (!can_create_companion())
	{
		msg_print("You cannot get anymore companion.");
		return;
	}

	if (!tgt_pt(&ii, &jj))
	{
		msg_print("You must target a pet.");
		return;
	}

	if (cave[jj][ii].m_idx)
	{
		char m_name[100];

		m_ptr = get_monster(cave[jj][ii].m_idx);

		monster_desc(m_name, m_ptr, 0);
		if (m_ptr->faction == FACTION_PLAYER)
		{
			bool_flag(m_ptr, FLAG_PERMANENT);
			msg_format("%^s agrees to follow you.", m_name);
		}
		else
		{
			msg_format("%^s is not in your faction!", m_name);
		}
	}
	else
		msg_print("You must target a monster of your own faction.");
}
Ejemplo n.º 26
0
void swap_wielding_hands(void)
{
	/* Swap hands wielding sub weapon */
	if (is_two_handed())
	{
		char o_name[MAX_NLEN];
		object_type *o_ptr = &inventory[INVEN_ARM];
		object_type *q_ptr = &inventory[INVEN_WIELD];

		object_copy(q_ptr, o_ptr);
		object_wipe(o_ptr);

		/* Describe local object */
		object_desc(o_name, q_ptr, 0);

#ifdef JP
		msg_format("%sを右手で構えた。", o_name);
#else
		msg_format("You are weilding %s in your right hand.", o_name);
#endif

		p_ptr->redraw |= (PR_EQUIPPY);
	}
}
Ejemplo n.º 27
0
/**********************************************************************
 * Powers
 **********************************************************************/
static void _mimic_spell(int cmd, variant *res)
{
    switch (cmd)
    {
    case SPELL_NAME:
        if (p_ptr->current_r_idx == MON_MIMIC)
            var_set_string(res, "Mimic");
        else
            var_set_string(res, "Stop Mimicry");
        break;
    case SPELL_DESC:
        if (p_ptr->current_r_idx == MON_MIMIC)
            var_set_string(res, "Mimic a nearby visible monster, gaining the powers and abilities of that form.");
        else
            var_set_string(res, "Return to your native form.");
        break;
    case SPELL_INFO:
        if (p_ptr->current_r_idx == MON_MIMIC)
            var_set_string(res, format("Lvl %d", _calc_level(p_ptr->lev) + 5));
        break;
    case SPELL_CAST:
    {
        var_set_bool(res, FALSE);

        if (p_ptr->current_r_idx == MON_MIMIC)
        {
            int           r_idx = _choose_mimic_form(); /*_prompt();*/
            monster_race *r_ptr = 0;

            if (r_idx <= 0 || r_idx > max_r_idx) return;

            r_ptr = &r_info[r_idx];
            if (r_ptr->level > _calc_level(p_ptr->lev) + 5)
                msg_format("You are not powerful enough to mimic this form (%s: Lvl %d).", r_name + r_ptr->name, r_ptr->level);
            else
                _set_current_r_idx(r_idx);
        }
        else
            _set_current_r_idx(MON_MIMIC);

        var_set_bool(res, TRUE);
        break;
    }
    default:
        default_spell(cmd, res);
        break;
    }
}
Ejemplo n.º 28
0
/*
 * 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;

    item_tester_no_ryoute = TRUE;
    /* Get an item */
    q = "Examine which item? ";
    s = "You have nothing to examine.";

    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];
    }


    /* Note, descriptions for potions, scrolls, wands, staves and rods all spoil 
       the object's effects. Some of the light and jewelry descriptions are also TMI.
       Descriptions for weapons and armor should always be displayed. */
    if (!object_is_weapon_armour_ammo(o_ptr) && !object_is_known(o_ptr))
    {
        msg_print("You have no special knowledge about that item.");
        return;
    }

    /* Description */
    object_desc(o_name, o_ptr, 0);

    /* Describe */
    msg_format("Examining %s...", o_name);

    /* Describe it fully */
    if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print("You see nothing special.");
}
Ejemplo n.º 29
0
static void _elemental_pack_destroy(object_p p, cptr destroy_fmt, int chance)
{
    int inven_ct = 0;
    int equip_ct = 0;
    int i;
    for (i = 0; i < INVEN_TOTAL; i++)
    {
        object_type *o_ptr = &inventory[i];
        char         o_name[MAX_NLEN];
        int          n = chance;
        int          old_ct = 0;

        if (!o_ptr->k_idx) continue;
        if (!p(o_ptr)) continue;
        
        if (i >= EQUIP_BEGIN) n /= 3;
        if (randint0(1000) >= MAX(1, n)) continue;

        old_ct = o_ptr->number;
        o_ptr->number = 1;
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        o_ptr->number = old_ct;

        msg_format(destroy_fmt, o_name);
        stats_on_p_destroy(o_ptr, 1);

        inven_item_increase(i, -1);
        inven_item_describe(i);
        inven_item_optimize(i);

        if (i >= EQUIP_BEGIN) ++equip_ct;
        else ++inven_ct;
    }

    if (equip_ct)
    {
        p_ptr->update |= PU_BONUS;
        p_ptr->update |= PU_TORCH;
        p_ptr->update |= PU_MANA;
        p_ptr->redraw |= PR_EQUIPPY;
        p_ptr->window |= PW_EQUIP | PW_PLAYER;
    }
    if (inven_ct)
        p_ptr->window |= PW_INVEN;

    if (equip_ct + inven_ct)
        disturb(1, 0);
}
Ejemplo n.º 30
0
void fear_update_m(monster_type *m_ptr)
{
    monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
    if ((r_ptr->flags2 & RF2_AURA_FEAR) && m_ptr->ml && !is_pet(m_ptr) && !is_friendly(m_ptr))
    {
        int r_level = _r_level(r_ptr);
        if (!fear_save_p(r_level))
        {
            char m_name[80];
            monster_desc(m_name, m_ptr, 0);
            msg_format("You behold the terrifying visage of %s!", m_name);
            mon_lore_2(m_ptr, RF2_AURA_FEAR);
            fear_add_p(r_level);
        }
    }
}