Hello.
I've been playing with having items hide their real face unless they are
identified.
So for instance potions would keep their generic face when not identified.
Here's a patch that makes that behaviour.
Right now it's only the face (and animation-related parameters), but I was
thinking of doing that for the name too. So eg unidentified skill scrolls could
have a generic blank face and name until they are identified.
Would that behaviour change be ok?
The code relies on key-values containing identified properties (see
common/item.c:object_give_identified_properties for more details).
Regards
Nicolas
--
Mon p'tit coin du web - http://nicolas.weeger.org
Index: include/libproto.h
===
--- include/libproto.h (révision 16608)
+++ include/libproto.h (copie de travail)
@@ -114,6 +114,7 @@
extern StringBuffer *describe_item(const object *op, const object *owner, StringBuffer *buf);
extern int is_magical(const object *op);
extern int need_identify(const object *op);
+extern void object_give_identified_properties(object *op);
extern object *identify(object *op);
/* languages.c */
const char *i18n(const object *who, const char *code);
Index: common/item.c
===
--- common/item.c (révision 16544)
+++ common/item.c (copie de travail)
@@ -1381,6 +1381,46 @@
}
/**
+ * Ensure op has all its identified properties set.
+ * @param op object to process.
+ */
+void object_give_identified_properties(object *op) {
+sstring key;
+
+key = object_get_value(op, identified_face);
+if (key != NULL) {
+op-face = new_faces[find_face(key, op-face-number)];
+/* if the face is defined, clean the animation, because else
+ * the face can be lost ; if an animation is defined, it'll be
+ * processed later on */
+CLEAR_FLAG(op, FLAG_CLIENT_ANIM_RANDOM);
+CLEAR_FLAG(op, FLAG_CLIENT_ANIM_SYNC);
+op-anim_speed = 0;
+op-animation_id = 0;
+object_set_value(op, identified_face, NULL, 0);
+}
+
+if (object_get_value(op, identified_anim_random) != NULL) {
+SET_FLAG(op, FLAG_CLIENT_ANIM_RANDOM);
+object_set_value(op, identified_anim_random, NULL, 0);
+}
+
+key = object_get_value(op, identified_anim_speed);
+if (key != NULL) {
+op-anim_speed = atoi(key);
+op-last_anim = 1;
+object_set_value(op, identified_anim_speed, NULL, 0);
+}
+
+key = object_get_value(op, identified_animation);
+if (key != NULL) {
+op-animation_id = atoi(key);
+SET_FLAG(op, FLAG_ANIMATE);
+animate_object(op, op-facing);
+object_set_value(op, identified_animation, NULL, 0);
+}
+}
+/**
* Identifies an item.
* Supposed to fix face-values as well here, but later.
* Note - this may merge op with other object, so
@@ -1400,6 +1440,8 @@
CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL);
CLEAR_FLAG(op, FLAG_NO_SKILL_IDENT);
+object_give_identified_properties(op);
+
/*
* We want autojoining of equal objects:
*/
Index: common/loader.l
===
--- common/loader.l (révision 16544)
+++ common/loader.l (copie de travail)
@@ -425,6 +425,10 @@
object_set_flag_inv(op, FLAG_IS_A_TEMPLATE);
}
+/* if the item is identified, ensure we got the correct face */
+if (QUERY_FLAG(op, FLAG_IDENTIFIED))
+object_give_identified_properties(op);
+
/* Here we'll handle custom monsters. In order to handle them correctly, especially in the fix_object
* method, we'll create a new temporary archetype containing defined values.
* Of course this doesn't apply when loading archetypes or artifacts.
Index: common/artifact.c
===
--- common/artifact.c (révision 16608)
+++ common/artifact.c (copie de travail)
@@ -267,31 +267,28 @@
*/
void add_abilities(object *op, const object *change) {
int i, tmp;
+char buf[MAX_BUF];
if (change-face != blank_face) {
#ifdef TREASURE_VERBOSE
LOG(llevDebug, FACE: %d\n, change-face-number);
#endif
-op-face = change-face;
-/* if the face is defined, clean the animation, because else
- * the face can be lost ; if an animation is defined, it'll be
- * processed later on */
-CLEAR_FLAG(op, FLAG_CLIENT_ANIM_RANDOM);
-CLEAR_FLAG(op, FLAG_CLIENT_ANIM_SYNC);
-op-anim_speed = 0;
-op-animation_id = 0;
+
+object_set_value(op, identified_face, change-face-name, 1);
+}
+if (QUERY_FLAG(change, FLAG_CLIENT_ANIM_RANDOM)) {
+object_set_value(op, identified_anim_random, 1, 1);
}
-if (QUERY_FLAG(change, FLAG_CLIENT_ANIM_RANDOM))
-SET_FLAG(op, FLAG_CLIENT_ANIM_RANDOM);
+
if (change-anim_speed 0) {
-op-anim_speed = change-anim_speed;