Пример #1
0
/**
 * Put the autoinscription on an object 
 */
int apply_autoinscription(object_type * o_ptr)
{
	char o_name[80];
	const char *note = get_autoinscription(o_ptr->k_idx);
	const char *existing_inscription = quark_str(o_ptr->note);

	/* Don't inscribe unaware objects */
	if (!note || !object_aware_p(o_ptr))
		return 0;

	/* Don't re-inscribe if it's already correctly inscribed */
	if (existing_inscription && streq(note, existing_inscription))
		return 0;

	/* Get an object description */
	object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

	if (note[0] != 0)
		o_ptr->note = quark_add(note);
	else
		o_ptr->note = 0;

	msg("You autoinscribe %s.", o_name);

	return 1;
}
Пример #2
0
/* Put the autoinscription on an object */
int apply_autoinscription(object_type *o_ptr)
{
	char o_name[80];
	const char *note = get_autoinscription(o_ptr->kind);

	/* Don't inscribe unaware objects */
	if (!note || !object_flavor_is_aware(o_ptr))
		return 0;

	/* Don't re-inscribe if it's already inscribed */
	if (o_ptr->note)
		return 0;

	/* Get an object description */
	object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

	if (note[0] != 0)
		o_ptr->note = quark_add(note);
	else
		o_ptr->note = 0;

	msg("You autoinscribe %s.", o_name);

	return 1;
}
Пример #3
0
/**
 * Put an autoinscription on an object
 */
int apply_autoinscription(struct object *obj)
{
	char o_name[80];
	const char *note = obj ? get_autoinscription(obj->kind) : NULL;

	/* Don't inscribe unaware objects */
	if (!note || !object_flavor_is_aware(obj))
		return 0;

	/* Don't re-inscribe if it's already inscribed */
	if (obj->note)
		return 0;

	/* Don't inscribe unless the player is carrying it */
	if (!object_is_carried(player, obj))
		return 0;

	/* Don't inscribe if ignored */
	if (ignore_item_ok(obj))
		return 0;

	/* Get an object description */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	if (note[0] != 0)
		obj->note = quark_add(note);
	else
		obj->note = 0;

	msg("You autoinscribe %s.", o_name);

	return 1;
}
Пример #4
0
/*
 * Special key actions for object inscription.
 */
static void o_xtra_act(struct keypress ch, int oid)
{
	object_kind *k_ptr = &k_info[oid];
	s16b idx = get_autoinscription_index(oid);

	/* Forget it if we've never seen the thing */
	if (!k_ptr->everseen)
		return;

	/* Uninscribe */
	if (ch.code == '}') {
		if (idx != -1)
			remove_autoinscription(oid);
		return;
	}

	/* Inscribe */
	else if (ch.code == '{') {
		char note_text[80] = "";

		/* Avoid the prompt getting in the way */
		screen_save();

		/* Prompt */
		prt("Inscribe with: ", 0, 0);

		/* Default note */
		if (idx != -1)
			strnfmt(note_text, sizeof(note_text), "%s",
					get_autoinscription(oid));

		/* Get an inscription */
		if (askfor_aux(note_text, sizeof(note_text), NULL)) {
			/* Remove old inscription if existent */
			if (idx != -1)
				remove_autoinscription(oid);

			/* Add the autoinscription */
			add_autoinscription(oid, note_text);

			/* Notice stuff (later) */
			p_ptr->notice |= (PN_AUTOINSCRIBE);
			p_ptr->redraw |= (PR_INVEN | PR_EQUIP);
		}

		/* Reload the screen */
		screen_load();
	}
}
Пример #5
0
void dump_autoinscriptions(ang_file *f) {
	int i;
	for (i = 1; i < z_info->k_max; i++) {
		struct object_kind *k = &k_info[i];
		char name[120];
		const char *note;

		if (!k->name || !k->tval) continue;
		note = get_autoinscription(k);
		if (note) {
			get_pref_name(name, sizeof name, k->name);
			file_putf(f, "inscribe:%s:%s:%s\n", tval_find_name(k->tval), name, note);
		}
	}
}
Пример #6
0
/*
 * Display the objects in a group.
 */
static void display_object(int col, int row, bool cursor, int oid)
{
    int k_idx = oid;

    object_kind *k_ptr = &k_info[k_idx];
    const char *inscrip = get_autoinscription(oid);

    char o_name[80];

    /* Choose a color */
    bool aware = (!k_ptr->flavor || k_ptr->aware);
    byte attr = curs_attrs[(int) aware][(int) cursor];

    /* Find graphics bits -- versions of the object_char and object_attr
     * defines */
    bool use_flavour = (k_ptr->flavor) && !(aware && k_ptr->tval == TV_SCROLL);

    byte a = use_flavour ? flavor_info[k_ptr->flavor].x_attr : k_ptr->x_attr;
    byte c = use_flavour ? flavor_info[k_ptr->flavor].x_char : k_ptr->x_char;

    /* Display known artifacts differently */
    if (kf_has(k_ptr->flags_kind, KF_INSTA_ART)
	&& artifact_is_known(get_artifact_from_kind(k_ptr))) {
	get_artifact_display_name(o_name, sizeof(o_name),
				  get_artifact_from_kind(k_ptr));
    } else {
	object_kind_name(o_name, sizeof(o_name), k_idx, OPT(cheat_know));
    }

    /* If the type is "tried", display that */
    if (k_ptr->tried && !aware)
	my_strcat(o_name, " {tried}", sizeof(o_name));

    /* Display the name */
    c_prt(attr, o_name, row, col);

    /* Show autoinscription if around */
    if (aware && inscrip)
	c_put_str(TERM_YELLOW, inscrip, row, 55);

    /* Hack - don't use if double tile */
    if ((tile_width > 1) || (tile_height > 1))
	return;

    /* Display symbol */
    big_pad(76, row, a, c);
}
Пример #7
0
/*
 * Display the objects in a group.
 */
static void display_object(int col, int row, bool cursor, int oid)
{
	object_kind *kind = &k_info[oid];
	const char *inscrip = get_autoinscription(kind);

	char o_name[80];

	/* Choose a color */
	bool aware = (!kind->flavor || kind->aware);
	byte attr = curs_attrs[(int)aware][(int)cursor];

	/* Find graphics bits -- versions of the object_char and object_attr defines */
	bool use_flavour = (kind->flavor) && !(aware && kind->tval == TV_SCROLL);

	byte a = use_flavour ? kind->flavor->x_attr : kind->x_attr;
	byte c = use_flavour ? kind->flavor->x_char : kind->x_char;

	/* Display known artifacts differently */
	if (of_has(kind->flags, OF_INSTA_ART) && artifact_is_known(get_artifact_from_kind(kind)))
		get_artifact_display_name(o_name, sizeof(o_name), get_artifact_from_kind(kind));
	else
 		object_kind_name(o_name, sizeof(o_name), kind, OPT(cheat_know));

	/* If the type is "tried", display that */
	if (kind->tried && !aware)
		my_strcat(o_name, " {tried}", sizeof(o_name));

	/* Display the name */
	c_prt(attr, o_name, row, col);

	/* Show squelch status */
	if ((aware && kind_is_squelched_aware(kind)) ||
		(!aware && kind_is_squelched_unaware(kind)))
		c_put_str(attr, "Yes", row, 46);


	/* Show autoinscription if around */
	if (aware && inscrip)
		c_put_str(TERM_YELLOW, inscrip, row, 55);

	if (tile_height == 1) {
		big_pad(76, row, a, c);
	}
}
Пример #8
0
/**
 * Put an autoinscription on an object
 */
int apply_autoinscription(struct object *obj)
{
	char o_name[80];
	bool aware = obj->kind->aware;
	const char *note = obj ? get_autoinscription(obj->kind, aware) : NULL;

	/* Remove unaware inscription if aware */
	if (aware && quark_str(obj->note) && quark_str(obj->kind->note_unaware) &&
		streq(quark_str(obj->note), quark_str(obj->kind->note_unaware)))
		obj->note = 0;

	/* Make rune autoinscription go first, for now */
	runes_autoinscribe(obj);

	/* No note - don't inscribe */
	if (!note)
		return 0;

	/* Don't re-inscribe if it's already inscribed */
	if (obj->note)
		return 0;

	/* Don't inscribe unless the player is carrying it */
	if (!object_is_carried(player, obj))
		return 0;

	/* Don't inscribe if ignored */
	if (ignore_item_ok(obj))
		return 0;

	/* Get an object description */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	if (note[0] != 0)
		obj->note = quark_add(note);
	else
		obj->note = 0;

	msg("You autoinscribe %s.", o_name);

	return 1;
}
Пример #9
0
/*
 * Special key actions for object inscription.
 */
static void o_xtra_act(struct keypress ch, int oid)
{
	object_kind *k = objkind_byid(oid);

	/* Toggle squelch */
	if (squelch_tval(k->tval) && (ch.code == 's' || ch.code == 'S'))
	{
		if (k->aware)
		{
			if (kind_is_squelched_aware(k))
				kind_squelch_clear(k);
			else
				kind_squelch_when_aware(k);
		}
		else
		{
			if (kind_is_squelched_unaware(k))
				kind_squelch_clear(k);
			else
				kind_squelch_when_unaware(k);
		}

		return;
	}

	/* Forget it if we've never seen the thing */
	if (k->flavor && !k->aware)
		return;

	/* Uninscribe */
	if (ch.code == '}') {
		if (k->note)
			remove_autoinscription(oid);
	} else if (ch.code == '{') {
		/* Inscribe */
		char note_text[80] = "";

		/* Avoid the prompt getting in the way */
		screen_save();

		/* Prompt */
		prt("Inscribe with: ", 0, 0);

		/* Default note */
		if (k->note)
			strnfmt(note_text, sizeof(note_text), "%s", get_autoinscription(k));

		/* Get an inscription */
		if (askfor_aux(note_text, sizeof(note_text), NULL))
		{
			/* Remove old inscription if existent */
			if (k->note)
				remove_autoinscription(oid);

			/* Add the autoinscription */
			add_autoinscription(oid, note_text);

			/* Notice stuff (later) */
			p_ptr->notice |= (PN_AUTOINSCRIBE);
			p_ptr->redraw |= (PR_INVEN | PR_EQUIP);
		}

		/* Reload the screen */
		screen_load();
	}
}