[crossfire] Patch proposal: unidentified generic faces

2012-01-18 Thread Nicolas Weeger
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;

Re: [crossfire] Patch proposal: unidentified generic faces

2012-01-18 Thread Mark Wedel

On 01/18/12 02:26 PM, Nicolas Weeger wrote:

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.


 In the distant past, potions used to work that way - generic face until 
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.


 Yes - this makes sense.  Using key/value or other abstraction vs coding in 
those values makes a lot more sense.  I suspect that is the reason that skill 
scrolls do not work that way - when they were put in, the code was not modified 
to hide their names.





Would that behaviour change be ok?


 Fine by me.




The code relies on key-values containing identified properties (see
common/item.c:object_give_identified_properties for more details).


 Is the way you see doing this is that the archetype contains the unidentified 
values?  I'm just curious as to how the unidentified name/face is determined.



___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire