Example #1
0
/**
 * Take off a non-cursed equipment item
 *
 * Note that taking off an item when "full" may cause that item
 * to fall to the ground.
 *
 * Note also that this function does not try to combine the taken off item
 * with other inventory items - that must be done by the calling function.
 */
void inven_takeoff(struct object *obj)
{
	int slot = equipped_item_slot(player->body, obj);
	const char *act;
	char o_name[80];

	/* Paranoia */
	if (slot == player->body.count) return;

	/* Describe the object */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Describe removal by slot */
	if (slot_type_is(slot, EQUIP_WEAPON))
		act = "You were wielding";
	else if (slot_type_is(slot, EQUIP_BOW))
		act = "You were holding";
	else if (slot_type_is(slot, EQUIP_LIGHT))
		act = "You were holding";
	else
		act = "You were wearing";

	/* De-equip the object */
	player->body.slots[slot].obj = NULL;
	player->upkeep->equip_cnt--;

	/* Message */
	msgt(MSG_WIELD, "%s %s (%c).", act, o_name, I2A(slot));

	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->notice |= (PN_IGNORE);
	return;
}
Example #2
0
/**
 * Get the slot multiplier for a flag's power rating
 *
 * \param flag is the flag in question.
 * \param slot is the wield_slot it's in.
 */
s16b flag_slot_mult(int flag, int slot)
{
	const struct object_flag *f = &object_flag_table[flag];

	switch (f->type) {
		/* Many flags are equally good (or bad) in any slot */
	case OFT_SUST:
	case OFT_PROT:
	case OFT_BAD:
	case OFT_CURSE:
	case OFT_DIG: return 1;
		/* Light-specific */
	case OFT_LIGHT: return (slot_type_is(slot, EQUIP_LIGHT)) ? 1 : 0;
		/* Melee weapon specific */
	case OFT_MELEE: return (slot_type_is(slot, EQUIP_WEAPON)) ? 1 : 0;
		/* Miscellaneous flags are a mixed bag */
	case OFT_MISC: {
		/* Weapon and bow slot are more useful for other purposes */
		if ((slot_type_is(slot, EQUIP_WEAPON)) || (slot_type_is(slot, EQUIP_BOW))) return 1;
		/* SD and FF are a bit lame */
		if ((flag == OF_FEATHER) || (flag == OF_SLOW_DIGEST)) return 1;
		/* FA on gloves is really nice */
		if ((flag == OF_FREE_ACT) && (slot_type_is(slot, EQUIP_GLOVES))) return 5;
		/* All the major powers are good */
		return 2;
	}
	default: return 1;
	}
}
Example #3
0
/**
 * Get the slot multiplier for a mod's power rating
 *
 * \param mod is the mod in question.
 * \param slot is the wield_slot it's in.
 */
s16b mod_slot_mult(int mod, int slot)
{
	/* Ammo gets -1 as a slot, and always has muliplier 1 */
	if (slot == -1) return 1;

	/* Gloves with DEX are good */
	if ((mod == OBJ_MOD_DEX) && (slot_type_is(slot, EQUIP_GLOVES))) return 2;

	/* Extra blows are silly on a bow, powerful off-weapon */
	if (mod == OBJ_MOD_BLOWS) {
		if (slot_type_is(slot, EQUIP_BOW)) return 0;
		if (slot_type_is(slot, EQUIP_WEAPON)) return 1;
		return 3;
	}

	/* Extra shots are silly on a melee weapon, powerful off-weapon */
	if (mod == OBJ_MOD_SHOTS) {
		if (slot_type_is(slot, EQUIP_WEAPON)) return 0;
		if (slot_type_is(slot, EQUIP_BOW)) return 1;
		return 4;
	}

	/* Extra might only works on bows */
	if (mod == OBJ_MOD_MIGHT) {
		if (slot_type_is(slot, EQUIP_BOW)) return 1;
		return 0;
	}

	/* Light is best on, well, lights */
	if (mod == OBJ_MOD_LIGHT) {
		if (slot_type_is(slot, EQUIP_LIGHT)) return 3;
		return 1;
	}

	/* Others are all easy */
	return 1;
}
Example #4
0
/**
 * Acid has hit the player, attempt to affect some armor.
 *
 * Note that the "base armor" of an object never changes.
 * If any armor is damaged (or resists), the player takes less damage.
 */
int minus_ac(struct player *p)
{
	int i, count = 0;
	struct object *obj = NULL;

	char o_name[80];

	/* Avoid crash during monster power calculations */
	if (!p->gear) return false;

	/* Count the armor slots */
	for (i = 0; i < player->body.count; i++) {
		/* Ignore non-armor */
		if (slot_type_is(i, EQUIP_WEAPON)) continue;
		if (slot_type_is(i, EQUIP_BOW)) continue;
		if (slot_type_is(i, EQUIP_RING)) continue;
		if (slot_type_is(i, EQUIP_AMULET)) continue;
		if (slot_type_is(i, EQUIP_LIGHT)) continue;

		/* Add */
		count++;
	}

	/* Pick one at random */
	for (i = player->body.count - 1; i >= 0; i--) {
		/* Ignore non-armor */
		if (slot_type_is(i, EQUIP_WEAPON)) continue;
		if (slot_type_is(i, EQUIP_BOW)) continue;
		if (slot_type_is(i, EQUIP_RING)) continue;
		if (slot_type_is(i, EQUIP_AMULET)) continue;
		if (slot_type_is(i, EQUIP_LIGHT)) continue;

		if (one_in_(count--)) break;
	}

	/* Get the item */
	obj = slot_object(player, i);

	/* Nothing to damage */
	if (!obj) return (false);

	/* No damage left to be done */
	if (obj->ac + obj->to_a <= 0) return (false);

	/* Describe */
	object_desc(o_name, sizeof(o_name), obj, ODESC_BASE);

	/* Object resists */
	if (obj->el_info[ELEM_ACID].flags & EL_INFO_IGNORE) {
		msg("Your %s is unaffected!", o_name);
		return (true);
	}

	/* Message */
	msg("Your %s is damaged!", o_name);

	/* Damage the item */
	obj->to_a--;
	if (p->obj_k->to_a)
		obj->known->to_a = obj->to_a;

	p->upkeep->update |= (PU_BONUS);
	p->upkeep->redraw |= (PR_EQUIP);

	/* Item was damaged */
	return (true);
}