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 ); }
/* odpala trapy na obiektach, jesli powinien */ bool obj_trap_handler( CHAR_DATA *ch, OBJ_DATA *obj, int type ) { TRAP_DATA * trap; char buf[ MAX_INPUT_LENGTH ]; if ( !ch || !ch->in_room || obj->trap <= 0 ) return FALSE; if ( ( trap = get_trap_index( obj->trap ) ) == NULL ) return FALSE; if ( !trap->active || !IS_SET( trap->type, type ) ) return FALSE; if ( !supermob ) init_supermob(); char_from_room ( supermob ); char_to_room( supermob, ch->in_room ); obj->trap = 0; sprintf( buf, "trap%d", trap->vnum ); create_rprog_env( buf, trap->triggered, ch->in_room, ch, obj, NULL, NULL, NULL ); program_flow(); release_supermob(); /* jednorazowo!!! */ return TRUE; }
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(); }
bool room_exit_trap_handler( CHAR_DATA *ch, EXIT_DATA *pexit, int type ) { TRAP_DATA * trap; char buf[ MAX_INPUT_LENGTH ]; if ( !ch || !ch->in_room || !pexit || pexit->trap <= 0 ) return FALSE; if ( ( trap = get_trap_index( pexit->trap ) ) == NULL ) return FALSE; if ( !trap->active || !IS_SET( trap->type, type ) || !IS_SET( pexit->exit_info, EX_TRAP ) ) return FALSE; if ( !supermob ) init_supermob(); char_from_room ( supermob ); char_to_room( supermob, ch->in_room ); REMOVE_BIT( pexit->exit_info, EX_TRAP ); sprintf( buf, "trap%d", trap->vnum ); create_rprog_env( buf, trap->triggered, ch->in_room, ch, NULL, NULL, NULL, NULL ); program_flow(); release_supermob(); return TRUE; }
bool room_trap_handler( CHAR_DATA *ch ) { TRAP_DATA * trap; int chance = 50; char buf[ MAX_INPUT_LENGTH ]; if ( IS_NPC( ch ) ) return FALSE; if ( !ch || !ch->in_room ) return FALSE; if ( ( trap = get_trap_index( ch->in_room->trap ) ) == NULL ) return FALSE; if ( !trap->active || !EXT_IS_SET( ch->in_room->room_flags, ROOM_TRAP ) ) return FALSE; chance += 5 * trap->level; switch ( ch->class ) { case CLASS_THIEF: chance -= 2*ch->level; chance -= UMAX( 0, get_curr_stat_deprecated( ch, STAT_DEX ) - 18 ) *5; break; default: chance -= ch->level;break; } chance = URANGE( 10, chance, 95 ); if ( number_percent() > chance ) return FALSE; if ( !supermob ) init_supermob(); char_from_room ( supermob ); char_to_room( supermob, ch->in_room ); EXT_REMOVE_BIT( ch->in_room->room_flags, ROOM_TRAP ); sprintf( buf, "trap%d", trap->vnum ); create_rprog_env( buf, trap->triggered, ch->in_room, ch, NULL, NULL, NULL, NULL ); program_flow(); release_supermob(); return TRUE; }
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 ); }
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 ; }
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 ); }
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 ; }
bool rp_precommand_trigger( ROOM_INDEX_DATA *room, CHAR_DATA *victim, OBJ_DATA *obj, DO_FUN * fun, char *fun_name, char *argument ) { PROG_LIST * prg; for ( prg = room->progs; prg; prg = prg->next ) { if ( prg->trig_type == &TRIG_PRECOMMAND && !str_cmp( prg->trig_phrase, fun_name ) ) { victim->precommand_fun = fun; free_string( victim->precommand_arg ); victim->precommand_arg = str_dup( argument ); victim->precommand_pending = FALSE; create_rprog_env( prg->name, prg->code, room, victim, ( void * ) obj, NULL, prg->trig_type, prg->trig_phrase ); release_supermob(); program_flow(); return TRUE; } } return FALSE; }
/* 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 ); }
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; }
void rp_delay_trigger( CHAR_DATA *ch ) { rset_supermob( ch->in_room ); rp_percent_trigger( supermob, ch, NULL, NULL, &TRIG_DELAY ); release_supermob(); }
void rp_random_trigger( ROOM_INDEX_DATA *pRoom, BITVECT_DATA *type ) { rset_supermob( pRoom ); rp_percent_trigger( supermob, NULL, NULL, NULL, type ); release_supermob(); }
void rp_enter_trigger( CHAR_DATA *ch ) { rset_supermob( ch->in_room ); rp_percent_trigger( supermob, ch, NULL, NULL, &TRIG_ENTRY ); release_supermob(); }