Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Saving to character ( hair and eye color)

Saving to character ( hair and eye color)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Valna   (15 posts)  Bio
Date Mon 29 Mar 2004 01:08 AM (UTC)

Amended on Mon 29 Mar 2004 01:14 AM (UTC) by Valna

Message
I'm trying to write something in right now that asks you for your choice of hair color, style, eye color, and skin tone.
I've written in some code in nanny that prompts for it and it will set the variable for that log in.
I added something to mset that allows you to set that on a PC as well,
which works fine. I added to the look command (took out the crappy ch->description nonsense) to show character hair and
eye color. All of that stuff work fine. However i can't figure out what i need to add to the save.c file to get it to
save the value. I added something into the fwrite_char that actually writes Hair Color into the player file and sets
it's value to the hairc variable i declared for players in CHAR_DATA. fwrite_char looks like this:

fprintf( fp, "HairColor     %d\n", ch->hairc );
[\code]

if i write something into bool load_char_obj it seems to just set the "default". rather than starting at the first element
of the array it will start at whatever integer i set.  Anyone know what and where i need to add code?
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #1 on Mon 29 Mar 2004 02:05 AM (UTC)

Amended on Mon 29 Mar 2004 02:06 AM (UTC) by Nick Cash

Message
Its in fread_char. I used the prefix p for all of them so they all went in the same case. Here is what I have:

        case 'P':
            KEY( "Phair",       ch->phair,              fread_number( fp ) );
            KEY( "Peye",        ch->peye,               fread_number( fp ) );
            KEY( "Pheight",     ch->pheight,            fread_number( fp ) );
            KEY( "Pbuild",      ch->pbuild,             fread_number( fp ) );

You can see I have a few more then just hair. Anyways, just follow the example above for each or just save them all as I did.

Also, you might want to add a few functions such as these (if you used array's to keep the names of your data in, which is what I'm guessing you did)

char *get_hair( CHAR_DATA *ch)
{
    if ( ch->phair < 7)
        return ( capitalize( hair_name[ch->phair] ) );
    return ("Black");
}

char *get_eye( CHAR_DATA *ch)
{
    if ( ch->peye < 8)
        return ( capitalize( eye_name[ch->peye]) );
    return ("Brown");
}

char *get_build( CHAR_DATA *ch)
{
    if ( ch->pbuild < 6)
        return ( capitalize( build_name[ch->pbuild] ) );
    return ("Muscular");
}

char *get_height( CHAR_DATA *ch )
{
        if ( ch->pheight < 4 )
        return ( capitalize( height_name[ch->pheight] ) );
        return ( "Tall" );
}

Of course you change the if checks. Such as if you had 10 hair colors it would be if ( ch->phair < 10 ). You would most likely need to change the table name and the character variable its referring to. Good luck.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Valna   (15 posts)  Bio
Date Reply #2 on Mon 29 Mar 2004 02:28 AM (UTC)
Message
Thanks, it looked to me like i needed to write a little chunk in the fwrite function
to actually write the variable into the pfile as well is
that necissary?
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #3 on Mon 29 Mar 2004 06:39 AM (UTC)
Message
Yes. You need to write it into fwrite_char.

~Nick Cash
http://www.nick-cash.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,281 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.