Scatter3.txt.txt
snippets · 4.2 KB · 2010-03-30
Scatter command by Dither (updated by Alderon): scatters everything in the room to random rooms.
Download « Back to the snippets list
/* 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 */
/* Further updated by Jaagari of Anime MUD 2 to allow specific areas to be */
/* chosen */
void do_scatter( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
int tmp;
CHAR_DATA *victim;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
ROOM_INDEX_DATA *pRoomIndex;
CHAR_DATA *vnext;
AREA_DATA *area = NULL;
argument = one_argument(argument, arg);
argument = one_argument(argument, arg2);
if (arg[0] == '\0' && arg2[0] == '\0') {
send_to_char("You must specify `#object`7, `#mobile`7, or `#players``.\n\r", ch);
return;
}
if (arg2[0] != '\0')
{
for (area = area_first; area; area = area->next)
{
if (!str_prefix(arg2, area->name) && area->security == 9)
{
break;
}
}
if (!str_prefix(arg2, "here") && ch->in_room->area->security == 9)
{
area = ch->in_room->area;
}
if (area == NULL)
{
send_to_char("That is not a valid area!\n\r", ch);
send_to_char("Syntax is:\n\rscatter <objext|mobile|player> [name of area|here]\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;
if (area)
{
/* This gets an actual loop because it can get caught in an inf-loop
much easier */
for (tmp=0;tmp < 1000;tmp++ )
{
pRoomIndex = get_room_index( number_range( area->min_vnum, area->max_vnum ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (pRoomIndex == NULL)
pRoomIndex = ch->in_room;
}
else
{
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;
if (area)
{
/* This gets an actual loop because it can get caught in an inf-loop
much easier */
for (tmp=0;tmp < 1000;tmp++ )
{
pRoomIndex = get_room_index( number_range( area->min_vnum, area->max_vnum ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (pRoomIndex == NULL)
pRoomIndex = ch->in_room;
}
else
{
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;
if (area)
{
/* This gets an actual loop because it can get caught in an inf-loop
much easier */
for (tmp=0;tmp < 1000;tmp++ )
{
pRoomIndex = get_room_index( number_range( area->min_vnum, area->max_vnum ) );
if ( pRoomIndex != NULL )
if ( CAN_ACCESS(pRoomIndex) )
break;
}
if (pRoomIndex == NULL)
pRoomIndex = ch->in_room;
}
else
{
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;
}
}