Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, DotBot, Yahoo!

Members: 0
Guests: 13
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWR FUSS » New Disguise System
Forum Rules | Mark all | Recent Posts

New Disguise System
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 May 26, 2008, 1:50 pm
Go to the top of the page
Go to the bottom of the page

Krylan
Fledgling
GroupMembers
Posts39
JoinedApr 14, 2005

Once again, I've another question. My understanding of C is improving as I'm slowly learning WHY Things go where they go. But, I've been working on a new disguise system. The introduction system in my MUD is the one that is in FotE. The disguise system is pretty complex.

Basically, there is the disguise_data struct.
struct disguise_data
{
   char *name;
   short race;
   int  pheight, build;
   char *description;
   DISGUISE_DATA *next_in_disguise;
   DISGUISE_DATA *prev_in_disguise;
};



And then in struct char_data there is
DISGUISE_DATA *first_disguise;
DISGUISE_DATA *last_disguise;
DISGUISE_DATA *curr_disguise


You type disguise <disguise name>
So say the name of the chosen disguise is Bob you disguise bob.


The setting of the disguise properties works well (You set race, build, and height through one command). But then I go to use the disguise skill, and I can't figure out for the life of me how to set the curr_disguise to the disguise that is chosen in the skill.

I tried ch->curr_disguise = disguise. But the MUD crashes on anything that looks at ch->curr_disguise.

Any ideas? (Eh, please, bear with me)
       
Post is unread #2 May 26, 2008, 11:46 pm
Go to the top of the page
Go to the bottom of the page

kiro_san
Fledgling
GroupMembers
Posts23
JoinedJan 27, 2007

Why not just edit their options? such as ch->short disguise->name(you might have to make more fields), etc etc instead of disguise, if your going to do a disguise feild I think you should have a check for if they are in fact disguised first. which would require a flag. Other than that you'd probably have to show us more of teh code for more ideas. If anyone else has any ideas/suggestion feel free:p
       
Post is unread #3 May 27, 2008, 8:19 am
Go to the top of the page
Go to the bottom of the page

Krylan
Fledgling
GroupMembers
Posts39
JoinedApr 14, 2005

Well, the code probably sucks, but here it is.

void do_disguise( CHAR_DATA * ch, char *argument )
{
   char arg[MAX_INPUT_LENGTH];
   OBJ_DATA *obj;
   int schance;
   bool checkoven, checksili;
   DISGUISE_DATA *disguise;
 

    argument = one_argument( argument, arg );
        switch( ch->substate )
        { 
    	   default:
           if( arg[0] == '\0' )
           {
              send_to_char( "&RSyntax: Disguise <disguise name>\n\r", ch );
              return;
           }
           if((disguise = get_disguise(ch, arg)) == NULL)
           {
                   send_to_char("&RNot one of your disguises.\n",ch);
                   return;
           }
           if( disguise->raceset != 1 )
           {
                   send_to_char("&RThe race on that disguise is not set.\n",ch);
                   return;
           }
           if( disguise->buildset != 1 )
           {
                   send_to_char("&RThe race on that disguise is not set.\n",ch);
                   return;
           }
           if( disguise->heightset != 1 )
           {
                   send_to_char("&RThe race on that disguise is not set.\n",ch);
                   return;
           }
           if( ch->curr_disguise && ch->dsguise == 1)
           {
                  send_to_char("&RYou are already disguised! Remove it first.\n",ch);
                  return;
           }

           checksili = FALSE;
           checkoven = FALSE;
           for ( obj = ch->last_carrying; obj; obj = obj->prev_content )     
           {
              if (obj->item_type == ITEM_SILICON)
                checksili = TRUE;
              if (obj->item_type == ITEM_OVEN)
                checkoven = TRUE;                  
           }
               
           if ( !checkoven )
           {
              send_to_char( "&RYou need an oven to heat the silicon.\n\r", ch);
              return;
           }
 
           if ( !checksili )
           {
               send_to_char( "&RYou need some silicon to mold the disguise.\n\r", ch);
               return;
           }
           schance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_disguise]);
           if ( number_percent( ) < schance )
           {
    	       send_to_char( "&GYou begin the long process of molding your disguise.\n\r", ch);
               add_timer ( ch , TIMER_DO_FUN , IS_IMMORTAL(ch) ? 1 : 25 , do_disguise , 1 );
    	       ch->dest_buf = str_dup(arg);
    	       return;
	   }
	   send_to_char("&RYou can't figure out how to mold it properly.\n\r",ch);
	   learn_from_failure( ch, gsn_disguise );
           return;
	
    	case 1: 
    		if ( !ch->dest_buf )
    		     return;
    		strcpy(arg, ch->dest_buf);
    		DISPOSE( ch->dest_buf);
    		break;
    		
    	case SUB_TIMER_DO_ABORT:
    		DISPOSE( ch->dest_buf );
    		ch->substate = SUB_NONE;    		                                   
    	        send_to_char("&RYou are interupted and fail to finish your work.\n\r", ch);
    	        return;
       }
     
       ch->substate = SUB_NONE;
       checksili = FALSE;
       checkoven = FALSE;

       for ( obj = ch->last_carrying; obj; obj = obj->prev_content )     
       {
          if (obj->item_type == ITEM_SILICON)
             checksili = TRUE;
          if (obj->item_type == ITEM_OVEN)
             checkoven = TRUE;        
       }   
       schance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_disguise]) ;
                
          if ( number_percent( ) > schance*2  || ( !checkoven ) || ( !checksili ) )
          {
              send_to_char( "&RYou complete the molding of your disguise and go to put it on...\n\r", ch);
              send_to_char( "&RYou watch it fall to pieces, useless\n\r", ch);
              learn_from_failure( ch, gsn_disguise );
              return;
           }
  
        send_to_char( "&GYou finish wearing your disguise.&w\n\r", ch );          
          
        learn_from_success( ch, gsn_disguise );
        return;
 }


And the edit function

void do_ddisguise( CHAR_DATA * ch, char *argument )
{
   char arg[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char arg3[MAX_INPUT_LENGTH];
   char arg4[MAX_INPUT_LENGTH];
   char buf[MAX_STRING_LENGTH];
   DISGUISE_DATA *disguise;
   int i=0;
   int value;

   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg2 );
   argument = one_argument( argument, arg3 );
   argument = one_argument( argument, arg4 );
 
   if( IS_NPC( ch ) )
      return;

   if( arg[0] == '\0' )
   {
      send_to_char( "&RSyntax: Disguise [list|create|edit|delete]\r\n", ch );
      return;
   }
 
   if ( !str_cmp( arg, "list" ) )
   {
         send_to_char( "&wYou rummage through your inventory of disguises.\n\r", ch );
         for( disguise = ch->first_disguise; disguise; disguise = disguise->next_in_disguise )
         {            
               i++;
               sprintf( buf, "%d %-21.21s\n\r", i, disguise->name );
               send_to_char( buf, ch );
          }   

          return;
   }
   if( !str_cmp( arg, "create" ) )
   {
         if( arg2[0] == '\0' )
         {
             send_to_char( "&RSyntax: Disguise create <disguise name>\n\r", ch );
             return;
         }
         if( !check_parse_name( arg2 ) )
         {
             send_to_char( "&RThat isn't a proper name for a disguise. Same rules apply as a real name", ch );
             return;
         }

         CREATE( disguise, DISGUISE_DATA, 1 );
         LINK( disguise, ch->first_disguise, ch->last_disguise, next_in_disguise, prev_in_disguise );
      
         strcpy(buf, arg2);
         disguise->name = STRALLOC(buf);
         disguise->raceset = 0;
         disguise->heightset = 0;
         disguise->buildset = 0;
         disguise->race = 0;
         send_to_char( "&GDisguise Created. Now, use edit to select the race, build, height, and description\n\r", ch );

         return;
      }        
        
      if( !str_cmp( arg, "delete" ) )
      {
         if( arg2[0] == '\0' )
         {
             send_to_char( "&RSyntax: Disguise delete <disguise name>\n\r", ch );
             return;
         }

          if((disguise = get_disguise(ch, arg2)) == NULL)
          {
                  send_to_char("&RNot one of your disguises.\n",ch);
                  return;
          }
          
          UNLINK( disguise, ch->first_disguise, ch->last_disguise, next_in_disguise, prev_in_disguise );
          send_to_char( "&GDisguise Removed.\n\r", ch );
          return;
      }

      if( !str_cmp( arg, "edit" ) )
      {
         if( arg2[0] == '\0' || arg3[0] == '\0' )
         {
             send_to_char( "&RSyntax: Disguise edit <disguise> <race/height/build> [option]\n\r", ch );
             return;
         }
          
         if((disguise = get_disguise(ch, arg2)) == NULL)
         {
                 send_to_char("&RNot one of your disguises.\n",ch);
                 return;
         }
         if( !str_cmp( arg3, "race" ) )
         {
              if( arg4[0] == '\0' )
              {
                  send_to_char( "&RSyntax: Disguise edit <disguise> race [pick race]\n\rUse showrace to see eligible races.", ch );
                  return;
              }
              value = get_pc_race( arg4 );
 
              if( value < 0 )
                 value = atoi( arg4 );
              if( value < 0 || value >= MAX_RACE  )
              {
                  send_to_char( "&RInvalid race. Try again.\n\r", ch);
                  return;
              }
              if(disguise->raceset == 1)
              {
                  send_to_char( "&RThat disguise already has a race. It'd be unwise to change it.\n\r", ch );
                  return;
              }
              disguise->race = value;
              disguise->raceset = 1;
              ch_printf( ch, "&G%s's race set to: %s\n\r", disguise->name, race_table[disguise->race]->race_name );
              return;
          }
          if( !str_cmp( arg3, "build" ) )
         {
              if( arg4[0] == '\0' )
              {
                  send_to_char( "&RSyntax: Disguise edit <disguise> build [build]\n\r", ch );
                  return;
              }
              value = get_pc_build( arg4 );
 
              if( value < 0 )
                 value = atoi( arg4 );
              if( value < 0 || value >= 5  )
              {
                  send_to_char( "&RInvalid build. Try again.\n\r", ch);
                  return;
              }
              if(disguise->buildset == 1)
              {
                  send_to_char( "&RThat disguise already has a build. It'd be unwise to change it.\n\r", ch );
                  return;
              }
              disguise->build = value;
              disguise->buildset = 1;
              ch_printf( ch, "&G%s's build set to: %s\n\r", disguise->name, build_name[disguise->build] );
              return;
          }
          if( !str_cmp( arg3, "height" ) )
         {
              if( arg4[0] == '\0' )
              {
                  send_to_char( "&RSyntax: Disguise edit <disguise> height [height]\n\r", ch );
                  return;
              }
              value = get_pc_height( arg4 );

              if( value < 0 )
                 value = atoi( arg4 );
              if( value < 0 || value >= 5  )
              {
                  send_to_char( "&RInvalid height. Try again.\n\r", ch);
                  return;
              }
              if(disguise->heightset == 1)
              {
                  send_to_char( "&RThat disguise already has a height. It'd be unwise to change it.\n\r", ch );
                  return;
              }
              disguise->pheight = value;
              disguise->heightset = 1;
              ch_printf( ch, "&G%s's height set to: %s\n\r", disguise->name, height_name[disguise->pheight] );
              return;
          }
         return;
      }

      send_to_char( "&RSyntax: Disguise [list|create|edit|delete]\r\n", ch );
      return;
}


Feel free to use it, though, its still primitive. Finding ways to improve it. One reason I wanted to provide a struct for it and let them save to a player is so they can actually introduce themselves as someone. From then on, I wanted whoever they introduce to to see them as that name when they're in said disguise. It's probably a complex way of going about it.
       
Pages:<< prev 1 next >>