コード例 #1
0
ファイル: identify.c プロジェクト: mjdrinen/FAangband
/**
 * Copy all the id_other flags an object is going to get to allflags
 */
void flags_other(object_type *o_ptr, bitflag *all_flags)
{
    int j;

    if_wipe(all_flags);

    /* Resists */
    for (j = 0; j < MAX_P_RES; j++) 
	if (o_ptr->percent_res[j] != RES_LEVEL_BASE)
	    if_on(all_flags, OBJECT_ID_BASE_RESIST + j);
    
    /* Slays */
    for (j = 0; j < MAX_P_SLAY; j++) 
	if (o_ptr->multiple_slay[j] != MULTIPLE_BASE)
	    if_on(all_flags, OBJECT_ID_BASE_SLAY + j);
    
    /* Brands */
    for (j = 0; j < MAX_P_BRAND; j++) 
	if (o_ptr->multiple_brand[j] != MULTIPLE_BASE)
	    if_on(all_flags, OBJECT_ID_BASE_BRAND + j);

    /* Others */
    if ((o_ptr->to_h) || is_weapon(o_ptr) || of_has(o_ptr->flags_obj, OF_SHOW_MODS))
	if_on(all_flags, IF_TO_H);
    if ((o_ptr->to_d) || is_weapon(o_ptr) || of_has(o_ptr->flags_obj, OF_SHOW_MODS))
	if_on(all_flags, IF_TO_D);
    if ((o_ptr->to_a) || is_armour(o_ptr))
	if_on(all_flags, IF_TO_A);
    if ((o_ptr->ac) || is_armour(o_ptr)) {
	if_on(all_flags, IF_AC);
	if_on(all_flags, IF_TO_A);
    }
    if_on(all_flags, IF_DD_DS);
}
コード例 #2
0
ファイル: identify.c プロジェクト: mjdrinen/FAangband
/**
 * Notice other properties
 */
void notice_other(int other_flag, int item)
{
    int i, j;
    bool already_ego = FALSE;
    object_type *o_ptr;

    if (item) {
	if (item > 0)
	    o_ptr = &p_ptr->inventory[item - 1];
	else
	    o_ptr = &o_list[0 - item];
	
	already_ego = has_ego_properties(o_ptr);
	
	/* Resists */
	for (j = 0; j < MAX_P_RES; j++) {
	    if (other_flag != OBJECT_ID_BASE_RESIST + j) continue;
	    if (o_ptr->percent_res[j] != RES_LEVEL_BASE) {
		if_on(o_ptr->id_other, other_flag);
	    }
	}
	
	/* Slays */
	for (j = 0; j < MAX_P_SLAY; j++) {
	    if (other_flag != OBJECT_ID_BASE_SLAY + j) continue;
	    if (o_ptr->multiple_slay[j] != MULTIPLE_BASE) {
		if_on(o_ptr->id_other, other_flag);
	    }
	}


	/* Brands */
	for (j = 0; j < MAX_P_BRAND; j++) {
	    if (other_flag != OBJECT_ID_BASE_BRAND + j) continue;
	    if (o_ptr->multiple_brand[j] != MULTIPLE_BASE) {
		if_on(o_ptr->id_other, other_flag);
	    }
	}
	
	/* Others */
	if ((other_flag == IF_TO_H) && ((o_ptr->to_h) || is_weapon(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_H);
	if ((other_flag == IF_TO_D) && ((o_ptr->to_d) || is_weapon(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_D);
	if ((other_flag == IF_TO_A) && ((o_ptr->ac) || is_armour(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_A);
	if ((other_flag == IF_AC) && ((o_ptr->ac) || is_armour(o_ptr)))
	    if_on(o_ptr->id_other, IF_AC);
	if ((other_flag == IF_DD_DS))
	    if_on(o_ptr->id_other, IF_DD_DS);
	
	/* Ego item? */
	if (already_ego != has_ego_properties(o_ptr))
	    label_as_ego(o_ptr, item);
	
	/* Fully identified now? */
	if (known_really(o_ptr))
	    identify_object(o_ptr);
	
	return;
    }
    
    for (i = INVEN_WIELD; i <= INVEN_FEET; i++) {
	o_ptr = &p_ptr->inventory[i];
	
	already_ego = has_ego_properties(o_ptr);
	
	/* Resists */
	for (j = 0; j < MAX_P_RES; j++) {
	    if (other_flag != OBJECT_ID_BASE_RESIST + j) continue;
	    if (o_ptr->percent_res[j] != RES_LEVEL_BASE) {
		if_on(o_ptr->id_other, other_flag);
		if ((j == INVEN_RIGHT) || (j == INVEN_LEFT)
		    || (j == INVEN_NECK)) {
		    if_on(o_ptr->id_other, other_flag);
		}
	    }
	}

	/* Slays */
	for (j = 0; j < MAX_P_SLAY; j++) {
	    if (other_flag != OBJECT_ID_BASE_SLAY + j) continue;
	    if (o_ptr->multiple_slay[j] != MULTIPLE_BASE) {
		if_on(o_ptr->id_other, other_flag);
		if ((j == INVEN_RIGHT) || (j == INVEN_LEFT)
		    || (j == INVEN_NECK)) {
		    if_on(o_ptr->id_other, other_flag);
		}
	    }
	}
	
	/* Brands */
	for (j = 0; j < MAX_P_BRAND; j++) {
	    if (other_flag != OBJECT_ID_BASE_BRAND + j) continue;
	    if (o_ptr->multiple_brand[j] != MULTIPLE_BASE) {
		if_on(o_ptr->id_other, other_flag);
		if ((j == INVEN_RIGHT) || (j == INVEN_LEFT)
		    || (j == INVEN_NECK)) {
		    if_on(o_ptr->id_other, other_flag);
		}
	    }
	}

	/* Others */
	if ((other_flag == IF_TO_H) && ((o_ptr->to_h) || is_weapon(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_H);
	if ((other_flag == IF_TO_D) && ((o_ptr->to_d) || is_weapon(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_D);
	if ((other_flag == IF_TO_A) && ((o_ptr->ac) || is_armour(o_ptr)))
	    if_on(o_ptr->id_other, IF_TO_A);
	if ((other_flag == IF_AC) && ((o_ptr->ac) || is_armour(o_ptr)))
	    if_on(o_ptr->id_other, IF_AC);
	if ((other_flag == IF_DD_DS))
	    if_on(o_ptr->id_other, IF_DD_DS);

	/* Ego item? */
	if (already_ego != has_ego_properties(o_ptr))
	    label_as_ego(o_ptr, item);

	/* Fully identified now? */
	if (known_really(o_ptr))
	    identify_object(o_ptr);
    }
}
コード例 #3
0
ファイル: cmd1.c プロジェクト: artes-liberales/FAangband
/**
 * 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);
}