Exemplo n.º 1
0
bool rp_input_trigger( CHAR_DATA *ch, char * string )
{
	char buf[ MAX_STRING_LENGTH ];
	PROG_LIST *prg;

	for ( prg = ch->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == &TRIG_INPUT )
		{
			if ( prg->trig_phrase[ 0 ] == '@' )
			{
				sprintf( buf, "%s\n", string );
				if ( !regexp_match( prg->trig_phrase + 1, buf ) )
					continue;
			}
			else if ( prg->trig_phrase[ 0 ] == '*' )
			{
				if ( str_prefix( string, prg->trig_phrase + 1 ) )
					continue;
			}
			else
			{
				if ( str_cmp( string, prg->trig_phrase ) )
					continue;
			}

			rset_supermob( ch->in_room );
			create_rprog_env( prg->name, prg->code, ch->in_room, ch, NULL, NULL, prg->trig_type, string );
			program_flow();
			release_supermob();
			return ( TRUE );
		}
	}
	return ( FALSE );
}
Exemplo n.º 2
0
void rp_reset_trigger( ROOM_INDEX_DATA *pRoom )
{
	if ( !HAS_RTRIGGER( pRoom, TRIG_RESET ) ) return ;
	rset_supermob( pRoom );
	rp_percent_trigger( supermob, NULL, NULL, NULL, &TRIG_RESET );
	release_supermob();
}
Exemplo n.º 3
0
bool rp_locks_trigger( CHAR_DATA *ch, int exit, BITVECT_DATA *type )
{
	PROG_LIST * prg;

	for ( prg = ch->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == type && exit == atoi( prg->trig_phrase ) )
		{
			rset_supermob( ch->in_room );
			create_rprog_env( prg->name, prg->code, ch->in_room, ch, NULL, NULL, prg->trig_type, prg->trig_phrase );
			program_flow();
			release_supermob();
			return ( TRUE );
		}
	}
	return ( FALSE );
}
Exemplo n.º 4
0
void rp_act_trigger( char *argument, CHAR_DATA *ch, BITVECT_DATA *type )
{
	PROG_LIST * prg;
	for ( prg = ch->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == type
		     && !str_infix( prg->trig_phrase, argument ) )
		{
			rset_supermob( ch->in_room );
			create_rprog_env( prg->name, prg->code, ch->in_room, ch, NULL, NULL, prg->trig_type, prg->trig_phrase );
			program_flow();
			release_supermob();
			break;
		}
	}
	return ;
}
Exemplo n.º 5
0
bool rp_exit_trigger( CHAR_DATA *ch, int door )
{
	PROG_LIST * prg;

	for ( prg = ch->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == &TRIG_EXIT
		     && door == atoi( prg->trig_phrase ) )
		{
			rset_supermob( ch->in_room );
			create_rprog_env( prg->name, prg->code, ch->in_room, ch, NULL, NULL, prg->trig_type, prg->trig_phrase );
			program_flow();
			release_supermob();
			return ( TRUE );
		}
	}
	return ( FALSE );
}
Exemplo n.º 6
0
void rp_time_trigger( ROOM_INDEX_DATA *room, int time )
{
	PROG_LIST * prg;


	for ( prg = room->progs; prg; prg = prg->next )
	{
		if ( prg->trig_type == &TRIG_TIME
		     && time == atoi( prg->trig_phrase ) )
		{
			rset_supermob( room );
			create_rprog_env( prg->name, prg->code, room, NULL, NULL, NULL, prg->trig_type, prg->trig_phrase );
			program_flow();
			release_supermob();
			break;
		}
	}
	return ;
}
Exemplo n.º 7
0
/* sit, rest, sleep + object ewentualny */
bool rp_pos_trigger( CHAR_DATA *ch, OBJ_DATA *obj, BITVECT_DATA *type )
{
	PROG_LIST * prg;

	for ( prg = ch->in_room->progs; prg != NULL; prg = prg->next )
	{
		if ( prg->trig_type == type )
			if ( ( is_number( prg->trig_phrase ) && obj != NULL
			       && ( obj->pIndexData->vnum == atoi( prg->trig_phrase ) ) )
			     || !str_cmp( prg->trig_phrase, "none" ) )
			{
				rset_supermob( ch->in_room );
				create_rprog_env( prg->name, prg->code, ch->in_room, ch, obj, NULL, prg->trig_type, prg->trig_phrase );
				program_flow();
				release_supermob();
				return ( TRUE );
			}
	}
	return ( FALSE );
}
Exemplo n.º 8
0
void read_obj_file( char *dirname, char *filename )
{
   ROOM_INDEX_DATA *room;
   FILE *fp;
   char fname[256];
   int vnum;

   vnum = atoi( filename );

   if( ( room = get_room_index( vnum ) ) == NULL )
   {
      bug( "read_obj_file: ARGH! Missing room index for %d!", vnum );
      return;
   }

   snprintf( fname, 256, "%s%s", dirname, filename );
   if( ( fp = fopen( fname, "r" ) ) != NULL )
   {
      short iNest;
      bool found;
      OBJ_DATA *tobj, *tobj_next;

      rset_supermob( room );
      for( iNest = 0; iNest < MAX_NEST; iNest++ )
         rgObjNest[iNest] = NULL;

      found = TRUE;
      for( ;; )
      {
         char letter;
         const char *word;

         letter = fread_letter( fp );
         if( letter == '*' )
         {
            fread_to_eol( fp );
            continue;
         }

         if( letter != '#' )
         {
            bug( "%s", "read_obj_file: # not found." );
            break;
         }

         word = fread_word( fp );
         if( !str_cmp( word, "OBJECT" ) ) /* Objects  */
            fread_obj( supermob, fp, OS_CARRY );
         else if( !str_cmp( word, "END" ) )  /* Done     */
            break;
         else
         {
            bug( "read_obj_file: bad section: %s", word );
            break;
         }
      }
      FCLOSE( fp );
      unlink( fname );
      for( tobj = supermob->first_carrying; tobj; tobj = tobj_next )
      {
         tobj_next = tobj->next_content;
#ifdef OVERLANDCODE
         if( IS_OBJ_STAT( tobj, ITEM_ONMAP ) )
         {
            SET_ACT_FLAG( supermob, ACT_ONMAP );
            supermob->map = tobj->map;
            supermob->x = tobj->x;
            supermob->y = tobj->y;
         }
#endif
         obj_from_char( tobj );
#ifndef OVERLANDCODE
         obj_to_room( tobj, room );
#else
         obj_to_room( tobj, room, supermob );
         REMOVE_ACT_FLAG( supermob, ACT_ONMAP );
         supermob->map = -1;
         supermob->x = -1;
         supermob->y = -1;
#endif
      }
      release_supermob(  );
   }
   else
      log_string( "Cannot open obj file" );

   return;
}
Exemplo n.º 9
0
void rp_delay_trigger( CHAR_DATA *ch )
{
	rset_supermob( ch->in_room );
	rp_percent_trigger( supermob, ch, NULL, NULL, &TRIG_DELAY );
	release_supermob();
}
Exemplo n.º 10
0
void rp_random_trigger( ROOM_INDEX_DATA *pRoom, BITVECT_DATA *type )
{
	rset_supermob( pRoom );
	rp_percent_trigger( supermob, NULL, NULL, NULL, type );
	release_supermob();
}
Exemplo n.º 11
0
void rp_enter_trigger( CHAR_DATA *ch )
{
	rset_supermob( ch->in_room );
	rp_percent_trigger( supermob, ch, NULL, NULL, &TRIG_ENTRY );
	release_supermob();
}