Пример #1
0
/**
 * Provide information on an ego-item type
 */
textblock *object_info_ego(struct ego_item *ego)
{
	struct object_kind *kind = NULL;
	struct object obj = OBJECT_NULL, known_obj = OBJECT_NULL;
	size_t i;

	for (i = 0; i < z_info->k_max; i++) {
		kind = &k_info[i];
		if (!kind->name)
			continue;
		if (i == ego->poss_items->kidx)
			break;
	}

	obj.kind = kind;
	obj.tval = kind->tval;
	obj.sval = kind->sval;
	obj.ego = ego;
	ego_apply_magic(&obj, 0);

	object_copy(&known_obj, &obj);
	obj.known = &known_obj;

	return object_info_out(&obj, OINFO_NONE | OINFO_EGO);
}
Пример #2
0
/*
 * Tweak an item
 */
static void wiz_tweak_item(object_type *o_ptr)
{
	const char *p;
	char tmp_val[80];
	int i, val;

	/* Hack -- leave artifacts alone */
	if (o_ptr->artifact) return;

	p = "Enter new ego item index: ";
	strnfmt(tmp_val, sizeof(tmp_val), "0");
	if (o_ptr->ego)
		strnfmt(tmp_val, sizeof(tmp_val), "%d", o_ptr->ego->eidx);
	if (!get_string(p, tmp_val, 6)) return;
	val = atoi(tmp_val);
	if (val) {
		o_ptr->ego = &e_info[val];
		ego_apply_magic(o_ptr, p_ptr->depth);
	} else
		o_ptr->ego = 0;
	wiz_display_item(o_ptr, TRUE);

	p = "Enter new artifact index: ";
	strnfmt(tmp_val, sizeof(tmp_val), "0");
	if (o_ptr->artifact)
		strnfmt(tmp_val, sizeof(tmp_val), "%d", o_ptr->artifact->aidx);
	if (!get_string(p, tmp_val, 6)) return;
	val = atoi(tmp_val);
	if (val) {
		o_ptr->artifact = &a_info[val];
		copy_artifact_data(o_ptr, o_ptr->artifact);
	} else
		o_ptr->artifact = 0;
	wiz_display_item(o_ptr, TRUE);

#define WIZ_TWEAK(attribute) do {\
	p = "Enter new '" #attribute "' setting: ";\
	strnfmt(tmp_val, sizeof(tmp_val), "%d", o_ptr->attribute);\
	if (!get_string(p, tmp_val, 6)) return;\
	o_ptr->attribute = atoi(tmp_val);\
	wiz_display_item(o_ptr, TRUE);\
} while (0)
	for (i = 0; i < MAX_PVALS; i++) {
		WIZ_TWEAK(pval[i]);
		if (o_ptr->pval[i])
			o_ptr->num_pvals = (i + 1);
	}
	WIZ_TWEAK(to_a);
	WIZ_TWEAK(to_h);
	WIZ_TWEAK(to_d);
}
Пример #3
0
/**
 * Try to find an ego-item for an object, setting o_ptr->ego if successful and
 * applying various bonuses.
 */
static void make_ego_item(object_type *o_ptr, int level)
{
	/* Cannot further improve artifacts or ego items */
	if (o_ptr->artifact || o_ptr->ego) return;

	/* Occasionally boost the generation level of an item */
	if (level > 0 && one_in_(GREAT_EGO))
		level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));

	/* Try to get a legal ego type for this item */
	o_ptr->ego = ego_find_random(o_ptr, level);

	/* Actually apply the ego template to the item */
	if (o_ptr->ego)
		ego_apply_magic(o_ptr, level);

	return;
}
Пример #4
0
/**
 * Try to find an affix for an object, setting o_ptr->affix[n] if successful
 * and checking for a theme for the object.
 */
static void obj_add_affix(object_type *o_ptr, int level, int max_lev,
	int min_lev)
{
	int i, chosen;
	object_type object_type_body;
	object_type *j_ptr = &object_type_body;

	/* Cannot further improve artifacts or maxed items or themed items */
	if (o_ptr->artifact || o_ptr->affix[MAX_AFFIXES - 1] || o_ptr->theme) return;

	/* Occasionally boost the generation level of an affix */
	if (level > 0 && one_in_(GREAT_EGO))
		level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));

	/* Make a copy of the object in case things go wrong */
	object_copy(j_ptr, o_ptr);

	/* Use the first available affix slot */
	for (i = 0; i < MAX_AFFIXES; i++)
		if (!o_ptr->affix[i]) {
			/* Try to get a legal affix for this item */
			chosen = obj_find_affix(o_ptr, level, max_lev, min_lev);

			/* Actually apply the affix to the item */
			if (chosen) {
				o_ptr->affix[i] = &e_info[chosen];
				ego_apply_magic(o_ptr, level, chosen);
			}
			break;
		}

	/* Roll back if we've broken something, otherwise check for a theme */
	if (object_power(o_ptr, FALSE, NULL, TRUE) >= INHIBIT_POWER)
		object_copy(o_ptr, j_ptr);
	else {
		chosen = obj_find_theme(o_ptr, level);
		if (chosen) {
			obj_apply_theme(o_ptr, level, chosen);
			if (object_power(o_ptr, FALSE, NULL, TRUE) >= INHIBIT_POWER)
				object_copy(o_ptr, j_ptr);
		}
	}
	return;
}
Пример #5
0
/**
 * Provide information on an ego-item type
 */
textblock *object_info_ego(struct ego_item *ego)
{
	object_kind *kind = NULL;
	object_type obj = { 0 };
	int i;

	for (i = 0; i < z_info->k_max; i++) {
		kind = &k_info[i];
		if (!kind->name)
			continue;
		if (kind->tval == ego->tval[0])
			break;
	}

	obj.kind = kind;
	obj.tval = kind->tval;
	obj.sval = kind->sval;
	obj.affix[0] = ego;
	ego_apply_magic(&obj, 0, ego->eidx);

	return object_info_out(&obj, OINFO_FULL | OINFO_EGO | OINFO_DUMMY);
}
Пример #6
0
/**
 * Try to find an ego-item for an object, setting o_ptr->ego if successful and
 * applying various bonuses.
 */
static void make_ego_item(struct object *o_ptr, int level)
{
	/* Cannot further improve artifacts or ego items */
	if (o_ptr->artifact || o_ptr->ego) return;

	/* Occasionally boost the generation level of an item */
	if (level > 0 && one_in_(z_info->great_ego))
		level = 1 + (level * z_info->max_depth / randint1(z_info->max_depth));

	/* Try to get a legal ego type for this item */
	o_ptr->ego = ego_find_random(o_ptr, level);

	/* Actually apply the ego template to the item */
	if (o_ptr->ego)
		ego_apply_magic(o_ptr, level);

	/* Ego lights are always known as such (why? - NRM) */
	if (tval_is_light(o_ptr))
		id_on(o_ptr->id_flags, ID_EGO_ITEM);

	return;
}
Пример #7
0
/**
 * Apply a theme to an object
 *
 * \param o_ptr is the object to which we're applying a theme.
 * \param level is the effective generation level.
 * \param this_one is the theme to apply.
 */
void obj_apply_theme(object_type *o_ptr, int level, int this_one)
{
	size_t i, j;

	o_ptr->theme = &themes[this_one];

	/* Apply the affixes we don't already have, but allow the second and
	   subsequent applications specified */
	for (i = 0; i < o_ptr->theme->num_affixes; i++) {
		bool gotit = FALSE;
		for (j = 0; j < MAX_AFFIXES; j++) {
			if (!o_ptr->affix[j]) continue;
			if ((o_ptr->affix[j]->eidx == o_ptr->theme->affix[i]) &&
					(o_ptr->theme->affix[i] != o_ptr->theme->affix[i - 1]))
				gotit = TRUE;
		}
		if (!gotit)
			ego_apply_magic(o_ptr, level, o_ptr->theme->affix[i]);
	}

	return;
}
Пример #8
0
/**
 * Try to find an ego-item for an object, setting obj->ego if successful and
 * applying various bonuses.
 */
static void make_ego_item(struct object *obj, int level)
{
	/* Cannot further improve artifacts or ego items */
	if (obj->artifact || obj->ego) return;

	/* Occasionally boost the generation level of an item */
	if (level > 0 && one_in_(z_info->great_ego)) {
		level = 1 + (level * z_info->max_depth / randint1(z_info->max_depth));

		/* Ensure valid allocation level */
		if (level >= z_info->max_depth)
			level = z_info->max_depth - 1;
	}

	/* Try to get a legal ego type for this item */
	obj->ego = ego_find_random(obj, level);

	/* Actually apply the ego template to the item */
	if (obj->ego)
		ego_apply_magic(obj, level);

	return;
}