Just a little help with SMAUG

Posted by Killfoobar on Fri 17 Mar 2006 07:44 PM — 49 posts, 155,931 views.

USA #0
I was wondering where you set the amount of classes and races that you see at the beginning, when you choose the class & race of your character.

Also, how would you write the "Your stats are: ..........." then ask for reroll, and call the rolling sequence.

And one last thing, with the Skill/Spell creation, i found some help with it, but i dont seem to be able to create a skill or spell correctly.

USA #1
You should just be able to add things to class.lst or race.lst for what to pick on creation.

At afkmud.com, there is a reroll snippet you could use.

Creating a skill? Using sset? I've never created a skill that way. I just code it in.
USA #2
Creating skills with sset is pretty straightforward if, like Zeno said, you have a code function to map it to. If you want to do it without a new do_function, it works kind of like spells. What problems are you having specifically?
USA #3
Well the thing is i have the class.lst and race.lst amended, but it still wont show all of the classes, or all of the races
USA #4
Are you using stock Smaug? If so, I suggest using FUSS.
http://www.smaugfuss.org

I seem to remember a bug in stock with class/race lists.

[EDIT - 11 March 2008] - The Smaug FUSS site is now http://www.smaugmuds.org/
Amended on Tue 11 Mar 2008 03:30 AM by Nick Gammon
USA #5
the thing is i made a lot of changes to the stock smaug as it was, and i was wondering if anyone knew where that problem was at, and how to fix it
USA #6
Check the fixes in FUSS, they should all be listed on the forum. I can't remember the fix offhand.
USA #7
ok, now i have a problem with...
act( AT_TELL, MXPTAG ("player $n") "$n" MXPTAG ("/player")
it says parse error before string constant when i try to compile
USA #8
That can't be the whole piece of code, it's not even a full act line. :(
USA #9
Yeah. Post the exact error, and the corresponding lines.
USA #10
Ok, i fixed the problem before, but it has some new problems

   case CON_GET_NEW_CLASS:
	argument = one_argument(argument, arg);

       if (!str_cmp(arg, "help"))
        {
        	
	for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
	{
	  if ( class_table[iClass]->who_name &&
	       class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)

	  {
            if (toupper(argument[0])==toupper(class_table[iClass]->who_name[0])
	    &&   !str_prefix( argument, class_table[iClass]->who_name ) )
	    {
	      do_help(ch, argument);
	      write_to_buffer( d, "Please choose a class: ", 0 );
              return;
	    }
	  }
        }  
	write_to_buffer( d, "No such help topic.  Please choose a class: ", 0 );
	return;
	}

	for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
	{
	  if ( class_table[iClass]->who_name &&
	       class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)

	    {
		ch->class =  iClass;
		break;
	    }
	  }
	}

	if ( iClass == MAX_PC_CLASS
	||  !class_table[iClass]->who_name 
	|| class_table[iClass]->who_name[0] == '\0'
	|| !str_cmp(class_table[iClass]->who_name,"unused"))
	{
	  write_to_buffer( d, "That's not a class.\n\rWhat IS your class? ",0);
	  return;
	}


        if ( check_bans( ch, BAN_CLASS ) )
        {
         write_to_buffer (d,
             "That class is not currently avaiable.\n\rWhat IS your class? ",0);
         return;
        }

	write_to_buffer( d, "\n\rYou may choose from the following races, or type help [race] to learn more:\n\r[", 0 );
	buf[0] = '\0';
	for ( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
	{
	  if (iRace != RACE_VAMPIRE && !race_table[iRace]->remort_race
	  && race_table[iRace]->race_name && race_table[iRace]->race_name[0] != '\0'
	  && !IS_SET(race_table[iRace]->class_restriction, 1 << ch->class) 
	  && str_cmp(race_table[iRace]->race_name,"unused") )
	  {
            if ( iRace > 0 )
	    {
		if ( strlen(buf)+strlen(race_table[iRace]->race_name) > 77 )
		{
		   strcat( buf, "\n\r" );
		   write_to_buffer( d, buf, 0 );
		   buf[0] = '\0';
		}
		else
		   strcat( buf, " " );
	    }
	    strcat( buf, race_table[iRace]->race_name );
          }
        }
	strcat( buf, "]\n\r: " );
	write_to_buffer( d, buf, 0 );
	d->connected = CON_GET_NEW_RACE;
	break; /*this line, it says break statement not within loop or switch*/

    case CON_GET_NEW_RACE: /*this line, it says case label not within a switch statement*/
	argument = one_argument(argument, arg);
       if (!str_cmp( arg, "help") )
        {
          for ( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
	  {	
	    if ( toupper(argument[0]) == toupper(race_table[iRace]->race_name[0]) && !race_table[iRace]->remort_race 
)
	    {
	      do_help(ch, argument);
      	      write_to_buffer( d, "Please choose a race: ", 0);
	      return;
	    }
	  }
   	  if (!str_cmp( arg, "help") )
        {
          for ( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
	  {	
	    if ( toupper(argument[0]) == toupper(race_table[iRace]->race_name[0]) && !race_table[iRace]->remort_race 
	    &&   !str_prefix( arg, race_table[iRace]->race_name ) )
	    {
		ch->race = iRace;
		break;
	    }
	}

    if ( iRace == MAX_PC_RACE
    ||  !race_table[iRace]->race_name || race_table[iRace]->race_name[0] == '\0'
    ||   iRace == RACE_VAMPIRE
    ||   IS_SET(race_table[iRace]->class_restriction, 1 << ch->class )
    ||   !str_cmp(race_table[iRace]->race_name,"unused")
       )
	{
	    write_to_buffer( d,
		"That's not a race.\n\rWhat IS your race? ", 0 );
	    return;
	}

       write_to_buffer( d, "You may now roll for your character's stats.\r\nYou may roll as often as you like.\r\n",0);
        
	  name_stamp_stats(ch);

        snprintf( buf, MAX_STRING_LENGTH, "\r\nStr: %d  Int: %d  Wis: %d  Dex: %d  Con: %d  Cha: %d  Lck: %d\r\nKeep? (Y/N)",
        ch->perm_str, ch->perm_int, ch->perm_wis, ch->perm_dex, ch->perm_con, 
	  ch->perm_cha, ch->perm_lck );
        write_to_buffer( d, buf, 0 );

        d->connected = CON_ROLL_STATS;
        break; /*this line, it says break statement not within loop or switch*/

      case CON_ROLL_STATS: /*this line, it says case label not within a switch statement*/
      switch (argument[0] )
      {
         case 'y': case 'Y':
	     write_to_buffer( d, "\r\nWould you like ANSI, or no graphic/color support, (A/N)? ", 0 );
	     d->connected = CON_GET_WANT_RIPANSI;
         break;

         case 'n': case 'N':
     
	   name_stamp_stats(ch);

         snprintf( buf, MAX_STRING_LENGTH, "\r\nStr: %d  Int: %d  Wis: %d  Dex: %d  Con: %d  Cha: %d  Lck: %d\r\nKeep? (Y/N)",
         ch->perm_str, ch->perm_int, ch->perm_wis, ch->perm_dex, ch->perm_con, 
	   ch->perm_cha, ch->perm_lck );
	   write_to_buffer( d, buf, 0 );
         return;
         default: write_to_buffer( d, "Yes or No? ", 0 );
         return;
       }
    break; /*this line, it says break statement not within loop or switch*/


Amended on Tue 21 Mar 2006 10:59 PM by Killfoobar
USA #11
And also

case CON_GET_WANT_RIPANSI: /*this line, it says case label not within a switch statement*/
	switch ( argument[0] )
	{
	case 'r': case 'R':
	    xSET_BIT(ch->act,PLR_RIP);
	    xSET_BIT(ch->act,PLR_ANSI);
	    break;
	case 'a': case 'A': xSET_BIT(ch->act,PLR_ANSI);  break;
	case 'n': case 'N': break;
	default:
	    write_to_buffer( d, "Invalid selection.\n\rRIP, ANSI or NONE? ", 0 );
	    return;
	}
	sprintf( log_buf, "%s@%s new %s %s.", ch->name, d->host,
		race_table[ch->race]->race_name,
		class_table[ch->class]->who_name );
	log_string_plus( log_buf, LOG_COMM, sysdata.log_level);
	to_channel( log_buf, CHANNEL_MONITOR, "Monitor", LEVEL_IMMORTAL );
	write_to_buffer( d, "Press [ENTER] ", 0 );
	show_title(d);
	ch->level = 0;
	ch->position = POS_STANDING;
	d->connected = CON_PRESS_ENTER;
	set_pager_color( AT_PLAIN, ch );
	return;
	break; /*this line, it says break statement not within loop or switch*/

    case CON_PRESS_ENTER: /*this line, it says case label not within a switch statement*/
        if ( chk_watch(get_trust(ch), ch->name, d->host) ) /*  --Gorog */
           SET_BIT( ch->pcdata->flags, PCFLAG_WATCH );
        else
           REMOVE_BIT( ch->pcdata->flags, PCFLAG_WATCH );

	if ( ch->position == POS_MOUNTED )
		ch->position = POS_STANDING;

	set_pager_color( AT_PLAIN, ch );
	if ( xIS_SET(ch->act, PLR_RIP) )
	  send_rip_screen(ch);
	if ( xIS_SET(ch->act, PLR_ANSI) )
	  send_to_pager( "\033[2J", ch );
	else
	  send_to_pager( "\014", ch );
	if ( IS_IMMORTAL(ch) )
	  do_help( ch, "imotd" );
	if ( ch->level == 50)
	  do_help( ch, "amotd" );
	if ( ch->level < 50 && ch->level > 0 )
	  do_help( ch, "motd" );
	if ( ch->level == 0 )
	  do_help( ch, "nmotd" );
	send_to_pager( "\n\rPress [ENTER] ", ch );
        d->connected = CON_READ_MOTD;
        break; /*this line, it says break statement not within loop or switch*/




Amended on Tue 21 Mar 2006 10:59 PM by Killfoobar
USA #12
and, finally:

bool pager_output( DESCRIPTOR_DATA *d )
{
  register char *last;
  CHAR_DATA *ch;
  int pclines;
  register int lines;
  bool ret;

  if ( !d || !d->pagepoint || d->pagecmd == -1 )
    return TRUE;
  ch = d->original ? d->original : d->character;
  pclines = UMAX(ch->pcdata->pagerlen, 5) - 1;
  switch(LOWER(d->pagecmd))
  {
  default:
    lines = 0;
    break;
  case 'b':
    lines = -1-(pclines*2);
    break;
  case 'r':
    lines = -1-pclines;
    break;
  case 'n':
    lines = 0;
    pclines = 0x7FFFFFFF;	/* As many lines as possible */
    break;
  case 'q':
    d->pagetop = 0;
    d->pagepoint = NULL;
    flush_buffer(d, TRUE);
    DISPOSE(d->pagebuf);
    d->pagesize = MAX_STRING_LENGTH;
    return TRUE;
  }
  while ( lines < 0 && d->pagepoint >= d->pagebuf )
    if ( *(--d->pagepoint) == '\n' )
      ++lines;
  if ( *d->pagepoint == '\n' && *(++d->pagepoint) == '\r' )
      ++d->pagepoint;
  if ( d->pagepoint < d->pagebuf )
    d->pagepoint = d->pagebuf;
  for ( lines = 0, last = d->pagepoint; lines < pclines; ++last )
    if ( !*last )
      break;
    else if ( *last == '\n' )
      ++lines;
  if ( *last == '\r' )
    ++last;
  if ( last != d->pagepoint )
  {
    if ( !write_to_descriptor(d->descriptor, d->pagepoint,
          (last-d->pagepoint)) )
      return FALSE;
    d->pagepoint = last;
  }
  while ( isspace(*last) )
    ++last;
  if ( !*last )
  {
    d->pagetop = 0;
    d->pagepoint = NULL;
    flush_buffer(d, TRUE);
    DISPOSE(d->pagebuf);
    d->pagesize = MAX_STRING_LENGTH;
    return TRUE;
  }
  d->pagecmd = -1;
  if ( xIS_SET( ch->act, PLR_ANSI ) )
      if ( write_to_descriptor(d->descriptor, "\033[1;36m", 7) == FALSE )
	return FALSE;
  if ( (ret=write_to_descriptor(d->descriptor,
	"(C)ontinue, (N)on-stop, (R)efresh, (B)ack, (Q)uit: [C] ", 0)) == FALSE )
	return FALSE;
  if ( xIS_SET( ch->act, PLR_ANSI ) )
  {
      char buf[32];

      if ( d->pagecolor == 7 )
	strcpy( buf, "\033[m" );
      else
	sprintf(buf, "\033[0;%d;%s%dm", (d->pagecolor & 8) == 8,
		(d->pagecolor > 15 ? "5;" : ""), (d->pagecolor & 7)+30);
      ret = write_to_descriptor( d->descriptor, buf, 0 );
  }
  return ret; /*this line, it says parse error at the end of input*/
}
Amended on Tue 21 Mar 2006 10:58 PM by Killfoobar
USA #13
there is one more, but i couldnt fit it, even on its own post
USA #14
what is wrong has a comment and what the error message was
USA #15
Please use the [code] tag when posting so many lines of code. Not having the lines formatted correctly makes them irritating to read. And please post the compiler output, also using the [code] tag, so that we can know exactly what the compiler is saying -- and then use comments in the code to indicate which line is which. (Don't post the code again, just edit your previous posts)
USA #16
in the comments, i have exactly what is being said by the compiler
USA #17
Look at this code:

	for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
	{
	  if ( class_table[iClass]->who_name &&
	       class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)

	    {
		ch->class =  iClass;
		break;
	    }
	  }
	}
Looks like you have one brace too many.

This kind of problem is very easy to find if code is indented properly. If you're using vi, go to the top of the function and type =a{. That means format the current block of code.

It will then be immediately apparent where the braces are missing.

You can also put the cursor over a brace, and press % to jump to the matching brace. If you do that and find yourself somewhere you didn't expect, then you have too many/too few braces.
USA #18
thank you much!
um where would i change the code to show how much damage you do during a fight.
USA #19
and what about the parse error at end of input
it is in bool pager_output
Amended on Tue 21 Mar 2006 11:25 PM by Killfoobar
Canada #20
Quote:
Killfoobar (12 posts) [Biography] bio
Date Tue 21 Mar 2006 11:24 PM (UTC)

Amended on Tue 21 Mar 2006 11:25 PM (UTC) by Killfoobar
Message
and what about the parse error at end of input
it is in bool pager_output


The probable cause of that is because your pager isn't parsing. Try replacing the batteries.
Australia Forum Administrator #21
Quote:

... and what about the parse error at end of input ...


You have probably added a brace too many. This example program will generate that error:


#include <stdio.h>

int main ()
  {
  printf ("hello, world\n");
  return 0;

  {  // <--- this shouldn't be here

  }


This generates:


test.c: In function `main':
test.c:11: parse error at end of input


You want an editor (vi is an example) that will match braces, so you can see which function has a brace too many.
USA #22
thanks, but what about the showing the damage during a fight
USA #23
and also i cant seem to find the non-matching brace
USA #24
and what do you mean replacing the batteries
USA #25
The batteries part was a joke.

For the braces, did you try using the auto-indent? Or using '%' to match braces? What editor are you using?

For damage in combat: why don't we fix one thing at a time? :)
USA #26
im using vi, and i tried the % thing, and the auto-indent, but i didnt find anything
Amended on Wed 22 Mar 2006 10:05 PM by Killfoobar
USA #27
let me know if you need something to find out what it is that is wrong, i can gladly give it to you
USA #28
The '%' command only works when you have your cursor over a brace.

Also, Nick suggested using vi's bracket highlighting feature. This is a very good idea. To enable this you might have to type the command ":syntax enable". It should then start highlighting mismatched braces.

I'm not sure how else to solve your problem, really. Basically you have to go find which brace doesn't have a matching brace. It's probably going to be in code you added.
USA #29
the problem is that it doesnt highlight any mismatched braces, or anything when i do any of those

let me know if you want me to send you my copy of comm.c
Australia Forum Administrator #30
Taking my example, buggy, program:


int main ()
  {  // <------ "A"
  printf ("hello, world\n");
  return 0;

  {  // <------ "B"
  }  // <------ "C"


If I edit this in vi and put the cursor on the "{" in line "A", and hit the % symbol, the cursor doesn't move. This is wrong because I expect it to move to the end of the function.

However if I move the cursor to where I believe the end of the function to be (line C) and hit % the cursor jumps back to line B. This is where the extra bracket is.

(Almost) every C program is going to consist of functions which generally look like this:


void function_name (arguments)
  {

  ..... body of function here .....

  }

void some_other_function (arguments)
  {

  ..... body of function here .....

  }


The word "void" in the example above will be the function return value, which might be "int" or something else (like "bool").

However the basic structure is the same.

You should be able to spot them because of indentation, comments, blank lines, and general source structure. Now in each case you should be able to put the cursor on the first "{" and hit "%" (in vi) and the cursor will move to the final "}" symbol. (And vice-versa, put the cursor on the final "}" and hit "%" and it will move to the first "{").

If that doesn't happen, you have found the function with the problem with brackets.



USA #31
the problem is i did that all the way through, with lining up the braces, :syntax enable, etc, but i didnt find anything, and i am highlighting a brace before i use the '%' command
Australia Forum Administrator #32
Another possibility is a misplaced comment. In this example:


int main ()
  {
  printf ("hello, world\n");
  return 0;

 /*
 }
  */


If I put the cursor on the final "}" and hit % it moves to the first "{".

However the compiler doesn't see it that way because the "}" is commented out.

All I can suggest is go back to the working version, and slowly add your changes back in. The block of changes that causes the message is the cause of the problem. Look carefully in that for a misplaced comment or extra or missing brace.
USA #33
thank you, um but back to my question on how to show the damage during a battle, how would i do that.
USA #34
Look in fight.c. The function damage is what deals the damage. It computes the final number. Find the part where it deals the damage. Add a function call to print a string, formatted however you like it. Voila, all done.

But again, may I suggest that you fix your brace problem before moving on to other things? By adding changes without making sure things work first, you run a very strong risk of breaking things even more and having a hard time of fixing it. And now, you have an especially pressing case, because your code doesn't even compile.
USA #35
i fixed the brace thing, but now i have a problem with player.c

void do_inventory( CHAR_DATA *ch, char *argument )
{
    set_char_color( AT_RED, ch );
    send_to_char( "You are carrying:\n\r", ch );
    show_list_to_char( ch->first_carrying, ch, TRUE, TRUE, eItemDrop ); /* the compiler says for this line says eItemDrop, first time it is declared, and it says too many arguments for the function show_list_to_char */
    return;
}
Amended on Fri 24 Mar 2006 12:52 AM by Killfoobar
USA #36
That doesn't look like it's stock. Where did eItemDrop originate from? It's not declared in the function.
USA #37
its from the mxp version
USA #38
The MXP version compiles just fine, you must have changed something to break it. What did you change in this file?
USA #39
Yes, that isn't stock MXP.
void show_list_to_char( OBJ_DATA *list, CHAR_DATA *ch, bool fShort, bool fShowNothing, const int iDefaultAction )

As you can tell, the function header there is fine and you shouldn't be getting the second error you have.
Australia Forum Administrator #40
Quote:

um but back to my question on how to show the damage during a battle, how would i do that.



Have you read this post? I think it covers that subject:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=289
USA #41
ok now it is giving me undefined _crypt, undefined _RENAME, and undefinded _bigregex errors after everything is made into the .o files.
And yes i went into the makefile file, and made the adjustments the comments suggested that i do.
Amended on Mon 27 Mar 2006 11:35 PM by Killfoobar
USA #42
When you make the makefile adjustments, you need to make clean and then make again.
USA #43
i did that, but it still is giving me the same error messages _re_exec, _RENAME, and _crypt
it says that they are undefined refrences
Amended on Fri 31 Mar 2006 03:35 PM by Killfoobar
USA #44
Maybe post what your makefile looks like? That could possibly help.

USA #45
Thats all right i got the problem fixed, but thanks anyway
USA #46
Maybe you could share what helped fix the problem, in case others have a similar problem at some point?

USA #47
i found out it is just a qwerk with the widows source code, but anyway, im having variable declaring problems, how would i declare a boolean variable called suppress, and then set it to FALSE
USA #48
never mind i gots it, but thanks any way