Thread: Wear location
View Single Post
Old 01-20-2003, 08:50 AM   #2
jornel
Member
 
Join Date: Sep 2002
Location: Canada
Posts: 73
jornel is on a distinguished road
I don't know ROM but I'll show you what you have to do in smaug and you can just do what applies in your case.  I'll assume the new wear location is called a 'greedle'.

First you want to define a new 'wear flag' for objects.  In mud.h insert your new

     #define ITEM_WEAR_GREEDLE  ??

just before the ITEM_WEAR_MAX and increment that constant as well.  Similarly, insert a WEAR_GREEDLE in the wear_locations enum just before MAX_WEAR.

Next you want your builders to be able to set and reset that bit on objects, so in build.c you have to place the element "greedle" at offset ?? in the w_flags[] array.  In smaug 1.4 there is also a duplicate of that array called item_w_flags[] which is only referenced by mprog.c  Add "greedle" there too.  Perhaps one day they will eliminate that redundancy.

At this stage, I would do a make clean and reboot the mud just to make sure you can set and reset this flag in OLC, as well as see it set when you ostat an item.  Once you are satisfied that you have control over this flag it is time to make the flag actually do something.

In act_info there is an array called where_name[] which is used when someone looks at someone else and sees what they are wearing in which location.  Here we insert the string "<worn on greedle>" at the appropriate offset.

In act_obj.c in function wear_obj() there is a big switch statement that you have to add a new case for WEAR_ITEM_GREEDLE.   I made this one by copying the case statements for case WEAR_ITEM_FACE, and changing all the FACEs to GREEDLEs like this:

[code]
 case ITEM_WEAR_GREEDLE;
   if ( !remove_obj( ch, WEAR_GREEDLE, fReplace ) )
      return;
   if ( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
   {
     act( AT_ACTION, "$n places $p on $s greedle.",   ch, obj, NULL, TO_ROOM );
     act( AT_ACTION, "You place $p on your greedle.", ch, obj, NULL, TO_CHAR );
   }
   equip_char( ch, obj, WEAR_GREEDLE );
   oprog_wear_trigger( ch, obj );
   return;
[/quote]
Your code may look different, but you get the general idea.
 
Recompile, reboot, and show off your new greedle to the world!
jornel is offline   Reply With Quote