Exemplo n.º 1
0
/*
 * Describe slays and brands on weapons
 */
static bool describe_slays(textblock *tb, const bitflag flags[OF_SIZE],
		int tval)
{
	bool printed = FALSE;
	const char *slay_descs[SL_MAX] = { 0 };
	bitflag slay_mask[OF_SIZE], kill_mask[OF_SIZE], brand_mask[OF_SIZE];
	size_t count;
	bool fulldesc;

	create_mask(slay_mask, FALSE, OFT_SLAY, OFT_MAX);
	create_mask(kill_mask, FALSE, OFT_KILL, OFT_MAX);
	create_mask(brand_mask, FALSE, OFT_BRAND, OFT_MAX);

	if (tval == TV_SWORD || tval == TV_HAFTED || tval == TV_POLEARM ||
			tval == TV_DIGGING || tval == TV_BOW || tval == TV_SHOT ||
			tval == TV_ARROW || tval == TV_BOLT || tval == TV_FLASK)
		fulldesc = FALSE;
	else
		fulldesc = TRUE;

	/* Slays */
	count = list_slays(flags, slay_mask, slay_descs, NULL, NULL, TRUE);
	if (count)
	{
		if (fulldesc)
			textblock_append(tb, "It causes your melee attacks to slay ");
		else
			textblock_append(tb, "Slays ");
		info_out_list(tb, slay_descs, count);
		printed = TRUE;
	}

	/* Kills */
	count = list_slays(flags, kill_mask, slay_descs, NULL, NULL, TRUE);
	if (count)
	{
		if (fulldesc)
			textblock_append(tb, "It causes your melee attacks to *slay* ");
		else
			textblock_append(tb, "*Slays* ");
		info_out_list(tb, slay_descs, count);
		printed = TRUE;
	}

	/* Brands */
	count = list_slays(flags, brand_mask, NULL, slay_descs, NULL, TRUE);
	if (count)
	{
		if (fulldesc)
			textblock_append(tb, "It brands your melee attacks with ");
		else
			textblock_append(tb, "Branded with ");
		info_out_list(tb, slay_descs, count);
		printed = TRUE;
	}

	return printed;
}
Exemplo n.º 2
0
/*
 * Describe immunities granted by an object.
 */
static bool describe_immune(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *i_descs[N_ELEMENTS(immunity_flags)];
	const char *r_descs[N_ELEMENTS(resist_flags)];
	const char *p_descs[N_ELEMENTS(protect_flags)];
	const char *v_descs[N_ELEMENTS(vuln_flags)];
	size_t count;

	bool prev = FALSE;

	/* Immunities */
	count = info_collect(tb, immunity_flags, N_ELEMENTS(immunity_flags),
			flags, i_descs);
	if (count)
	{
		textblock_append(tb, "Provides immunity to ");
		info_out_list(tb, i_descs, count);
		prev = TRUE;
	}

	/* Resistances */
	count = info_collect(tb, resist_flags, N_ELEMENTS(resist_flags),
			flags, r_descs);
	if (count)
	{
		textblock_append(tb, "Provides resistance to ");
		info_out_list(tb, r_descs, count);
		prev = TRUE;
	}

	/* Protections */
	count = info_collect(tb, protect_flags, N_ELEMENTS(protect_flags),
			flags, p_descs);
	if (count)
	{
		textblock_append(tb, "Provides protection from ");
		info_out_list(tb, p_descs, count);
		prev = TRUE;
	}

	/* Vulnerabilities */
	count = info_collect(tb, vuln_flags, N_ELEMENTS(vuln_flags),
			flags, v_descs);
	if (count)
	{
		textblock_append(tb, "Makes you vulnerable to ");
		info_out_list(tb, v_descs, count);
		prev = TRUE;
	}

	return prev;
}
Exemplo n.º 3
0
/**
 * Describe immunities, resistances and vulnerabilities granted by an object.
 */
static bool describe_elements(textblock *tb,
							  const struct element_info el_info[])
{
	const char *i_descs[N_ELEMENTS(elements)];
	const char *r_descs[N_ELEMENTS(elements)];
	const char *v_descs[N_ELEMENTS(elements)];
	size_t i, count;

	bool list[N_ELEMENTS(elements)], prev = FALSE;

	/* Immunities */
	for (i = 0; i < N_ELEMENTS(elements); i++)
		list[i] = (el_info[i].res_level == 3);
	count = element_info_collect(list, i_descs);
	if (count)
	{
		textblock_append(tb, "Provides immunity to ");
		info_out_list(tb, i_descs, count);
		prev = TRUE;
	}

	/* Resistances */
	for (i = 0; i < N_ELEMENTS(elements); i++)
		list[i] = (el_info[i].res_level == 1);
	count = element_info_collect(list, r_descs);
	if (count)
	{
		textblock_append(tb, "Provides resistance to ");
		info_out_list(tb, r_descs, count);
		prev = TRUE;
	}

	/* Vulnerabilities */
	for (i = 0; i < N_ELEMENTS(elements); i++)
		list[i] = (el_info[i].res_level == -1);
	count = element_info_collect(list, v_descs);
	if (count)
	{
		textblock_append(tb, "Makes you vulnerable to ");
		info_out_list(tb, v_descs, count);
		prev = TRUE;
	}

	return prev;
}
Exemplo n.º 4
0
/*
 * Describe stat sustains.
 */
static bool describe_sustains(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *descs[N_ELEMENTS(sustain_flags)];
	size_t count = info_collect(tb, sustain_flags, N_ELEMENTS(sustain_flags),
			flags, descs);

	if (!count)
		return FALSE;

	textblock_append(tb, "Sustains ");
	info_out_list(tb, descs, count);

	return TRUE;
}
Exemplo n.º 5
0
/*
 * Describe 'ignores' of an object.
 */
static bool describe_ignores(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *descs[N_ELEMENTS(ignore_flags)];
	size_t count = info_collect(tb, ignore_flags, N_ELEMENTS(ignore_flags),
			flags, descs);

	if (!count)
		return FALSE;

	textblock_append(tb, "Cannot be harmed by ");
	info_out_list(tb, descs, count);

	return TRUE;
}
Exemplo n.º 6
0
/*
 * Describe 'ignores' of an object.
 */
static bool describe_ignores(textblock * tb, const object_type * o_ptr,
							 oinfo_detail_t mode)
{
	bool full = mode & OINFO_FULL;
	const char *descs[N_ELEMENTS(ignore_flags)];
	size_t count = info_collect(ignore_flags, N_ELEMENTS(ignore_flags),
								full ? o_ptr->flags_obj : o_ptr->id_obj,
								descs);

	if (!count)
		return FALSE;

	textblock_append(tb, "Cannot be harmed by ");
	info_out_list(tb, descs, count);

	return TRUE;
}
Exemplo n.º 7
0
/**
 * Describe protections granted by an object.
 */
static bool describe_protects(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *p_descs[N_ELEMENTS(protect_flags)];
	size_t count;

	/* Protections */
	count = flag_info_collect(protect_flags, N_ELEMENTS(protect_flags),
			flags, p_descs);

	if (!count)
		return false;

	textblock_append(tb, "Provides protection from ");
	info_out_list(tb, p_descs, count);

	return  true;
}
Exemplo n.º 8
0
/*
 * Describe stat modifications.
 */
static bool describe_stats(textblock *tb, const object_type *o_ptr,
		bitflag flags[MAX_PVALS][OF_SIZE], oinfo_detail_t mode)
{
	const char *descs[N_ELEMENTS(pval_flags)];
	size_t count, i;
	bool full = mode & OINFO_FULL;
	bool dummy = mode & OINFO_DUMMY;
	bool search = FALSE;

	if (!o_ptr->num_pvals && !dummy)
		return FALSE;

	for (i = 0; i < o_ptr->num_pvals; i++) {
		count = info_collect(tb, pval_flags, N_ELEMENTS(pval_flags), flags[i], descs);

		if (count)
		{
			if ((object_this_pval_is_visible(o_ptr, i) || full) && !dummy)
				textblock_append_c(tb, (o_ptr->pval[i] > 0) ? TERM_L_GREEN : TERM_RED,
					"%+i ", o_ptr->pval[i]);
			else
				textblock_append(tb, "Affects your ");

			info_out_list(tb, descs, count);
		}
		if (of_has(flags[i], OF_SEARCH))
			search = TRUE;
	}

	if (search)
	{
		if ((object_this_pval_is_visible(o_ptr, which_pval(o_ptr, OF_SEARCH)) || full) && !dummy)
		{
			textblock_append_c(tb, (o_ptr->pval[which_pval(o_ptr, OF_SEARCH)] > 0) ? TERM_L_GREEN : TERM_RED,
				"%+i%% ", o_ptr->pval[which_pval(o_ptr, OF_SEARCH)] * 5);
			textblock_append(tb, "to searching.\n");
		}
		else if (count)
			textblock_append(tb, "Also affects your searching skill.\n");
		else
			textblock_append(tb, "Affects your searching skill.\n");
	}

	return TRUE;
}
Exemplo n.º 9
0
/**
 * Describe elements that damage or destroy an object.
 */
static bool describe_hates(textblock *tb, const struct element_info el_info[])
{
	const char *descs[N_ELEMENTS(elements)];
	size_t i, count = 0;
	bool list[N_ELEMENTS(elements)];

	for (i = 0; i < N_ELEMENTS(elements); i++)
		list[i] = (el_info[i].flags & EL_INFO_HATES);
	count = element_info_collect(list, descs);

	if (!count)
		return false;

	textblock_append(tb, "Can be destroyed by ");
	info_out_list(tb, descs, count);

	return true;
}
Exemplo n.º 10
0
/**
 * Describe elements an object ignores.
 */
static bool describe_ignores(textblock *tb, const struct element_info el_info[])
{
	const char *descs[N_ELEMENTS(elements)];
	size_t i, count;
	bool list[N_ELEMENTS(elements)];

	for (i = 0; i < N_ELEMENTS(elements); i++)
		list[i] = (el_info[i].flags & EL_INFO_IGNORE);
	count = element_info_collect(list, descs);

	if (!count)
		return FALSE;

	textblock_append(tb, "Cannot be harmed by ");
	info_out_list(tb, descs, count);

	return TRUE;
}
Exemplo n.º 11
0
/**
 * Describe stat sustains.
 */
static bool describe_sustains(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *descs[STAT_MAX];
	int i, count = 0;

	for (i = 0; i < STAT_MAX; i++) {
		struct obj_property *prop = lookup_obj_property(OBJ_PROPERTY_STAT, i);
		if (of_has(flags, sustain_flag(prop->index)))
			descs[count++] = prop->name;
	}

	if (!count)
		return false;

	textblock_append(tb, "Sustains ");
	info_out_list(tb, descs, count);

	return true;
}
Exemplo n.º 12
0
/*
 * Describe stat sustains.
 */
static bool describe_sustains(textblock *tb, const object_type *o_ptr, 
			      oinfo_detail_t mode)
{

    bool full = mode & OINFO_FULL;
    const char *descs[N_ELEMENTS(sustain_flags)];
    size_t count = info_collect(sustain_flags, N_ELEMENTS(sustain_flags),
				full ? o_ptr->flags_obj : o_ptr->id_obj, 
				descs);

    if (!count)
	return FALSE;

    if (count == 6) textblock_append(tb, "It sustains all your stats. ");
    else {
	textblock_append(tb, "Sustains ");
	info_out_list(tb, descs, count);
    }

    return TRUE;
}
Exemplo n.º 13
0
/**
 * Describe protections granted by an object.
 */
static bool describe_protects(textblock *tb, const bitflag flags[OF_SIZE])
{
	const char *p_descs[OF_MAX];
	int i, count = 0;

	/* Protections */
	for (i = 1; i < OF_MAX; i++) {
		struct obj_property *prop = lookup_obj_property(OBJ_PROPERTY_FLAG, i);
		if (prop->subtype != OFT_PROT) continue;
		if (of_has(flags, prop->index)) {
			p_descs[count++] = prop->desc;
		}
	}

	if (!count)
		return false;

	textblock_append(tb, "Provides protection from ");
	info_out_list(tb, p_descs, count);

	return  true;
}