bool spec_janitor( CHAR_DATA *ch ) { OBJ_DATA *trash; OBJ_DATA *trash_next; if ( !IS_AWAKE(ch) ) return FALSE; for ( trash = ch->in_room->contents; trash != NULL; trash = trash_next ) { trash_next = trash->next_content; if ( !IS_SET( trash->wear_flags, ITEM_TAKE ) || !can_loot(ch,trash)) continue; if ( trash->item_type == ITEM_DRINK_CON || trash->item_type == ITEM_TRASH || trash->cost < 10 ) { act( "$n picks up some trash.", ch, NULL, NULL, TO_ROOM ); obj_from_room( trash ); obj_to_char( trash, ch ); return TRUE; } } return FALSE; }
/* * Mob autonomous action. * This function takes 25% to 35% of ALL Merc cpu time. * -- Furey */ void mobile_update( void ) { CHAR_DATA *ch; CHAR_DATA *ch_next; EXIT_DATA *pexit; int door; /* Examine all mobs. */ for ( ch = char_list; ch != NULL; ch = ch_next ) { ch_next = ch->next; if ( !IS_NPC(ch) || ch->in_room == NULL || IS_AFFECTED(ch,AFF_CHARM)) continue; if (ch->in_room->area->empty && !IS_SET(ch->act,ACT_UPDATE_ALWAYS)) continue; /* Examine call for special procedure */ if ( ch->spec_fun != 0 ) { if ( (*ch->spec_fun) ( ch ) ) continue; } if (ch->pIndexData->pShop != NULL) /* give him some gold */ if ((ch->gold * 100 + ch->silver) < ch->pIndexData->wealth) { ch->gold += ch->pIndexData->wealth * number_range(1,20)/5000000; ch->silver += ch->pIndexData->wealth * number_range(1,20)/50000; } /* That's all for sleeping / busy monster, and empty zones */ if ( ch->position != POS_STANDING ) continue; /* Scavenge */ if ( IS_SET(ch->act, ACT_SCAVENGER) && ch->in_room->contents != NULL && number_bits( 6 ) == 0 ) { OBJ_DATA *obj; OBJ_DATA *obj_best; int max; max = 1; obj_best = 0; for ( obj = ch->in_room->contents; obj; obj = obj->next_content ) { if ( CAN_WEAR(obj, ITEM_TAKE) && can_loot(ch, obj) && obj->cost > max && obj->cost > 0) { obj_best = obj; max = obj->cost; } } if ( obj_best ) { obj_from_room( obj_best ); obj_to_char( obj_best, ch ); act( "$n gets $p.", ch, obj_best, NULL, TO_ROOM ); } } /* Wander */ if ( !IS_SET(ch->act, ACT_SENTINEL) && number_bits(3) == 0 && ( door = number_bits( 5 ) ) <= 5 && ( pexit = ch->in_room->exit[door] ) != NULL && pexit->u1.to_room != NULL && !IS_SET(pexit->exit_info, EX_CLOSED) && !IS_SET(pexit->u1.to_room->room_flags, ROOM_NO_MOB) && ( !IS_SET(ch->act, ACT_STAY_AREA) || pexit->u1.to_room->area == ch->in_room->area ) && ( !IS_SET(ch->act, ACT_OUTDOORS) || !IS_SET(pexit->u1.to_room->room_flags,ROOM_INDOORS)) && ( !IS_SET(ch->act, ACT_INDOORS) || IS_SET(pexit->u1.to_room->room_flags,ROOM_INDOORS))) { move_char( ch, door, FALSE ); } } return; }