-----------------------------------------------------------------
SMAUG Pretitle 1.0 By Xerves (Released August 2, 1999)
Xerves is the admin/owner of Rafermand (mud.rafermand.net port 3002)
Website: http://www.rafermand.net
Contact: xerves@rafermand.net
-----------------------------------------------------------------

As the name might suggest, Pretitle is a title that goes before the
player's name.  You might want to add this feature as a normal feature
like title, or make it an immortal one like rank.  Anyway you go, it is
a really nice little feature to add to the mud.

-----------------------------------------------------------------

Files Needed:  act_info.c, mud.h save.c tables.c
Files Optional: Finger.c (if you have the finger command)

Note:  Pretitle has "hard-coded" colors in it, meaning that they
will affect some of your color choices.  As of now, it is assuming
your who screen is in green, so it will reset your colors back to
green so it will not bleed, if you want to change it, you can, and
it will be noted in the code where to make the changes.

-----------------------------------------------------------------

1.   Act_info.c

   Need to drop this function into the file, it is the actual
   command for setting pretitle.

/* Orginal done by Azalin for ???
   Converted to Smaug by Xerves 8/2/99 */
void do_pretitle( CHAR_DATA *ch, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   int value;

    if ( IS_NPC(ch) )
    {
        send_to_char( "Not on NPC's.\n\r", ch );
        return;
    }
    /* Used the notitle flag to ban abuse of the command, if you want to make
       your own flags and put them in, you can -- Xerves */
    if ( IS_SET( ch->pcdata->flags, PCFLAG_NOTITLE ))
    {
	  set_char_color( AT_IMMORT, ch );
        send_to_char( "The Gods prohibit you from changing your title or pretitle.\n\r", ch );
        return;
    }

    if ( ch->pcdata->pretit == '\0' )
        ch->pcdata->pretit = "&G"; /* Hard-coded Color part here, change if needed -- Xerves */

    if ( argument[0] == '\0' )
    {
        send_to_char("Syntax: pretitle show\n\r", ch);
        send_to_char("Syntax: pretitle clear\n\r", ch);
        send_to_char("Syntax: pretitle <text>\n\r", ch);
        return;
    }

    if ( !str_cmp( argument, "show" ) )
    {
        sprintf(buf, "Your current pretitle is '%s&g'.\n\r",ch->pcdata->pretit);
        send_to_char(buf,ch);/* Above is hard-coded also -- Xerves */
        return;
    }

    if ( !str_cmp( argument, "clear" ) )
    {
       ch->pcdata->pretit = "&G"; /* Hard-coded Color -- Xerves */
       send_to_char("Pretitle Removed.\n\r",ch);
       return;
    }
    /* Will only allow for 25 characters in the pretitle, color code included
       If you want to have a longer pretitle (or shorter) change the number below
       and change the number in the arrays to match -- Xerves */
    if ( strlen(argument) > 25 )
    {
        argument[25] = '&'; /* Hard-coded Color again */
        argument[26] = 'G';
        argument[27] = '\0';
    }
    else
    {
        value = strlen(argument);
        argument[value] = '&';
        argument[value+1] = 'G';   /* Color again */
        argument[value+2] = '\0';
    }

    smash_tilde( argument );
    ch->pcdata->pretit = str_dup( argument );
    send_to_char("Done.\n\r",ch);
    return;

}

      In do_who find this code.......

      sprintf( buf, "%*s%-15s %s%s%s%s%s%s%s%s.%s%s%s\n\r",
	  (fGroup ? whogr->indent : 0), "",
	  class,
	  invis_str,
          (wch->desc && wch->desc->connected) ? "[WRITING] " : "",
	  xIS_SET(wch->act, PLR_AFK) ? "[AFK] " : "",
	  xIS_SET(wch->act, PLR_ATTACKER) ? "(ATTACKER) " : "",
	  xIS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
	  xIS_SET(wch->act, PLR_THIEF)  ? "(THIEF) "  : "",
	  char_name,
	  wch->pcdata->title,
          extra_title,
	  clan_name,
	  council_name );


    You need to tact up another %s right before the . (the %s.%s%s%s) that
    dot.

    And then before char_name, you need to put wch->pcdata->pretit

    It should look like this after you get done...

          sprintf( buf, "%*s%-15s %s%s%s%s%s%s%s%s%s.%s%s%s\n\r",
	  (fGroup ? whogr->indent : 0), "",
	  class,
	  invis_str,
          (wch->desc && wch->desc->connected) ? "[WRITING] " : "",
	  xIS_SET(wch->act, PLR_AFK) ? "[AFK] " : "",
	  xIS_SET(wch->act, PLR_ATTACKER) ? "(ATTACKER) " : "",
	  xIS_SET(wch->act, PLR_KILLER) ? "(KILLER) " : "",
	  xIS_SET(wch->act, PLR_THIEF)  ? "(THIEF) "  : "",
          wch->pcdata->pretit,
	  char_name,
	  wch->pcdata->title,
          extra_title,
	  clan_name,
	  council_name );

      IN do_whois, you need to find this code

        set_pager_color( AT_GREY, ch );
        pager_printf(ch, "\n\r'%s%s.\n\r",
	victim->name, victim->pcdata->title);

            AND change it to look like this

        set_pager_color( AT_GREY, ch );
        pager_printf(ch, "\n\r'%s&c&w%s%s.\n\r",
	victim->pcdata->pretit, victim->name, victim->pcdata->title);

            (NOTE ON ABOVE:  My mud has a fun time with the &w color, so I use
             &c&w for the &w code.  Again, this is hard coded, and if you want
             to remove the color, remove that one also)


       FINALLY, in show_char_to_char_0  Find this Code

    if ( victim->morph != NULL && victim->morph->morph != NULL &&
          !IS_IMMORTAL( ch ) )
	strcat( buf, MORPHPERS( victim, ch ) );
     else
    	strcat( buf, PERS( victim, ch ) );
    }

    if ( !IS_NPC(victim) && !xIS_SET(ch->act, PLR_BRIEF) )
	strcat( buf, victim->pcdata->title );

   And change it to look like this


     if ( victim->morph != NULL && victim->morph->morph != NULL &&
	    !IS_IMMORTAL( ch ) )
	strcat( buf, MORPHPERS( victim, ch ) );
     else
        if (!IS_NPC(victim) && victim->pcdata->pretit != NULL)
        {
           strcat (buf, victim->pcdata->pretit );
           strcat (buf, "&P");
        }
    	strcat( buf, PERS( victim, ch ) );
    }

    if ( !IS_NPC(victim) && !xIS_SET(ch->act, PLR_BRIEF) )
	strcat( buf, victim->pcdata->title );

2.  MUD.H
    In the declare_do_fun section, you need to add pretitle to it.

    In the pc_data structure, you need to add this to it
    char *              pretit;

    (I added this after the pointer for title)

3.  TABLES.C
    You need to add the pretitle commands into the tables.  Remember, there
    are two spots which it needs to be added!

4.  Save.c

    IN fwrite_char, you need to add this

       fprintf( fp, "Pretit       %s~\n",    ch->pcdata->pretit       ); /* Xerves 8-2-99 */

    You will most likely want to put it after the one for title

    In load_char_obj you need to put it in two spots, first...

    Right below
       	ch->pcdata->bestowments		= str_dup( "" );
	ch->pcdata->title		= STRALLOC( "" );
    Add This Line
        ch->pcdata->pretit              = str_dup( "" ); /* Xerves 8-2-99 */

    Next, down about 20 lines or so, find this

        if ( !ch->pcdata->deity_name )
	{
	  ch->pcdata->deity_name = STRALLOC( "" );
	  ch->pcdata->deity	 = NULL;
	}
        if ( !ch->pcdata->bio )
          ch->pcdata->bio	 = STRALLOC( "" );

    Right below it add this...

          if ( !ch->pcdata->pretit )
          ch->pcdata->pretit     = str_dup( "" ); /* Xerves 8-2-99 */


    IN fread_char, there are once again two spots...First

    Right below this line..
          KEY( "Practice",	ch->practice,		fread_number( fp ) );
    Add all of this

    if ( !str_cmp( word, "Ptit" )  || !str_cmp( word, "pretit"))
            {
                ch->pcdata->pretit = fread_string( fp );
                if (ch->pcdata->pretit[0] != '.' && ch->pcdata->pretit[0] != ','
                &&  ch->pcdata->pretit[0] != '!' && ch->pcdata->pretit[0] != '?')
                {
                    sprintf( buf, "%s", ch->pcdata->pretit );
                    STRFREE( ch->pcdata->pretit );
                    ch->pcdata->pretit = str_dup( buf );
                }
                fMatch = TRUE;
                break;
            }

    (NOTE:  The above will check to see if there is an . , ! ? in the pretitle, if
            one is found, it will not save the pretitle, remove this if you want, or
            feel free to add on to it )

    Lastly, down about a few pages, there should be a bunch of checks to see if
    titles/bios/etc exsist, it looks like this

    		if (!ch->pcdata->bestowments)
		  ch->pcdata->bestowments = str_dup( "" );
		if (!ch->pcdata->title)
		  ch->pcdata->title	= STRALLOC( "" );

    You need to add right after that

                if (!ch->pcdata->pretit)
		  ch->pcdata->pretit = str_dup( "" );

5.  (Optional, if you have finger.c (the finger command) in your code)
    If you still have the finger function in finger.c, you will probably want
    to add pretitle support there also, if you moved the finger code, or have
    your own, you might want to find it again, and add this to it.

   ch_printf(ch, "&c&wSex  : &G%-20s &w   Race: &G%s\n\r",
                  victim->sex == SEX_MALE   ? "Male"   :
                  victim->sex == SEX_FEMALE ? "Female" : "Neutral",
		    capitalize( npc_race[victim->race] ) );
   ch_printf(ch, "&c&wTitle: &G%s\n\r", victim->pcdata->title );

   This is what the code I have looks like, again the &c&w is used to for &w in
   my code.  Anyway, you will probably want to add the Pretitle right below that

      ch_printf(ch, "&c&wPreTitle: &G%s\n\r", victim->pcdata->pretit );
------------------------------------------------------------------------------

That is mainly it, once you compile the code, you will need to login, and use
cedit to create the command.  Here is what I advice for ideas on that

1.  Level 5 if you want it for players, so they get title/pretitle at the same
    time
2.  Allow it to be a gift for avatars, or a special command given in avatar
    quests (set to 51, bestow).
3.  Set it same level as rank, for imm use only.

What ever you choose, here is what you will need for the cedit commands

cedit pretitle create do_pretitle
cedit pretitle level 5
cedit save cmdtable

That should be it, pretitle doesn't add a space after the string, so you will
want to add that, or add it to the code itself.  Finally, if you seen above
in save.c, any pretitle with . , ! ? will be removed when saving/quiting.

------------------------------------------------------------------------------

Pretitle was installed into a modified Smaug 1.4 mud, and might not totally
work in your version.  If you run into problems, and cannot figure it out, you
can contact the email above for directions.  If you find out that you need to
make a few changes to 1.4a or 1.02 and you get it to work, I would appreciate
any changes you came up so I can add them into a later updated version if one
is ever released.  Thanks, and I hope the code is useful and fun to have.

-- The evil Imp Xerves the great (eh what pretitle can do)









