Exemplo n.º 1
0
/*
 * Apply magic to armour
 */
static void a_m_aux_2(object_type *o_ptr, int level, int power)
{
	int toac1 = randint1(5) + m_bonus(5, level);
	int toac2 = m_bonus(10, level);


	if (power == -2)
		o_ptr->to_a -= toac1 + toac2;
	else if (power == -1)
		o_ptr->to_a -= toac1;
	else if (power == 1)
		o_ptr->to_a += toac1;
	else if (power == 2)
		o_ptr->to_a += toac1 + toac2;


	/* Analyze type */
	switch (o_ptr->tval)
	{
		case TV_DRAG_ARMOR:
		{
			/* Rating boost */
			rating += object_power(o_ptr, FALSE, NULL, TRUE) / 15;

			/* Mention the item */
			if (OPT(cheat_peek)) object_mention(o_ptr);

			break;
		}
	}
}
Exemplo n.º 2
0
/**
 * Apply magic to armour
 */
static void apply_magic_armour(struct object *obj, int level, int power)
{
	if (power <= 0)
		return;

	obj->to_a += randint1(5) + m_bonus(5, level);
	if (power > 1)
		obj->to_a += m_bonus(10, level);
}
Exemplo n.º 3
0
/*
 * Apply magic to armour
 */
static void apply_magic_armour(object_type *o_ptr, int level, int power)
{
	if (power <= 0)
		return;

	o_ptr->to_a += randint1(5) + m_bonus(5, level);
	if (power > 1)
		o_ptr->to_a += m_bonus(10, level);
}
Exemplo n.º 4
0
/**
 * Attempt to make an object
 *
 * \param c is the current dungeon level.
 * \param j_ptr is the object struct to be populated.
 * \param lev is the creation level of the object (not necessarily == depth).
 * \param good is whether the object is to be good
 * \param great is whether the object is to be great
 * \param value is the value to be returned to the calling function
 *
 * Returns the whether or not creation worked.
 */
bool make_object(struct cave *c, object_type *j_ptr, int lev, bool good,
	bool great, s32b *value)
{
	int base, art, div;
	object_kind *kind;

	/* Base level and artifact chance for the object */
	if (great) {
		art = ART_GREAT;
		base = lev + 10 + m_bonus(5, lev);
	} else if (good) {
		art = ART_GOOD;
		base = lev + 5 + m_bonus(5, lev);
	} else {
		art = ART_NORMAL;
		base = lev;
	}

	/* Small hack to bring artifact frequencies at low depths in line with V */
	div = 9 - p_ptr->depth;
	if (div < 1)
		div = 1;

	/* Try to make an artifact */
	if (one_in_(art * div)) {
		if (make_artifact(j_ptr, lev)) {
			if (value)
				*value = object_value_real(j_ptr, 1, FALSE, TRUE);
			return TRUE;
		}
	}

	/* Get the object, prep it and apply magic */
	kind = get_obj_num(base, good || great);
	if (!kind) return FALSE;
	object_prep(j_ptr, kind, base, RANDOMISE);
	apply_magic(j_ptr, base, FALSE, good, great);

	/* Generate multiple items */
	if (kind->gen_mult_prob >= randint1(100))
		j_ptr->number = randcalc(kind->stack_size, lev, RANDOMISE);

	if (j_ptr->number >= MAX_STACK_SIZE)
		j_ptr->number = MAX_STACK_SIZE - 1;

	/* Return value, increased for uncursed out-of-depth objects */
	if (value)
		*value = object_value_real(j_ptr, j_ptr->number, FALSE, TRUE);

	if (!cursed_p(j_ptr->flags) && (kind->alloc_min > c->depth)) {
		if (value) *value = (kind->alloc_min - c->depth) * (*value / 5);
	}

	return TRUE;
}
Exemplo n.º 5
0
static bool _create_arrows(void)
{
    int             item, slot;
    object_type  forge;

    item_tester_hook = _create_ammo_p;
    if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) 
        return FALSE;

    object_prep(&forge, lookup_kind(TV_ARROW, m_bonus(1, p_ptr->lev)+ 1));
    forge.number = (byte)rand_range(5, 10);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");
    if (item >= 0)
    {
        inven_item_increase(item, -1);
        inven_item_describe(item);
        inven_item_optimize(item);
    }
    else
    {
        floor_item_increase(0 - item, -1);
        floor_item_describe(0 - item);
        floor_item_optimize(0 - item);
    }

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);
    return TRUE;
}
Exemplo n.º 6
0
/**
 * Attempt to apply curses to an object, with a corresponding increase in
 * generation level of the object
 */
static void apply_curse(struct object *obj, int *lev)
{
	int pick = randint1(z_info->curse_max - 1);
	int power = 10 * m_bonus(9, *lev);
	if (!curses[pick].poss[obj->tval]) {
		return;
	}
	append_curse(&obj->curses, pick, power);
	*lev += randint0(power / 10);
	while(one_in_(100 - power)) {
		apply_curse(obj, lev);
	}
}
Exemplo n.º 7
0
/**
 * Apply magic to a weapon.
 */
static void apply_magic_weapon(struct object *obj, int level, int power)
{
	if (power <= 0)
		return;

	obj->to_h += randint1(5) + m_bonus(5, level);
	obj->to_d += randint1(5) + m_bonus(5, level);

	if (power > 1) {
		obj->to_h += m_bonus(10, level);
		obj->to_d += m_bonus(10, level);

		if (tval_is_melee_weapon(obj) || tval_is_ammo(obj)) {
			/* Super-charge the damage dice */
			while ((obj->dd * obj->ds > 0) &&
					one_in_(10L * obj->dd * obj->ds))
				obj->dd++;

			/* But not too high */
			if (obj->dd > 9) obj->dd = 9;
		}
	}
}
Exemplo n.º 8
0
/*
 * Apply magic to a weapon.
 */
static void apply_magic_weapon(object_type *o_ptr, int level, int power)
{
	if (power <= 0)
		return;

	o_ptr->to_h += randint1(5) + m_bonus(5, level);
	o_ptr->to_d += randint1(5) + m_bonus(5, level);

	if (power > 1) {
		o_ptr->to_h += m_bonus(10, level);
		o_ptr->to_d += m_bonus(10, level);

		if (wield_slot(o_ptr) == INVEN_WIELD || obj_is_ammo(o_ptr)) {
			/* Super-charge the damage dice */
			while ((o_ptr->dd * o_ptr->ds > 0) &&
					one_in_(10L * o_ptr->dd * o_ptr->ds))
				o_ptr->dd++;

			/* But not too high */
			if (o_ptr->dd > 9) o_ptr->dd = 9;
		}
	}
}
Exemplo n.º 9
0
/**
 * Perform the command "lock door"
 *
 * Assume there is no monster blocking the destination
 *
 * Returns true if repeated commands may continue
 */
static bool do_cmd_lock_door(int y, int x)
{
	int i, j, power;
	bool more = false;

	/* Verify legality */
	if (!do_cmd_disarm_test(y, x)) return false;

	/* Get the "disarm" factor */
	i = player->state.skills[SKILL_DISARM_PHYS];

	/* Penalize some conditions */
	if (player->timed[TMD_BLIND] || no_light())
		i = i / 10;
	if (player->timed[TMD_CONFUSED] || player->timed[TMD_IMAGE])
		i = i / 10;

	/* Calculate lock "power" */
	power = m_bonus(7, player->depth);

	/* Extract the difficulty */
	j = i - power;

	/* Always have a small chance of success */
	if (j < 2) j = 2;

	/* Success */
	if (randint0(100) < j) {
		msg("You lock the door.");
		square_set_door_lock(cave, y, x, power);
	}

	/* Failure -- Keep trying */
	else if ((i > 5) && (randint1(i) > 5)) {
		event_signal(EVENT_INPUT_FLUSH);
		msg("You failed to lock the door.");

		/* We may keep trying */
		more = true;
	}
	/* Failure */
	else
		msg("You failed to lock the door.");

	/* Result */
	return more;
}
Exemplo n.º 10
0
/*
 * Perform the command "lock door"
 *
 * Assume there is no monster blocking the destination
 *
 * Returns TRUE if repeated commands may continue
 */
static bool do_cmd_lock_door(int y, int x)
{
	int i, j, power;
	bool more = FALSE;

	/* Verify legality */
	if (!do_cmd_disarm_test(y, x)) return FALSE;

	/* Get the "disarm" factor */
	i = p_ptr->state.skills[SKILL_DISARM];

	/* Penalize some conditions */
	if (p_ptr->timed[TMD_BLIND] || no_light())
		i = i / 10;
	if (p_ptr->timed[TMD_CONFUSED] || p_ptr->timed[TMD_IMAGE])
		i = i / 10;

	/* Calculate lock "power" */
	power = m_bonus(7, p_ptr->depth);

	/* Extract the difficulty */
	j = i - power;

	/* Always have a small chance of success */
	if (j < 2) j = 2;

	/* Success */
	if (randint0(100) < j) {
		msg("You lock the door.");
		cave_set_feat(cave, y, x, FEAT_DOOR_HEAD + power);
	}

	/* Failure -- Keep trying */
	else if ((i > 5) && (randint1(i) > 5)) {
		flush();
		msg("You failed to lock the door.");

		/* We may keep trying */
		more = TRUE;
	}
	/* Failure */
	else
		msg("You failed to lock the door.");

	/* Result */
	return more;
}
Exemplo n.º 11
0
static bool _create_shots(void)
{
    int         x, y, dir, slot;
    cave_type  *c_ptr;
    object_type forge;

    if (!get_rep_dir(&dir, FALSE)) 
        return FALSE;

    y = py + ddy[dir];
    x = px + ddx[dir];
    c_ptr = &cave[y][x];

    if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_CAN_DIG))
    {
        msg_print("You need pile of rubble.");
        return FALSE;
    }

    if (!cave_have_flag_grid(c_ptr, FF_CAN_DIG) || !cave_have_flag_grid(c_ptr, FF_HURT_ROCK))
    {
        msg_print("You failed to make ammo.");
        return FALSE;
    }

    object_prep(&forge, lookup_kind(TV_SHOT, m_bonus(1, p_ptr->lev) + 1));
    forge.number = (byte)rand_range(15,30);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);

    cave_alter_feat(y, x, FF_HURT_ROCK);
    p_ptr->update |= PU_FLOW;
    return TRUE;
}
Exemplo n.º 12
0
static bool _create_bolts(void)
{
    int             item, slot;
    object_type  forge;

    item_tester_hook = _create_ammo_p;
    if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) 
        return FALSE;

    /* Note: You won't ever get Steel Bolts this way since I:18:1 is shared with 
       by Bolts and Steel Bolts and lookup_kind() picks the first match in k_info.txt.
       However, getting Steel from Bones/Junk would be a bit odd anyway ... */
    object_prep(&forge, lookup_kind(TV_BOLT, m_bonus(1, p_ptr->lev)+ 1));
    forge.number = (byte)rand_range(4, 8);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");
    if (item >= 0)
    {
        inven_item_increase(item, -1);
        inven_item_describe(item);
        inven_item_optimize(item);
    }
    else
    {
        floor_item_increase(0 - item, -1);
        floor_item_describe(0 - item);
        floor_item_optimize(0 - item);
    }

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);
    return TRUE;
}
Exemplo n.º 13
0
/**
 * Apply slightly randomised percentage resistances -NRM-
 * Also add element proofing flags where appropriate
 */
void apply_resistances(object_type * o_ptr, int lev, bitflag *flags)
{
    int i, res = 0;

    /* Get the ego type resists */
    if (o_ptr->name2) {
	ego_item_type *e_ptr = &e_info[o_ptr->name2];

	for (i = 0; i < MAX_P_RES; i++) {
	    /* Get the resistance value */
	    if (e_ptr->percent_res[i] != RES_LEVEL_BASE) {
		res = o_ptr->percent_res[i] * e_ptr->percent_res[i] / 100;
		o_ptr->percent_res[i] = res;
	    }

	}
    }

    /* Add extra resists */

    /* Vulnerability */
    if (kf_has(flags, KF_RAND_RES_NEG)) {
	int roll = 0;
	/* This gets done more often as we go deeper */
	while (roll < 2) {
	    /* Low resists more likely at low levels */
	    int k = randint0(128);
	    bool low = (k < (128 - lev));

	    k = (low ? randint0(4) : randint0(10) + 4);
	    o_ptr->percent_res[k] += 10 + randint0(5) + m_bonus(30, lev);

	    roll = randint0(10 - (lev / 30));
	}
    }

    /* Rings of Protection, etc */
    if (kf_has(flags, KF_RAND_RES_SML)) {
	int roll = 0;
	/* This gets done more often as we go deeper */
	while (roll < 2) {
	    /* Low resists more likely at low levels */
	    int k = randint0(128);
	    bool low = (k < (128 - lev));

	    k = (low ? randint0(4) : randint0(10) + 4);
	    o_ptr->percent_res[k] -= 4 + randint0(8) + m_bonus(10, lev);

	    /* Twice as many of these */
	    k = randint0(128);
	    low = (k < (128 - lev));
	    k = (low ? randint0(4) : randint0(10) + 4);
	    o_ptr->percent_res[k] -= 4 + randint0(8) + m_bonus(10, lev);

	    /* Occasionally reverse one */
	    if (randint0(3) == 0)
		o_ptr->percent_res[k] = RES_LEVEL_MAX - o_ptr->percent_res[k];

	    roll = randint0(10 - (lev / 30));
	}
    }

    /* Armour of Resistance etc */
    if (kf_has(flags, KF_RAND_RES)) {
	int roll = 0;
	/* This gets done more often as we go deeper */
	while (roll < 2) {
	    /* Low resists more likely at low levels */
	    int k = randint0(128);
	    bool low = (k < (128 - lev));

	    k = (low ? randint0(4) : randint0(10) + 4);
	    o_ptr->percent_res[k] -= 20 + randint0(5) + m_bonus(20, lev);

	    roll = randint0(10 - (lev / 30));
	}
    }

    /* Former one high resist objects */
    if (kf_has(flags, KF_RAND_RES_XTRA)) {
	int roll = 0;
	/* This gets done more often as we go deeper */
	while (roll < 2) {
	    /* Low resists less likely here */
	    int k = ((randint0(10) == 0) ? randint0(4) : randint0(10) + 4);
	    o_ptr->percent_res[k] -= 30 + randint0(5) + m_bonus(20, lev);

	    roll = randint0(10 - (lev / 30));
	}
    }


    /* Randomise a bit */
    for (i = 0; i < MAX_P_RES; i++) {
	res = 100 - o_ptr->percent_res[i];

	/* Only randomise proper resistances */
	if ((res > 0) && (res < 100)) {
	    if (randint0(2) == 0)
		o_ptr->percent_res[i] -= randint0(res >> 2);
	    else
		o_ptr->percent_res[i] += randint0(res >> 2);
	}

	/* Enforce bounds - no item gets better than 80% resistance */
	if (o_ptr->percent_res[i] < RES_CAP_ITEM)
	    o_ptr->percent_res[i] = RES_CAP_ITEM;
	if (o_ptr->percent_res[i] > RES_LEVEL_MAX)
	    o_ptr->percent_res[i] = RES_LEVEL_MAX;
    }
Exemplo n.º 14
0
/**
 * Apply magic to an item known to be "armor"
 *
 * Hack -- note special processing for crown/helm
 * Hack -- note special processing for robe of permanence
 */
static void a_m_aux_2(object_type * o_ptr, int level, int power)
{
    int toac1, toac2;

    /* Boots and handgear aren't as important to total AC. */
    if ((o_ptr->tval == TV_BOOTS) || (o_ptr->tval == TV_GLOVES)) {
	toac1 = randint1(3) + m_bonus(4, level);
	toac2 = m_bonus(8, level);
    } else {
	toac1 = randint1(5) + m_bonus(5, level);
	toac2 = m_bonus(10, level);
    }


    /* Good */
    if (power > 0) {
	/* Enchant */
	o_ptr->to_a += toac1;

	/* Very good */
	if (power > 1) {
	    /* Enchant again */
	    o_ptr->to_a += toac2;
	}
    }

    /* Bad */
    else if (power < 0) {
	/* Penalize */
	o_ptr->to_a -= toac1;

	/* Very bad */
	if (power < -1) {
	    /* Penalize again */
	    o_ptr->to_a -= toac2;
	}
    }


    /* Analyze type */
    switch (o_ptr->tval) {
    case TV_DRAG_ARMOR:
	{
	    /* Mention the item */
	    if (OPT(cheat_peek))
		object_mention(o_ptr);

	    break;
	}


    case TV_HARD_ARMOR:
    case TV_SOFT_ARMOR:
    case TV_SHIELD:
    case TV_GLOVES:
    case TV_BOOTS:
    case TV_CROWN:
    case TV_HELM:
    case TV_CLOAK:
	{
	    break;
	}
    }
}
Exemplo n.º 15
0
/**
 * Apply magic to an item known to be a "weapon"
 *
 * Hack -- note special base damage dice boosting
 * Hack -- note special processing for weapon/digger
 */
static void a_m_aux_1(object_type * o_ptr, int level, int power)
{
    int tohit1 = randint1(5) + m_bonus(5, level);
    int todam1 = randint1(5) + m_bonus(5, level);

    int tohit2 = m_bonus(10, level);
    int todam2 = m_bonus(10, level);

    /* Good */
    if (power > 0) {
	/* Enchant */
	o_ptr->to_h += tohit1;
	o_ptr->to_d += todam1;

	/* Very good */
	if (power > 1) {
	    /* Enchant again */
	    o_ptr->to_h += tohit2;
	    o_ptr->to_d += todam2;
	}
    }

    /* Bad */
    else if (power < 0) {
	/* Penalize */
	o_ptr->to_h -= tohit1;
	o_ptr->to_d -= todam1;

	/* Perilous - more random now */
	if (power < -1) {
	    /* Shake it up */
	    if (randint0(3) == 0)
		o_ptr->to_h = 0 - o_ptr->to_h;
	    if (randint0(3) == 0)
		o_ptr->to_d = 0 - o_ptr->to_d;
	    if (randint0(2) == 0)
		o_ptr->to_h -= tohit2;
	    else
		o_ptr->to_h += tohit2;
	    if (randint0(2) == 0)
		o_ptr->to_d -= todam2;
	    else
		o_ptr->to_d += todam2;
	}
    }


    /* Analyze type */
    switch (o_ptr->tval) {
    case TV_DIGGING:
	{
	    /* Very bad */
	    if (power < -1) {
		/* Hack -- Horrible digging bonus */
		o_ptr->bonus_other[P_BONUS_TUNNEL] = 0 - (5 + randint1(5));
	    }

	    /* Bad */
	    else if (power < 0) {
		/* Hack -- Reverse digging bonus */
		o_ptr->bonus_other[P_BONUS_TUNNEL] =
		    0 - (o_ptr->bonus_other[P_BONUS_TUNNEL]);
	    }

	    break;
	}


    case TV_HAFTED:
    case TV_POLEARM:
    case TV_SWORD:
	{
	    /* Very bad */
	    if (power < -1) {
		if (o_ptr->to_d < 0)
		    o_ptr->to_d *= 2;
	    }

	    break;
	}

    case TV_BOLT:
    case TV_ARROW:
    case TV_SHOT:
	{
	    /* First, a little hack to keep certain values sane. */
	    /* If at least good, */
	    if (power > 0) {
		/* chop the bonuses in half, rounded up. */
		o_ptr->to_h -= o_ptr->to_h / 2;
		o_ptr->to_d -= o_ptr->to_d / 2;

	    }
	}
    }
}
Exemplo n.º 16
0
/*
 * Apply magic to an item known to be a "weapon"
 *
 * Hack -- note special base damage dice boosting
 * Hack -- note special processing for weapon/digger
 * Hack -- note special rating boost for dragon scale mail
 */
static void a_m_aux_1(object_type *o_ptr, int level, int power)
{
	int tohit1 = randint1(5) + m_bonus(5, level);
	int tohit2 = m_bonus(10, level);

	int todam1 = randint1(5) + m_bonus(5, level);
	int todam2 = m_bonus(10, level);

	switch (power)
	{
		case -2:
			o_ptr->to_h -= tohit2;
			o_ptr->to_d -= todam2;

		case -1:
			o_ptr->to_h -= tohit1;
			o_ptr->to_d -= todam1;
			break;

		case 2:
			o_ptr->to_h += tohit2;
			o_ptr->to_d += todam2;

		case 1:
			o_ptr->to_h += tohit1;
			o_ptr->to_d += todam1;
			break;
	}


	/* Analyze type */
	switch (o_ptr->tval)
	{
		case TV_DIGGING:
		{
			/* Very bad */
			if (power < -1)
			{
				/* Hack -- Horrible digging bonus */
				o_ptr->pval = 0 - (5 + randint1(5));
			}

			/* Bad */
			else if (power < 0)
			{
				/* Hack -- Reverse digging bonus */
				o_ptr->pval = -o_ptr->pval;
			}

			break;
		}


		case TV_HAFTED:
		case TV_POLEARM:
		case TV_SWORD:
		{
			/* Very Good */
			if (power > 1)
			{
				/* Hack -- Super-charge the damage dice */
				while ((o_ptr->dd * o_ptr->ds > 0) &&
				       one_in_(10L * o_ptr->dd * o_ptr->ds))
				{
					o_ptr->dd++;
				}

				/* Hack -- Lower the damage dice */
				if (o_ptr->dd > 9) o_ptr->dd = 9;
			}

			break;
		}


		case TV_BOLT:
		case TV_ARROW:
		case TV_SHOT:
		{
			/* Very good */
			if (power > 1)
			{
				/* Hack -- super-charge the damage dice */
				while ((o_ptr->dd * o_ptr->ds > 0) &&
				       one_in_(10L * o_ptr->dd * o_ptr->ds))
				{
					o_ptr->dd++;
				}

				/* Hack -- restrict the damage dice */
				if (o_ptr->dd > 9) o_ptr->dd = 9;
			}

			break;
		}
	}
}