Exemplo n.º 1
0
/* Create a new class online. -Shaddai */
bool create_new_class( int Class, char *argument )
{
    int                     i;

    if ( Class >= MAX_CLASS || class_table[Class] == NULL || !VLD_STR( argument ) )
        return FALSE;

    if ( class_table[Class]->who_name )
        STRFREE( class_table[Class]->who_name );
    if ( class_table[Class]->filename )
        STRFREE( class_table[Class]->filename );
    if ( argument[0] != '\0' )
        argument[0] = UPPER( argument[0] );
    class_table[Class]->who_name = STRALLOC( argument );
    class_table[Class]->filename = STRALLOC( argument );
    xCLEAR_BITS( class_table[Class]->affected );
    class_table[Class]->attr_prime = 0;
    class_table[Class]->attr_second = 0;
    class_table[Class]->attr_deficient = 0;
    class_table[Class]->race_restriction = 0;
    class_table[Class]->combo_restriction = 0;
    class_table[Class]->resist = 0;
    class_table[Class]->suscept = 0;
    class_table[Class]->skill_adept = 0;
    class_table[Class]->thac0_00 = 0;
    class_table[Class]->thac0_32 = 0;
    class_table[Class]->hp_min = 0;
    class_table[Class]->hp_max = 0;
    class_table[Class]->mana_min = 0;
    class_table[Class]->mana_max = 0;
    class_table[Class]->starting = FALSE;              /* Default to not a starting class 
                                                        */
    class_table[Class]->exp_base = 0;
    class_table[Class]->craft_base = 0;
    for ( i = 0; i < MAX_LEVEL; i++ ) {
        title_table[Class][i][0] = STRALLOC( "Not set." );
        title_table[Class][i][1] = STRALLOC( "Not set." );
    }
    return TRUE;
}
Exemplo n.º 2
0
/* Of course, to create means you need to be able to destroy as well :P - Samson 8-3-98 */
void do_destroyslay( CHAR_DATA * ch, char *argument )
{
   char arg[MAX_INPUT_LENGTH];
   SLAY_DATA *pslay;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   one_argument( argument, arg );

   if( arg[0] == '\0' )
   {
      send_to_char( "Destroy which slaytype?\r\n", ch );
      return;
   }

   for( pslay = first_slay; pslay; pslay = pslay->next )
   {
      if( !str_cmp( arg, pslay->type ) )
      {
         UNLINK( pslay, first_slay, last_slay, next, prev );
         STRFREE( pslay->owner );
         STRFREE( pslay->type );
         STRFREE( pslay->cmsg );
         STRFREE( pslay->vmsg );
         STRFREE( pslay->rmsg );
         DISPOSE( pslay );
         ch_printf( ch, "Slaytype \"%s\" has beed deleted.\r\n", arg );
         save_slays(  );
         return;
      }
   }

   send_to_char( "No such slaytype.\r\n", ch );
   return;
}
Exemplo n.º 3
0
void set_auth(DESCRIPTOR_DATA *d)
{
  CHAR_DATA *ch = (d->original ? d->original : d->character);
  AUTH_DATA *a;
  struct sockaddr_in us, them;
  int ulen = sizeof(us), tlen = sizeof(them);
  
  /* To stop an uninitialized memory read --Shaddai */
  us.sin_port =    0;
  them.sin_port =  0;

  if (sysdata.ident_retries <= 0)
  {
    STRFREE(d->user);
    d->user = STRALLOC("(ident not active)");
    return;
  }
  if (getsockname(d->descriptor, (struct sockaddr *)&us, &ulen) < 0)
  {
    perror("set_auth: getsockname");
    ENDRET("Set_auth: getsockname error for %s@%s.", "(getsockname error)");
  }
  if (getpeername(d->descriptor, (struct sockaddr *)&them, &tlen) < 0)
  {
    perror("set_auth: getpeername");
    ENDRET("Set_auth: getpeername error for %s@%s.", "(getpeername error)");
  }
  CREATE(a, AUTH_DATA, 1);
  a->d = d;
  a->state = AS_TOOPEN;
  a->times = sysdata.ident_retries;
  a->us = us;
  a->them = them;
  LINK(a, first_auth, last_auth, next, prev);
  STRFREE(d->user);
  d->user = STRALLOC("(in progress)");
  return;
}
Exemplo n.º 4
0
void auth_check(fd_set *ins, fd_set *outs, fd_set *excs)
{
  AUTH_DATA *a, *a_next;
  CHAR_DATA *ch;
  bool ferr;

  for (a = first_auth; a; a = a_next)
  {
    a_next = a->next;
    ferr = FALSE;
    ch = (a->d->original ? a->d->original : a->d->character);
    if (a->state == AS_TOOPEN)
    {
      if (!auth_open(a, ch))
        ferr = TRUE;
    }
    else if (FD_ISSET(a->afd, excs))
    {
      FD_CLR(a->afd, ins);
      FD_CLR(a->afd, outs);
      bug("Auth_check: exception found for %s@%s.",
          (ch ? ch->name : "(unknown)"), a->d->host);
      STRFREE(a->d->user);
      a->d->user = STRALLOC("Exception");
      ferr = TRUE;
    }
    else if (FD_ISSET(a->afd, ins) && a->state == AS_TOREAD)
    {
      if (!auth_read(a, ch))
      {
        FD_CLR(a->afd, outs);
        ferr = TRUE;
      }
    }
    else if (FD_ISSET(a->afd, outs) && a->state == AS_TOSEND)
    {
      if (!auth_write(a, ch))
        ferr = TRUE;
    }
    if (ferr)
    {
      if (a->state != AS_TOOPEN)
        closesocket(a->afd);
      UNLINK(a, first_auth, last_auth, next, prev);
      DISPOSE(a);
    }
  }
  return;
}
Exemplo n.º 5
0
void comment_remove( CHAR_DATA * ch, CHAR_DATA * victim, NOTE_DATA * pnote )
{
    if( !victim->comments )
    {
        bug( "comment remove: null board", 0 );
        return;
    }

    if( !pnote )
    {
        bug( "comment remove: null pnote", 0 );
        return;
    }

    /*
     * Remove comment from linked list.
     */
    if( !pnote->prev )
        victim->comments = pnote->next;
    else
        pnote->prev->next = pnote->next;

    STRFREE( pnote->text );
    STRFREE( pnote->subject );
    STRFREE( pnote->to_list );
    STRFREE( pnote->date );
    STRFREE( pnote->sender );
    DISPOSE( pnote );

    /*
     * Rewrite entire list.
     */
    save_char_obj( victim );

    return;
}
Exemplo n.º 6
0
int
mfs_ramdir_remove(
    VNODE_T *dvp,
    char *nm,
    VNODE_T **vpp,
    CALL_DATA_T *cd
)
{
    register mfs_mnode_t *mnp;
    register int vnum;
    int error;

    ASSERT(MFS_ISVIEWDIR(VTOM(dvp)));

    mnp =  VTOM(dvp);
    MLOCK(mnp);

    error = ENOENT;
    for (vnum=0; vnum < mnp->mn_ramdir.hwm; vnum++) {
        if (mnp->mn_ramdir.ents[vnum].nm == NULL) continue;
        if (STRCMP(mnp->mn_ramdir.ents[vnum].nm, nm) == 0) {
            if (MVFS_ISVTYPE(mnp->mn_ramdir.ents[vnum].vp, VDIR))
                mnp->mn_ramdir.lnk_cnt--;
            *vpp = mnp->mn_ramdir.ents[vnum].vp;  /* return vnode */
            mnp->mn_ramdir.ents[vnum].vp = NULL;
            STRFREE(mnp->mn_ramdir.ents[vnum].nm);

            mnp->mn_ramdir.mtime.tv_sec = MDKI_CTIME();	

            /* Update high water mark if required */
        
            if (vnum == mnp->mn_ramdir.hwm-1) {
                while (mnp->mn_ramdir.ents[--vnum].nm == NULL) {}
                mnp->mn_ramdir.hwm = vnum+1;
            }

            error = 0;
            MVFS_WRAP_UPDATE_ATTRS(dvp, cd);
            break;
        }
    }
    MUNLOCK(mnp);
    if (error)
        *vpp = NULL;
    else
        MVFS_RM_DCACHE(*vpp);
    return(error);
}
Exemplo n.º 7
0
bool spec_auth(CHAR_DATA * ch)
{
	CHAR_DATA *victim;
	CHAR_DATA *v_next;
	char buf[MAX_STRING_LENGTH];
	OBJ_INDEX_DATA *pObjIndex;
	OBJ_DATA *obj;
	bool hasdiploma;

	for (victim = ch->in_room->first_person; victim; victim = v_next) {
		v_next = victim->next_in_room;

		if (!IS_NPC(victim)
		    && (pObjIndex =
			get_obj_index(OBJ_VNUM_SCHOOL_DIPLOMA)) != NULL) {
			hasdiploma = FALSE;

			for (obj = victim->last_carrying; obj;
			     obj = obj->prev_content)
				if (obj->pIndexData ==
				    get_obj_index(OBJ_VNUM_SCHOOL_DIPLOMA))
					hasdiploma = TRUE;

			if (!hasdiploma) {
				obj = create_object(pObjIndex, 1);
				obj = obj_to_char(obj, victim);
				send_to_char
				    ("&cThe schoolmaster gives you a diploma, and shakes your hand.\n\r&w",
				     victim);
			}
		}

		if (IS_NPC(victim)
		    || !IS_SET(victim->pcdata->flags, PCFLAG_UNAUTHED))
			continue;

		victim->pcdata->auth_state = 3;
		REMOVE_BIT(victim->pcdata->flags, PCFLAG_UNAUTHED);
		if (victim->pcdata->authed_by)
			STRFREE(victim->pcdata->authed_by);
		victim->pcdata->authed_by = QUICKLINK(ch->name);
		sprintf(buf, "%s authorized %s", ch->name, victim->name);
		to_channel(buf, CHANNEL_MONITOR, "Monitor", ch->top_level);

	}
	return FALSE;

}
Exemplo n.º 8
0
void kill_auth(DESCRIPTOR_DATA *d)
{
  AUTH_DATA *a;
  
  for (a = first_auth; a; a = a->next)
    if (a->d == d)
    {
      if (a->state != AS_TOOPEN)
        closesocket(a->afd);
      UNLINK(a, first_auth, last_auth, next, prev);
      DISPOSE(a);
      STRFREE(d->user);
      d->user = STRALLOC("(killed)");
      return;
    }
  return;
}
Exemplo n.º 9
0
/* Ripped off do_description for whois bio's -- Scryn*/
void do_bio( CHAR_DATA* ch, const char* argument)
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs cannot set a bio.\r\n", ch );
      return;
   }
   if( ch->level < 5 )
   {
      set_char_color( AT_SCORE, ch );
      send_to_char( "You must be at least level five to write your bio...\r\n", ch );
      return;
   }
   if( !ch->desc )
   {
      bug( "%s", "do_bio: no descriptor" );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "%s", "do_bio: illegal substate" );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_BIO;
         ch->dest_buf = ch;
         start_editing( ch, ch->pcdata->bio );
         return;

      case SUB_PERSONAL_BIO:
         STRFREE( ch->pcdata->bio );
         ch->pcdata->bio = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Exemplo n.º 10
0
void do_prompt( CHAR_DATA * ch, const char *argument )
{
	char arg[MAX_INPUT_LENGTH];

	set_char_color( AT_GREY, ch );

	if ( IS_NPC( ch ) )
	{
		send_to_char( "NPC's can't change their prompt..\r\n", ch );
		return;
	}
	smash_tilde( argument );
	one_argument( argument, arg );
	if ( !*arg || !str_cmp( arg, "display" ) )
	{
		send_to_char( "Your current prompt string:\r\n", ch );
		set_char_color( AT_WHITE, ch );
		ch_printf( ch, "%s\r\n", !str_cmp( ch->pcdata->prompt, "" ) ? "(default prompt)" : ch->pcdata->prompt );
		set_char_color( AT_GREY, ch );
		send_to_char( "Type 'help prompt' for information on changing your prompt.\r\n", ch );
		return;
	}
	send_to_char( "Replacing old prompt of:\r\n", ch );
	set_char_color( AT_WHITE, ch );
	ch_printf( ch, "%s\r\n", !str_cmp( ch->pcdata->prompt, "" ) ? "(default prompt)" : ch->pcdata->prompt );
	if ( ch->pcdata->prompt )
		STRFREE( ch->pcdata->prompt );

	char prompt[128];

	mudstrlcpy( prompt, argument, 128 );

	/*
	 * Can add a list of pre-set prompts here if wanted.. perhaps
	 * 'prompt 1' brings up a different, pre-set prompt 
	 */
	if ( !str_cmp( arg, "default" ) )
		ch->pcdata->prompt = STRALLOC( "" );
	else
		ch->pcdata->prompt = STRALLOC( prompt );
	return;
}
Exemplo n.º 11
0
void set_title( CHAR_DATA * ch, const char *title )
{
   char buf[MAX_STRING_LENGTH];

   if( IS_NPC( ch ) )
   {
      bug( "%s: NPC.", __FUNCTION__ );
      return;
   }

   if( isalpha( title[0] ) || isdigit( title[0] ) )
   {
      buf[0] = ' ';
      mudstrlcpy( buf + 1, title, MAX_STRING_LENGTH - 1 );
   }
   else
      mudstrlcpy( buf, title, MAX_STRING_LENGTH );

   STRFREE( ch->pcdata->title );
   ch->pcdata->title = STRALLOC( buf );
}
Exemplo n.º 12
0
void
mfs_ramdir_purgevp(
    VNODE_T *dvp,
    VNODE_T *vp,
    CALL_DATA_T *cd
)
{
    register mfs_mnode_t *mnp;
    register int vnum;
    int hwm;

    ASSERT(MFS_ISVIEWDIR(VTOM(dvp)));

    mnp =  VTOM(dvp);
    MLOCK(mnp);

    /* Must continue scan to remove multiple links to same object. */

    for (vnum=0; vnum < mnp->mn_ramdir.hwm; vnum++) {
        if (mnp->mn_ramdir.ents[vnum].vp == vp) {
            if (MVFS_ISVTYPE(vp, VDIR))
                mnp->mn_ramdir.lnk_cnt--;
            ATRIA_VN_RELE(vp, cd);
            mnp->mn_ramdir.ents[vnum].vp = NULL;
            ASSERT(mnp->mn_ramdir.ents[vnum].nm);
            STRFREE(mnp->mn_ramdir.ents[vnum].nm);

            mnp->mn_ramdir.mtime.tv_sec = MDKI_CTIME();	

            /* Update high water mark if releasing the highest slot */

	    if (vnum == mnp->mn_ramdir.hwm-1) {
	        hwm = vnum;
		while (mnp->mn_ramdir.ents[--hwm].nm == NULL) {}
		mnp->mn_ramdir.hwm = hwm+1;
	    }
	}
    }
    MUNLOCK(mnp);
}
Exemplo n.º 13
0
bool auth_read(AUTH_DATA *a, CHAR_DATA *ch)
{
  char readbuf[MAX_STRING_LENGTH];
  char system[MAX_INPUT_LENGTH], user[MAX_INPUT_LENGTH];
  char *s = readbuf;
  int n;
  
  n = recv(a->afd, readbuf, sizeof(readbuf)-10, 0);
  if (n < 0)
  {
    perror("auth_read: read");
    KILLRET("Auth_read: Error on read for %s@%s.", "(Error on read)");
  }
  if (!n)
    return TRUE;
/*    KILLRET("Auth_read: EOF on read for %s@%s.", "(EOF on read)");*/
  readbuf[n] = '\0';
  while (isspace(*s))
    ++s;
  if (!*s)
    KILLRET("Auth_read: blank auth for %s@%s.", "(blank auth)");
  /* That 1024 check should actually be against the port the user is
     logged into, but in SMAUG theres like 4 possible, and I don't
     feel like checking every single one.. -- Alty */
/*  bug("ident = '%s'.", s);*/
  if (!atoi(break_arg(&s, ',')) || atoi(break_arg(&s, ':')) < 1024)
    KILLRET("Auth_read: Invalid ident reply for %s@%s.", "(invalid ident)");
  break_arg(&s, ':');
  sprintf(system, "%.*s", (int)sizeof(system)-1, break_arg(&s, ':'));
/*  if (!str_cmp(system, "OTHER"))
    KILLRET("Auth_read: invalid system for %s@%s.", "(invalid system)");*/
  sprintf(user, "%.*s", (int)sizeof(user)-1, break_arg(&s, ' '));
  if (!*user)
    KILLRET("Auth_read: no username for %s@%s.", "(no username)");
  sprintf(log_buf, "Auth reply ok.  Incoming user [%s@%s] for %s.",
          user, a->d->host, (ch ? ch->name : "(unknown)"));
  STRFREE(a->d->user);
  a->d->user = STRALLOC(user);
  return FALSE; /* FALSE actually removes the AUTH_DATA, which is good. */
}
Exemplo n.º 14
0
void set_title( CHAR_DATA * ch, const char *title )
{
   char buf[MAX_STRING_LENGTH];

   if( IS_NPC( ch ) )
   {
      bug( "Set_title: NPC.", 0 );
      return;
   }

   if( isalpha( title[0] ) || isdigit( title[0] ) )
   {
      buf[0] = ' ';
      strcpy( buf + 1, title );
   }
   else
      strcpy( buf, title );

   STRFREE( ch->pcdata->title );
   ch->pcdata->title = STRALLOC( buf );
   return;
}
Exemplo n.º 15
0
/* Ripped off do_description for whois bio's -- Scryn*/
void do_bio( CHAR_DATA * ch, const char *argument )
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't set bio's!\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "do_bio: no descriptor", 0 );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "do_bio: illegal substate", 0 );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_BIO;
         ch->dest_buf = ch;
         start_editing( ch, (char *)ch->pcdata->bio );
         return;

      case SUB_PERSONAL_BIO:
         STRFREE( ch->pcdata->bio );
         ch->pcdata->bio = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Exemplo n.º 16
0
/*
 * Set your personal description				-Thoric
 */
void do_description( CHAR_DATA* ch, const char* argument)
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Monsters are too dumb to do that!\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "%s", "do_description: no descriptor" );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "%s", "do_description: illegal substate" );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_DESC;
         ch->dest_buf = ch;
         start_editing( ch, ch->description );
         return;

      case SUB_PERSONAL_DESC:
         STRFREE( ch->description );
         ch->description = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Exemplo n.º 17
0
HINT_DATA *read_hint( char *filename, FILE * fp )
{
   HINT_DATA *hintData;
   const char *word;
   bool fMatch;
   char letter;

   do
   {
      letter = getc( fp );
      if( feof( fp ) )
      {
         fclose( fp );
         fp = NULL;
         return NULL;
      }
   }
   while( isspace( letter ) );
   ungetc( letter, fp );

   CREATE( hintData, HINT_DATA, 1 );
   hintData->next = NULL;
   hintData->prev = NULL;
   hintData->text = STRALLOC( "" );
   hintData->low = 0;
   hintData->high = 0;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case 'T':
            if( !str_cmp( word, "Text" ) )
               STRFREE( hintData->text );
            KEY( "Text", hintData->text, fread_string( fp ) );
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
            {
               if( !hintData->text )
                  hintData->text = STRALLOC( "" );
               return hintData;
            }
            break;

         case 'H':
            KEY( "High", hintData->high, fread_number( fp ) );
            break;

         case 'L':
            KEY( "Low", hintData->low, fread_number( fp ) );
            break;
      }

      if( !fMatch )
         bug( "%s: no match: %s", __func__, word );
   }
   STRFREE( hintData->text );
   DISPOSE( hintData );
   return NULL;
}
Exemplo n.º 18
0
void do_hintedit( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_STRING_LENGTH];
   char arg2[MAX_STRING_LENGTH];
   char arg3[MAX_STRING_LENGTH];
   HINT_DATA *hintData;
   int i;
   int no = 0;
   int ano = 0;
   bool found = FALSE;

   if( IS_NPC( ch ) )
      return;

   if( !IS_IMMORTAL( ch ) )
      return;

   set_char_color( AT_LBLUE, ch );
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg2 );
   argument = one_argument( argument, arg3 );
   if( !str_cmp( arg, "help" ) || arg[0] == '\0' )
   {
      do_help( ch, "imm_hints" );
      return;
   }

   if( !str_cmp( arg, "list" ) )
   {
      if( first_hint )
      {
         pager_printf( ch, "No | Low | High |            Text             \r\n" );
         pager_printf( ch, "---|-----|------|--------------------------------------------------\r\n" );
         i = 0;
         for( hintData = first_hint; hintData; hintData = hintData->next )
         {
            ++i;
            pager_printf( ch, "%2d | %3d | %4d | %-30s\r\n", i, hintData->low, hintData->high, hintData->text );
         }
         pager_printf( ch, "\r\n%d hints in file.\r\n", i );
      }
      else
         send_to_char( "No hints in file.\r\n", ch );
      return;
   }

   else if( !str_cmp( arg, "remove" ) )
   {
      no = 0;
      if( !is_number( arg2 ) )
      {
         send_to_char_color( "Remove which hint?\r\n", ch );
         return;
      }
      ano = atoi( arg2 );
      found = FALSE;
      for( hintData = first_hint; hintData; hintData = hintData->next )
      {
         ++no;
         if( no == ano )
         {
            ch_printf_color( ch, "&CHint Number %d removed\r\n", ano );
            UNLINK( hintData, first_hint, last_hint, next, prev );
            STRFREE( hintData->text );
            DISPOSE( hintData );
            found = TRUE;
            break;
         }
      }
      if( !found )
      {
         send_to_char( "Hint not found\r\n", ch );
         return;
      }
      return;
   }
   else if( !str_cmp( arg, "add" ) )
   {
      if( arg2 == '\0' )
      {
         send_to_char( "What is the minimum level for this hint?\r\n", ch );
         return;
      }
      if( arg3 == '\0' )
      {
         send_to_char( "What is the maximum level for this hint?\r\n", ch );
         return;
      }
      if( atoi( arg2 ) > atoi( arg3 ) )
      {
         send_to_char( "Aborting:  max less than min!\r\n", ch );
         return;
      }
      CREATE( hintData, HINT_DATA, 1 );
      hintData->low = atoi( arg2 );
      hintData->high = atoi( arg3 );
      hintData->text = STRALLOC( argument );
      LINK( hintData, first_hint, last_hint, next, prev );
      send_to_char( "Ok.  Hint created\r\n", ch );
      return;
   }
   else if( !str_cmp( arg, "force" ) )
   {
      ch_printf_color( ch, "&p( &wHINT&p ):  &P%s\r\n", get_hint( LEVEL_AVATAR ) );
      return;
   }
   else if( !str_cmp( arg, "edit" ) )
   {
      no = 0;
      i = 0;

      if( arg2[0] == '\0' )
      {
         send_to_char( "Edit which hint number?\r\n", ch );
         return;
      }
      else
         no = atoi( arg2 );
      if( arg3[0] == '\0' )
      {
         ch_printf( ch, "Edit which field of hint %d (low/high/text)?\r\n", no );
         return;
      }
      if( argument[0] == '\0' )
      {
         ch_printf( ch, "Change hint %d's field %s to what ?\r\n", no, arg3 );
         return;
      }
      for( hintData = first_hint; hintData; hintData = hintData->next )
      {
         ++i;
         if( i == no )
         {
            found = TRUE;
            break;
         }
      }
      if( !found )
      {
         ch_printf( ch, "Hint %d not found.\r\n", no );
         return;
      }
      else
      {
         if( !str_cmp( arg3, "text" ) )
         {
            STRFREE( hintData->text );
            hintData->text = STRALLOC( argument );
            send_to_char( "Hint text changed!\r\n", ch );
            return;
         }
         else if( !str_cmp( arg3, "low" ) )
         {
            if( atoi( argument ) > hintData->high )
            {
               send_to_char( "Aborting:  min higher than max.\r\n", ch );
               return;
            }
            hintData->low = atoi( argument );
            send_to_char( "Minimum level for hint changed.\r\n", ch );
            return;
         }
         else if( !str_cmp( arg3, "high" ) )
         {
            if( atoi( argument ) < hintData->low )
            {
               send_to_char( "Aborting:  max lower than min.\r\n", ch );
               return;
            }
            hintData->high = atoi( argument );
            send_to_char( "Maximum level for hint changed.\r\n", ch );
            return;
         }
         else
         {
            send_to_char( "Valid fields are:  low/high/text\r\n", ch );
            return;
         }
      }
   }
   else if( !str_cmp( arg, "save" ) )
   {
      write_hint(  );
      send_to_char( "Saved.\r\n", ch );
      return;
   }
   else
   {
      send_to_char( "Syntax:  hint (list/add/remove/edit/save/force)\r\n", ch );
      return;
   }
}
Exemplo n.º 19
0
void do_comment( CHAR_DATA * ch, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   char arg[MAX_INPUT_LENGTH];
   char arg1[MAX_INPUT_LENGTH];
   NOTE_DATA *pnote;
   CHAR_DATA *victim;
   int vnum;
   int anum;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't use the comment command.\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "do_comment: no descriptor", 0 );
      return;
   }

   /*
    * Put in to prevent crashing when someone issues a comment command
    * from within the editor. -Narn 
    */
   if( ch->desc->connected == CON_EDITING || ch->desc->connected == CON_NOTE_TO )
   {
      send_to_char( "You can't use the comment command from within the editor.\r\n", ch );
      return;
   }

   switch ( ch->substate )
   {
      default:
         break;
      case SUB_WRITING_NOTE:
         if( !ch->pnote )
         {
            bug( "do_comment: note got lost?", 0 );
            send_to_char( "Your note got lost!\r\n", ch );
            stop_editing( ch );
            return;
         }
         if( ch->dest_buf != ch->pnote )
            bug( "do_comment: sub_writing_note: ch->dest_buf != ch->pnote", 0 );
         STRFREE( ch->pnote->text );
         ch->pnote->text = copy_buffer( ch );
         stop_editing( ch );
         return;
   }

   set_char_color( AT_NOTE, ch );
   argument = one_argument( argument, arg );
   smash_tilde( argument );

   if( !str_cmp( arg, "about" ) )
   {

      victim = get_char_world( ch, argument );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }


   }


   if( !str_cmp( arg, "list" ) )
   {
      victim = get_char_world( ch, argument );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) >= get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      if( !victim->comments )
      {
         send_to_char( "There are no relevant comments.\r\n", ch );
         return;
      }

      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         sprintf( buf, "%2d) %-10s [%s] %s\r\n", vnum, pnote->sender, pnote->date, pnote->subject );
/* Brittany added date to comment list and whois with above change */
         send_to_char( buf, ch );
      }

      /*
       * act( AT_ACTION, "$n glances over the notes.", ch, NULL, NULL, TO_ROOM ); 
       */
      return;
   }

   if( !str_cmp( arg, "read" ) )
   {
      bool fAll;

      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) >= get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      if( !victim->comments )
      {
         send_to_char( "There are no relevant comments.\r\n", ch );
         return;
      }



      if( !str_cmp( argument, "all" ) )
      {
         fAll = TRUE;
         anum = 0;
      }
      else if( is_number( argument ) )
      {
         fAll = FALSE;
         anum = atoi( argument );
      }
      else
      {
         send_to_char( "Note read which number?\r\n", ch );
         return;
      }

      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         if( vnum == anum || fAll )
         {
            sprintf( buf, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n",
                     vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list );
            send_to_char( buf, ch );
            send_to_char( pnote->text, ch );
            /*
             * act( AT_ACTION, "$n reads a note.", ch, NULL, NULL, TO_ROOM ); 
             */
            return;
         }
      }

      send_to_char( "No such comment.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "write" ) )
   {
      note_attach( ch );
      ch->substate = SUB_WRITING_NOTE;
      ch->dest_buf = ch->pnote;
      start_editing( ch, ch->pnote->text );
      return;
   }

   if( !str_cmp( arg, "subject" ) )
   {
      note_attach( ch );
      STRFREE( ch->pnote->subject );
      ch->pnote->subject = STRALLOC( argument );
      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "to" ) )
   {
      note_attach( ch );
      STRFREE( ch->pnote->to_list );
      ch->pnote->to_list = STRALLOC( argument );
      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "clear" ) )
   {
      if( ch->pnote )
      {
         STRFREE( ch->pnote->text );
         STRFREE( ch->pnote->subject );
         STRFREE( ch->pnote->to_list );
         STRFREE( ch->pnote->date );
         STRFREE( ch->pnote->sender );
         DISPOSE( ch->pnote );
      }
      ch->pnote = NULL;

      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "show" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no comment in progress.\r\n", ch );
         return;
      }

      sprintf( buf, "%s: %s\r\nTo: %s\r\n", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list );
      send_to_char( buf, ch );
      send_to_char( ch->pnote->text, ch );
      return;
   }

   if( !str_cmp( arg, "post" ) )
   {
      char *strtime;

      if( !ch->pnote )
      {
         send_to_char( "You have no comment in progress.\r\n", ch );
         return;
      }

      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) > get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      /*
       * act( AT_ACTION, "$n posts a note.", ch, NULL, NULL, TO_ROOM ); 
       */

      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      ch->pnote->date = STRALLOC( strtime );

      pnote = ch->pnote;
      ch->pnote = NULL;


      /*
       * LIFO to make life easier 
       */
      pnote->next = victim->comments;
      if( victim->comments )
         victim->comments->prev = pnote;
      pnote->prev = NULL;
      victim->comments = pnote;

      save_char_obj( victim );


#ifdef NOTDEFD
      fclose( fpReserve );
      sprintf( notefile, "%s/%s", BOARD_DIR, board->note_file );
      if( ( fp = fopen( notefile, "a" ) ) == NULL )
      {
         perror( notefile );
      }
      else
      {
         fprintf( fp, "Sender  %s~\nDate    %s~\nTo      %s~\nSubject %s~\nText\n%s~\n\n",
                  pnote->sender, pnote->date, pnote->to_list, pnote->subject, pnote->text );
         fclose( fp );
      }
      fpReserve = fopen( NULL_FILE, "r" );
#endif

      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "remove" ) )
   {
      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( ( get_trust( victim ) >= get_trust( ch ) ) || ( get_trust( ch ) < 58 ) )  /* switch to some LEVEL_ thingie */
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      /*
       * argument = one_argument(argument, arg); 
       */
      if( !is_number( argument ) )
      {
         send_to_char( "Comment remove which number?\r\n", ch );
         return;
      }

      anum = atoi( argument );
      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         if( ( 58 <= get_trust( ch ) ) /* switch to some LEVEL_ thingie */
             && ( vnum == anum ) )
         {
            comment_remove( victim, pnote );
            send_to_char( "Ok.\r\n", ch );
            /*
             * act( AT_ACTION, "$n removes a note.", ch, NULL, NULL, TO_ROOM ); 
             */
            return;
         }
      }

      send_to_char( "No such comment.\r\n", ch );
      return;
   }

   send_to_char( "Type 'help comment' for usage (i hope!).\r\n", ch );
   return;
}
Exemplo n.º 20
0
void do_buy( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    int maxgold;
    bool debit;
    OBJ_DATA *obj;    

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char( "Buy what?\n\r", ch );
	return;
    }

    if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) )
    {
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *pet;
	ROOM_INDEX_DATA *pRoomIndexNext;
	ROOM_INDEX_DATA *in_room;

   if ( argument[0] == '\0' )
      debit = FALSE;
   else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
   {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
     if ( has_card == TRUE )
      debit = TRUE;
     else
     {
       send_to_char( "You don't even have your card with you!\n\r", ch );
       return;    
     }    
    }

	if ( IS_NPC(ch) )
	    return;

	pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 );
	if ( !pRoomIndexNext )
	{
	    bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum );
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	in_room     = ch->in_room;
	ch->in_room = pRoomIndexNext;
	pet         = get_char_room( ch, arg );
	ch->in_room = in_room;

	if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) )
	{
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE)
	{
	    send_to_char( "You can't afford it.\n\r", ch );
	    return;
	}
	else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE )
	{
	  send_to_char( "You dont have enough money in your bank account for it.\n\r", ch );
          return;    
        } 

	maxgold = 10 * pet->top_level * pet->top_level;
        if ( debit == FALSE )
	  ch->gold	-= maxgold; /* this was already here, btw */
	else
	  ch->pcdata->bank  -= maxgold;

	boost_economy( ch->in_room->area, maxgold );
	pet		= create_mobile( pet->pIndexData );
	SET_BIT(pet->act, ACT_PET);
	SET_BIT(pet->affected_by, AFF_CHARM);

	argument = one_argument( argument, arg );
	if ( arg[0] != '\0' )
	{
	    sprintf( buf, "%s %s", pet->name, arg );
	    STRFREE( pet->name );
	    pet->name = STRALLOC( buf );
	}

	sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r",
	    pet->description, ch->name );
	STRFREE( pet->description );
	pet->description = STRALLOC( buf );

	char_to_room( pet, ch->in_room );
	add_follower( pet, ch );
	send_to_char( "Enjoy your pet.\n\r", ch );
    	act( AT_ACTION, "$n bought $N as a pet.", ch, NULL, pet, TO_ROOM );
	return;
    }
    else
    {
	CHAR_DATA *keeper;
	int cost;
	int noi = 1;		/* Number of items */
	sh_int mnoi = 20;	/* Max number of items to be bought at once */

	if ( ( keeper = find_keeper( ch ) ) == NULL )
	    return;

	maxgold = keeper->top_level * 10;

	if ( is_number( arg ) )
	{
	    noi = atoi( arg );
	    argument = one_argument( argument, arg );
	    if ( noi > mnoi )
	    {
		act( AT_TELL, "$n tells you 'I don't sell that many items at"
		  " once.'", keeper, NULL, ch, TO_VICT );
		ch->reply = keeper;
		return;
	    }
	}

    if ( argument[0] == '\0' )
      debit = FALSE;
    else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
    {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
      if ( has_card == TRUE )
       debit = TRUE;
      else
      {
        send_to_char( "You don't even have your card with you!\n\r", ch );
        return;    
      }    
     }  

	obj  = get_obj_carry( keeper, arg );
	
	if ( !obj && arg[0] == '#' )
        {     
              int onum, oref;
              bool ofound = FALSE;
              
              onum =0;
              oref = atoi(arg+1);
              for ( obj = keeper->last_carrying; obj; obj = obj->prev_content )
	      { 
	        if ( obj->wear_loc == WEAR_NONE
	        &&   can_see_obj( ch, obj ) )
	            onum++;
                if ( onum == oref ) 
                {
                    ofound = TRUE;
                    break;
                }
                else if ( onum > oref )
                   break;
	      }
	      if (!ofound)
	         obj = NULL;
        }
	if (keeper->home != NULL && obj->cost > 0)
          cost= obj->cost;
	cost = ( get_cost( ch, keeper, obj, TRUE ) * noi );

	if( !IS_NPC(ch) && ch->pcdata->learned[gsn_bargain] > 0 && ch->pcdata->learned[gsn_bargain] > number_percent())
	 {
	   ch_printf(ch,"You are able to bargain from %d credits to %d credits!\n\r", cost, (cost/3)+(cost/2));
	   cost = (cost/3) + (cost/2);
	   if(number_percent() > 50)
	    learn_from_success(ch, gsn_bargain);
	 }

	if ( cost <= 0 || !can_see_obj( ch, obj ) )
	{
	    act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'",
		keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}

	if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) )
	{
	    interpret( keeper, "laugh" );
	    act( AT_TELL, "$n tells you 'I don't have enough of those in stock"
	     " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
	if ( ch->gold < cost && debit == FALSE)
	{
	    act( AT_TELL, "$n tells you 'You can't afford to buy $p.'",
		keeper, obj, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
        if ( ch->pcdata->bank < cost && debit == TRUE)
	{
	    send_to_char( "You are almost slide your card through, but you remember you don't have enough money!\n\r", ch );
	    return;	    
        }  

	if ( IS_SET(obj->extra_flags, ITEM_PROTOTYPE) 
             && get_trust( ch ) < LEVEL_IMMORTAL )
	{
	    act( AT_TELL, "$n tells you 'This is a only a prototype!  I can't sell you that...'", 
		keeper, NULL, ch, TO_VICT );
      	    ch->reply = keeper;
	    return;
	}

	if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
	{
	    send_to_char( "You can't carry that many items.\n\r", ch );
	    return;
	}

	if ( ch->carry_weight + ( get_obj_weight( obj ) * noi )
		+ (noi > 1 ? 2 : 0) > can_carry_w( ch ) )
	{
	    send_to_char( "You can't carry that much weight.\n\r", ch );
	    return;
	}

	if ( noi == 1 )
	{
	    if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) )  
	       separate_obj( obj );
	    act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM );
    	    act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR );
	}
        else
	{
	    sprintf( arg, "$n buys %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM );
	    sprintf( arg, "You buy %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR );
	    act( AT_ACTION, "$N puts them into a bag and hands it to you.",
		ch, NULL, keeper, TO_CHAR );
	}

        if ( debit == FALSE )
	  ch->gold     -= cost; /* this line was already here, btw */
        else if ( debit == TRUE )
          ch->pcdata->bank     -= cost;
	keeper->gold += cost;

	if ( keeper->gold > maxgold )
	{
	    boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 );
	    keeper->gold = maxgold/2;
	    act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM );
	}

	if ( IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
	{
	    OBJ_DATA *buy_obj, *bag;

	    buy_obj = create_object( obj->pIndexData, obj->level );

	    /*
	     * Due to grouped objects and carry limitations in SMAUG
	     * The shopkeeper gives you a bag with multiple-buy,
	     * and also, only one object needs be created with a count
	     * set to the number bought.		-Thoric
	     */
	    if ( noi > 1 )
	    {
		bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ), 1 );
		/* perfect size bag ;) */
		bag->value[0] = bag->weight + (buy_obj->weight * noi);
		buy_obj->count = noi;
		obj->pIndexData->count += (noi - 1);
		numobjsloaded += (noi - 1);
		obj_to_obj( buy_obj, bag );
		obj_to_char( bag, ch );
	    }
	    else
		obj_to_char( buy_obj, ch );
	}
        else
	{
	    obj_from_char( obj );
	    obj_to_char( obj, ch );
	}

	return;
    }
}
Exemplo n.º 21
0
/* olc editnews command */
void do_editnews( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_INPUT_LENGTH];

   if( IS_NPC( ch ) || !IS_IMMORTAL( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   set_char_color( AT_GREEN, ch );

   switch ( ch->substate )
   {
      default:
         break;

      case SUB_NEWS_POST:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;

      case SUB_NEWS_EDIT:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;
   }

   argument = one_argument( argument, arg );

   if( arg[0] == '\0' )
   {
      send_to_char( "Syntax: editnews addtype <name>\r\n"
                    "        editnews addnews <type> <subject>\r\n"
                    "        editnews removetype <number>\r\n"
                    "        editnews removenews <type> <number>\r\n"
                    "        editnews edittype <field> <value>\r\n"
                    "        editnews editnews <type> <number> <new subject [optional]>\r\n"
                    " Fields being one of the following:\r\n" " name header cmd_name level\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "save" ) )
   {
      renumber_news(  );
      save_news(  );
      send_to_char( "News saved.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "addtype" ) )
   {
      NEWS_TYPE *type = NULL;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addtype <name>\r\n", ch );
         return;
      }

      if( top_news_type >= NEWS_MAX_TYPES )
      {
         send_to_char( "There are too many news types.\r\n", ch );
         return;
      }

      CREATE( type, NEWS_TYPE, 1 );
      type->name = STRALLOC( argument );
      type->cmd_name = STRALLOC( argument );
      type->vnum = top_news_type++;
      type->level = -1;

      news_command_table[type->vnum] = STRALLOC( type->cmd_name );

      LINK( type, first_news_type, last_news_type, next, prev );
      ch_printf( ch, "Newstype '%s' created.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "removetype" ) )
   {
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL, *news_next;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews removetype <name>\r\n", ch );
         return;
      }

      if( ( type = figure_type( argument ) ) == NULL )
      {
         send_to_char( "Invaild newstype.\r\n", ch );
         return;
      }

      UNLINK( type, first_news_type, last_news_type, next, prev );
      STRFREE( type->name );
      STRFREE( type->header );
      STRFREE( type->cmd_name );
      STRFREE( news_command_table[type->vnum] );
      STRFREE( news_command_table[type->level] );

      for( news = type->first_news; news; news = news_next )
      {
         news_next = news->next;

         UNLINK( news, type->first_news, type->last_news, next, prev );
         STRFREE( news->name );
         STRFREE( news->title );
         STRFREE( news->date );
         STRFREE( news->post );
         DISPOSE( news );
      }

      DISPOSE( type );
      --top_news_type;
      renumber_news(  );
      save_news(  );
      ch_printf( ch, "Newstype '%s' removed.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "edittype" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' || arg3[0] == '\0' )
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype.\r\n", ch );
         return;
      }

      if( !str_cmp( arg3, "cmd_name" ) )
      {
         type->cmd_name = STRALLOC( argument );
         news_command_table[type->vnum] = STRALLOC( type->cmd_name );
         send_to_char( "Cmd_name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "name" ) )
      {
         type->name = STRALLOC( argument );
         send_to_char( "Name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "level" ) )
      {
         if( argument[0] == '\0' )
         {
            ch_printf( ch, "%d\r\n", type->level );
            return;
         }
         else
            type->level = atoi( argument );
         send_to_char( "Level set.\r\n", ch );
         save_news(  );
         return;
      }
      else
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }
   }

   if( !str_cmp( arg, "addnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL;

      argument = one_argument( argument, arg2 );

      if( arg2[0] == '\0' || argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addnews <type> <subject>\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invaild newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      CREATE( news, NEWS, 1 );
      news->title = STRALLOC( argument );
      news->name = STRALLOC( ch->name );
      news->date = STRALLOC( stamp_time(  ) );
      news->post = STRALLOC( "" );

      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_POST;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      LINK( news, type->first_news, type->last_news, next, prev );
      return;
   }

   if( !str_cmp( arg, "editnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews editnews <type> <number> <new subject [optional]>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, arg3 ) ) == NULL )
      {
         pager_printf_color( ch, "That's not a valid news number.\r\nUse '%s' to view the valid numbers.\r\n",
                             type->cmd_name );
         return;
      }

      /*
       * a changed title 
       */
      if( argument[0] != '\0' )
         news->title = STRALLOC( argument );

      /*
       * new date news was edited 
       */
      news->date = STRALLOC( stamp_time(  ) );
      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_EDIT;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      return;
   }

   if( !str_cmp( arg, "removenews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      if( argument[0] == '\0' || arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews remove <number>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, argument ) ) == NULL )
      {
         send_to_char( "Type 'news' to gain a list of the news numbers.\r\n", ch );
         return;
      }

      UNLINK( news, type->first_news, type->last_news, next, prev );
      STRFREE( news->name );
      STRFREE( news->title );
      STRFREE( news->date );
      STRFREE( news->post );
      DISPOSE( news );
      renumber_news(  );
      save_news(  );
      send_to_char( "News item removed.\r\n", ch );
      return;
   }
}
Exemplo n.º 22
0
/* This function takes the character string in ch->pnote and
 *  creates rooms laid out in the appropriate configuration.
 */
void map_to_rooms( CHAR_DATA * ch, MAP_INDEX_DATA * m_index )
{
   struct map_stuff map[49][78]; /* size of edit buffer */
   const char *newmap;
   int row, col, i, n, x, y, tvnum, proto_vnum = 0, leftmost, rightmost;
   int newx, newy;
   const char *l;
   char c;
   ROOM_INDEX_DATA *newrm;
   MAP_INDEX_DATA *map_index = NULL, *tmp;
   EXIT_DATA *xit;   /* these are for exits */
   bool getroomnext = FALSE;

   if( !ch->pnote )
   {
      bug( "%s: ch->pnote==NULL!", __FUNCTION__ );
      return;
   }

   /*
    * Make sure format is right 
    */
   newmap = check_map( ch->pnote->text );
   STRFREE( ch->pnote->text );
   ch->pnote->text = STRALLOC( newmap );

   n = 0;
   row = col = 0;
   leftmost = rightmost = 0;

   /*
    * Check to make sure map_index exists.  
    * If not, then make a new one.
    */
   if( !m_index )
   {
      /*
       * Make a new vnum 
       */
      for( i = ch->pcdata->area->low_r_vnum; i <= ch->pcdata->area->hi_r_vnum; i++ )
      {
         if( ( tmp = get_map_index( i ) ) == NULL )
         {
            map_index = make_new_map_index( i );
            break;
         }
      }
   }
   else
      map_index = m_index;

   /*
    *  
    */
   if( !map_index )
   {
      send_to_char( "Couldn't find or make a map_index for you!\r\n", ch );
      bug( "%s", "map_to_rooms: Couldn't find or make a map_index\r\n" );
      /*
       * do something. return failed or somesuch 
       */
      return;
   }

   for( x = 0; x < 49; x++ )
   {
      for( y = 0; y < 78; y++ )
      {
         map[x][y].vnum = 0;
         map[x][y].proto_vnum = 0;
         map[x][y].exits = 0;
         map[x][y].index = 0;
      }
   }

   l = ch->pnote->text;
   do
   {
      c = l[0];
      switch ( c )
      {
         case '\n':
            break;
         case '\r':
            col = 0;
            row++;
            break;
      }
      if( c != ' ' && c != '-' && c != '|' && c != '=' && c != '\\' && c != '/' && c != '^'
          && c != ':' && c != '[' && c != ']' && c != '^' && !getroomnext )
      {
         l++;
         continue;
      }
      if( getroomnext )
      {
         n++;
         /*
          * Actual room info 
          */
         map[row][col].vnum = add_new_room_to_map( ch, c );
         map_index->map_of_vnums[row][col] = map[row][col].vnum;
         map[row][col].proto_vnum = proto_vnum;
         getroomnext = FALSE;
      }
      else
      {
         map_index->map_of_vnums[row][col] = 0;
         map[row][col].vnum = 0;
         map[row][col].exits = 0;
      }
      map[row][col].code = c;
      /*
       * Handle rooms 
       */
      if( c == '[' )
         getroomnext = TRUE;
      col++;
      l++;
   }
   while( c != '\0' );

   for( y = 0; y < ( row + 1 ); y++ )
   {  /* rows */
      for( x = 0; x < 78; x++ )
      {  /* cols (78, i think) */

         if( map[y][x].vnum == 0 )
            continue;

         newrm = get_room_index( map[y][x].vnum );
         /*
          * Continue if no newrm 
          */
         if( !newrm )
            continue;

         /*
          * Check up 
          */
         if( y > 1 )
         {
            newx = x;
            newy = y;
            newy--;
            while( newy >= 0 && ( map[newy][x].code == '^' ) )
               newy--;

            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][x].vnum )
               break;
            if( ( tvnum = map[newy][x].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_UP );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }

         /*
          * Check down 
          */
         if( y < 48 )
         {
            newx = x;
            newy = y;
            newy++;
            while( newy <= 48 && ( map[newy][x].code == '^' ) )
               newy++;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][x].vnum )
               break;
            if( ( tvnum = map[newy][x].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_DOWN );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }

         /*
          * Check north 
          */
         if( y > 1 )
         {
            newx = x;
            newy = y;
            newy--;
            while( newy >= 0 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) )
               newy--;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][x].vnum )
               break;
            if( ( tvnum = map[newy][x].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTH );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               if( map[newy + 1][x].code == ':' || map[newy + 1][x].code == '=' )
               {
                  SET_BIT( xit->exit_info, EX_ISDOOR );
                  SET_BIT( xit->exit_info, EX_CLOSED );
               }
               else
                  xit->exit_info = 0;
            }
         }

         /*
          * Check south 
          */
         if( y < 48 )
         {
            newx = x;
            newy = y;
            newy++;
            while( newy <= 48 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) )
               newy++;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][x].vnum )
               break;
            if( ( tvnum = map[newy][x].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTH );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               if( map[newy - 1][x].code == ':' || map[newy - 1][x].code == '=' )
               {
                  SET_BIT( xit->exit_info, EX_ISDOOR );
                  SET_BIT( xit->exit_info, EX_CLOSED );
               }
               else
                  xit->exit_info = 0;
            }
         }

         /*
          * Check east 
          */
         if( x < 79 )
         {
            newx = x;
            newy = y;
            newx++;
            while( newx <= 79 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '='
                                   || map[y][newx].code == '[' || map[y][newx].code == ']' ) )
               newx++;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[y][newx].vnum )
               break;
            if( ( tvnum = map[y][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_EAST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               if( map[y][newx - 2].code == ':' || map[y][newx - 2].code == '=' )
               {
                  SET_BIT( xit->exit_info, EX_ISDOOR );
                  SET_BIT( xit->exit_info, EX_CLOSED );
               }
               else
                  xit->exit_info = 0;
            }
         }

         /*
          * Check west 
          */
         if( x > 1 )
         {
            newx = x;
            newy = y;
            newx--;
            while( newx >= 0 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '='
                                  || map[y][newx].code == '[' || map[y][newx].code == ']' ) )
               newx--;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[y][newx].vnum )
               break;
            if( ( tvnum = map[y][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_WEST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               if( map[y][newx + 2].code == ':' || map[y][newx + 2].code == '=' )
               {
                  SET_BIT( xit->exit_info, EX_ISDOOR );
                  SET_BIT( xit->exit_info, EX_CLOSED );
               }
               else
                  xit->exit_info = 0;
            }
         }

         /*
          * Check southeast 
          */
         if( y < 48 && x < 79 )
         {
            newx = x;
            newy = y;
            newx += 2;
            newy++;
            while( newx <= 79 && newy <= 48 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':'
                                                 || map[newy][newx].code == '=' ) )
            {
               newx++;
               newy++;
            }
            if( map[newy][newx].code == '[' )
               newx++;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][newx].vnum )
               break;
            if( ( tvnum = map[newy][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHEAST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }

         /*
          * Check northeast 
          */
         if( y > 1 && x < 79 )
         {
            newx = x;
            newy = y;
            newx += 2;
            newy--;
            while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':'
                                                || map[newy][newx].code == '=' ) )
            {
               newx++;
               newy--;
            }
            if( map[newy][newx].code == '[' )
               newx++;

            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][newx].vnum )
               break;
            if( ( tvnum = map[newy][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHEAST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }

         /*
          * Check northwest 
          */
         if( y > 1 && x > 1 )
         {
            newx = x;
            newy = y;
            newx -= 2;
            newy--;
            while( newx >= 0 && newy >= 0 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':'
                                               || map[newy][newx].code == '=' ) )
            {
               newx--;
               newy--;
            }
            if( map[newy][newx].code == ']' )
               newx--;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][newx].vnum )
               break;
            if( ( tvnum = map[newy][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHWEST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }

         /*
          * Check southwest 
          */
         if( y < 48 && x > 1 )
         {
            newx = x;
            newy = y;
            newx -= 2;
            newy++;
            while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':'
                                                || map[newy][newx].code == '=' ) )
            {
               newx--;
               newy++;
            }
            if( map[newy][newx].code == ']' )
               newx--;
            /*
             * dont link it to itself 
             */
            if( map[y][x].vnum == map[newy][newx].vnum )
               break;
            if( ( tvnum = map[newy][newx].vnum ) != 0 )
            {
               xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHWEST );
               xit->keyword = STRALLOC( "" );
               xit->description = STRALLOC( "" );
               xit->key = -1;
               xit->exit_info = 0;
            }
         }
      }
   }
}
Exemplo n.º 23
0
void do_bankedit( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;
    int                     type = DEFAULT_CURR;
    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    arg3[MAX_INPUT_LENGTH];
    char                    arg4[MIL];
    char                    arg5[MSL];

    int                     amount;

    if ( IS_NPC( ch ) ) {
        return;
    }

    if ( argument[0] == '\0' ) {
        send_to_char
            ( "Syntax:\tbankedit [delete/password/amount] [name] [new password or amount] [currency] [add/subtract]\r\n",
              ch );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    bank = find_bank( arg2 );

    if ( !bank ) {
        send_to_char( "There is no account with that name!\r\n", ch );
        return;
    }

    if ( !str_cmp( arg1, "delete" ) ) {
        ch_printf( ch, "Deleting... (%s)\r\n", bank->name );
        free_bank_to_chars( bank );
        unlink_bank( bank );
        free_bank( bank );
        save_bank(  );
        send_to_char( "The account has successfully been deleted.\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg3 );

    if ( !str_cmp( arg1, "password" ) ) {
        char                   *pwdnew,
                               *p;

        if ( arg3 == '\0' ) {
            send_to_char( "You have to have something for a password.\r\n", ch );
            return;
        }
        if ( strlen( arg3 ) < 5 ) {
            send_to_char( "Invalid Password.  Must be at least 5 characters in length.\r\n", ch );
            return;
        }
        if ( arg3[0] == '!' ) {
            send_to_char( "Password cannot begin with the '!' character.\r\n", ch );
            return;
        }

        pwdnew = crypt( arg3, bank->name );
        for ( p = pwdnew; *p != '\0'; p++ ) {
            if ( *p == '~' ) {
                send_to_char( "Password not acceptable, try again.\r\n", ch );
                return;
            }
        }

        STRFREE( bank->password );
        bank->password = STRALLOC( pwdnew );
        bank->lastused = current_time;
        save_bank(  );
        ch_printf( ch, "The password has been changed to %s.\r\n", arg3 );
        return;
    }
    argument = one_argument( argument, arg4 );
    if ( !str_cmp( arg1, "amount" ) ) {
        amount = atoi( arg3 );

        if ( arg3 && arg4 )
            type = get_currency_type( arg4 );

        if ( amount < 0 ) {
            send_to_char( "A positive value please.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg5, "add" ) ) {
            if ( type == CURR_BRONZE ) {
                bank->bronze += amount;
            }
            if ( type == CURR_COPPER ) {
                bank->copper += amount;
            }
            if ( type == CURR_GOLD ) {
                bank->gold += amount;
            }
            if ( type == CURR_SILVER ) {
                bank->silver += amount;
            }
        }

        if ( !str_cmp( arg5, "subtract" ) ) {
            if ( type == CURR_BRONZE ) {
                bank->bronze -= amount;
            }
            if ( type == CURR_COPPER ) {
                bank->copper -= amount;
            }
            if ( type == CURR_GOLD ) {
                bank->gold -= amount;
            }
            if ( type == CURR_SILVER ) {
                bank->silver -= amount;
            }

        }
        bank->lastused = current_time;
        save_bank(  );
        ch_printf( ch, "The amount has been changed to %d.\r\n", bank->amount );
        return;
    }
}
Exemplo n.º 24
0
SHIP_DATA *load_ship( FILE * fp )
{
   SHIP_DATA *ship = NULL;
   const char *word;
   bool fMatch;

   word = feof( fp ) ? "EndShip" : fread_word( fp );
   if( !str_cmp( word, "EndShip" ) )
      return NULL;

   if( !str_cmp( word, "SHIPFNAME" ) )
   {
     const char *name = fread_string_nohash( fp ); /* is this right? - Gavin */
      SHIP_DATA *temp_ship = NULL;

      for( temp_ship = first_ship; temp_ship; temp_ship = temp_ship->next )
      {
         if( !str_cmp( name, temp_ship->filename ) )
         {
            ship = temp_ship;
            break;
         }
      }

      if( ship == NULL )
      {
         bug( "%s: No ship data for filename %s", __FUNCTION__, name );
         DISPOSE( name );
         return NULL;

         for( ;; )
         {
            word = feof( fp ) ? "EndShip" : fread_word( fp );
            if( !str_cmp( word, "EndShip" ) )
               break;
         }
      }
      DISPOSE( name );
   }
   else
   {
      for( ;; )
      {
         word = feof( fp ) ? "EndShip" : fread_word( fp );
         if( !str_cmp( word, "EndShip" ) )
            break;
      }
      bug( "%s: shipfname not found", __FUNCTION__ );
      return NULL;
   }

   for( ;; )
   {
      word = feof( fp ) ? "EndShip" : fread_word( fp );
      fMatch = FALSE;
      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

            /*
             * case '#':
             * if ( !str_cmp( word, "#TORPEDO" ) )
             * {
             * mob->tempnum = -9999; 
             * fread_obj( mob, fp, OS_CARRY );
             * }
             * break;
             */

         case 'A':
            KEY( "Autorecharge", ship->autorecharge, ( bool ) fread_number( fp ) );
            KEY( "Autotrack", ship->autotrack, ( bool ) fread_number( fp ) );
            KEY( "Autospeed", ship->autospeed, ( bool ) fread_number( fp ) );
            KEY( "Autopilot", ship->autopilot, ( bool ) fread_number( fp ) );
            break;

         case 'C':
            KEY( "Currspeed", ship->currspeed, fread_number( fp ) );
            if( !str_cmp( word, "Currjump" ) )
            {
	      const char *temp = fread_string_nohash( fp );

               extract_ship( ship );
               ship->location = 0;
               ship->currjump = starsystem_from_name( temp );
               DISPOSE( temp );
               fMatch = TRUE;
               break;
            }
            KEY( "Chaff", ship->chaff, fread_number( fp ) );
            break;

         case 'E':
            KEY( "Energy", ship->energy, fread_number( fp ) );
            if( !str_cmp( word, "EndShip" ) )
            {
               return ship;
            }
            if( !str_cmp( word, "End" ) ) /* End of object, need to ignore this. sometimes they creep in there somehow -- Scion */
               fMatch = TRUE; /* Trick the system into thinking it matched something */
            break;

         case 'H':
            KEY( "Hull", ship->hull, fread_number( fp ) );
            KEY( "HX", ship->hx, ( float )fread_number( fp ) );
            KEY( "HY", ship->hy, ( float )fread_number( fp ) );
            KEY( "HZ", ship->hz, ( float )fread_number( fp ) );
            KEY( "Hyperdistance", ship->hyperdistance, fread_number( fp ) );
            break;

         case 'J':
            KEY( "JX", ship->jx, ( float )fread_number( fp ) );
            KEY( "JY", ship->jy, ( float )fread_number( fp ) );
            KEY( "JZ", ship->jz, ( float )fread_number( fp ) );
            break;

         case 'L':
            if( !str_cmp( word, "Landdest" ) )
            {
               STRFREE( ship->dest );
               ship->dest = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            break;

         case 'M':
            KEY( "Missiles", ship->missiles, fread_number( fp ) );
            break;

         case 'R':
            KEY( "Rockets", ship->rockets, fread_number( fp ) );
            break;

         case 'S':
            KEY( "Shield", ship->shield, fread_number( fp ) );
            KEY( "Shipstate", ship->shipstate, fread_number( fp ) );

            if( !str_cmp( word, "Starsystem" ) )
            {
	      const char *star_name = fread_string_nohash( fp );
               SPACE_DATA *starsystem = starsystem_from_name( star_name );
               DISPOSE( star_name );
               fMatch = TRUE;

               extract_ship( ship );
               ship->location = 0;
               if( ship->starsystem )
                  ship_from_starsystem( ship, starsystem );
               ship_to_starsystem( ship, starsystem );
               break;
            }
            break;

         case 'T':
            KEY( "Torpedos", ship->torpedos, fread_number( fp ) );
            if( !str_cmp( word, "target0" ) )
            {
	      const char *temp = fread_string( fp );
               SHIP_DATA *target = get_ship( temp );

               ship->target0 = target;
               STRFREE( temp );
               fMatch = TRUE;
               break;
            }

            if( !str_cmp( word, "target1" ) )
            {
	      const char *temp = fread_string( fp );
               SHIP_DATA *target = get_ship( temp );

               ship->target1 = target;
               STRFREE( temp );
               fMatch = TRUE;
               break;
            }

            if( !str_cmp( word, "target2" ) )
            {
	      const char *temp = fread_string( fp );
               SHIP_DATA *target = get_ship( temp );

               ship->target2 = target;
               STRFREE( temp );
               fMatch = TRUE;
               break;
            }
            break;

         case 'V':
            KEY( "VX", ship->vx, ( float )fread_number( fp ) );
            KEY( "VY", ship->vy, ( float )fread_number( fp ) );
            KEY( "VZ", ship->vz, ( float )fread_number( fp ) );
            break;

      }
      if( !fMatch && str_cmp( word, "End" ) )
         bug( "%s: no match: %s", __FUNCTION__, word );
   }
   return NULL;
}
Exemplo n.º 25
0
void do_mposet( CHAR_DATA * ch, const char *argument )
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	char arg3[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	OBJ_DATA *obj;
	char outbuf[MAX_STRING_LENGTH];
	int value, tmp;

	/*
	 * A desc means switched.. too many loopholes if we allow that.. 
	 */
	if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc )
	{
		send_to_char( "Huh?\r\n", ch );
		return;
	}

	smash_tilde( argument );

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH );

	if ( !*arg1 )
	{
		progbug( "MpOset: no args", ch );
		return;
	}

	if ( ( obj = get_obj_here( ch, arg1 ) ) == NULL )
	{
		progbug( "MpOset: no object", ch );
		return;
	}

	if ( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) )
	{
		progbug( "MpOset: can't set prototype items", ch );
		return;
	}
	separate_obj( obj );
	value = atoi( arg3 );

	if ( !str_cmp( arg2, "value0" ) || !str_cmp( arg2, "v0" ) )
	{
		obj->value[0] = value;
		return;
	}

	if ( !str_cmp( arg2, "value1" ) || !str_cmp( arg2, "v1" ) )
	{
		obj->value[1] = value;
		return;
	}

	if ( !str_cmp( arg2, "value2" ) || !str_cmp( arg2, "v2" ) )
	{
		obj->value[2] = value;
		return;
	}

	if ( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) )
	{
		obj->value[3] = value;
		return;
	}

	if ( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) )
	{
		obj->value[4] = value;
		return;
	}

	if ( !str_cmp( arg2, "value5" ) || !str_cmp( arg2, "v5" ) )
	{
		obj->value[5] = value;
		return;
	}

	if ( !str_cmp( arg2, "type" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no type", ch );
			return;
		}
		value = get_otype( argument );
		if ( value < 1 )
		{
			progbug( "MpOset: Invalid type", ch );
			return;
		}
		obj->item_type = ( short ) value;
		return;
	}

	if ( !str_cmp( arg2, "flags" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no flags", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_oflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpOset: Invalid flag", ch );
			else
			{
				if ( value == ITEM_PROTOTYPE )
					progbug( "MpOset: can't set prototype flag", ch );
				else
					xTOGGLE_BIT( obj->extra_flags, value );
			}
		}
		return;
	}

	if ( !str_cmp( arg2, "wear" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no wear", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_wflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpOset: Invalid wear", ch );
			else
				TOGGLE_BIT( obj->wear_flags, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "level" ) )
	{
		obj->level = value;
		return;
	}

	if ( !str_cmp( arg2, "weight" ) )
	{
		obj->weight = value;
		return;
	}

	if ( !str_cmp( arg2, "cost" ) )
	{
		obj->cost = value;
		return;
	}

	if ( !str_cmp( arg2, "timer" ) )
	{
		obj->timer = value;
		return;
	}

	if ( !str_cmp( arg2, "name" ) )
	{
		STRFREE( obj->name );
		obj->name = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "short" ) )
	{
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( arg3 );

		if ( obj == supermob_obj )
		{
			STRFREE( supermob->short_descr );
			supermob->short_descr = QUICKLINK( obj->short_descr );
		}

		/*
		 * Feature added by Narn, Apr/96 
		 * * If the item is not proto, add the word 'rename' to the keywords
		 * * if it is not already there.
		 */
		if ( str_infix( "mprename", obj->name ) )
		{
			snprintf( buf, MAX_STRING_LENGTH, "%s %s", obj->name, "mprename" );
			STRFREE( obj->name );
			obj->name = STRALLOC( buf );
		}
		return;
	}

	if ( !str_cmp( arg2, "long" ) )
	{
		STRFREE( obj->description );
		mudstrlcpy( buf, arg3, MAX_STRING_LENGTH );
		obj->description = STRALLOC( buf );
		return;
	}

	if ( !str_cmp( arg2, "actiondesc" ) )
	{
		if ( strstr( arg3, "%n" ) || strstr( arg3, "%d" ) || strstr( arg3, "%l" ) )
		{
			progbug( "MpOset: Illegal actiondesc", ch );
			return;
		}
		STRFREE( obj->action_desc );
		obj->action_desc = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "affect" ) )
	{
		AFFECT_DATA *paf;
		short loc;
		int bitv;

		argument = one_argument( argument, arg2 );
		if ( arg2[0] == '\0' || !argument || argument[0] == 0 )
		{
			progbug( "MpOset: Bad affect syntax", ch );
			send_to_char( "Usage: oset <object> affect <field> <value>\r\n", ch );
			return;
		}
		loc = get_atype( arg2 );
		if ( loc < 1 )
		{
			progbug( "MpOset: Invalid affect field", ch );
			return;
		}
		if ( loc >= APPLY_AFFECT && loc < APPLY_WEAPONSPELL )
		{
			bitv = 0;
			while ( argument[0] != '\0' )
			{
				argument = one_argument( argument, arg3 );
				if ( loc == APPLY_AFFECT )
					value = get_aflag( arg3 );
				else
					value = get_risflag( arg3 );
				if ( value < 0 || value > 31 )
					progbug( "MpOset: bad affect flag", ch );
				else
					SET_BIT( bitv, 1 << value );
			}
			if ( !bitv )
				return;
			value = bitv;
		}
		else
		{
			argument = one_argument( argument, arg3 );
			value = atoi( arg3 );
		}
		CREATE( paf, AFFECT_DATA, 1 );
		paf->type = -1;
		paf->duration = -1;
		paf->location = loc;
		paf->modifier = value;
		xCLEAR_BITS( paf->bitvector );
		paf->next = NULL;
		LINK( paf, obj->first_affect, obj->last_affect, next, prev );
		++top_affect;
		return;
	}

	if ( !str_cmp( arg2, "rmaffect" ) )
	{
		AFFECT_DATA *paf;
		short loc, count;

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no rmaffect", ch );
			return;
		}
		loc = atoi( argument );
		if ( loc < 1 )
		{
			progbug( "MpOset: Invalid rmaffect", ch );
			return;
		}

		count = 0;

		for ( paf = obj->first_affect; paf; paf = paf->next )
		{
			if ( ++count == loc )
			{
				UNLINK( paf, obj->first_affect, obj->last_affect, next, prev );
				DISPOSE( paf );
				send_to_char( "Removed.\r\n", ch );
				--top_affect;
				return;
			}
		}
		progbug( "MpOset: rmaffect not found", ch );
		return;
	}

	/*
	 * save some finger-leather
	 */
	if ( !str_cmp( arg2, "ris" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "r" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "i" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "s" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "ri" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "rs" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "is" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	/*
	 * Make it easier to set special object values by name than number
	 *                  -Thoric
	 */
	tmp = -1;
	switch ( obj->item_type )
	{
		case ITEM_WEAPON:
			if ( !str_cmp( arg2, "weapontype" ) )
			{
				unsigned int x;

				value = -1;
				for ( x = 0; x < sizeof( attack_table ) / sizeof( attack_table[0] ); x++ )
					if ( !str_cmp( arg3, attack_table[x] ) )
						value = x;
				if ( value < 0 )
				{
					progbug( "MpOset: Invalid weapon type", ch );
					return;
				}
				tmp = 3;
				break;
			}
			if ( !str_cmp( arg2, "condition" ) )
				tmp = 0;
			break;
		case ITEM_ARMOR:
			if ( !str_cmp( arg2, "condition" ) )
				tmp = 3;
			if ( !str_cmp( arg2, "ac" ) )
				tmp = 1;
			break;
		case ITEM_SALVE:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "maxdoses" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "doses" ) )
				tmp = 2;
			if ( !str_cmp( arg2, "delay" ) )
				tmp = 3;
			if ( !str_cmp( arg2, "spell1" ) )
				tmp = 4;
			if ( !str_cmp( arg2, "spell2" ) )
				tmp = 5;
			if ( tmp >= 4 && tmp <= 5 )
				value = skill_lookup( arg3 );
			break;
		case ITEM_SCROLL:
		case ITEM_POTION:
		case ITEM_PILL:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "spell1" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "spell2" ) )
				tmp = 2;
			if ( !str_cmp( arg2, "spell3" ) )
				tmp = 3;
			if ( tmp >= 1 && tmp <= 3 )
				value = skill_lookup( arg3 );
			break;
		case ITEM_STAFF:
		case ITEM_WAND:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "spell" ) )
			{
				tmp = 3;
				value = skill_lookup( arg3 );
			}
			if ( !str_cmp( arg2, "maxcharges" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "charges" ) )
				tmp = 2;
			break;
		case ITEM_CONTAINER:
			if ( !str_cmp( arg2, "capacity" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "cflags" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "key" ) )
				tmp = 2;
			break;
		case ITEM_SWITCH:
		case ITEM_LEVER:
		case ITEM_PULLCHAIN:
		case ITEM_BUTTON:
			if ( !str_cmp( arg2, "tflags" ) )
			{
				tmp = 0;
				value = get_trigflag( arg3 );
			}
			break;
	}
	if ( tmp >= 0 && tmp <= 3 )
	{
		obj->value[tmp] = value;
		return;
	}

	progbug( "MpOset: Invalid field", ch );
	return;
}
Exemplo n.º 26
0
void do_mapout( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_INPUT_LENGTH];
   OBJ_DATA *map_obj;   /* an obj made with map as an ed */
   OBJ_INDEX_DATA *map_obj_index;   /*    obj_index for previous     */
   EXTRA_DESCR_DATA *ed;   /*    the ed for it to go in     */
   int rooms, rows, cols, avail_rooms;

   if( !ch )
   {
      bug( "%s", "do_mapout: null ch" );
      return;
   }
   if( IS_NPC( ch ) )
   {
      send_to_char( "Not in mobs.\r\n", ch );
      return;
   }
   if( !ch->desc )
   {
      bug( "%s", "do_mapout: no descriptor" );
      return;
   }
   switch ( ch->substate )
   {
      default:
         break;
      case SUB_WRITING_NOTE:
         if( ch->dest_buf != ch->pnote )
            bug( "%s", "do_mapout: sub_writing_map: ch->dest_buf != ch->pnote" );
         STRFREE( ch->pnote->text );
         ch->pnote->text = copy_buffer( ch );
         stop_editing( ch );
         return;
   }

   set_char_color( AT_NOTE, ch );
   argument = one_argument( argument, arg );
   smash_tilde( argument );

   if( !str_cmp( arg, "stat" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      map_stats( ch, &rooms, &rows, &cols );
      ch_printf( ch, "Map represents %d rooms, %d rows, and %d columns\r\n", rooms, rows, cols );
      avail_rooms = num_rooms_avail( ch );
      ch_printf( ch, "You currently have %d unused rooms.\r\n", avail_rooms );
      act( AT_ACTION, "$n glances at an etherial map.", ch, NULL, NULL, TO_ROOM );
      return;
   }


   if( !str_cmp( arg, "write" ) )
   {
      note_attach( ch );
      ch->substate = SUB_WRITING_NOTE;
      ch->dest_buf = ch->pnote;
      start_editing( ch, ch->pnote->text );
      return;
   }
   if( !str_cmp( arg, "clear" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress\r\n", ch );
         return;
      }
      STRFREE( ch->pnote->text );
      STRFREE( ch->pnote->subject );
      STRFREE( ch->pnote->to_list );
      STRFREE( ch->pnote->date );
      STRFREE( ch->pnote->sender );
      DISPOSE( ch->pnote );
      ch->pnote = NULL;
      send_to_char( "Map cleared.\r\n", ch );
      return;
   }
   if( !str_cmp( arg, "show" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      send_to_char( ch->pnote->text, ch );
      do_mapout( ch, "stat" );
      return;
   }
   if( !str_cmp( arg, "create" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      map_stats( ch, &rooms, &rows, &cols );
      avail_rooms = num_rooms_avail( ch );

      /*
       * check for not enough rooms 
       */
      if( rooms > avail_rooms )
      {
         send_to_char( "You don't have enough unused rooms allocated!\r\n", ch );
         return;
      }
      act( AT_ACTION, "$n warps the very dimensions of space!", ch, NULL, NULL, TO_ROOM );

      map_to_rooms( ch, NULL );  /* this does the grunt work */

      map_obj_index = get_obj_index( 91 );
      if( map_obj_index )
      {
         map_obj = create_object( map_obj_index, 0 );
         ed = SetOExtra( map_obj, "runes map scrawls" );
         STRFREE( ed->description );
         ed->description = QUICKLINK( ch->pnote->text );
         obj_to_char( map_obj, ch );
      }
      else
      {
         send_to_char( "Couldn't give you a map object.  Need Great Eastern Desert\r\n", ch );
         return;
      }

      do_mapout( ch, "clear" );
      send_to_char( "Ok.\r\n", ch );
      return;
   }
   send_to_char( "mapout write: create a map in edit buffer.\r\n", ch );
   send_to_char( "mapout stat: get information about a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout clear: clear a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout show: show a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout create: turn a written map into rooms in your assigned room vnum range.\r\n", ch );
   return;
}
Exemplo n.º 27
0
void do_setquest( CHAR_DATA *ch, char *argument )
{
    char                    arg1[MIL],
                            arg2[MIL],
                            arg3[MIL],
                            arg4[MIL];
    QUEST_DATA             *quest;
    int                     x;

    set_char_color( AT_PLAIN, ch );

    if ( IS_NPC( ch ) ) {
        error( ch );
        return;
    }

    if ( !IS_IMMORTAL( ch ) ) {
        error( ch );
        return;
    }

    if ( !ch->desc ) {
        bug( "%s", "do_setquest (desc): no descriptor" );
        return;
    }

    switch ( ch->substate ) {
        default:
            break;

        case SUB_QUEST_DESC:
            if ( !ch->dest_buf || !( quest = ( QUEST_DATA * ) ch->dest_buf ) ) {
                bug( "%s: sub_quest_desc: NULL ch->dest_buf", __FUNCTION__ );
                ch->substate = SUB_NONE;
                return;
            }
            ch->dest_buf = NULL;
            if ( VLD_STR( quest->desc ) )
                STRFREE( quest->desc );
            quest->desc = copy_buffer( ch );
            stop_editing( ch );
            write_quest_list(  );
            ch->substate = SUB_NONE;
            return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( arg1[0] == '\0' ) {
        send_to_char( "&cUsage: setquest save all\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> create\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> delete\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> chapter <#> delete\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> desc\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> <&Cfield&c>\r\n", ch );
        send_to_char( "       setquest <&Cquest&c> remove <&Cplayer&c>\r\n", ch );
        send_to_char( "       showquest <&Cqname&c>\r\n", ch );
        send_to_char( "  Field being one of:\r\n", ch );
        send_to_char( "level svnum stype chapters chapter timelimit skipchapters glory\r\n", ch );
        send_to_char( "\r\nchapter <n> <field2>\r\n", ch );
        send_to_char( "  Field2 being one of:\r\n", ch );
        send_to_char( "create delete svnum stype\r\n", ch );
        send_to_char( "name timelimit level kamount\r\n", ch );
        send_to_char( "Note: 3600 = 1 hour timelimit\r\n", ch );
        return;
    }

    if ( ( !str_cmp( arg1, "tutorial" ) && ch->level < 108 )
         || ( !str_cmp( arg1, "etutorial" ) && ch->level < 108 ) || ( !str_cmp( arg1, "dtutorial" )
                                                                      && ch->level < 108 ) ) {
        send_to_char( "You need Vladaar's permission to change anything with tutorials.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg1, "save" ) ) {
        if ( !str_cmp( arg2, "all" ) ) {
            write_quest_list(  );
            send_to_char( "All quests saved.\r\n", ch );
            return;
        }
    }

    quest = get_quest_from_name( arg1 );

    if ( !str_cmp( arg2, "create" ) ) {
        if ( quest && VLD_STR( quest->name ) && !str_cmp( quest->name, arg1 ) ) {
            ch_printf( ch, "(%s): quest already exists!\r\n", quest->name );
            return;
        }

        CREATE( quest, QUEST_DATA, 1 );
        quest->name = STRALLOC( arg1 );
        quest->number = -1;
        add_new_quest( ch, quest );
        write_quest_list(  );
        return;
    }

    if ( !quest ) {
        send_to_char( "No quest by that name.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "desc" ) ) {
        if ( !ch->desc ) {
            bug( "%s", "do_setquest (desc): no descriptor" );
            return;
        }

        ch->substate = SUB_QUEST_DESC;
        ch->dest_buf = quest;
        start_editing( ch, quest->desc );
        return;
    }

    if ( !str_cmp( arg2, "delete" ) ) {
        free_quest( quest );
        send_to_char( "Deleted.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "skipchapters" ) ) {
        quest->skipchapters = !quest->skipchapters;
        ch_printf( ch, "That quest will %s allow chapters to be skipped.\r\n",
                   quest->skipchapters ? "now" : "no longer" );
        return;
    }

    if ( !str_cmp( arg2, "chapters" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 30 ) {
            send_to_char( "Chapters must be between 0 and 30.\r\n", ch );
            return;
        }
        quest->chapters = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "svnum" ) ) {
        quest->svnum = atoi( argument );
        ch_printf( ch, "That quest's svnum (starting vnum) is set to %d.\r\n", quest->svnum );
        return;
    }

    if ( !str_cmp( arg2, "stype" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 2 ) {
            send_to_char
                ( "Can only set stype (starting type) to 0 for Mobiles, 1 for Objects, 2 for Rooms.\r\n",
                  ch );
            return;
        }
        quest->stype = x;
        ch_printf( ch, "That quest's stype (starting type) is set to %d[%s].\r\n", quest->stype,
                   ( quest->stype == 0 ) ? "Mobile" : ( quest->stype ==
                                                        1 ) ? "Object" : ( quest->stype ==
                                                                           2 ) ? "Room" :
                   "Unknown" );
        return;
    }

    if ( !str_cmp( arg2, "glory" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 1 ) {
            send_to_char( "Can only set 0 for no glory, or 1 for glory.\r\n", ch );
            return;
        }
        quest->glory = x;
        return;
    }

    if ( !str_cmp( arg2, "chapter" ) ) {
        CHAP_DATA              *chap = NULL;

        argument = one_argument( argument, arg3 );
        argument = one_argument( argument, arg4 );

        int                     chapno = atoi( arg3 );

        if ( chapno < 1 || chapno > MAX_CHAPTERS ) {
            ch_printf( ch, "Chapter range is 1 to %d.\r\n", MAX_CHAPTERS );
            return;
        }

        if ( !str_cmp( arg4, "create" ) ) {
            if ( get_chap_from_quest( chapno, quest ) ) {
                send_to_char( "That chapter already exists!\r\n", ch );
                return;
            }

            if ( !get_chap_from_quest( ( chapno - 1 ), quest ) && chapno > 1 ) {
                ch_printf( ch, "How can you create chapter %d before chapter %d even exists?\r\n",
                           chapno, chapno - 1 );
                return;
            }
            if ( chapno > quest->chapters ) {
                ch_printf( ch, "How can you create chapter %d when there are only %d chapters?\r\n",
                           chapno, quest->chapters );
                send_to_char( "Set more - 'setquest (questname) chapters (number)'.\r\n", ch );
                return;
            }
            CREATE( chap, CHAP_DATA, 1 );
            chap->number = chapno;
            add_chapter( quest, chap );
            send_to_char( "New chapter added.\r\n", ch );
            write_quest_list(  );
            return;
        }

        chap = get_chap_from_quest( chapno, quest );

        if ( !chap ) {
            send_to_char( "No such chapter.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "delete" ) ) {
            free_chapter( quest, chap );
            send_to_char( "Chapter Deleted.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "name" ) ) {
            if ( VLD_STR( chap->desc ) )
                STRFREE( chap->desc );
            if ( VLD_STR( argument ) ) {
                if ( strlen( argument ) > 50 )
                    argument[50] = '\0';
                chap->desc = STRALLOC( argument );
            }
            write_quest_list(  );
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "timelimit" ) ) {
            x = atoi( argument );

            if ( x < 0 || x > 3600 ) {
                send_to_char( "Time limit is between 0 and 3600 (one hour).\r\n", ch );
                return;
            }

            chap->timelimit = x;
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "kamount" ) ) {
            int                     kamount = atoi( argument );

            if ( kamount < 0 ) {
                send_to_char( "You have to set kamount to 0 or higher.\r\n", ch );
                return;
            }
            chap->kamount = kamount;
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "level" ) ) {
            int                     level = atoi( argument );

            if ( level < 0 || level > MAX_LEVEL ) {
                ch_printf( ch, "Level range is between 0 and %d.\r\n", MAX_LEVEL );
                return;
            }

            chap->level = level;
            send_to_char( "Done.\r\n", ch );
            return;
        }
        do_setquest( ch, ( char * ) "" );
        return;
    }

    if ( !str_cmp( arg2, "level" ) ) {
        x = atoi( argument );
        if ( x < 1 || x > MAX_LEVEL ) {
            send_to_char( "Quest level must be between 1 and max.\r\n", ch );
            return;
        }
        quest->level = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "timelimit" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 3600 ) {
            send_to_char
                ( "Quest time limit must be between 0 (no timer) and 3600 seconds (1 hour).\r\n",
                  ch );
            return;
        }
        quest->timelimit = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "remove" ) ) {
        CHAR_DATA              *victim;
        CHQUEST_DATA           *chquest;

        if ( ( victim = get_char_world( ch, argument ) ) != NULL && !IS_NPC( victim ) ) {
            x = get_number_from_quest( quest );
            for ( chquest = victim->pcdata->first_quest; chquest; chquest = chquest->next ) {
                if ( chquest->questnum != quest->number )
                    continue;
                UNLINK( chquest, victim->pcdata->first_quest, victim->pcdata->last_quest, next,
                        prev );
                DISPOSE( chquest );
                ch_printf( ch, "You remove quest %s from %s.\r\n", quest->name, victim->name );
                ch_printf( victim, "Quest %s has been removed from your journal.\r\n",
                           quest->name );
                return;
            }
            send_to_char( "That player isn't currently on that quest.\r\n", ch );
            return;
        }
        else
            send_to_char( "That player isn't currently online.\r\n", ch );
        return;
    }

    do_setquest( ch, ( char * ) "" );
    return;
}
Exemplo n.º 28
0
/* Set slay values online - Samson 8-3-98 */
void do_setslay( CHAR_DATA * ch, char *argument )
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   SLAY_DATA *slay;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   switch ( ch->substate )
   {
      default:
         break;

      case SUB_RESTRICTED:
         send_to_char( "You cannot do this while in another command.\r\n", ch );
         return;

      case SUB_SLAYCMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->cmsg );
         slay->cmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
      case SUB_SLAYVMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->vmsg );
         slay->vmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
      case SUB_SLAYRMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->rmsg );
         slay->rmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
   }

   smash_tilde( argument );
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1[0] == '\0' )
   {
      send_to_char( "Usage: setslay <slaytype> <field> <value>\r\n", ch );
      send_to_char( "Usage: setslay save\r\n", ch );
      send_to_char( "\r\nField being one of:\r\n", ch );
      send_to_char( "owner color cmsg vmsg rmsg\r\n", ch );
      return;
   }

   if( !str_cmp( arg1, "save" ) )
   {
      save_slays(  );
      send_to_char( "Slay table saved.\r\n", ch );
      return;
   }

   if( ( slay = get_slay( arg1 ) ) == NULL )
   {
      send_to_char( "No such slaytype.\r\n", ch );
      return;
   }

   if( !str_cmp( arg2, "owner" ) )
   {
      STRFREE( slay->owner );
      slay->owner = STRALLOC( argument );
      send_to_char( "New owner set.\r\n", ch );
      save_slays(  );
      return;
   }

   if( !str_cmp( arg2, "cmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYCMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->cmsg );
      return;
   }

   if( !str_cmp( arg2, "vmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYVMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->vmsg );
      return;
   }

   if( !str_cmp( arg2, "rmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYRMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->rmsg );
      return;
   }

   if( !str_cmp( arg2, "color" ) )
   {
      slay->color = atoi( argument );
      send_to_char( "Slay color set.\r\n", ch );
      save_slays(  );
      return;
   }

   do_setslay( ch, "" );
   return;
}
Exemplo n.º 29
0
CHAR_DATA *load_mobile( FILE * fp )
{
   CHAR_DATA *mob = NULL;
   const char *word;
   bool fMatch;
   int inroom = 0;
   ROOM_INDEX_DATA *pRoomIndex = NULL;

   word = feof( fp ) ? "EndMobile" : fread_word( fp );
   if( !str_cmp( word, "Vnum" ) )
   {
      int vnum;

      vnum = fread_number( fp );
      if( get_mob_index( vnum ) == NULL )
      {
         bug( "%s: No index data for vnum %d", __FUNCTION__, vnum );
         return NULL;
      }
      mob = create_mobile( get_mob_index( vnum ) );
      if( !mob )
      {
         for( ;; )
         {
            word = feof( fp ) ? "EndMobile" : fread_word( fp );
            /*
             * So we don't get so many bug messages when something messes up
             * * --Shaddai 
             */
            if( !str_cmp( word, "EndMobile" ) )
               break;
         }
         bug( "%s: Unable to create mobile for vnum %d", __FUNCTION__, vnum );
         return NULL;
      }
   }
   else
   {
      for( ;; )
      {
         word = feof( fp ) ? "EndMobile" : fread_word( fp );
         /*
          * So we don't get so many bug messages when something messes up
          * * --Shaddai 
          */
         if( !str_cmp( word, "EndMobile" ) )
            break;
      }
      extract_char( mob, TRUE );
      bug( "%s: Vnum not found", __FUNCTION__ );
      return NULL;
   }

   for( ;; )
   {
      word = feof( fp ) ? "EndMobile" : fread_word( fp );
      fMatch = FALSE;
      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case '#':
            if( !str_cmp( word, "#OBJECT" ) )
            {
               mob->tempnum = -9999;   /* Hackish, yes. Works though doesn't it? */
               fread_obj( mob, fp, OS_CARRY );
            }
            break;

         case 'A':
            if( !str_cmp( word, "Affect" ) || !str_cmp( word, "AffectData" ) )
            {
               AFFECT_DATA *paf;

               CREATE( paf, AFFECT_DATA, 1 );
               if( !str_cmp( word, "Affect" ) )
               {
                  paf->type = fread_number( fp );
               }
               else
               {
                  int sn;
                  const char *sname = fread_word( fp );

                  if( ( sn = skill_lookup( sname ) ) < 0 )
                  {
                     if( ( sn = herb_lookup( sname ) ) < 0 )
                        bug( "%s", "load_mobile: unknown skill." );
                     else
                        sn += TYPE_HERB;
                  }
                  paf->type = sn;
               }

               paf->duration = fread_number( fp );
               paf->modifier = fread_number( fp );
               paf->location = fread_number( fp );
               if( paf->location == APPLY_WEAPONSPELL
                   || paf->location == APPLY_WEARSPELL
                   || paf->location == APPLY_REMOVESPELL || paf->location == APPLY_STRIPSN )
                  paf->modifier = slot_lookup( paf->modifier );
               paf->bitvector = fread_bitvector( fp );
               LINK( paf, mob->first_affect, mob->last_affect, next, prev );
               fMatch = TRUE;
               break;
            }
            KEY( "AffectedBy", mob->affected_by, fread_bitvector( fp ) );
            break;

#ifdef OVERLANDCODE
         case 'C':
            if( !str_cmp( word, "Coordinates" ) )
            {
               mob->x = fread_number( fp );
               mob->y = fread_number( fp );
               mob->map = fread_number( fp );

               fMatch = TRUE;
               break;
            }
            break;
#endif

         case 'D':
            if( !str_cmp( word, "Description" ) )
            {
               STRFREE( mob->description );
               mob->description = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            break;

         case 'E':
            if( !str_cmp( word, "EndMobile" ) )
            {
               if( inroom == 0 )
                  inroom = ROOM_VNUM_LIMBO;
               pRoomIndex = get_room_index( inroom );
               if( !pRoomIndex )
                  pRoomIndex = get_room_index( ROOM_VNUM_LIMBO );
               char_to_room( mob, pRoomIndex );
               mob->tempnum = -9998;   /* Yet another hackish fix! */
               update_room_reset( mob, FALSE );
               return mob;
            }
            if( !str_cmp( word, "End" ) ) /* End of object, need to ignore this. sometimes they creep in there somehow -- Scion */
               fMatch = TRUE; /* Trick the system into thinking it matched something */
            break;

         case 'F':
            KEY( "Flags", mob->act, fread_number( fp ) );
            break;

         case 'G':
            KEY( "Gold", mob->gold, fread_number( fp ) );
            break;

         case 'H':
            if( !str_cmp( word, "HpManaMove" ) )
            {
               mob->hit = fread_number( fp );
               mob->max_hit = fread_number( fp );
               mob->mana = fread_number( fp );
               mob->max_mana = fread_number( fp );
               mob->move = fread_number( fp );
               mob->max_move = fread_number( fp );

               if( mob->max_move <= 0 )
                  mob->max_move = 150;

               fMatch = TRUE;
               break;
            }
            break;

         case 'L':
            if( !str_cmp( word, "Long" ) )
            {
               STRFREE( mob->long_descr );
               mob->long_descr = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            KEY( "Level", mob->top_level, fread_number( fp ) );
            break;

         case 'M':
            if( !str_cmp( word, "Mobclan" ) )
            {
               STRFREE( mob->mob_clan );
               mob->mob_clan = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            break;

         case 'N':
            if( !str_cmp( word, "Name" ) )
            {
               STRFREE( mob->name );
               mob->name = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            break;

         case 'P':
            KEY( "Position", mob->position, fread_number( fp ) );
            break;

         case 'R':
            KEY( "Room", inroom, fread_number( fp ) );
            KEY( "Resetvnum", mob->resetvnum, fread_number( fp ) );
            KEY( "Resetnum", mob->resetnum, fread_number( fp ) );
            break;

         case 'S':
            if( !str_cmp( word, "Short" ) )
            {
               STRFREE( mob->short_descr );
               mob->short_descr = fread_string( fp );
               fMatch = TRUE;
               break;
            }
            break;
      }
      if( !fMatch && str_cmp( word, "End" ) )
         bug( "%s: no match: %s", __FUNCTION__, word );
   }
   return NULL;
}
Exemplo n.º 30
0
void do_mpmset( CHAR_DATA * ch, const char *argument )
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	char arg3[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	char log_buf[MAX_STRING_LENGTH];
	char outbuf[MAX_STRING_LENGTH];
	CHAR_DATA *victim;
	int value, v2;
	int minattr, maxattr;

	/*
	 * A desc means switched.. too many loopholes if we allow that.. 
	 */
	if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc )
	{
		send_to_char( "Huh?\r\n", ch );
		return;
	}

	smash_tilde( argument );

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH );

	if ( !*arg1 )
	{
		progbug( "MpMset: no args", ch );
		return;
	}

	if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
	{
		progbug( "MpMset: no victim", ch );
		return;
	}

	if ( IS_IMMORTAL( victim ) )
	{
		send_to_char( "You can't do that!\r\n", ch );
		return;
	}

	if ( IS_NPC( victim ) && xIS_SET( victim->act, ACT_PROTOTYPE ) )
	{
		progbug( "MpMset: victim is proto", ch );
		return;
	}

	if ( IS_NPC( victim ) )
	{
		minattr = 1;
		maxattr = 25;
	}
	else
	{
		minattr = 3;
		maxattr = 18;
	}

	value = is_number( arg3 ) ? atoi( arg3 ) : -1;
	if ( atoi( arg3 ) < -1 && value == -1 )
		value = atoi( arg3 );

	if ( !str_cmp( arg2, "str" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid str", ch );
			return;
		}
		victim->perm_str = value;
		return;
	}

	if ( !str_cmp( arg2, "int" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid int", ch );
			return;
		}
		victim->perm_int = value;
		return;
	}

	if ( !str_cmp( arg2, "wis" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid wis", ch );
			return;
		}
		victim->perm_wis = value;
		return;
	}

	if ( !str_cmp( arg2, "dex" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid dex", ch );
			return;
		}
		victim->perm_dex = value;
		return;
	}

	if ( !str_cmp( arg2, "con" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid con", ch );
			return;
		}
		victim->perm_con = value;
		return;
	}

	if ( !str_cmp( arg2, "cha" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid cha", ch );
			return;
		}
		victim->perm_cha = value;
		return;
	}

	if ( !str_cmp( arg2, "lck" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid lck", ch );
			return;
		}
		victim->perm_lck = value;
		return;
	}

	if ( !str_cmp( arg2, "sav1" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav1", ch );
			return;
		}
		victim->saving_poison_death = value;
		return;
	}

	if ( !str_cmp( arg2, "sav2" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav2", ch );
			return;
		}
		victim->saving_wand = value;
		return;
	}

	if ( !str_cmp( arg2, "sav3" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav3", ch );
			return;
		}
		victim->saving_para_petri = value;
		return;
	}

	if ( !str_cmp( arg2, "sav4" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav4", ch );
			return;
		}
		victim->saving_breath = value;
		return;
	}

	if ( !str_cmp( arg2, "sav5" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav5", ch );
			return;
		}
		victim->saving_spell_staff = value;
		return;
	}

	if ( !str_cmp( arg2, "sex" ) )
	{
		if ( value < 0 || value > 2 )
		{
			progbug( "MpMset: Invalid sex", ch );
			return;
		}
		victim->sex = value;
		return;
	}

	if ( !str_cmp( arg2, "class" ) )
	{
		if ( IS_NPC( victim ) )	/* Broken by Haus... fixed by Thoric */
		{
			if ( value >= MAX_NPC_CLASS || value < 0 )
			{
				progbug( "MpMset: Invalid npc class", ch );
				return;
			}
			victim->Class = value;
			return;
		}
		progbug( "MpMset: can't set pc class", ch );
	}

	if ( !str_cmp( arg2, "race" ) )
	{
		value = get_npc_race( arg3 );
		if ( value < 0 )
			value = atoi( arg3 );
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc race", ch );
			return;
		}
		if ( value < 0 || value >= MAX_NPC_RACE )
		{
			progbug( "MpMset: Invalid npc race", ch );
			return;
		}
		victim->race = value;
		return;
	}

	if ( !str_cmp( arg2, "armor" ) )
	{
		if ( value < -300 || value > 300 )
		{
			send_to_char( "AC range is -300 to 300.\r\n", ch );
			return;
		}
		victim->armor = value;
		return;
	}

	if ( !str_cmp( arg2, "level" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc level", ch );
			return;
		}

		if ( value < 0 || value > LEVEL_AVATAR + 5 )
		{
			progbug( "MpMset: Invalid npc level", ch );
			return;
		}
		victim->level = value;
		return;
	}

	if ( !str_cmp( arg2, "numattacks" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc numattacks", ch );
			return;
		}

		if ( value < 0 || value > 20 )
		{
			progbug( "MpMset: Invalid npc numattacks", ch );
			return;
		}
		victim->numattacks = value;
		return;
	}

	if ( !str_cmp( arg2, "gold" ) )
	{
		victim->gold = value;
		return;
	}

	if ( !str_cmp( arg2, "hitroll" ) )
	{
		victim->hitroll = URANGE( 0, value, 85 );
		return;
	}

	if ( !str_cmp( arg2, "damroll" ) )
	{
		victim->damroll = URANGE( 0, value, 65 );
		return;
	}

	if ( !str_cmp( arg2, "hp" ) )
	{
		if ( value < 1 || value > 32700 )
		{
			progbug( "MpMset: Invalid hp", ch );
			return;
		}
		victim->max_hit = value;
		return;
	}

	if ( !str_cmp( arg2, "mana" ) )
	{
		if ( value < 0 || value > 30000 )
		{
			progbug( "MpMset: Invalid mana", ch );
			return;
		}
		victim->max_mana = value;
		return;
	}

	if ( !str_cmp( arg2, "move" ) )
	{
		if ( value < 0 || value > 30000 )
		{
			progbug( "MpMset: Invalid move", ch );
			return;
		}
		victim->max_move = value;
		return;
	}

	if ( !str_cmp( arg2, "practice" ) )
	{
		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid practice", ch );
			return;
		}
		victim->practice = value;
		return;
	}

	if ( !str_cmp( arg2, "align" ) )
	{
		if ( value < -1000 || value > 1000 )
		{
			progbug( "MpMset: Invalid align", ch );
			return;
		}
		victim->alignment = value;
		return;
	}

/* non-functional for now -- Blod
    if ( !str_cmp( arg2, "quest" ) )
    {
	if ( IS_NPC(victim) )
	{
	    progbug("MpMset: can't set npc quest", ch);
	    return;
	}

	if ( value < 0 || value > 500 )
	{
	    progbug("MpMset: Invalid pc quest", ch);
	    return;
	}

	victim->pcdata->quest = value;
	return;
    }
*/

	if ( !str_cmp( arg2, "questplus" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc qp", ch );
			return;
		}

		if ( value < 0 || value > 5000 )
		{
			progbug( "MpMset: Invalid pc qp", ch );
			return;
		}
		snprintf( log_buf, MAX_STRING_LENGTH, "%s raising glory of %s by %d ...", ch->name, victim->name, value );
		log_string( log_buf );
		victim->pcdata->quest_curr += value;
		victim->pcdata->quest_accum += value;
		return;
	}

	if ( !str_cmp( arg2, "favor" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc favor", ch );
			return;
		}

		if ( value < -2500 || value > 2500 )
		{
			progbug( "MpMset: Invalid pc favor", ch );
			return;
		}

		victim->pcdata->favor = value;
		return;
	}

	if ( !str_cmp( arg2, "mentalstate" ) )
	{
		if ( value < -100 || value > 100 )
		{
			progbug( "MpMset: Invalid mentalstate", ch );
			return;
		}
		victim->mental_state = value;
		return;
	}

	if ( !str_cmp( arg2, "emotion" ) )
	{
		if ( value < -100 || value > 100 )
		{
			progbug( "MpMset: Invalid emotion", ch );
			return;
		}
		victim->emotional_state = value;
		return;
	}

	if ( !str_cmp( arg2, "thirst" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc thirst", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc thirst", ch );
			return;
		}

		victim->pcdata->condition[COND_THIRST] = value;
		return;
	}

	if ( !str_cmp( arg2, "drunk" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc drunk", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc drunk", ch );
			return;
		}

		victim->pcdata->condition[COND_DRUNK] = value;
		return;
	}

	if ( !str_cmp( arg2, "full" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc full", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc full", ch );
			return;
		}

		victim->pcdata->condition[COND_FULL] = value;
		return;
	}

	if ( !str_cmp( arg2, "blood" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc blood", ch );
			return;
		}

		if ( value < 0 || value > MAX_LEVEL + 10 )
		{
			progbug( "MpMset: Invalid pc blood", ch );
			return;
		}

		victim->pcdata->condition[COND_BLOODTHIRST] = value;
		return;
	}

	if ( !str_cmp( arg2, "name" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc name", ch );
			return;
		}

		STRFREE( victim->name );
		victim->name = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "deity" ) )
	{
		DEITY_DATA *deity;

		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc deity", ch );
			return;
		}

		if ( arg3[0] == '\0' )
		{
			STRFREE( victim->pcdata->deity_name );
			victim->pcdata->deity_name = STRALLOC( "" );
			victim->pcdata->deity = NULL;
			return;
		}

		deity = get_deity( arg3 );
		if ( !deity )
		{
			progbug( "MpMset: Invalid deity", ch );
			return;
		}
		STRFREE( victim->pcdata->deity_name );
		victim->pcdata->deity_name = QUICKLINK( deity->name );
		victim->pcdata->deity = deity;
		return;
	}

	if ( !str_cmp( arg2, "short" ) )
	{
		STRFREE( victim->short_descr );
		victim->short_descr = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "long" ) )
	{
		STRFREE( victim->long_descr );
		mudstrlcpy( buf, arg3, MAX_STRING_LENGTH );
		mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH );
		victim->long_descr = STRALLOC( buf );
		return;
	}

	if ( !str_cmp( arg2, "title" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc title", ch );
			return;
		}

		set_title( victim, arg3 );
		return;
	}

	if ( !str_cmp( arg2, "spec" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc spec", ch );
			return;
		}

		if ( !str_cmp( arg3, "none" ) )
		{
			victim->spec_fun = NULL;
			return;
		}

		if ( ( victim->spec_fun = spec_lookup( arg3 ) ) == 0 )
		{
			progbug( "MpMset: Invalid spec", ch );
			return;
		}
		return;
	}

	if ( !str_cmp( arg2, "flags" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc flags", ch );
			return;
		}

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no flags", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_actflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid flag", ch );
			else
			{
				if ( value == ACT_PROTOTYPE )
					progbug( "MpMset: can't set prototype flag", ch );
				else if ( value == ACT_IS_NPC )
					progbug( "MpMset: can't remove npc flag", ch );
				else
					xTOGGLE_BIT( victim->act, value );
			}
		}
		return;
	}

	if ( !str_cmp( arg2, "affected" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't modify pc affected", ch );
			return;
		}

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no affected", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_aflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid affected", ch );
			else
				xTOGGLE_BIT( victim->affected_by, value );
		}
		return;
	}

	/*
	 * save some more finger-leather for setting RIS stuff
	 * Why there's can_modify checks here AND in the called function, Ill
	 * never know, so I removed them.. -- Alty
	 */
	if ( !str_cmp( arg2, "r" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "i" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "s" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "ri" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "rs" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "is" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "ris" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "resistant" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc resistant", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no resistant", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid resistant", ch );
			else
				TOGGLE_BIT( victim->resistant, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "immune" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc immune", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no immune", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid immune", ch );
			else
				TOGGLE_BIT( victim->immune, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "susceptible" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc susceptible", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no susceptible", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid susceptible", ch );
			else
				TOGGLE_BIT( victim->susceptible, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "part" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc part", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no part", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_partflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid part", ch );
			else
				TOGGLE_BIT( victim->xflags, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "attack" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc attack", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no attack", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_attackflag( arg3 );
			if ( value < 0 )
				progbug( "MpMset: Invalid attack", ch );
			else
				xTOGGLE_BIT( victim->attacks, value );
		}
		return;
	}

	if ( !str_cmp( arg2, "defense" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc defense", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no defense", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_defenseflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid defense", ch );
			else
				xTOGGLE_BIT( victim->defenses, value );
		}
		return;
	}

	if ( !str_cmp( arg2, "pos" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc pos", ch );
			return;
		}
		if ( value < 0 || value > POS_STANDING )
		{
			progbug( "MpMset: Invalid pos", ch );
			return;
		}
		victim->position = value;
		return;
	}

	if ( !str_cmp( arg2, "defpos" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc defpos", ch );
			return;
		}
		if ( value < 0 || value > POS_STANDING )
		{
			progbug( "MpMset: Invalid defpos", ch );
			return;
		}
		victim->defposition = value;
		return;
	}

	if ( !str_cmp( arg2, "speaks" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no speaks", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_langflag( arg3 );
			v2 = get_langnum( arg3 );
			if ( value == LANG_UNKNOWN )
				progbug( "MpMset: Invalid speaks", ch );
			else if ( !IS_NPC( victim ) )
			{
				if ( !( value &= VALID_LANGS ) )
				{
					progbug( "MpMset: Invalid player language", ch );
					continue;
				}
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
			else
			{
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
		}
		if ( !IS_NPC( victim ) )
		{
			REMOVE_BIT( victim->speaks, race_table[victim->race]->language );
			if ( !knows_language( victim, victim->speaking, victim ) )
				victim->speaking = race_table[victim->race]->language;
		}
		return;
	}

	if ( !str_cmp( arg2, "speaking" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc speaking", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no speaking", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_langflag( arg3 );
			if ( value == LANG_UNKNOWN )
				progbug( "MpMset: Invalid speaking", ch );
			else
			{
				v2 = get_langnum( arg3 );
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
		}
		return;
	}

	progbug( "MpMset: Invalid field", ch );
	return;
}