예제 #1
0
파일: db.c 프로젝트: MUDOmnibus/Merc21
/*
 * Repopulate areas periodically.
 */
void area_update( void )
{
    AREA_DATA *pArea;

    for ( pArea = area_first; pArea != NULL; pArea = pArea->next )
    {
	CHAR_DATA *pch;

	if ( ++pArea->age < 3 )
	    continue;

	/*
	 * Check for PC's.
	 */
	if ( pArea->nplayer > 0 && pArea->age == 15 - 1 )
	{
	    for ( pch = char_list; pch != NULL; pch = pch->next )
	    {
		if ( !IS_NPC(pch)
		&&   IS_AWAKE(pch)
		&&   pch->in_room != NULL
		&&   pch->in_room->area == pArea )
		{
		    send_to_char( "You hear the patter of little feet.\n\r",
			pch );
		}
	    }
	}

	/*
	 * Check age and reset.
	 * Note: Mud School resets every 3 minutes (not 15).
	 */
	if ( pArea->nplayer == 0 || pArea->age >= 15 )
	{
	    ROOM_INDEX_DATA *pRoomIndex;

	    reset_area( pArea );
	    pArea->age = number_range( 0, 3 );
	    pRoomIndex = get_room_index( ROOM_VNUM_SCHOOL );
	    if ( pRoomIndex != NULL && pArea == pRoomIndex->area )
		pArea->age = 15 - 3;
	}
    }

    return;
}
예제 #2
0
//The world list is just a file with a line-by-line list of all the areas
//in the game.
void load_world()
{
   FILE *fp;
   ITERATOR iter;
   D_AREA *area;
   char buf[MAX_BUFFER];
   
   area_loader = luaL_newstate();
   luaL_openlibs( area_loader );
   
   log_string( "Loading World" );
   
   if( ( fp = fopen( "../areas/list.are", "r" ) ) == NULL )
   {
      log_string( "FATAL ERROR: Area List (areas/list.are) does not exist!" );
      abort();
      return;
   }
   
   while( !feof( fp ) )
   {
      fgets( buf, MAX_BUFFER, fp );
      buf[strlen(buf)-1] = '\0'; //fgets includes the newline in the read, so we kill it here.
      if( !strcasecmp( buf, "END" ) )
         break;
      load_area( buf );
   }  
   fclose( fp );
   link_exits();
   
   AttachIterator( &iter, area_list );
   while( ( area = (D_AREA*)NextInList( &iter ) ) != NULL )
      reset_area( area );
   DetachIterator( &iter );
   
   return;
}
예제 #3
0
void ram(void) {
    getInputWaitRelease();
    reset_area();
    random_area(life,1,1,RESX,RESY,40);

    static int nickx=2,nicky=10;
    signed char movy=1;
    static int nickwidth,nickheight;
    static int nickoff=10;
    static char delaytime=10;
    static char speedmode=0;
    static char LCDSHIFTX_EVERY_N=2;
    static char LCDSHIFTY_EVERY_N=2;
    static char ITER_EVERY_N=1;

    lcdClear();
    setExtFont(GLOBAL(nickfont));
    
    nickwidth=DoString(nickx,nicky,GLOBAL(nickname));
    if(nickwidth<50)nickoff=30;
    nickheight=getFontHeight();

    char stepmode=0;
    while (1) {
        draw_area(); // xor life pattern over display content
        lcdDisplay();
        lcdClear();
        // draw_area(); // xor life pattern again to restore original display content
        // Old shift code. Can't handle longer Nicks...
        // if(iter%LCDSHIFT_EVERY_N==0) lcdShift(1,-2,1);
        // if(iter%LCDSHIFT_EVERY_N==0) { nickx=(nickx+1)%100-nickwidth; nicky=(nicky+1)%50;}
        if(iter%LCDSHIFTX_EVERY_N==0) { nickx--; 
        if(nickx<(-1*nickwidth-nickoff))nickx=0; }
        if(iter%LCDSHIFTY_EVERY_N==0) { nicky+=movy;
        if(nicky<1 || nicky>RESY-nickheight) movy*=-1; }
        DoString(nickx,nicky,GLOBAL(nickname));
        DoString(nickx+nickwidth+nickoff,nicky,GLOBAL(nickname));
        if(nickwidth<RESX) DoString(nickx+2*(nickwidth+nickoff),nicky,GLOBAL(nickname));
	char key=stepmode?getInputWait():getInputRaw();
	stepmode=0;
	switch(key) {
	case BTN_ENTER:
	  return;
	case BTN_RIGHT:
	  getInputWaitRelease();
          speedmode=(speedmode+1)%7;
          delaytime=15;
          switch(speedmode) {
            case 0:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 1:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=2; LCDSHIFTY_EVERY_N=2; break;
            case 2:
              ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=4; LCDSHIFTY_EVERY_N=4; break;
            case 3:
              ITER_EVERY_N=2; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 4:
              ITER_EVERY_N=4; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 5:
              ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
            case 6:
              delaytime=5; ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break;
          }
	  break; 
	case BTN_DOWN:
	  stepmode=1;
	  getInputWaitRelease();
	  break;
	case BTN_LEFT:
	  pattern=(pattern+1)%PATTERNCOUNT;
	case BTN_UP:
	  stepmode=1;
	  reset_area();
	  getInputWaitRelease();
	  break;
	}
        delayms_queue_plus(delaytime,0);
#ifdef SIMULATOR
  fprintf(stderr,"Iteration %d - x %d, y %d \n",iter,nickx,nicky);
#endif
        if(iter%ITER_EVERY_N==0) calc_area(); else ++iter;
    }
    return;
}
예제 #4
0
void do_reset( CHAR_DATA * ch, const char *argument )
{
	char arg[MAX_INPUT_LENGTH];

	if ( !argument || argument[0] == '\0' )
	{
		send_to_char( "Usage: reset area\r\n", ch );
		send_to_char( "Usage: reset list\r\n", ch );
		send_to_char( "Usage: reset randomize <direction>\r\n", ch );
		send_to_char( "Usage: reset delete <number>\r\n", ch );
		send_to_char( "Usage: reset hide <objname>\r\n", ch );
		send_to_char( "Usage: reset trap room <type> <charges> [flags]\r\n", ch );
		send_to_char( "Usage: reset trap obj <name> <type> <charges> [flags]\r\n", ch );
		return;
	}

	argument = one_argument( argument, arg );
	if ( !str_cmp( arg, "area" ) )
	{
		reset_area( ch->in_room->area );
		send_to_char( "Area has been reset.\r\n", ch );
		return;
	}

	if ( !str_cmp( arg, "list" ) )
	{
		RESET_DATA *pReset;
		char *rbuf;
		short num;
		ROOM_INDEX_DATA *room;
		bool found = FALSE;

		for ( room = ch->in_room->area->first_room; room; room = room->next_aroom )
		{
			num = 0;
			if ( !room->first_reset )
				continue;

			for ( pReset = room->first_reset; pReset; pReset = pReset->next )
			{
				num++;
				found = TRUE;
				if ( num == 1 )
					ch_printf( ch, "Room:[%d]\r\n", room->vnum );
				if ( !( rbuf = sprint_reset( pReset, &num ) ) )
					continue;
				send_to_char( rbuf, ch );
			}
		}
		if ( !found )
			send_to_char( "The area your in has no resets.\r\n", ch );
		return;
	}

	/*
	 * Yeah, I know, this function is mucho ugly... but... 
	 */
	if ( !str_cmp( arg, "delete" ) )
	{
		RESET_DATA *pReset, *tReset, *pReset_next, *tReset_next, *gReset, *gReset_next;
		int num, nfind = 0;

		if ( !argument || argument[0] == '\0' )
		{
			send_to_char( "You must specify a reset # in this room to delete one.\r\n", ch );
			return;
		}

		if ( !is_number( argument ) )
		{
			send_to_char( "Specified reset must be designated by number. See &Wredit rlist&D.\r\n", ch );
			return;
		}
		num = atoi( argument );

		for ( pReset = ch->in_room->first_reset; pReset; pReset = pReset_next )
		{
			pReset_next = pReset->next;

			nfind++;
			if ( nfind == num )
			{
				UNLINK( pReset, ch->in_room->first_reset, ch->in_room->last_reset, next, prev );
				delete_reset( pReset );
				send_to_char( "Reset deleted.\r\n", ch );
				return;
			}

			for ( tReset = pReset->first_reset; tReset; tReset = tReset_next )
			{
				tReset_next = tReset->next_reset;

				nfind++;
				if ( nfind == num )
				{
					UNLINK( tReset, pReset->first_reset, pReset->last_reset, next_reset, prev_reset );
					delete_reset( tReset );
					send_to_char( "Reset deleted.\r\n", ch );
					return;
				}

				for ( gReset = tReset->first_reset; gReset; gReset = gReset_next )
				{
					gReset_next = gReset->next_reset;

					nfind++;
					if ( nfind == num )
					{
						UNLINK( gReset, tReset->first_reset, tReset->last_reset, next_reset, prev_reset );
						delete_reset( gReset );
						send_to_char( "Reset deleted.\r\n", ch );
						return;
					}
				}
			}
		}
		send_to_char( "No reset matching that number was found in this room.\r\n", ch );
		return;
	}

	if ( !str_cmp( arg, "random" ) )
	{
		RESET_DATA *pReset;
		int vnum = get_dir( arg );

		argument = one_argument( argument, arg );

		if ( vnum < 0 || vnum > 9 )
		{
			send_to_char( "Reset which random doors?\r\n", ch );
			return;
		}

		if ( vnum == 0 )
		{
			send_to_char( "There is no point in randomizing one door.\r\n", ch );
			return;
		}

		if ( !get_room_index( vnum ) )
		{
			send_to_char( "Target room does not exist.\r\n", ch );
			return;
		}

		pReset = make_reset( 'R', 0, ch->in_room->vnum, vnum, 0 );
		pReset->prev = NULL;
		pReset->next = ch->in_room->first_reset;
		if ( ch->in_room->first_reset )
			ch->in_room->first_reset->prev = pReset;
		ch->in_room->first_reset = pReset;
		if ( !ch->in_room->last_reset )
			ch->in_room->last_reset = pReset;
		send_to_char( "Reset random doors created.\r\n", ch );
		return;
	}

	if ( !str_cmp( arg, "trap" ) )
	{
		RESET_DATA *pReset = NULL;
		RESET_DATA *tReset = NULL;
		char oname[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
		int num, chrg, value, extra = 0, vnum;

		argument = one_argument( argument, arg2 );

		if ( !str_cmp( arg2, "room" ) )
		{
			vnum = ch->in_room->vnum;
			extra = TRAP_ROOM;

			argument = one_argument( argument, arg );
			num = is_number( arg ) ? atoi( arg ) : -1;
			argument = one_argument( argument, arg );
			chrg = is_number( arg ) ? atoi( arg ) : -1;
		}
		else if ( !str_cmp( arg2, "obj" ) )
		{
			argument = one_argument( argument, oname );
			if ( !( pReset = find_oreset( ch->in_room, oname ) ) )
			{
				send_to_char( "No matching reset found to set a trap on.\r\n", ch );
				return;
			}
			vnum = 0;
			extra = TRAP_OBJ;

			argument = one_argument( argument, arg );
			num = is_number( arg ) ? atoi( arg ) : -1;
			argument = one_argument( argument, arg );
			chrg = is_number( arg ) ? atoi( arg ) : -1;
		}
		else
		{
			send_to_char( "Trap reset must be on 'room' or 'obj'\r\n", ch );
			return;
		}

		if ( num < 1 || num > MAX_TRAPTYPE )
		{
			send_to_char( "Invalid trap type.\r\n", ch );
			return;
		}

		if ( chrg < 0 || chrg > 10000 )
		{
			send_to_char( "Invalid trap charges. Must be between 1 and 10000.\r\n", ch );
			return;
		}

		while ( *argument )
		{
			argument = one_argument( argument, arg );
			value = get_trapflag( arg );
			if ( value < 0 || value > 31 )
			{
				ch_printf( ch, "Bad trap flag: %s\r\n", arg );
				continue;
			}
			SET_BIT( extra, 1 << value );
		}
		tReset = make_reset( 'T', extra, num, chrg, vnum );
		if ( pReset )
		{
			tReset->prev_reset = NULL;
			tReset->next_reset = pReset->first_reset;
			if ( pReset->first_reset )
				pReset->first_reset->prev_reset = tReset;
			pReset->first_reset = tReset;
			if ( !pReset->last_reset )
				pReset->last_reset = tReset;
		}
		else
		{
			tReset->prev = NULL;
			tReset->next = ch->in_room->first_reset;
			if ( ch->in_room->first_reset )
				ch->in_room->first_reset->prev = tReset;
			ch->in_room->first_reset = tReset;
			if ( !ch->in_room->last_reset )
				ch->in_room->last_reset = tReset;
		}
		send_to_char( "Trap created.\r\n", ch );
		return;
	}

	if ( !str_cmp( arg, "hide" ) )
	{
		RESET_DATA *pReset = NULL;
		RESET_DATA *tReset = NULL;

		if ( !( pReset = find_oreset( ch->in_room, argument ) ) )
		{
			send_to_char( "No such object to hide in this room.\r\n", ch );
			return;
		}
		tReset = make_reset( 'H', 1, 0, 0, 0 );
		if ( pReset )
		{
			tReset->prev_reset = NULL;
			tReset->next_reset = pReset->first_reset;
			if ( pReset->first_reset )
				pReset->first_reset->prev_reset = tReset;
			pReset->first_reset = tReset;
			if ( !pReset->last_reset )
				pReset->last_reset = tReset;
		}
		else
		{
			tReset->prev = NULL;
			tReset->next = ch->in_room->first_reset;
			if ( ch->in_room->first_reset )
				ch->in_room->first_reset->prev = tReset;
			ch->in_room->first_reset = tReset;
			if ( !ch->in_room->last_reset )
				ch->in_room->last_reset = tReset;
		}
		send_to_char( "Hide reset created.\r\n", ch );
		return;
	}
	do_reset( ch, "" );
	return;
}