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
➜ do_who
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2 3
4
| Posted by
| Greven
Canada (835 posts) Bio
|
| Date
| Reply #15 on Mon 29 Mar 2004 08:03 AM (UTC) |
| Message
| | That looks ok, whats wrong? Is it not compiling, not working properly, or just displaying the entirely wrong text. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #16 on Mon 29 Mar 2004 03:16 PM (UTC) |
| Message
| it compiled ok and everything, but nothing changed at all. i'm not in my room right now so i can't post any code. i will later though. my output was the same. i'll post my code later tonite.
weren't any errors or anything. not sure wha'ts up | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #17 on Mon 29 Mar 2004 05:15 PM (UTC) |
| Message
| here's part of the code:
sprintf( class_text, "%s%2d %s", NOT_AUTHED(wch) ? "N" : " ", wch->level, class_table[wch->class]->who_name );
class = class_text;
switch ( wch->level )
{
default: break;
case MAX_LEVEL - 0: class = "&W&cSu&Cp&Br&ceme Entity&Y&W"; break;
case MAX_LEVEL - 1: class = "&W&CInfinite&Y&W "; break;
case MAX_LEVEL - 2: class = "&W&pEternal&Y&W "; break;
case MAX_LEVEL - 3: class = "&Y&WAncient "; break;
case MAX_LEVEL - 4: class = "&Y&WExalted God "; break;
case MAX_LEVEL - 5: class = "&Y&WAscendant God "; break;
case MAX_LEVEL - 6: class = "&Y&WGreater God "; break;
case MAX_LEVEL - 7: class = "&Y&WGod "; break;
case MAX_LEVEL - 8: class = "&Y&WLesser God "; break;
case MAX_LEVEL - 9: class = "&Y&WImmortal "; break;
case MAX_LEVEL - 10: class = "&Y&WDemi God "; break;
case MAX_LEVEL - 11: class = "&Y&WSavior "; break;
case MAX_LEVEL - 12: class = "&Y&WCreator "; break;
case MAX_LEVEL - 13: class = "&Y&WAcolyte "; break;
case MAX_LEVEL - 14: class = "&Y&WNeophyte "; break;
case MAX_LEVEL - 15: class = "&Y&WAvatar "; break;
}
switch ( wch->class )
{
default: break;
case MAX_CLASS - 0: class = "&PMage "; break;
case MAX_CLASS - 1: class = "&YCleric "; break;
case MAX_CLASS - 2: class = "&RThief "; break;
case MAX_CLASS - 3: class = "&bWarrior "; break;
case MAX_CLASS - 4: class = "&zVampire "; break;
case MAX_CLASS - 5: class = "&GDruid "; break;
case MAX_CLASS - 6: class = "&gRanger "; break;
case MAX_CLASS - 7: class = "&OAugurer "; break;
case MAX_CLASS - 8: class = "&WPaladin "; break;
}
and then...
if ( xIS_SET(wch->act, PLR_WIZINVIS) )
sprintf( invis_str, "(%d) ", wch->pcdata->wizinvis );
else
invis_str[0] = '\0';
sprintf( buf, "&w[&W%*s%-15s&w] %s%s%s%s%s%s%s%s.%s%s%s &w(&W%s&w)\n\r",
(fGroup ? whogr->indent : 0), "",
class,
invis_str,
(wch->desc && wch->desc->connected) ? "" : "",
xIS_SET(wch->act, PLR_AFK) ? "" : "",
xIS_SET(wch->act, PLR_ATTACKER) ? "" : "",
xIS_SET(wch->act, PLR_KILLER) ? "" : "",
xIS_SET(wch->act, PLR_THIEF) ? "" : "",
char_name,
wch->pcdata->title,
extra_title,
clan_name,
council_name,
get_race(wch));
how do i point that switch function to go into the class? | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #18 on Wed 31 Mar 2004 05:03 AM (UTC) |
| Message
| well. i think i might try this sometime. something along these lines...
if (wch->class == Mage)
send_to_pager( "&Pmage ", ch);
elseif (wch-> == Thief)
send_to_pager( "&Rthief ", ch);
and go through the classes. i dont' have enough time to try it now, but would that work? also, is that the correct way to write it?
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #19 on Wed 31 Mar 2004 06:47 AM (UTC) |
| Message
| I don't get this bit ...
switch ( wch->level )
{
default: break;
case MAX_LEVEL - 0: class = "&W&cSu&Cp&Br&ceme Entity&Y&W"; break;
// blah blah
case MAX_LEVEL - 15: class = "&Y&WAvatar "; break;
}
switch ( wch->class )
{
default: break;
case MAX_CLASS - 0: class = "&PMage "; break;
// blah blah
case MAX_CLASS - 8: class = "&WPaladin "; break;
}
Isn't the second switch statement going to overwrite the first? The first one sets "class" to something, and then the second one sets it to something else.
Also, I would personally choose a different word than "class" (like mud_class). If you ever convert to C++ "class" is a reserved word, as I found out when I tried to do exactly that. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #20 on Wed 31 Mar 2004 07:09 AM (UTC) |
| Message
| well, that's the thing, i'm just tryin to figure out how to do it. i just put that in there to see if it would work. but it doesn't. i tried putting the color codes into the class and race files, and that works, but when you start up, you can see the &*class at the get class thing. also, in the score on some of the classes, it only shows &ycleric and such. but on others it shows the actual colors. here's what an imm said on another mud, but i'm not sure how to do this:
Quote:
have some kind of a colored name associated to each race ahead of
time. This typically involves adding a new field to your race
data structure, something thats a character string. Then you
go in and just color each race you want to be a different color
by making that new variable/string be the colored race-name.
This might be kinda tricky however, since it involves modifying
how the game saves race files, and to make things worse, you might
have a hard time sorting pc races out from npc races. I think
initially, pc races are indeed seperate from npc ones, and since
only players show up on the who list, this makes things a little
simpler since you wouldn't have to worry about any of the 100 or
however many npc races that there are.
but anyway, after you've succeeded in adding the new string field
to your races, its a simple matter to make the who command call
on that string instead of the race-name string, you just swap it
in with the other one. Watch out for the length of some of those
colored names, they can shift the other parts of the who list
around a lot, and in some cases even crash the mud.
would be like this:
struct race_type
{
char race_name [16]; /* Race name */
char race_name_color; <----added
EXT_BV affected; /* Default affect bitvectors */
sh_int str_plus; /* Str bonus/penalty */
then change the way that the code saves the races?
| | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #21 on Wed 31 Mar 2004 07:13 AM (UTC) |
| Message
| here's what i could do with the output:
void write_class_file( int cl )
{
FILE *fpout;
char buf[MAX_STRING_LENGTH];
char filename[MAX_INPUT_LENGTH];
struct class_type *class = class_table[cl];
int x, y;
sprintf( filename, "%s%s.class", CLASSDIR, class->who_name );
if ( (fpout=fopen(filename, "w")) == NULL )
{
sprintf( buf, "Cannot open: %s for writing", filename );
bug( buf, 0 );
return;
}
fprintf( fpout, "Name %s~\n", class->who_name );
fprintf( fpout, "Namecolor %s~\n", class->who_name );
i'm not really sure how it would automatically know to do namecolor. i might need some help on that idea as well.
Thanks Nick.
Tyler | | Top |
|
| Posted by
| Greven
Canada (835 posts) Bio
|
| Date
| Reply #22 on Wed 31 Mar 2004 07:49 AM (UTC) |
| Message
| If your going to write to files, its not actually that hard. If the field for name is already race_name, and you want a colored version, just add like you had, "race_name_color" to the structure. Then you could change fwrite_race to
fprintf( fpout, "Name %s~\n", class->race_name );
fprintf( fpout, "Namecolor %s~\n", class->race_name_color );
Add the field to read it in, and maybe to initialize it to race_name if it is null in the end part of fread_race, and that should be all you need. I dunno if races are OLC in smaug, but either way you have to modify each PC races race_name_color to the one you want. Then in do_who: Which would return race_name_color instead of race_name. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #23 on Thu 01 Apr 2004 02:10 AM (UTC) |
| Message
| ok, here's what i have:
fprintf( fpout, "Name %s~\n", race->race_name );
fprintf( fpout, "Namecolor %s~\n", race->race_name_color );
and...
case 'N':
KEY( "Name", race_name, fread_string( fp ) );
KEY( "Namecolor", race_name_color, fread_string( fp ) );
break;
it's giving me a warning:
warning: format argument is not a pointer (arg 3)
i'm not sure what that warning is meaning. it goes to the
fprintf( fpout, "Namecolor %s~\n", race->race_name_color )
line of code. what am i doing wrong here.
| | Top |
|
| Posted by
| Greven
Canada (835 posts) Bio
|
| Date
| Reply #24 on Thu 01 Apr 2004 02:11 AM (UTC) |
| Message
| | How did you define it in your structure? |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #25 on Thu 01 Apr 2004 02:47 AM (UTC) |
| Message
| You have it defined like this:
char race_name_color; <----added
Now you are printing it with %s which expects a pointer to a string, a couple of possibilities would be:
char * race_name_color;
char race_name_color [32];
But, not what you have. That is a single 8-byte field.
Do you mean:
int race_name_color;
If that is the case you need to print it with %i not %s.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #26 on Thu 01 Apr 2004 03:12 AM (UTC) |
| Message
| ok i switched the char race_name_color to the
char race_name_color [32];
and it compiled clean. is that what you were wanting me to do or do i want the int? i'm confused. sorry.
in the who function i added:
instead of
get_race(wch)
i put
get_race_name_color(wch)
and that didn't work.
i'm just kinda confused on this thing right now. | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #27 on Thu 01 Apr 2004 03:18 AM (UTC) |
| Message
| here's some code:
in mud.h
struct race_type
{
char race_name [16]; /* Race name */
char race_name_color [32]; /*Name for who*/
EXT_BV affected; /* Default affect bitvectors */
sh_int str_plus; /* Str bonus/penalty */
in table.c
fprintf( fpout, "Name %s~\n", race->race_name );
fprintf( fpout, "Namecolor %s~\n", race->race_name_color );
fprintf( fpout, "Race %d\n", ra );
further down in load race
case 'N':
KEY( "Name", race_name, fread_string( fp ) );
KEY( "Namecolor", race_name_color, fread_string( fp ) );
break;
act_info.c
do_who function
get_race(wch));
do you need anymore? | | Top |
|
| Posted by
| Greven
Canada (835 posts) Bio
|
| Date
| Reply #28 on Thu 01 Apr 2004 03:35 AM (UTC) |
| Message
| | you need to make a copy of get_race, and change it to return race_name_color. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #29 on Thu 01 Apr 2004 05:07 AM (UTC) Amended on Thu 01 Apr 2004 05:13 AM (UTC) by Ithildin
|
| Message
| with this one?
char * get_race args( (CHAR_DATA *ch) );
char * get_race_name_color args( (CHAR_DATA *ch) );
or this one?
char *
get_race( CHAR_DATA *ch)
{
if( ch->race < MAX_PC_RACE && ch->race >= 0)
return (race_table[ch->race]->race_name);
if ( ch->race < MAX_NPC_RACE && ch->race >= 0)
return ( npc_race[ch->race] );
return ("Unknown");
}
char *
get_race_name_color( CHAR_DATA *ch)
{
if( ch->race < MAX_PC_RACE && ch->race >= 0)
return (race_table[ch->race]->race_name_color);
if ( ch->race < MAX_NPC_RACE && ch->race >= 0)
return ( npc_race[ch->race] );
return ("Unknown");
}
or both?
when i use both i get a clean compile, but here is my output:
[ 66 Cleric ] Gomer the great ()
i switched the who function to
get_race_name_color(wch)
so there's still a little something that i'm missing. | | 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.
126,878 views.
This is page 2, subject is 4 pages long:
1
2 3
4
It is now over 60 days since the last post. This thread is closed.
Refresh page
top