/*****************************************************
 * Get Random Mob
 * Snippet by Amras of Hexahedron
 * hexahedron.genesismuds.com port 1414
 *
 * Anyone may freely use this snippet provided they include this header.
 *****************************************************/



/*
 * Find a random mob in play and returns it.
 */
CHAR_DATA * get_random_mob()
{
	CHAR_DATA * mob;
	int i = 0, randnum = 0, totin;

	totin = tot_mobs();

	if(totin <= 0) //Something went wrong! No NPCs are in play! Bail out!!
		return NULL;

	randnum = number_range(0, totin);

	for(mob = char_list; mob != NULL; mob = mob->next)
	{
		if(IS_NPC(mob))
			i++;
		if(i >= randnum)
			break;
	}
	return mob;
}

/*
 * Return the total number of NPCs in play
 */
int tot_mobs()
{
	int i = 0;
	CHAR_DATA * mob;
	for(mob = char_list; mob != NULL; mob = mob->next)
		if(IS_NPC(mob))
			i++;
	return i;
}