Ejemplo n.º 1
0
/**
 * Determines if an object is eligable for squelching.
 */
extern bool squelch_item_ok(const object_type * o_ptr)
{
	size_t i;
	int num = -1;

	object_kind *k_ptr = &k_info[o_ptr->k_idx];
	bool fullid = object_known_p(o_ptr);
	bool sensed = (o_ptr->ident & IDENT_SENSE) || fullid;
	byte feel =
		fullid ? value_check_aux1((object_type *) o_ptr) : o_ptr->feel;
	int quality_squelch = SQUELCH_NONE;

	/* Don't squelch artifacts */
	if (artifact_p(o_ptr))
		return FALSE;

	/* Don't squelch stuff inscribed not to be destroyed (!k) */
	if (check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) {
		return FALSE;
	}

	/* Auto-squelch dead chests */
	if (o_ptr->tval == TV_CHEST && o_ptr->pval == 0)
		return TRUE;

	/* Do squelching by sval, if we 'know' the flavour. */
	if (k_ptr->squelch && (k_ptr->flavor == 0 || k_ptr->aware)) {
		if (squelch_tval(k_info[o_ptr->k_idx].tval))
			return TRUE;
	}

	/* Squelch some ego items if known */
	if (has_ego_properties(o_ptr) && (e_info[o_ptr->name2].squelch)) {
		return TRUE;
	}

	/* Don't check pseudo-ID for nonsensed things */
	if (!sensed)
		return FALSE;

	/* Find the appropriate squelch group */
	for (i = 0; i < N_ELEMENTS(quality_choices); i++) {
		if (quality_choices[i].tval == o_ptr->tval) {
			num = i;
			break;
		}
	}

	/* Never squelched */
	if (num == -1)
		return FALSE;

	/* Get result based on the feeling and the squelch_profile */
	quality_squelch = feel_to_squelch_level(feel);

	if (quality_squelch == SQUELCH_NONE)
		return FALSE;
	else
		return squelch_profile[num][quality_squelch];
}
Ejemplo n.º 2
0
/**
 * Determines if an object is eligable for squelching.
 */
extern bool squelch_item_ok(const object_type * o_ptr)
{
	size_t i;
	int num = -1;

	object_kind *k_ptr = &k_info[o_ptr->k_idx];
	bool fullid = object_known_p(o_ptr);
	bool sensed = (o_ptr->ident & IDENT_SENSE) || fullid;
	byte feel =
		fullid ? value_check_aux1((object_type *) o_ptr) : o_ptr->feel;


	/* Don't squelch artifacts */
	if (artifact_p(o_ptr))
		return FALSE;

	/* Don't squelch stuff inscribed not to be destroyed (!k) */
	if (check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) {
		return FALSE;
	}

	/* Auto-squelch dead chests */
	if (o_ptr->tval == TV_CHEST && o_ptr->pval == 0)
		return TRUE;

	/* Do squelching by sval, if we 'know' the flavour. */
	if (k_ptr->squelch && (k_ptr->flavor == 0 || k_ptr->aware)) {
		if (squelch_tval(k_info[o_ptr->k_idx].tval))
			return TRUE;
	}

	/* Squelch some ego items if known */
	if (has_ego_properties(o_ptr) && (e_info[o_ptr->name2].squelch)) {
		return TRUE;
	}


	/* Don't check pseudo-ID for nonsensed things */
	if (!sensed)
		return FALSE;



	/* Find the appropriate squelch group */
	for (i = 0; i < N_ELEMENTS(quality_choices); i++) {
		if (quality_choices[i].enum_val == o_ptr->tval) {
			num = i;
			break;
		}
	}

	/* Never squelched */
	if (num == -1)
		return FALSE;


	/* Get result based on the feeling and the squelch_level */
	switch (squelch_level[num]) {
	case SQUELCH_CURSED:
		{
			if (o_ptr->ident & IDENT_CURSED) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_DUBIOUS:
		{
			if ((feel == FEEL_DUBIOUS_WEAK) || (feel == FEEL_PERILOUS) ||
				(feel == FEEL_DUBIOUS_STRONG)) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_DUBIOUS_NON:
		{
			if (feel == FEEL_DUBIOUS_STRONG) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_NON_EGO:
		{
			if ((feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE) ||
				(feel == FEEL_GOOD_STRONG)) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_AVERAGE:
		{
			if ((feel == FEEL_DUBIOUS_WEAK) || (feel == FEEL_PERILOUS) ||
				(feel == FEEL_DUBIOUS_STRONG) || (feel == FEEL_AVERAGE)) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_GOOD_STRONG:
		{
			if ((feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG) ||
				(feel == FEEL_AVERAGE) || (feel == FEEL_GOOD_STRONG)) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_GOOD_WEAK:
		{
			if ((feel == FEEL_PERILOUS) || (feel == FEEL_DUBIOUS_STRONG) ||
				(feel == FEEL_AVERAGE) || (feel == FEEL_GOOD_WEAK) ||
				(feel == FEEL_GOOD_STRONG)) {
				return TRUE;
			}

			break;
		}

	case SQUELCH_ALL:
		{
			return TRUE;
			break;
		}
	}

	/* Failure */
	return FALSE;
}
Ejemplo n.º 3
0
/**
 * Carry an object and delete it.
 */
extern void py_pickup_aux(int o_idx, bool msg)
{
    int slot, quiver_slot = 0;

    char o_name[120];
    object_type *o_ptr = &o_list[o_idx];
    object_type *i_ptr = &p_ptr->inventory[INVEN_LIGHT];
    bitflag f[OF_SIZE], obvious_mask[OF_SIZE];


    flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);
    of_copy(f, o_ptr->flags_obj);
    
    /* Carry the object */
    slot = inven_carry(p_ptr, o_ptr);

    /* Handle errors (paranoia) */
    if (slot < 0) return;

    /* If we have picked up ammo which matches something in the quiver, note
     * that it so that we can wield it later (and suppress pick up message) */
    if (obj_is_quiver_obj(o_ptr)) 
    {
	int i;
	for (i = QUIVER_START; i < QUIVER_END; i++) 
	{
	    if (!p_ptr->inventory[i].k_idx) continue;
	    if (!object_similar(&p_ptr->inventory[i], o_ptr,
				OSTACK_QUIVER)) continue;
	    quiver_slot = i;
	    break;
	}
    }

    /* Get the object again */
    o_ptr = &p_ptr->inventory[slot];

    /* Set squelch status */
    p_ptr->notice |= PN_SQUELCH;

    /* Stone of Lore gives id on pickup */
    if (!object_known_p(o_ptr)) {
	if (i_ptr->sval == SV_STONE_LORE)
	    identify_object(o_ptr);

	/* Otherwise pseudo-ID */
	else {
	    bool heavy = FALSE;
	    int feel;

	    /* Heavy sensing */
	    heavy = (player_has(PF_PSEUDO_ID_HEAVY));

	    /* Type of feeling */
	    feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));

	    /* We have "felt" it */
	    o_ptr->ident |= (IDENT_SENSE);

	    /* Inscribe it textually */
	    o_ptr->feel = feel;

	    /* Set squelch flag as appropriate */
	    p_ptr->notice |= PN_SQUELCH;
	}
    }

    /* Log artifacts if found */
    if (artifact_p(o_ptr))
	history_add_artifact(o_ptr->name1, object_is_known(o_ptr), TRUE);

    /* Notice dice and other obvious stuff */
    notice_other(IF_DD_DS, slot + 1);
    (void) of_inter(f, obvious_mask);
    of_union(o_ptr->id_obj, f);

    /* Average things are average */
    if ((o_ptr->feel == FEEL_AVERAGE) && (is_weapon(o_ptr) || is_armour(o_ptr))){
	notice_other(IF_AC, slot + 1);
	notice_other(IF_TO_A, slot + 1);
	notice_other(IF_TO_H, slot + 1);
	notice_other(IF_TO_D, slot + 1);
    }

    /* Recalculate the bonuses */
    p_ptr->update |= (PU_BONUS);

    /* Optionally, display a message */
    if (msg && !quiver_slot)
    {
	/* Describe the object */
	object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg_format("You have %s (%c).", o_name, index_to_label(slot));
    }


    /* Delete the object */
    delete_object_idx(o_idx);

    /* If we have a quiver slot that this item matches, use it */
    if (quiver_slot) wield_item(o_ptr, slot, quiver_slot);
}
Ejemplo n.º 4
0
int squelch_itemp(object_type *o_ptr, byte feeling, int fullid)
{
	int i, num, result;
	byte feel;

	/* default */
	result = SQUELCH_NO;


	/* Check to see if the object is eligible for squelching on id. */
	num=-1;
	for (i=0; tvals[i].tval; i++)
	{
		if (tvals[i].tval==o_ptr->tval)
		{
			num=i;
		}
	}
	if (num==-1) return result;

	/*
	 * Get the "feeling" of the object.  If the object is being identified
	 * get the feeling returned by a heavy pseudoid.
	 */
	feel = feeling;
	if (fullid==1)
	  feel = value_check_aux1(o_ptr);

	/* Get result based on the feeling and the squelch_level */
	switch (squelch_level[num])
	{
		case SQUELCH_NONE:
		{
			return result;
			break;
		}

		case SQUELCH_CURSED:
		{
			result = (((feel==FEEL_BROKEN) ||
				   (feel==FEEL_TERRIBLE) ||
				   (feel==FEEL_WORTHLESS) ||
				   (feel==FEEL_CURSED)) ? SQUELCH_YES : SQUELCH_NO);
			break;
		}

		case SQUELCH_AVERAGE:
		{
			result = (((feel==FEEL_BROKEN) ||
				   (feel==FEEL_TERRIBLE) ||
				   (feel==FEEL_WORTHLESS) ||
				   (feel==FEEL_CURSED) ||
				   (feel==FEEL_AVERAGE)) ? SQUELCH_YES : SQUELCH_NO);
			break;
		}

		case SQUELCH_GOOD:
		{
			result = (((feel==FEEL_BROKEN) ||
				   (feel==FEEL_TERRIBLE) ||
				   (feel==FEEL_WORTHLESS) ||
				   (feel==FEEL_CURSED) ||
				   (feel==FEEL_AVERAGE) ||
				   (feel==FEEL_GOOD)) ? SQUELCH_YES : SQUELCH_NO);
			break;
		}

		case SQUELCH_ALL:
		{
			if (!(artifact_p(o_ptr))) result = SQUELCH_YES;
			break;
		}
	}


	if (result==SQUELCH_NO) return result;

	/* Extra Paranoia */
	if (artifact_p(o_ptr))
	  result = SQUELCH_FAILED;

	/* Items inscribed with '!k' or '!*' are note squelchable. */
	if (o_ptr->note)
	{
	        cptr s = strchr(quark_str(o_ptr->note), '!');
		while (s)
		{
		        if ((s[1] == 'k') || (s[1] == '*')) result = SQUELCH_FAILED;
			s = strchr(s + 1, '!');
		}
	}

	return result;
}