示例#1
0
/* xcatf a formated string */
void safe_strcatf( const char *file, const char *function, int line, int size, char *prev, char *next, ... )
{
   char buf[MAS];
   va_list args;

   va_start( args, next );
   vsnprintf( buf, MAS, next, args );
   va_end( args );

   /*
    * Max Alloc Size is allot!
    */
   if( size > MAS )
   {
      char egbug[MSL];
      log_string( LOG_BUG, "xcatf size greater then MAS!!!!\n\r" );
      log_string( LOG_BUG, "ERROR: System Memory Corrupted by Overflow, through xcatf.\n\r" );
      log_string( LOG_BUG, "Memcheck: xcatf:File %s, Function %s, Line %d.\n\r", file, function, line );
      xprintf( egbug, "Memcheck: System memory corrupted by overflow through xcatf: File: %s Function: %s Line: %d", file,
               function, line );
      wiznet( egbug, NULL, NULL, WIZ_MEMCHECK, 0, 0 );
      return;
   }

   if( ( unsigned )size < strlen( buf ) + 1 )
   {
      char egbug[MSL];
      log_string( LOG_BUG, "XCATF error: fmt %s.\n\r", next );
      log_string( LOG_BUG, "ERROR: System Memory Corrupted by Overflow, through xcatf.\n\r" );
      log_string( LOG_BUG, "Memcheck: xcatf: File %s, Function %s, Line %d.\n\r", file, function, line );
      /*
       * Yes, this is a potential loop bug if infact the xcatf does collapse in on itself..
       */
      xprintf( egbug, "Memcheck: System memory corrupted by overflow through xcatf: File: %s Function: %s Line: %d", file,
               function, line );
      wiznet( egbug, NULL, NULL, WIZ_MEMCHECK, 0, 0 );
      return;
   }

   mudstrlcat( prev, buf, size );

   /*
    * Just double checking.
    */
   if( strlen( prev ) > ( unsigned )size - 1 )
   {
      char egbug[MSL];
      log_string( LOG_BUG, "XCATF error: fmt %s.\n\r", next );
      log_string( LOG_BUG, "ERROR: System Memory Corrupted by Overflow, through xcatf.\n\r" );
      log_string( LOG_BUG, "Memcheck: Xcatf: File %s, Function %s, Line %d.\n\r", file, function, line );
      /*
       * Yes, this is a potential loop bug if infact the xcatf does collapse in on itself..
       */
      xprintf( egbug, "Memcheck: System memory corrupted by overflow through xcatf: File: %s Function: %s Line: %d", file,
               function, line );
      wiznet( egbug, NULL, NULL, WIZ_MEMCHECK, 0, 0 );
   }
}
示例#2
0
文件: guild.c 项目: michaelmwu/bota
void do_noclan( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH],buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
 
    one_argument( argument, arg );
 
    if ( arg[0] == '\0' )
    {
        send_to_char( "Noclan whom?\n\r", ch );
        return;
    }
       
    if ( ( victim = get_char_world( ch, arg ) ) == NULL )
    {
        send_to_char( "They aren't here.\n\r", ch );
        return;
    }
       
    if ( IS_NPC(victim) )
    {
        send_to_char( "Not on NPC's.\n\r", ch );
        return;
    }
       
    if ( get_trust( victim ) >= get_trust( ch ) )
    {
        send_to_char( "You failed.\n\r", ch );
        return;
    }
       
    if ( IS_SET(victim->act, PLR_NOCLAN) )
    {
        REMOVE_BIT(victim->act, PLR_NOCLAN);
        send_to_char( "NOCLAN removed.\n\r", ch );
        sprintf(buf,"$N allows %s to join pkill clans.",victim->name);
        wiznet(buf,ch,NULL,WIZ_PENALTIES,WIZ_SECURE,0);
    }
    else
    {
        SET_BIT(victim->act, PLR_NOCLAN);

        if(ch->clan)
        {
	    victim->clan = 0;
	    victim->rank = 0;
        }

        send_to_char( "NOCLAN set.\n\r", ch );
        sprintf(buf,"$N forbids %s to join pkill clans.",victim->name);
        wiznet(buf,ch,NULL,WIZ_PENALTIES,WIZ_SECURE,0);
    }
       
    save_char_obj( victim );
 
    return;
}
示例#3
0
//gdy gracz wywala artefakt to zdejmujemy go raz z listy
//ktos pozbyl sie artefaktu, wywalam go z listy raz
//znaczy zostaje na mudzie ale nie ma go gracz
void artefact_from_char( OBJ_DATA *obj, CHAR_DATA *ch )
{
	ARTEFACT_DATA * atmp = NULL;
	ARTEFACT_OWNER *otmp, *prev = NULL;

	for ( atmp = artefact_system;atmp;atmp = atmp->next )
	{
		if ( obj->pIndexData->vnum == atmp->avnum )
		{
			for ( otmp = atmp->first_owner;otmp;otmp = otmp->next )
			{
				if ( !strcmp( ch->name, otmp->owner ) )
				{
					if ( prev != NULL )
						prev->next = otmp->next;
					else
						atmp->first_owner = otmp->next;

					otmp->next = NULL;
					free_artefact_owner( otmp );


					wiznet( "$N {RSTRACIL(a){x artefakt : $p.", ch, obj, WIZ_ARTEFACT, 0, get_trust( ch ) );
					append_file_format_daily( ch, ARTEFACT_LOG_FILE, "-> STRACIL :%s vnum:%d count:%d max: %d (move)", obj->short_descr, atmp->avnum, atmp->count, atmp->max_count );
					return ;
				}
				else //to nie ten
					prev = otmp;
			}
		}
	}

}
示例#4
0
void gain_exp (CHAR_DATA * ch, int gain)
{
    char buf[MAX_STRING_LENGTH];

    if (IS_NPC (ch) || ch->level >= LEVEL_HERO)
        return;

    if(gain > 99)
    gain = 99;
    ch->exp += gain;

    while (ch->level < LEVEL_HERO && ch->exp >=
           exp_per_level (ch, ch->pcdata->points) * (ch->level + 1))
    {
        send_to_char ("{GYou raise a level!!  {x", ch);
        ch->level += 1;
        sprintf (buf, "%s gained level %d", ch->name, ch->level);
        log_string (buf);
        sprintf (buf, "$N has attained level %d!", ch->level);
        wiznet (buf, ch, NULL, WIZ_LEVELS, 0, 0);
        advance_level (ch, FALSE);
        save_char_obj (ch);
    }

    return;
}
示例#5
0
文件: ban.c 项目: rezalas/riftshadow
bool check_ban(char *usite,int type,int host)
{
    BAN_DATA *pban;
    char buf[MSL],site[MSL];
	int res=0;
	CRow row;

	strcpy(site,capitalize(usite));
    site[0] = LOWER(site[0]);


	
	res = RS.SQL.Select("site,duration FROM bans WHERE ban_type=%d AND host_type=%d", type,host);
	if(res)
	{
		while(!RS.SQL.End())
		{
			row = RS.SQL.GetRow();
			if(strstr(site,row[0]) != NULL)
			{
				sprintf(buf,"BANNED - %s just tried to connect.", site);
				wiznet(buf,NULL,NULL,WIZ_LOGINS,0,0);
				return TRUE;
			}
		}
	}

	return FALSE;
}
示例#6
0
void InvadeArea(AREA_DATA * pArea, MOB_INDEX_DATA * pMobIndex, int count)
{
    int created;
    int nTries = 5000;                                      //Limiting factor to keep from going on contiously.
    ROOM_INDEX_DATA * location;
    CHAR_DATA * victim;
    char * victimname;
    char buffer[MAX_STRING_LENGTH];

    if(pArea == NULL || pMobIndex == NULL)
    {
        return;
    }

    victimname = pMobIndex->short_descr;
    if ( !IS_SET(pArea->area_flags,AREA_QUESTOK) )
    {
        log_string( "Autoquest: Illegal zone." );
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest: Illegal zone...retrying." );
        pulse_autoquest = 1;
        return;
    }

    for ( created=0; (created < count) && (nTries > 0); created++ )
    {
        if ( (location = get_room_index(number_range(pArea->lvnum, pArea->uvnum ))) == NULL )
        {
            --created;
            nTries--;
            continue;
        }
        if (IS_SET( location->room_flags, ROOM_SAFE) || IS_SET(location->room_flags, ROOM_ASTRAL) || IS_SET(location->room_flags, ROOM_NO_MOB))
        {
            --created;
            nTries--;
            continue;
        }

        victim = create_mobile( pMobIndex );
        char_to_room( victim, location );
        if ( !IS_SET(victim->act, ACT_QUEST) )
            SET_BIT(victim->act,ACT_QUEST);
    }

    if(nTries == 0)
    {
        sprintf( buffer, "#RA half-hearted force of %d %s's has invaded #y%s.\n\r", created, victimname, pArea->name);
        do_questchat2( buffer );
    }
    else
    {
        sprintf( buffer, "#RAn Invasion on the area#y %s #Rhas occurred by %d deadly %s's !!!\n\r", pArea->name, created, victimname );
        do_questchat2( buffer );
    }

    return;
}
示例#7
0
/*Originaly, i heard on gamedev that someone was looking for a way to stop xprintf
 *from overflowing, ofcourse, people fail to think of functions like strlcpy, which
 *is essentaily a safe xprintf, atleast as it has been described to me.  I however
 *chose to write my own system.  This allows me to capture the function, and line
 *of the overflowing string in question.  Thus allowing me to essentaily find out
 *where the mud overflows, and stop it from happening.  Great little tool.
 *All i ask is that you leave this header in place.  -- Darien of Sandstorm:Mages Sanctuary
 */
void safe_printf( const char *file, const char *function, int line, int size, char *str, char *fmt, ... )
{
   char buf[MAS];
   va_list args;
   va_start( args, fmt );
   vsprintf( buf, fmt, args );
   va_end( args );

   /*
    * Max Alloc Size is allot!
    */
   if( size > MAS )
   {
      log_string( LOG_BUG, "xprintf size greater then MAS!!!!\n\r" );
      log_string( LOG_BUG, "Warning: Overflow has been caught by xprintf.\n\r" );
      log_string( LOG_BUG, "Memcheck: xprintf:File %s, Function %s, Line %d.\n\r", file, function, line );
      wiznet_printf( NULL, NULL, WIZ_MEMCHECK, 0, 0, "Memcheck: System memory corrupted by overflow through xprintf: File: %s Function: %s Line: %d", file, function, line  );
      return;
   }

   if( ( unsigned )size < strlen( buf ) + 1 )
   {
      log_string( LOG_BUG, "XPRINTF error: fmt %s.\n\r", fmt );
      log_string( LOG_BUG, "Warning: Overflow has been caught by xprintf.\n\r" );
      log_string( LOG_BUG, "Memcheck: xprintf: File %s, Function %s, Line %d.\n\r", file, function, line );
      wiznet_printf( NULL, NULL, WIZ_MEMCHECK, 0, 0, "Memcheck: System memory corrupted by overflow through xprintf: File: %s Function: %s Line: %d", file, function, line  );
   }
   else
   {
      mudstrlcpy( str, buf, size );

      /*
       * Just double checking.
       */
      if( strlen( str ) > ( unsigned )size - 1 )
      {
         char egbug[MSL];
         log_string( LOG_BUG, "XPRINTF error: fmt %s.\n\r", fmt );
         log_string( LOG_BUG, "Warning: Overflow has been caught by xprintf.\n\r" );
         log_string( LOG_BUG, "Memcheck: Xprintf: File %s, Function %s, Line %d.\n\r", file, function, line );

         /*
          * Yes, this is a potential loop bug if infact the xprintf does collapse in on itself..
          */
         xprintf( egbug, "Memcheck: System memory corrupted by overflow through xprintf: File: %s Function: %s Line: %d",
                  file, function, line );
         wiznet( egbug, NULL, NULL, WIZ_MEMCHECK, 0, 0 );
      }
   }
}
示例#8
0
void do_delete( CHAR_DATA * ch, char * argument ) {
  DESCRIPTOR_DATA * d;

  if ( !ch->desc ) {
    return;
  }

  if ( str_cmp( ch->desc->incomm, "delete yes" ) ) {
    send_to_char( C_DEFAULT, "If you want to DELETE yourself, type 'delete yes'\n\r", ch );
    return;
  }

  if ( ch->desc->original || IS_NPC( ch ) ) {
    send_to_char( C_DEFAULT, "You may not delete a switched character.\n\r", ch );
    return;
  }

  stop_fighting( ch, TRUE );
  send_to_char( C_DEFAULT, "You are no more.\n\r", ch );
  act( AT_BLOOD, "$n is no more.", ch, NULL, NULL, TO_ROOM );
  info( "%s is no more.", (int)( ch->name ), 0 );
  sprintf( log_buf, "$N has DELETED in room vnum %d.", ch->in_room->vnum );
  wiznet( log_buf, ch, NULL, WIZ_LOGINS, 0, 0 );

  // delete player file
  sprintf( log_buf, "%s%c/%s", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) );
  remove( log_buf );

  // delete finger file
  sprintf( log_buf, "%s%c/%s.fng", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) );
  remove( log_buf );

  // delete corpses
  sprintf( log_buf, "%s%c/%s.cps", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) );
  remove( log_buf );

  delete_playerlist( ch->name );

  d = ch->desc;

  extract_char( ch, TRUE );

  if ( d ) {
    close_socket( d );
  }

  return;
}
示例#9
0
void update_handler( void )
{
    static  int     pulse_area;
    static  int     pulse_mobile;
    static  int     pulse_violence;
    static  int     pulse_point;
    static  int	    pulse_music;

    if ( --pulse_area     <= 0 )
    {
	pulse_area	= PULSE_AREA;
	/* number_range( PULSE_AREA / 2, 3 * PULSE_AREA / 2 ); */
	area_update	( );
    }

    if ( --pulse_music	  <= 0 )
    {
	pulse_music	= PULSE_MUSIC;
	song_update();
    }

    if ( --pulse_mobile   <= 0 )
    {
	pulse_mobile	= PULSE_MOBILE;
	mobile_update	( );
    }

    if ( --pulse_violence <= 0 )
    {
	pulse_violence	= PULSE_VIOLENCE;
	violence_update	( );
    }

    if ( --pulse_point    <= 0 )
    {
	wiznet("TICK!",NULL,NULL,WIZ_TICKS,0,0);
	pulse_point     = PULSE_TICK;
/* number_range( PULSE_TICK / 2, 3 * PULSE_TICK / 2 ); */
	weather_update	( );
	char_update	( );
	obj_update	( );
    }

    aggr_update( );
    tail_chain( );
    return;
}
示例#10
0
//na przyklad jak cialko sie robi, to calkiem z listy wywala
//ownera ale zostaje na mudzie artef. count sie nie zmienia
void all_artefact_from_char( CHAR_DATA *ch )
{
	ARTEFACT_DATA * atmp = NULL;
	ARTEFACT_OWNER *otmp, *prev = NULL;
	OBJ_DATA *obj = NULL;

	for ( atmp = artefact_system;atmp;atmp = atmp->next )
	{
		otmp = atmp->first_owner;
		for ( ;otmp; )
		{
			if ( !strcmp( ch->name, otmp->owner ) )
			{
				if ( prev != NULL )
					prev->next = otmp->next;
				else
					atmp->first_owner = otmp->next;

				obj = create_object( get_obj_index( atmp->avnum ), FALSE );
				wiznet( "$N STRACIL(a) artefact : $p.", ch, obj, WIZ_ARTEFACT, 0, get_trust( ch ) );

				append_file_format_daily( ch, ARTEFACT_LOG_FILE, "-> STRACIL (zgon):%s vnum:%d count:%d max: %d (move)", obj->short_descr, atmp->avnum, atmp->count, atmp->max_count );

				extract_obj( obj );

				otmp->next = NULL;
				free_artefact_owner( otmp );

				//nastepny element
				if ( prev != NULL )
					otmp = prev->next;
				else
					otmp = atmp->first_owner;


			}
			else //to nie ten
			{
				prev = otmp;
				otmp = otmp->next;
			}
		}
	}

}
示例#11
0
//ktos podniosl artefakt i to go wrzuca na liste
void artefact_to_char( OBJ_DATA *obj, CHAR_DATA *ch )
{
	char buf[ MAX_STRING_LENGTH ];
	ARTEFACT_DATA *atmp = NULL;
	ARTEFACT_OWNER *ow, *otmp = NULL;
	int licznik;

	for ( atmp = artefact_system;atmp;atmp = atmp->next )
	{

		if ( atmp->avnum == obj->pIndexData->vnum )
		{
			licznik = 0;
			for ( otmp = atmp->first_owner;otmp;otmp = otmp->next )
			{
				licznik++;
				if ( otmp->next == NULL ) break;
			}
			if ( licznik > atmp->max_count )   //jak by sie cos jeblo
			{
				sprintf( buf, "Artefact error posiadacze: %d, max_count: %d", licznik, atmp->max_count );
				log_string( buf );
			}

			ow = new_artefact_owner();

			if ( atmp->first_owner != NULL )
				otmp->next = ow;
			else
				atmp->first_owner = ow;

			ow->next = NULL;
			ow->owner = str_dup( ch->name );
			ow->status = 1;
			ow->last_logoff = current_time;

			wiznet( "$N {GDOSTAL(a){x artefakt : $p.", ch, obj, WIZ_ARTEFACT, 0, get_trust( ch ) );
			append_file_format_daily( ch, ARTEFACT_LOG_FILE, "-> DOSTAL :%s vnum:%d count:%d max: %d (move)", obj->short_descr, atmp->avnum, atmp->count, atmp->max_count );

			return ;
		}
	}
}
示例#12
0
char * get_master_defend(sh_int masterform, int index)
{
	int formmultiplier = 0;
	int i = 0;
        char buf[256];
        if (index < 0 || index > 11)
        {
                sprintf(buf, "GetMasterAttack: index invalid: %d{x",index);
                wiznet(buf,NULL,NULL,WIZ_SECURE,0,0);
                index = number_range(0,11);
        }
	for (i = 0; i < MASTERFORMS; i++)
	{
		if (masterformslookup_table[i].gsn == masterform)
		{
			formmultiplier = masterformslookup_table[i].formindex;
			break;	
		}	
	}
	
	return masterforms_table[(formmultiplier * MOVES_PER_FORM) + index].defensestring;
		
}
示例#13
0
void channels_permission(struct char_data *grantor, struct char_data *grantee, bool granted, const CHANNEL_DEFINITION const *channel)
{
    static char buf[MAX_INPUT_LENGTH];

    DENY_NPC(grantor);

    if (IS_NPC(grantee)) {
	send_to_char("Not on NPC's.\n\r", grantor);
	return;
    }

    if (get_trust(grantee) >= get_trust(grantor)) {
	send_to_char("You failed.\n\r", grantor);
	return;
    }


    if (granted) {
	if (!CHAN_DENIED(grantee, channel->flag)) {
	    printf_to_char(grantor, "%s is already granted channel %s.\n\r", capitalize(grantee->name), channel->name);
	    return;
	}
	GRANT_CHAN(grantee, channel->flag);
    } else {
	if (CHAN_DENIED(grantee, channel->flag)) {
	    printf_to_char(grantor, "%s is already denied channel %s.\n\r", capitalize(grantee->name), channel->name);
	    return;
	}
	DENY_CHAN(grantee, channel->flag);
    }

    printf_to_char(grantee, "You have been %s access to channel %s.\n\r", granted ? "granted": "denied", channel->name);
    printf_to_char(grantor, "Channel access %s to %s.", granted ? "granted": "denied", capitalize(grantee->name));
    (void)snprintf(buf, MAX_INPUT_LENGTH, "$N %s %s to %s.", granted ? "grants" : "denies", channel->name, grantee->name);
    wiznet(buf, grantor, NULL, WIZ_PENALTIES, WIZ_SECURE, 0);
}
示例#14
0
void log_string( int type, const char *fmt, ... )
{
   DESCRIPTOR_DATA *d;
   va_list args;
   char *strtime;
   char buf[45];
   char bufew[2 * MSL];
   char bufee[2 * MSL];
   FILE *log_file;
   buf[0] = '\0';

   log_file = NULL;

   // Get the wanted text
   va_start( args, fmt );
   vsprintf( bufew, fmt, args );
   va_end( args );

   if( type & LOG_CRIT )
   {
      xprintf( buf, "../log/%s.critical", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      for( d = descriptor_list; d != NULL; d = d->next )
         if( d->connected == CON_PLAYING && IS_IMMORTAL( d->character ) )
            printf_to_char( d->character, "Critical: %s\n\r", bufew );
      xprintf( bufee, "Critical: %s", bufew );
   }
   if( type & LOG_ERR )
   {
      xprintf( buf, "../log/%s.error", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fprintf( stderr, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Error: %s", bufew );
   }
   if( type & LOG_BUG )
   {
      xprintf( buf, "../log/%s.bug", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Bug: %s", bufew );
      log_string2( bufee );
   }
   if( type & LOG_SECURITY )
   {
      xprintf( buf, "../log/%s.security", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Security: %s", bufew );
   }
   if( type & LOG_CONNECT )
   {
      xprintf( buf, "../log/%s.connect", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Connect: %s", bufew );
   }
   if( type & LOG_GAME )
   {
      xprintf( buf, "../log/%s.game", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fprintf( stderr, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Game: %s", bufew );
   }
   if( type & LOG_COMMAND )
   {
      xprintf( buf, "../log/%s.comm", get_curdate(  ) );
      log_file = fopen( buf, "a" );
      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      fprintf( log_file, "%s :: %s\n", strtime, bash_color( bufew ) );
      fflush( log_file );
      fclose( log_file );
      xprintf( bufee, "Command: %s", bufew );
   }
   wiznet(bufee,NULL,NULL, WIZ_DEBUG, 0, 7);
}
示例#15
0
void do_quit( CHAR_DATA * ch, char * argument ) {
  DESCRIPTOR_DATA * d;
  CHAR_DATA       * PeT;
  CHAR_DATA       * gch;

  if ( ch->position == POS_FIGHTING ) {
    send_to_char( AT_WHITE, "No way! You are fighting.\n\r", ch );
    return;
  }

  if ( ch->position  < POS_STUNNED  ) {
    send_to_char( AT_WHITE, "You're not DEAD yet.\n\r", ch );
    return;
  }

  if ( ch->combat_timer ) {
    send_to_char( AT_WHITE, "Your adrenaline is pumping too hard.\n\r", ch );
    return;
  }

  if ( ch->in_room->vnum == ROOM_VNUM_SMITHY ) {
    send_to_char( AT_WHITE, "You cannot quit in this room.\n\r", ch );
    return;
  }

  if ( ch->questobj ) {
    if ( ch->questobj->carried_by == ch ) {
      extract_obj( ch->questobj );
    } else {
      ch->questobj->timer = 1;
    }
  }

  send_to_char( AT_BLUE, "[ The clear sky of reality slowly crosses the horizon.\n\r", ch );
  send_to_char( AT_BLUE, "  With much effort you tear yourself free of the storm, but\n\r  ", ch );
  send_to_char( AT_BLUE, "deep within your heart you know that there is no escaping\n\r ", ch );
  send_to_char( AT_BLUE, " the storm that rages within... ]\n\r\n\r", ch );
  send_to_char( C_DEFAULT, "", ch );

  if (   !CHECK_BIT( ch->act, PLR_WIZINVIS ) && !IS_AFFECTED2( ch, AFF_PLOADED ) ) {
    act( AT_BLOOD, "$n has left the game.", ch, NULL, NULL, TO_ROOM );

    if ( !CHECK_BIT( ch->act, PLR_CLOAKED ) ) {
      info( "%s has left the storm.", (int)( ch->name ), 0 );
    }
  } else {
    for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) {
      if ( ch != gch && get_trust( gch ) >= ch->wizinvis ) {
        act( AT_BLOOD, "$N slightly phased has left the storm.", gch, NULL, ch, TO_CHAR );
      }
    }
  }

  if ( IS_AFFECTED2( ch, AFF_PLOADED ) ) {
    REMOVE_BIT( ch->affected_by2, AFF_PLOADED );
  }

  if ( ch->level != L_IMP ) {
    sprintf( log_buf, "$N has quit in room vnum %d.", ch->in_room->vnum );
    wiznet( log_buf, ch, NULL, WIZ_LOGINS, 0, get_trust( ch ) );
  }

  if ( CHECK_BIT( ch->act, PLR_QUEST ) ) {
    REMOVE_BIT( ch->act, PLR_QUEST );
  }

  if ( CHECK_BIT( ch->act, PLR_QUESTOR ) ) {
    REMOVE_BIT( ch->act, PLR_QUESTOR );
  }

  save_char_obj( ch );
  save_finger( ch );

  for ( PeT = ch->in_room->people; PeT; PeT = PeT->next_in_room ) {
    if ( IS_NPC( PeT ) ) {
      if ( CHECK_BIT( PeT->act, ACT_PET ) && ( PeT->master == ch ) ) {
        extract_char( PeT, TRUE );
        break;
      }
    }
  }

  d = ch->desc;
  extract_char( ch, TRUE );

  if ( d ) {
    close_socket( d );
  }

  return;
}
示例#16
0
//to calkowita obsluga ladowania artefactow
//sprawdzanie czy mozna + ladowanie + ew. zakladanie
void load_artefact( ROOM_INDEX_DATA *room, OBJ_DATA *obj, CHAR_DATA *ch )
{
	char buf[ MAX_INPUT_LENGTH ];
	ARTEFACT_DATA *atmp = NULL;
	ARTEFACT_LOADER *ltmp = NULL;
	OBJ_DATA *loaded_obj;

	int type;
	int vnum = 0;


	if ( room != NULL )
	{
		vnum = room->vnum;type = 0;
	}
	else if ( obj != NULL )
	{
		vnum = obj->pIndexData->vnum;type = 1;
	}
	else if ( ch != NULL )
	{
		vnum = ch->pIndexData->vnum;type = 2;
	}
	else return ;


	//gdzie
	for ( atmp = artefact_system;atmp;atmp = atmp->next )
	{
		for ( ltmp = atmp->loader;ltmp;ltmp = ltmp->next )
		{
			//jesli nie zgadza sie typ (np: obj=obj) i vnumy to wychodzimy
			if (!( ltmp->type == type && ltmp->vnum == vnum ))
			{
                                continue;
                        }

                        //jesli room to sprawdzanie czy juz tam nie ma
			if (( type == 0 ) &&
                            ( count_obj_list( get_obj_index( atmp->avnum ), room->contents ) > 0 ) )
			{
				sprintf( buf, "NIE LADUJE do room a (juz jest): %d do %d", atmp->avnum, room->vnum );
				wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 );
				continue;
			}

                        //aktualizacja ilosci
			atmp->count = artefact_new_count( atmp );


			//tera prawd. jesli mniejsze to nastepny loader
			if ( number_range( 1, ltmp->probup ) > ltmp->probdown )
			{
				continue;
			}

                        //juz max artefaktu, nastepny loader
			if ( atmp->count >= atmp->max_count ) continue;


			//ladujemy bo wsie warunki spelnione
			loaded_obj = create_object ( get_obj_index( atmp->avnum ), FALSE );
			create_artefact( loaded_obj->pIndexData->vnum );

			//dokad ladujemy
			if ( type == 0 )   //do rooma
			{
				sprintf( buf, "Artefakt [%d] za³adowany do rooma [%d].", loaded_obj->pIndexData->vnum, room->vnum );
				obj_to_room( loaded_obj, room );
				wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 );
			}
			else if ( type == 1 )   //do srodka objectu
			{
				sprintf( buf, "Artefakt [%d] za³adowany do wnêtrza obiektu [%d],", loaded_obj->pIndexData->vnum, obj->pIndexData->vnum );
				obj_to_obj( loaded_obj, obj );
				wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 );
					//okresla room
				if ( obj->in_room )
					sprintf( buf, "	w roomie [%d]", obj->in_room->vnum );
				if ( obj->carried_by )
					sprintf( buf, "	na mobie [%d] w roomie [%d]", obj->carried_by->pIndexData->vnum, obj->carried_by->in_room->vnum );
				wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 );
				}
			else if ( type == 2 )   //mobowi
			{
				sprintf( buf, "Artefakt [%d] za³adowany mobowi [%d] roomie [%d].", loaded_obj->pIndexData->vnum, ch->pIndexData->vnum, ch->in_room->vnum );
				obj_to_char( loaded_obj, ch );
				wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 );
					//+zakladanie jesli moze (nie sprzedawca)
				if ( ch->pIndexData->pShop == NULL && loaded_obj->wear_loc == WEAR_NONE && can_see_obj( ch, loaded_obj ) )
				{
					if ( loaded_obj->item_type == ITEM_WEAPON )
					{
						if ( !get_eq_char( ch, WEAR_WIELD ) )
							wield_weapon( ch, loaded_obj, TRUE );
					}
					else
						wear_obj( ch, loaded_obj, FALSE );
				}

			} //end dokad
//		} //end typ=typ, vnum=vnum
	} //end po loaderach
} //end po artefaktach
}
示例#17
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret (CHAR_DATA * ch, char *argument)
{
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;

    /*
     * Strip leading spaces.
     */
    while (isspace (*argument))
        argument++;
    if (argument[0] == '\0')
        return;

    /*
     * No hiding.
     */
    REMOVE_BIT (ch->affected_by, AFF_HIDE);

    /*
     * Implement freeze command.
     */
    if (!IS_NPC (ch) && IS_SET (ch->act, PLR_FREEZE))
    {
        send_to_char ("You're totally frozen!\n\r", ch);
        return;
    }

    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     * also no spaces needed after punctuation.
     */
    strcpy (logline, argument);
    if (!isalpha (argument[0]) && !isdigit (argument[0]))
    {
        command[0] = argument[0];
        command[1] = '\0';
        argument++;
        while (isspace (*argument))
            argument++;
    }
    else
    {
        argument = one_argument (argument, command);
    }

    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust (ch);
    for (cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++)
    {
        if (command[0] == cmd_table[cmd].name[0]
            && !str_prefix (command, cmd_table[cmd].name)
            && cmd_table[cmd].level <= trust)
        {
            found = TRUE;
            break;
        }
    }

    /*
     * Log and snoop.
     */
    smash_dollar(logline);
    
    if (cmd_table[cmd].log == LOG_NEVER)
        strcpy (logline, "");

	/* Replaced original block of code with fix from Edwin
	 * to prevent crashes due to dollar signs in logstrings.
	 * I threw in the above call to smash_dollar() just for
	 * the sake of overkill :) JR -- 10/15/00
	 */
    if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
		||   fLogAll
		||   cmd_table[cmd].log == LOG_ALWAYS )
	{
    	char    s[2*MAX_INPUT_LENGTH],*ps;
    	int     i;

    	ps=s; 
    	sprintf( log_buf, "Log %s: %s", ch->name, logline );
    	/* Make sure that was is displayed is what is typed */
    	for (i=0;log_buf[i];i++)
    	{ 
			*ps++=log_buf[i];  
			if (log_buf[i]=='$')
	    		*ps++='$';
			if (log_buf[i]=='{')
	    		*ps++='{';
    	}
    	*ps=0;
    	wiznet(s,ch,NULL,WIZ_SECURE,0,get_trust(ch));
    	log_string( log_buf );
	}

    if (ch->desc != NULL && ch->desc->snoop_by != NULL)
    {
        write_to_buffer (ch->desc->snoop_by, "% ", 2);
        write_to_buffer (ch->desc->snoop_by, logline, 0);
        write_to_buffer (ch->desc->snoop_by, "\n\r", 2);
    }

    if (!found)
    {
        /*
         * Look for command in socials table.
         */
        if (!check_social (ch, command, argument)

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

    /*
     * Character not in position for command?
     */
    if (ch->position < cmd_table[cmd].position)
    {
        switch (ch->position)
        {
            case POS_DEAD:
                send_to_char ("Lie still; you are DEAD.\n\r", ch);
                break;

            case POS_MORTAL:
            case POS_INCAP:
                send_to_char ("You are hurt far too bad for that.\n\r", ch);
                break;

            case POS_STUNNED:
                send_to_char ("You are too stunned to do that.\n\r", ch);
                break;

            case POS_SLEEPING:
                send_to_char ("In your dreams, or what?\n\r", ch);
                break;

            case POS_RESTING:
                send_to_char ("Nah... You feel too relaxed...\n\r", ch);
                break;

            case POS_SITTING:
                send_to_char ("Better stand up first.\n\r", ch);
                break;

            case POS_FIGHTING:
                send_to_char ("No way!  You are still fighting!\n\r", ch);
                break;

        }
        return;
    }

    /*
     * Dispatch the command.
     */
    (*cmd_table[cmd].do_fun) (ch, argument);

    tail_chain ();
    return;
}
示例#18
0
/*
 * Inflict damage from a hit.
 */
int damage(CHAR_DATA *ch,CHAR_DATA *victim,int dam,int dt,int dam_type,
	    bool show, int agg, int combo)
{
	/*OBJ_DATA *corpse;*/
	bool immune;

	if ( victim->position == P_DEAD )
		return P_DEAD;

	/* @@@@@ FIX TORPOR
    if ( victim->position == P_TORPOR )
	return P_TORPOR;
	 */

	/* damage reduction */
	if ( dam > 15)
		dam = (dam - 5)/2 + 5;

	if(IS_SET(ch->form, FORM_HORRID)) dam++;

	/* @@@@@ FIX BITE DAMAGE FOR SERPENTIS 3
    if(is_affected(ch, skill_lookup("skin of the adder"))
	&& dam_type == DAM_BITE)
	    dam++;
	 */

	/* In case of -ve agg ratings */
	if (agg < 0) agg = 0;

	/* soakage */
	dam = do_soak(victim, dam, agg);

	if ( victim != ch )
	{
		if ( victim->position > P_STUN )
		{
			if ( victim->fighting == NULL )
			{
				set_fighting( victim, ch );
				if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL ) )
					mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL );
			}
			if (victim->timer <= 4)
				victim->position = P_FIGHT;
		}

		if ( victim->position > P_STUN )
		{
			if ( ch->fighting == NULL )
				set_fighting( ch, victim );
		}

		/*
		 * More charm stuff.
		 */
		if ( victim->master == ch )
			stop_follower( victim );
	}

	/*
	 * Inviso attacks ... not.
	 */
	if ( IS_AFFECTED(ch, AFF_INVISIBLE) )
	{
		affect_strip( ch, gsn_invis );
		REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
		act( "$n fades into existence.", ch, NULL, NULL, TO_ROOM, 0 );
	}

	/*
	 * Damage modifiers.
	 */

	if ( dam > 1 && !IS_NPC(victim)
			&&   victim->condition[COND_DRUNK]  > 10 )
		dam = 9 * dam / 10;
	if ( dam > 1 && !IS_NPC(victim)
			&&   victim->condition[COND_HIGH]  > 10 )
		dam = 9 * dam / 10;

	if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && !IS_NATURAL(ch) )) )
		dam -= dam / 4;

	immune = FALSE;


	/*
	 * Check for parry, and dodge.

    if ( dt >= TYPE_HIT && ch != victim)
    {
        if ( check_parry( ch, victim ) )
	    return -1;
	if ( check_dodge( ch, victim ) )
	    return -1;
    }
	 */

	switch(check_immune(victim,dam_type))
	{
	case(IS_IMMUNE):
	    		immune = TRUE;
	dam = 0;
	break;
	case(IS_RESISTANT):
	    		dam -= dam/3;
	break;
	case(IS_VULNERABLE):
	    		dam += dam/2;
	break;
	}

	if (show)
		dam_message( ch, victim, dam, dt, immune, combo );

	if(dam > (victim->health + victim->agghealth -7))
	{
		victim->position = P_MORT;
		stop_fighting(ch, TRUE);
	}
	else if(dam == (victim->health + victim->agghealth -7))
	{
		victim->position = P_INCAP;
		stop_fighting(ch, TRUE);
	}

	if (dam == 0)
		return -1;
	else if(IS_SET(ch->off_flags, BANDAGED))
		REMOVE_BIT(ch->off_flags, BANDAGED);

	/*
	 * Hurt the victim.
	 * Inform the victim of his new state.
	 */
	if( (victim->race == race_lookup("vampire")) && (dt == DAM_FIRE) )
	{
		victim->agghealth -= dam;
		update_pos( victim, UMAX(1, agg) );
		if(agg <= 0) agg = 1;
	}
	else if( (victim->race == race_lookup("werewolf")) && (dt == DAM_SILVER) )
	{
		victim->agghealth -= dam;
		update_pos( victim, UMAX(1, agg) );
		if(agg <= 0) agg = 1;
	}
	else if( (victim->race == race_lookup("faerie")) && (dt == DAM_IRON) )
	{
		victim->health -= dam;
		victim->GHB += dam/3;
		update_pos( victim, agg );
	}
	else if(agg)
	{
		victim->agghealth -= dam;
		update_pos( victim, agg );
	}
	else
	{
		victim->health -= dam;
		update_pos( victim, 0 );
	}

	switch( victim->position )
	{
	case P_MORT:
		act( "$n is mortally wounded, and will die soon, if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are mortally wounded, and may die soon, if not aided.\n\r", victim );
		break;

	case P_INCAP:
		act( "$n is incapacitated and will slowly die, if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are incapacitated and will slowly die, if not aided.\n\r", victim );
		break;

	case P_TORPOR:
		act( "$n is mortally wounded, and will slowly die if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You enter torpor.\n\r", victim );
		break;

	case P_STUN:
		act( "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are stunned, but will probably recover.\n\r", victim );
		break;

	case P_DEAD:
		act( "$n is DEAD!!", victim, 0, 0, TO_ROOM, 0 );
		send_to_char( "You have been KILLED!!\n\r\n\r", victim );
		break;

	default:
		if ( dam > MAX_HEALTH / 4 )
			send_to_char( "That really did HURT!\n\r", victim );
		if ( (victim->health + victim->agghealth - 7) < MAX_HEALTH / 4 )
			send_to_char( "You sure are BLEEDING!\n\r", victim );
		break;
	}

	if(dam_type == DAM_FIRE)
		fire_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_COLD)
		cold_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_LIGHTNING)
		shock_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_ACID)
		acid_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_POISON)
		poison_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);

	/*
	 * Sleep spells and extremely wounded folks.
	 */
	if ( !IS_AWAKE(victim) )
		stop_fighting( victim, FALSE );

	/*
	 * Payoff for killing things.
	 */
	if ( (victim->position == P_INCAP && IS_NPC(victim))
			|| victim->position == P_DEAD
			|| victim->position == P_TORPOR )
	{
		if ( !IS_NPC(victim) )
		{
			log_string( LOG_GAME, Format("%s killed by %s at %d", victim->name, (IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->vnum) );
		}

		snprintf( log_buf, 2*MIL, "\tY[WIZNET]\tn %s got toasted by %s at %s [room %d]",
				(IS_NPC(victim) ? victim->short_descr : victim->name),
				(IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->name, ch->in_room->vnum);

		if (IS_NPC(victim))
			wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0);
		else
			wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);

		/*
		 * Death trigger
		 */
		if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
		{
			victim->position = P_STAND;
			mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
		}

		if((!str_cmp(ch->description, "") || strlen(ch->description) < 10)
				&& ch->played > 10*60*60)
		{
			send_to_char("No experience without a description.\n\r", ch);
		}
		else
		{
			if(ch->ooc_xp_count < 2) {
				send_to_char("You learn from your encounter.\n\r", ch);
				ch->oocxp += 1;
				ch->ooc_xp_count++;
			} else if(IS_SET(victim->act2, ACT2_HUNTER) && ch->ooc_xp_count < 50) {
				send_to_char("You learn from your encounter.\n\r", ch);
				ch->exp += 1;
				ch->ooc_xp_count++;
			}
		}

		if(ch->quest)
		{
			if(ch->quest->quest_type == Q_HITMAN && ch->quest->victim == victim)
				(*quest_table[ch->quest->quest_type].q_fun) (ch, 2);

			if(victim->quest != NULL && victim->quest->quest_type == Q_HITMAN
					&& victim->quest->victim == victim
					&& victim->quest->questor != ch)
				(*quest_table[victim->quest->quest_type].q_fun)
				(victim->quest->questor, 3);

			if(victim->quest != NULL && (victim->quest->quest_type == Q_BODYGUARD
					|| victim->quest->quest_type == Q_RESCUE)
					&& victim->quest->victim == victim)
				(*quest_table[victim->quest->quest_type].q_fun)
				(victim->quest->questor, 3);
		}

		if(victim->position != P_TORPOR || agg) update_pos( victim, agg );

		return victim->position;
	}

	if ( victim == ch )
		return ch->position;

	/* Link dead salvation. */
	if ( !IS_NPC(victim) && victim->desc == NULL )
	{
		do_function(victim, &do_flee,"");
	}

	tail_chain( );
	return victim->position;
}
示例#19
0
文件: interp.C 项目: SinaC/OldMud
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, const char *argument0 )
{
  char command[MAX_INPUT_LENGTH];
  char logline[MAX_INPUT_LENGTH];
  int cmd;
  int trust;
  bool found;
  // Added by SinaC 2001, true if it's a mob program command
  bool found_mob;

  char *argument = new char [MAX_INPUT_LENGTH];
  strcpy(argument,argument0);
  for( char *s = argument; *s; s++ )
    *s = ( *s == '~' ? '-' : *s );

  /*
   * Strip leading spaces.
   */
  while ( isspace(*argument) )
    argument++;
  if ( argument[0] == '\0' )
    return;

  // Added by SinaC 2001
  if ( ch->in_room == NULL ) {
    send_to_char("You're not in a room ... How did you do that ?", ch );
    return;
  }


  /*
   * No hiding.
   */
  /* Oxtal> I still don't figure out what this does */
  // when we're Hiding, if we do something, Hide disappears  SinaC 2000
  if (IS_SET(ch->bstat(affected_by),AFF_HIDE)) {
    REMOVE_BIT( ch->bstat(affected_by), AFF_HIDE );
    recompute(ch);
  }

  /*
   * Implement freeze command.
   */
  if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) ) {
    send_to_char( "You're totally frozen!\n\r", ch );
    return;
  }

  /*
   * Grab the command word.
   * Special parsing so ' can be a command,
   *   also no spaces needed after punctuation.
   */
  strcpy( logline, argument );

  sprintf(last_command,"%s(%d) in room[%d]: %s.",
	  ch->name,
	  IS_NPC(ch)?ch->pIndexData->vnum:-1,
	  ch->in_room?ch->in_room->vnum:-1,
	  argument );

  const char* argument2;
  if ( !isalpha(argument[0]) && !isdigit(argument[0])) {
    command[0] = argument[0];
    command[1] = '\0';
    argument++;
    while ( isspace(*argument) )
      argument++;

    argument2 = argument;
  }
  else {
    // Added by SinaC 2003, really crappy
    if ( !str_prefix( "jog", argument ) || !str_prefix( "jo", argument ) ) // for jog command
      argument2 = no_lower_one_argument( argument, command );
    else
      argument2 = one_argument( argument, command );
  }

  /*
   * Look for command in command table.
   */
  // Added by SinaC 2001
  found_mob = FALSE;
  found = FALSE;
  trust = get_trust( ch );
  //for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ ) {
  for ( cmd = 0; cmd < MAX_COMMANDS; cmd++ ) {
    if ( command[0] == cmd_table[cmd].name[0]
	 &&   !str_prefix( command, cmd_table[cmd].name )
	 &&   cmd_table[cmd].level <= trust ) {
      found = TRUE;
      break;
    }
  }

  /*
   * Log and snoop.
   */
  if ( found && cmd_table[cmd].log == LOG_NEVER )
    strcpy( logline, "" );

  if ( found && 
       ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
	 ||   fLogAll
	 ||   cmd_table[cmd].log == LOG_ALWAYS ) ) {
    // Modified by SinaC 2000
    sprintf( log_buf, "Log %s: %s (%s)", 
	     ch->name, 
	     logline, 
	     cmd_table[cmd].name
	     );
    wiznet(log_buf,ch,NULL,WIZ_SECURE,0,get_trust(ch));
    log_string( log_buf );
  }

  
  // Added by SinaC 2001, if player was afk, afk is removed.
  if ( IS_SET(ch->comm,COMM_AFK)
       // unless player is trying to remove afk with afk command
       && ( found && str_cmp(cmd_table[cmd].name,"afk") )
       && !IS_IMMORTAL(ch) ) {
    send_to_char("{GAFK{x mode removed.\n\r",ch);
    if (buf_string(ch->pcdata->buffer)[0] != '\0' )
      send_to_char("{rYou have received tells: Type {Y'replay'{r to see them.{x\n\r",ch);
    REMOVE_BIT(ch->comm,COMM_AFK);
  }


  if ( ch->desc != NULL && ch->desc->snoop_by != NULL ) {
    write_to_buffer( ch->desc->snoop_by, "% ",    2 );
    write_to_buffer( ch->desc->snoop_by, logline, 0 );
    write_to_buffer( ch->desc->snoop_by, "\n\r",  2 );
  }

  if ( !found ) {
    if( !check_social( ch, command, argument2 ) ) {
      // Modified by SinaC 2000
      //	    send_to_char( "Huh?\n\r", ch );
      random_error( ch );
      if ( SCRIPT_VERBOSE > 0 ) {
	if ( IS_NPC(ch) ) // Added by SinaC 2003
	  log_stringf("%s (%d) tries to use command: %s %s", 
		      NAME(ch), ch->pIndexData->vnum,
		      command, argument2 );
      }
    }
      
      return;
  }
  else {
    if ( check_disabled(&cmd_table[cmd]) ) {
      send_to_char( "This command has been temporarily disabled.\n\r", ch );
      return;
    }
    // Added by SinaC 2001 for player disabled commands
    if ( check_disabled_plr( ch, &cmd_table[cmd] ) ) {
      send_to_char( "The gods has removed your ability to use that command.\n\r", ch );
      return;
    }
  }

  /*
   * Character not in position for command?
   */
  if ( ch->position < cmd_table[cmd].position ) {
    switch( ch->position ) {
    case POS_DEAD:
      send_to_char( "Lie still; you are DEAD.\n\r", ch );
      break;

    case POS_MORTAL:
    case POS_INCAP:
      send_to_char( "You are hurt far too bad for that.\n\r", ch );
      break;

      // Added by SinaC 2003
    case POS_PARALYZED:
      send_to_char( "You are paralyzed, you can't move.\n\r", ch);
      break;

    case POS_STUNNED:
      send_to_char( "You are too stunned to do that.\n\r", ch );
      break;

    case POS_SLEEPING:
      send_to_char( "In your dreams, or what?\n\r", ch );
      break;

    case POS_RESTING:
      send_to_char( "Nah... You feel too relaxed...\n\r", ch);
      break;

    case POS_SITTING:
      send_to_char( "Better stand up first.\n\r",ch);
      break;

    case POS_FIGHTING:
      send_to_char( "No way!  You are still fighting!\n\r", ch);
      break;

    }
    return;
  }

  /*
   * Dispatch the command.
   */

  /* Oxtal -- Output the commands */
  /* SinaC --- We don't need that for the moment
   *if ( cmd_table[cmd].log != LOG_NEVER ) {
   * char *strtime;
   *
   * strtime = ctime( &current_time );
   * strtime[strlen(strtime)-1] = '\0';
   * fprintf( stdout, "%s %15s [%5d] %s %s\n",
   *  strtime,
   *  ch->name,
   *  ch->in_room ? ch->in_room->vnum : 0,
   *  cmd_table[cmd].name,
   *  argument);
   *}
   */ // removed by SinaC 2000
  
  // Modified by SinaC 2001 to detect memory leak
  char buf[MAX_STRING_LENGTH];

  // Modified by SinaC 2001
  if ( found )
    (*cmd_table[cmd].do_fun) ( ch, argument2 );

  return;
}
示例#20
0
文件: classes.C 项目: SinaC/OldMud
void do_multiclass(CHAR_DATA *ch, const char *argument) {
  int iClass;
  //  char arg[MAX_INPUT_LENGTH];

  ROOM_INDEX_DATA *pRoom;
  OBJ_DATA *obj;

  if (IS_NPC(ch)){
    send_to_char("Mobs can't multiclass!\n\r",ch);
    return;
  }

  if (IS_IMMORTAL(ch)) {
    send_to_char("Immortals are damned to be immortals.\n\r",ch);
    return;
  }

  //  argument = one_argument(argument,arg);

  if (argument[0] == 0) {
    send_to_char("You must provide a class name to add to your class list.\n\r",ch);
    return;
  }

  iClass = class_lookup(argument, TRUE );
  if (iClass == -1) {
    send_to_char("You must provide an existing class name to add to your class list.\n\r",ch);
    return;
  }

  if ((1<<iClass) & ch->bstat(classes)) {
    send_to_char("Choose a class that you don't already have.\n\r",ch);
    return;
  }

  // Added by SinaC 2001
  if ( !check_class_god( iClass, ch->pcdata->god ) ){
    send_to_charf(ch,
		  "%s doesn't allow that class.\n\r",
		  god_name(ch->pcdata->god));
    return;
  }
  if ( !check_class_race( ch, iClass ) ){
    send_to_char( "You can't choose that class because of your race.\n\r", ch );
    return;
  }
  // Added by SinaC 2003 for subclass system
  //  If trying to multiclass in a subclass without having the parent class
  //  Should be able to get only one sub-class for each parent-class
  //   Cannot be fire and water elementalist
  //   Cannot be enchanter and transmuter
  //   But can be assassin and fire elementalist
  if ( class_table[iClass].parent_class != iClass
       && !((1<<class_table[iClass].parent_class) & ch->bstat(classes))) {
    send_to_char("You can't choose this sub-class because you don't have the parent class.\n\r", ch );
    return;
  }
  // Added by SinaC 2003 to determine if a class can be picked during creation/multiclass
  if ( class_table[iClass].choosable != CLASS_CHOOSABLE_YES ) {
    send_to_char("This class cannot be picked.\n\r", ch );
    return;
  }

  // check wild-magic
  if ( ch->isWildMagic                                                    // can't get non-wild magic class
       && IS_SET( class_table[iClass].type, CLASS_MAGIC )                 //  if wild mage
       && !IS_SET( class_table[iClass].type, CLASS_WILDABLE ) ) {
    send_to_charf(ch,"This class cannot be picked by a wild-mage.\n\r");
    return;
  }

  // kill pet and charmies
  die_follower( ch );

  /* Test if fighting ? */
  stop_fighting( ch, TRUE );

  /* Go to donation room */

  pRoom = get_donation_room( ch );
  //pRoom = get_room_index( ROOM_VNUM_DONATION );
  if (pRoom==NULL) {
    bug("do_multiclass: donation room not found for player [%s] clan [%s] hometown [%s]!",
	NAME(ch), get_clan_table(ch->clan)->name,
	(IS_NPC(ch)||ch->pcdata->hometown<0)?"none":hometown_table[ch->pcdata->hometown].name);
    //bug("multiclass: donation room not found %d!",ROOM_VNUM_DONATION);
    return;
  }

  if (ch->in_room != pRoom) {
    act("$n disapears!",ch,NULL,NULL,TO_ROOM);
    char_from_room( ch );
    char_to_room( ch, pRoom );
    act( "$n appears in the donation room.", ch, NULL, NULL, TO_ROOM );
  }

  ch->level = 1;
  ch->bstat(classes) |= 1<<iClass;
  ch->hit = 20;        /* I should place constants instead of "hard code" */
  ch->bstat(max_hit) = 20;
  ch->mana = 100;
  ch->bstat(max_mana) = 100;
  // Added by SinaC 2001 for mental user
  ch->psp = 100;
  ch->bstat(max_psp) = 100;
  ch->move = 100;
  ch->bstat(max_move) = 100;
  ch->wimpy = 0;

  /* ch->pcdata->points = ? creation points*/
  ch->exp = exp_per_level(ch,ch->pcdata->points);

  /* Train - Pra ?*/

  /* Gain base group*/
  group_add(ch,class_table[iClass].base_group,FALSE);

  /*group_add(ch,class_table[iClass].default_group,TRUE);*/
  /* adding this would raise creation points too much*/

  /*group_add(ch,class_table[iClass].default_group,FALSE);*/
  /* adding this would be too easy for the player */

  /* gold & silver ?*/

  /* Dealing with equipment */
  // FIXME: item STAY_DEATH or owned equipement must be dropped ?
  while ( ch->carrying != NULL ) {
    /* Remove the obj if it is worn */
    obj = ch->carrying;
    if (obj->wear_loc != WEAR_NONE)
      unequip_char( ch, obj );

    obj_from_char( obj );
    obj_to_room( obj, pRoom );
    SET_OBJ_STAT( obj, ITEM_DONATED);
  }

  // Added by SinaC 2001
  recompute(ch); 
  // Added by SinaC 2001
  recomproom(pRoom);

  do_outfit(ch,"");

  send_to_char("You are now mortal again...\n\r",ch);
  send_to_char("You see all your possesions lying on the ground...\n\r",ch);
  send_to_char("Probably few things are still usable, you'd better\n\r"
	       "leave them here.\n\r",ch);

  char buf[MAX_INPUT_LENGTH];
  sprintf( buf, "$N has multiclassed in %s.", class_table[iClass].name );
  wiznet(buf, ch, NULL, WIZ_MULTICLASS, 0, 0 );
}
示例#21
0
void do_autoinvade()
{
    AREA_DATA *tarea;
    int count = number_range(5,100);
    int nPick = number_range(10,90);
    int nMobVnum;
    int nTries = 100;
    int nTimes = number_range(1,15);
    bool found=FALSE;
    MOB_INDEX_DATA *pMobIndex;
    //    count = number_range(1,100);

    do
    {
        nMobVnum = number_range(1,100000);
    }while(( pMobIndex = get_mob_index( nMobVnum ) ) == NULL && nTries-- >= 0);

    for ( tarea = area_first; tarea; tarea = tarea->next )
        if ( nTimes++ == nPick )
    {
        found = TRUE;
        break;
    }
    if ( !found )
    {
        log_string("Autoquest Failed." );
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest failed to start." );
        return;
    }
    if ( !IS_SET(tarea->area_flags,AREA_QUESTOK) )
    {
        log_string( "Autoquest: Illegal zone." );
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest: Illegal zone...retrying." );
        pulse_autoquest = 1;
        return;
    }

    if ( ( pMobIndex = get_mob_index( nMobVnum ) ) == NULL )
    {
        log_string( "Autoquest: No mobile has that vnum." );
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest: No mobile has that vnum." );
        pulse_autoquest = 1;
        return;
    }

    if ( IS_SET(pMobIndex->act, ACT_TRAIN))
    {
        log_string( "Autoquest: Illegal Mobile." );
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest: Illegal Mobile...retrying." );
        pulse_autoquest = 1;
        return;
    }

    if ( pMobIndex->level > 1000 )
    {
        do_autoinvade();
        return;
    }
    /*	if ( count < 20)
    //	{
    //		count=20;
    //	}
    //	else if ( count == 0)
    //	{
    //		count=20;
    //	}
    */
    if ( count==0)
    {
        wiznet( NULL, WIZ_DEBUG, 0, "Autoquest: Count came up 0.");
        pulse_autoquest = 1;
        return;
    }

    count = number_range(20,100);
    count = count+1;
    InvadeArea(tarea, pMobIndex, count);

    return;
}