Ejemplo n.º 1
0
/**
 * Fill in a value in the slay cache. Return TRUE if a change is made.
 *
 * \param index is the set of slay flags whose value we are adding
 * \param value is the value of the slay flags in index
 */
bool fill_slay_cache(bitflag *index, s32b value)
{
	int i;

	for (i = 0; !of_is_empty(slay_cache[i].flags); i++) {
		if (of_is_equal(index, slay_cache[i].flags)) {
			slay_cache[i].value = value;
			return TRUE;
		}
	}

	return FALSE;
}
Ejemplo n.º 2
0
/**
 * Notice curses on an object.
 *
 * \param o_ptr is the object to notice curses on
 */
bool object_notice_curses(object_type *o_ptr)
{
	bitflag f[OF_SIZE];

	object_flags(o_ptr, f);

	/* Know whatever curse flags there are to know */
	flags_mask(f, OF_SIZE, OF_CURSE_MASK, FLAG_END);

	/* give knowledge of which curses are present */
	object_notice_flags(o_ptr, f);

	object_check_for_ident(o_ptr);

	p_ptr->notice |= PN_SQUELCH;

	return !of_is_empty(f);
}
Ejemplo n.º 3
0
/**
 * Browse known specialty abilities -BR-
 * Adapted from birth.c get_player_choice
 */
void view_specialties(void)
{
    int i;

    /* Count the number of specialties we know */
    for (i = 0, spec_known = 0; i < MAX_SPECIALTIES; i++) {
	if (p_ptr->specialty_order[i] != PF_NO_SPECIALTY)
	    spec_list[spec_known++] = abilities[p_ptr->specialty_order[i]];
    }

    /* Count the number of class powers we have */
    for (i = 0; i < PF_MAX; i++) {
	if (player_class_has(i)) {
	    spec_list[spec_known++] = abilities[i];
	}
    }

    /* Count the number of race powers we have */
    for (i = 0; i < PF_MAX; i++) {
	if (player_race_has(i)) {
	    spec_list[spec_known++] = abilities[i];
	}
    }

    /* Standard racial flags */
    if (!of_is_empty(rp_ptr->flags_obj) || !cf_is_empty(rp_ptr->flags_curse)) 
    {
	spec_list[spec_known].index = PF_MAX;
	spec_list[spec_known].name = "";
	spec_list[spec_known].desc = "";
	view_abilities_aux(race_other_desc);
	spec_list[spec_known++].type = PF_MAX;
    }

    /* View choices until user exits */
    view_spec_menu();

    /* exit */
    return;
}
Ejemplo n.º 4
0
/*
 * Given an object, return a short identifier which gives some idea of what
 * the item is.
 */
obj_pseudo_t object_pseudo(const object_type *o_ptr)
{
	object_kind *k_ptr = &k_info[o_ptr->k_idx];
	bitflag flags[OF_SIZE];

	/* Get the known and obvious flags on the object,
	 * not including curses or properties of the kind
	 */
	object_flags_known(o_ptr, flags);

	/* MEGA-hack : there needs to be a table of what is obvious in each slot perhaps for each class */
	/* FA on gloves is obvious to mage casters */
	if (object_FA_would_be_obvious(o_ptr))
		flags_mask(flags, OF_SIZE, OF_OBVIOUS_MASK, OF_FREE_ACT, FLAG_END);
	else
		flags_mask(flags, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);

	flags_clear(flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
	of_diff(flags, k_ptr->flags);

	if (o_ptr->ident & IDENT_INDESTRUCT)
		return INSCRIP_SPECIAL;
	if ((object_was_sensed(o_ptr) || object_was_worn(o_ptr)) && artifact_p(o_ptr))
		return INSCRIP_SPECIAL;

	/* jewelry does not pseudo */
	if (object_is_jewelry(o_ptr))
		return INSCRIP_NULL;

	/* XXX Eddie should also check for flags with pvals where the pval exceeds
	 * the base pval for things like picks of digging, though for now acid brand gets those
	 */
	if (!of_is_empty(flags))
		return INSCRIP_SPLENDID;

	if (!object_is_known(o_ptr) && !object_was_sensed(o_ptr))
		return INSCRIP_NULL;

	if (ego_item_p(o_ptr))
	{
		/* uncursed bad egos are not excellent */
		if (flags_test(e_info[o_ptr->name2].flags, OF_SIZE, OF_CURSE_MASK, FLAG_END))
			return INSCRIP_STRANGE; /* XXX Eddie need something worse */
		else
			return INSCRIP_EXCELLENT;
	}

	if (o_ptr->to_a == randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h == randcalc(k_ptr->to_h, 0, MINIMISE) &&
		 o_ptr->to_d == randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_AVERAGE;

	if (o_ptr->to_a >= randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h >= randcalc(k_ptr->to_h, 0, MINIMISE) &&
	    o_ptr->to_d >= randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_MAGICAL;

	if (o_ptr->to_a <= randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h <= randcalc(k_ptr->to_h, 0, MINIMISE) &&
	    o_ptr->to_d <= randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_MAGICAL;

	return INSCRIP_STRANGE;
}
Ejemplo n.º 5
0
/*
 * Calculate the rating for a given slay combination
 */
static s32b slay_power(const object_type *o_ptr, int verbose, ang_file* log_file,
	const bitflag flags[OF_SIZE])
{
	bitflag s_index[OF_SIZE];
	s32b sv = 0;
	int i;
	int mult;
	const slay_t *s_ptr;

	/* Combine the slay bytes into an index value */
	of_copy(s_index, flags);
	flags_mask(s_index, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END);

	/* Look in the cache to see if we know this one yet */
	for (i = 0; !of_is_empty(slay_cache[i].flags); i++)
	{
		if (of_is_equal(s_index, slay_cache[i].flags))
			break;
	}

	sv = slay_cache[i].value;

	/* If it's cached (or there are no slays), return the value */
	if (sv)
	{
		LOG_PRINT("Slay cache hit\n");
		return sv;
	}

	/*
	 * Otherwise we need to calculate the expected average multiplier
	 * for this combination (multiplied by the total number of
	 * monsters, which we'll divide out later).
	 */
	for (i = 0; i < z_info->r_max; i++)
	{
		monster_race *r_ptr = &r_info[i];
		mult = 1;

		/*
		 * Do the following in ascending order so that the best
		 * multiple is retained
		 */
		for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++)
		{
			if (!of_has(flags, s_ptr->slay_flag)) continue;

			if (rf_has(r_ptr->flags, s_ptr->monster_flag) ||
			    (s_ptr->resist_flag && !rf_has(r_ptr->flags,
			    s_ptr->resist_flag)))
			{
			    mult = s_ptr->mult;
			}
		}

		/* Add the multiple to sv */
		sv += mult * r_ptr->power;
	}

	/*
	 * To get the expected damage for this weapon, multiply the
	 * average damage from base dice by sv, and divide by the
	 * total number of monsters.
	 */
	if (verbose)
	{
		/* Write info about the slay combination and multiplier */
		file_putf(log_file,"Slay multiplier for:");

		if (of_has(flags, OF_SLAY_EVIL)) file_putf(log_file,"Evl ");
		if (of_has(flags, OF_KILL_DRAGON)) file_putf(log_file,"XDr ");
		if (of_has(flags, OF_KILL_DEMON)) file_putf(log_file,"XDm ");
		if (of_has(flags, OF_KILL_UNDEAD)) file_putf(log_file,"XUn ");
		if (of_has(flags, OF_SLAY_ANIMAL)) file_putf(log_file,"Ani ");
		if (of_has(flags, OF_SLAY_UNDEAD)) file_putf(log_file,"Und ");
		if (of_has(flags, OF_SLAY_DRAGON)) file_putf(log_file,"Drg ");
		if (of_has(flags, OF_SLAY_DEMON)) file_putf(log_file,"Dmn ");
		if (of_has(flags, OF_SLAY_TROLL)) file_putf(log_file,"Tro ");
		if (of_has(flags, OF_SLAY_ORC)) file_putf(log_file,"Orc ");
		if (of_has(flags, OF_SLAY_GIANT)) file_putf(log_file,"Gia ");
		if (of_has(flags, OF_BRAND_ACID)) file_putf(log_file,"Acd ");
		if (of_has(flags, OF_BRAND_ELEC)) file_putf(log_file,"Elc ");
		if (of_has(flags, OF_BRAND_FIRE)) file_putf(log_file,"Fir ");
		if (of_has(flags, OF_BRAND_COLD)) file_putf(log_file,"Cld ");
		if (of_has(flags, OF_BRAND_POIS)) file_putf(log_file,"Poi ");

		file_putf(log_file,"sv is: %d\n", sv);
		file_putf(log_file," and t_m_p is: %d \n", tot_mon_power);

		file_putf(log_file,"times 1000 is: %d\n", (1000 * sv) / tot_mon_power);
	}

	/* Add to the cache */
	for (i = 0; !of_is_empty(slay_cache[i].flags); i++)
	{
		if (of_is_equal(s_index, slay_cache[i].flags))
		{
			slay_cache[i].value = sv;
			LOG_PRINT("Added to slay cache\n");
			break;
		}
	}

	return sv;
}