scatter2.txt
snippets · 3.0 KB · 2010-03-30
Scatter command (updated version).
Download « Back to the snippets list
You will need to add a line to interp.c and interp.h as needed.
And then add this somewhere.. maybe act_wiz.c
/* Scatters everything in the room to random rooms all over your mud */
/* Written by Dither of Planes of Dominion webmaster@podmud.com */
/* Updated by Alderon of Anime MUD 2, anime2.ipupdater.net:7000 */
/* Added the ability to scatter objects, mobiles, and players seperately */
void do_scatter( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
ROOM_INDEX_DATA *pRoomIndex;
CHAR_DATA *vnext;
one_argument(argument, arg);
if (arg[0] == '\0') {
send_to_char("You must specify object, mobile, or players.\n\r", ch);
return;
}
if (!str_prefix(arg, "object")){
for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next ) {
obj_next = obj->next_content;
for ( ; ; )
{
pRoomIndex = get_room_index( number_range( 0, 65535 ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (CAN_WEAR(obj, ITEM_TAKE))
{
obj_from_room(obj);
obj_to_room(obj, pRoomIndex);
}
}
send_to_char("Items scattered.\n\r",ch);
return;
}
if (!str_prefix(arg, "mobile")){
for (victim = ch->in_room->people; victim != NULL; victim = vnext) {
vnext = victim->next_in_room;
for ( ; ; )
{
pRoomIndex = get_room_index( number_range( 0, 65535 ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (IS_NPC(victim)
&& !IS_SET(victim->act, ACT_AGGRESSIVE) )
{
char_from_room(victim);
char_to_room(victim, pRoomIndex);
}
}
send_to_char("Mobiles scattered.\n\r",ch);
return;
}
if (!str_prefix(arg, "players")){
for (victim = ch->in_room->people; victim != NULL; victim = vnext) {
vnext = victim->next_in_room;
for ( ; ; )
{
pRoomIndex = get_room_index( number_range( 0, 65535 ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (!IS_NPC(victim)
&& !IS_IMMORTAL(victim))
{
char_from_room(victim);
char_to_room(victim, pRoomIndex);
send_to_char("`!You have been scattered!``\n\r", victim);
do_look(victim, "auto");
}
}
send_to_char("Players scattered.\n\r",ch);
return;
}
}
Add this to merc.h and modify as needed:
#define CAN_ACCESS(room) ( !IS_SET(room->room_flags, ROOM_PRIVATE) \
&& !IS_SET(room->room_flags, ROOM_SOLITARY) \
&& !IS_SET(room->room_flags, ROOM_NOTELEPORT) \
&& !IS_SET(room->room_flags, ROOM_NEWBIES_ONLY) \
&& !IS_SET(room->room_flags, ROOM_GODS_ONLY) \
&& !IS_SET(room->room_flags, ROOM_IMP_ONLY) \
&& !IS_SET(room->room_flags, ROOM_HOUSE) \
&& !IS_SET(room->room_flags, ROOM_ARENA) )