area/
build/testing/
log/
player/
player/backup/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/
#include <glib.h>

#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <merc.h>
#include <interp.h>
#include <tables.h>
#include <power.h>
#include <fight.h>

extern int sphere_lookup args((char * sphere)); 
extern bool create_foci args((CHAR_DATA *ch, OBJ_DATA *obj, int want_sphere));

bool check_time_sence(CHAR_DATA *victim){
	if (get_disc(victim,DISC_TEMPORIS) > 0 )
		return TRUE;
	if (has_sphere(victim, SPHERE_TIME) > 4)
		return TRUE;
	return FALSE;

}
void power_heal(CHAR_DATA *ch, CHAR_DATA *victim, char *argument)
{
	if (victim->hit >= victim->max_hit)
                return;
	
	victim->hit += ( number_range(100,175) * (has_sphere(ch,SPHERE_LIFE)));
	
//	if (victim->hit >= victim->max_hit)
//		victim->hit = victim->max_hit;
	
	act("You can feel your life force heal $N.", ch, NULL, victim, TO_CHAR);
	act("Energy flows from $n to $n.", ch, NULL, victim, TO_NOTVICT);
	act("You feel more alive.", ch, NULL, victim, TO_VICT);
    return;
}

void power_life_shield(CHAR_DATA *ch, CHAR_DATA *victim, char *argument)
{
	SPHERE_DATA af;
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_LIFE_SHIELD) )
		return;
	af.spell_number = mage_affect_slot("Life Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_LIFE);
	af.bitvector = AFSPHERE_LIFE_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Life Shield")].on_msg, ch );
    return;
}

void power_mregen(CHAR_DATA *ch, CHAR_DATA *victim, char *argument)
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_REGEN) )
		return;
	af.spell_number = mage_affect_slot("Regen");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_LIFE);
	af.bitvector = AFSPHERE_REGEN;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Regen")].on_msg, ch );
    return;
}

void power_entropy_shield( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_ENTROPY_SHIELD) )
		return;
	af.spell_number = mage_affect_slot("Entropy Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_ENTROPY);
	af.bitvector = AFSPHERE_ENTROPY_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Entropy Shield")].on_msg, ch );
	return;
}

void power_force_shield( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_FORCES_SHIELD) )
		return;
	af.spell_number = mage_affect_slot("Force Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_FORCES);
	af.bitvector = AFSPHERE_FORCES_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Force Shield")].on_msg, ch );
	return;
	
}

void power_mind_shield( CHAR_DATA *ch,CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_MIND_SHIELD) )
		return;
	
    af.spell_number = mage_affect_slot("Mind Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_MIND);
	af.bitvector = AFSPHERE_MIND_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Mind Shield")].on_msg, ch );
	return;
	
}

void power_prime_shield( CHAR_DATA *ch,CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_PRIME_SHIELD) )
		return;
	af.spell_number = mage_affect_slot("Prime Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_PRIME);
	af.bitvector = AFSPHERE_PRIME_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Prime Shield")].on_msg, ch );
	return;
	
}

void power_spirit_shield( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_SPIRIT_SHIELD) )
		return;
	af.spell_number = mage_affect_slot("Spirit Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_SPIRIT);
	af.bitvector = AFSPHERE_SPIRIT_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Spirit Shield")].on_msg, ch );
	return;
	
}

void power_create_foci( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	char      arg1 [MAX_INPUT_LENGTH];
	char      buf [MAX_INPUT_LENGTH];
	OBJ_DATA *obj = NULL;
	int want_sphere;
	
	argument = one_argument( argument, arg1);
	
	if ( arg1[0] == '\0' )
	{
		send_to_char("Avalible shperes:\n\r",ch);
		send_to_char("Correspondence,Entropy,Forces,Mind,Matter,\n\r",ch);
		send_to_char("Prime,Spirit,Life, and Time\n\r",ch);
		return;	
	}	
	
	if (( want_sphere = sphere_lookup(arg1)) == 666 )
	{
		send_to_char("Available spheres:\n\r",ch);
		send_to_char("Correspondence, Entropy, Forces, Mind, Matter,\n\r",ch);
		send_to_char("Prime, Spirit, Life, and Time\n\r",ch);
		return;	
	}	
	
	if ( has_sphere(ch,want_sphere) < 1 )
	{
		send_to_char("You are not trained in that sphere.\n\r",ch);
		return;
	}
	
	if ( ( obj = get_obj_carry( ch, "foci" ) ) != NULL )
	{
		create_foci(ch,obj,want_sphere);
		return;	
	}
	
	if ( ( obj = get_obj_wear( ch, "foci" ) ) != NULL )
	{
		create_foci(ch,obj,want_sphere);
		return;
	}	
	
	if ((obj = create_object(get_obj_index(OBJ_VNUM_FOCI),ch->level)) == NULL)
	{
		send_to_char( "Error in Create Foci! Tell a Admin it's missing!.\n\r", ch);
		return;
	}
	else 
	{	
		obj->sphere[0]  = 0;
		obj->sphere[1]  = 0;
		obj->sphere[2]  = 0;
		obj->sphere[3]  = 0;
		obj->sphere[4]  = 0;
		obj->sphere[5]  = 0;
		obj->sphere[6]  = 0;
		obj->sphere[7]  = 0;
		obj->sphere[8]  = 0;
	}
	
	if (create_foci(ch,obj,want_sphere))
	{
		
		sprintf(buf,"%s foci",ch->name->str);
		obj->name = g_string_assign(obj->name,buf);
		if (IS_NPC(ch)) sprintf(buf,"the foci of %s",ch->short_descr->str);
		else sprintf(buf,"the foci of %s",ch->name->str);
		buf[0] = UPPER(buf[0]);
		obj->short_descr = g_string_assign(obj->short_descr,buf);
		if (IS_NPC(ch)) sprintf(buf,"A mage's foci is here.  %s might need it later.",ch->short_descr->str);
		else sprintf(buf,"A mage's foci is here.  %s might need it later.",ch->name->str);
		buf[0] = UPPER(buf[0]);
		obj->description = g_string_assign(obj->description,buf);
		
		obj->questmaker = g_string_assign(obj->questmaker,ch->name->str);
		if (!IS_NPC(ch))
		{
			obj->questowner = g_string_assign(obj->questowner,ch->name->str);
		}
		obj_to_char(obj,ch);
		act("$p fades into existance in your hand.", ch, obj, NULL, TO_CHAR);
		act("$p fades into existance in $n's hand.", ch, obj, NULL, TO_ROOM);
		return;
		
	}
	send_to_char("Foci, Denied!\n\r",ch);	
}

void power_charged_bolt( CHAR_DATA *ch,CHAR_DATA *victim, char *argument )
{
	int sn;
	int DAMAGE_MOD = 4;
    bool Passed = FALSE;
	
	
	if ( ( sn = skill_lookup( "call lightning" ) ) < 0)
	{
		send_to_char("Whoops error in the code.. please report to Spiral/Dominion.\n\r",ch);
		return;
	}

	if (!IS_NPC(victim))
    {
        if (IS_IMMMERIT(victim, IMM_MERIT_LIGHTNING))
		    DAMAGE_MOD = 2;
	    if (IS_IMMFLAW(victim, IMM_FLAW_LIGHTNING))
		    DAMAGE_MOD = 8;
    }

    if (IS_NPC(victim))
    {
        if (IS_SET(victim->mob_con, MOBCON_RESLIGHT))
            DAMAGE_MOD = 2; 	
        else
            DAMAGE_MOD = 4;
    }
    
	if (has_sphere(ch,SPHERE_FORCES) >= 1)
    {
       Passed = TRUE;
       if (!IS_NPC(victim) && victim->pcdata->willpower >= number_range(10,50))
            Passed = FALSE;
       if (Passed) 
           damage( ch, victim, (850 * has_sphere(ch,SPHERE_FORCES)) * DAMAGE_MOD, sn );
    }
    
    if (has_sphere(ch,SPHERE_FORCES) >= 4)
    {
       Passed = TRUE;
       if (!IS_NPC(victim) && victim->pcdata->willpower >= number_range(10,50))
            Passed = FALSE;
       if (Passed) 
           damage( ch, victim, (850 * has_sphere(ch,SPHERE_FORCES)) * DAMAGE_MOD, sn );
    }

    if (has_sphere(ch,SPHERE_FORCES) >= 6)
    {
       Passed = TRUE;
       if (!IS_NPC(victim) && victim->pcdata->willpower >= number_range(10,50))
            Passed = FALSE;
       if (Passed) 
           damage( ch, victim, (850 * has_sphere(ch,SPHERE_FORCES)) * DAMAGE_MOD, sn );
    }

	set_attack_flag(ch,victim);
	act("You grin with a evil smile as your body charges a bolt and hits $N dead on.", ch, NULL, victim, TO_CHAR);
	act("$N dances in pain as $n hits them with a charged bolt of lighting.", ch, NULL, victim, TO_NOTVICT);
	act("You feel like fried chicken after $n's bolt nails you dead on.", ch, NULL, victim, TO_VICT);
	if (ch->mana > 5000)
		ch->mana -= number_range(100,3000);
	return;
}

void power_alter_flow( CHAR_DATA *ch, CHAR_DATA *victim, char *argument )
{
	int sn;
    int DAMAGE_MOD =4;
    bool Passed;

	if ( ( sn = skill_lookup( "energy drain" ) ) < 0)
	{
		send_to_char("Whoops error in the code.. please report to Spiral or Dominion.\n\r",ch);
		return;
	}

	if (!IS_NPC(victim))
    {
        if (IS_IMMMERIT(victim, IMM_MERIT_DRAIN))
		    DAMAGE_MOD = 2;
	    if (IS_IMMFLAW(victim, IMM_FLAW_DRAIN))
		    DAMAGE_MOD = 8;
    }

    if (IS_NPC(victim))
            DAMAGE_MOD = 4;
    
	Passed = TRUE;
    if (!IS_NPC(victim) && victim->pcdata->willpower >= number_range(10,50))
       Passed = FALSE;

    if (Passed) 
    {
        damage( ch, victim, (1000 * has_sphere(ch,SPHERE_PRIME) * DAMAGE_MOD )* number_range(3,10), sn );
        damage( ch, victim, (1000 * has_sphere(ch,SPHERE_PRIME) * DAMAGE_MOD )* number_range(3,10), sn );
    }
    
    act("You raise your hand and energy surges forth and hits $N dead on.", ch, NULL, victim, TO_CHAR);
	act("$N whinces in pain as $n hits them with a flow of energy."
		, ch, NULL, victim, TO_NOTVICT);
	act("You feel energy flow out of your body as $n's blast hits you.", ch
		, NULL, victim, TO_VICT);
	if (ch->mana > 5000)
		ch->mana -= number_range(100,3000);
	return;
}

void power_mana_shield( CHAR_DATA *ch,CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_MANA_SHIELD) )
		return;
	
	af.spell_number = mage_affect_slot("Mana Shield");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_MIND);
	af.bitvector = AFSPHERE_MANA_SHIELD;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Mana Shield")].on_msg, ch );
	return;
	
}


void power_pathos( CHAR_DATA *ch, CHAR_DATA *victim, char *argument )
{
	char      buf [MAX_INPUT_LENGTH];
	char      buf2 [MAX_INPUT_LENGTH];
	sh_int    count,lcount = 0;
	
	if (!IS_NPC(victim) && IS_IMMUNE(victim,IMM_SHIELDED) && !IS_ITEMAFF(ch, ITEMA_VISION))
	{
		send_to_char("You are unable to read their aura.\n\r",ch);
	        ch->mana -= 250;
		return;
	}
	
	if (!IS_NPC(victim) && IS_SET(victim->sphere_spaffect,AFSPHERE_SHIELD) && !IS_ITEMAFF(ch, ITEMA_VISION))
	{
		send_to_char("You are unable to read their aura.\n\r",ch);
	        ch->mana -= 250;
		return;
	}
	
	act("$n examines $N intently.",ch,NULL,victim,TO_NOTVICT);
	act("$n examines you intently.",ch,NULL,victim,TO_VICT);
	if (IS_NPC(victim)) sprintf(buf, "%s is an NPC.\n\r",victim->short_descr->str);
	else 
	{
		if      (victim->level == 12) sprintf(buf, "%s is an Implementor.\n\r", victim->name->str);
		else if (victim->level == 11) sprintf(buf, "%s is a High Judge.\n\r", victim->name->str);
		else if (victim->level == 10) sprintf(buf, "%s is a Judge.\n\r", victim->name->str);
		else if (victim->level == 9 ) sprintf(buf, "%s is an Enforcer.\n\r", victim->name->str);
		else if (victim->level == 8 ) sprintf(buf, "%s is a Quest Maker.\n\r", victim->name->str);
		else if (victim->level == 7 ) sprintf(buf, "%s is a Builder.\n\r", victim->name->str);
		else if (victim->level >= 3 ) sprintf(buf, "%s is an Avatar.\n\r", victim->name->str);
		else sprintf(buf, "%s is a Mortal.\n\r", victim->name->str);
	}
	send_to_char(buf,ch);
	if (!IS_NPC(victim))
	{
		sprintf(buf,"Str:%d, Int:%d, Wis:%d, Dex:%d, Con:%d.\n\r",
                    get_curr_str(victim),
                    get_curr_int(victim), 
                    get_curr_wis(victim), 
                    get_curr_dex(victim), 
                    get_curr_con(victim));
		send_to_char(buf,ch);
	}
	sprintf(buf,"Hp:%d/%d, Mana:%d/%d, Move:%d/%d.\n\r", 
            victim->hit,
            victim->max_hit, 
            victim->mana,
            victim->max_mana,
            victim->move,
            victim->max_move);
	send_to_char(buf,ch);
	if (!IS_NPC(victim)) sprintf(buf,"Hitroll:%d, Damroll:%d, AC:%d.\n\r",
            char_hitroll(victim),
            char_damroll(victim),
            char_ac(victim));
	else sprintf(buf,"AC:%d.\n\r",char_ac(victim));
	send_to_char(buf,ch);
	if (!IS_NPC(victim))
	{
		sprintf(buf,"Status:%d, ",victim->race);
		send_to_char(buf,ch);
		if (IS_CLASS(victim, CLASS_VAMPIRE))    
		{
			sprintf(buf,"Blood:%d, ",victim->pcdata->condition[COND_THIRST]);
			send_to_char(buf,ch);
		}
	}
	sprintf(buf,"Alignment:%d.\n\r",victim->alignment);
	send_to_char(buf,ch);
	if (!IS_NPC(victim) && IS_EXTRA(victim, EXTRA_PREGNANT))
		act("$N is pregnant.",ch,NULL,victim,TO_CHAR);
	if (!IS_NPC(victim) && IS_CLASS(victim, CLASS_VAMPIRE))    
	{
		str_cpy(buf2,"");
        str_cpy(buf,"");
        send_to_char("Disciplines:",ch);
		for ( count = 0 ; count < MAX_DISC ; count++ )
		{
			if ( get_disc(victim,count) > 0 )
			{
				sprintf(buf2, " %s %d,", discipline_table[count].name, 
                                                         get_disc(victim,count));
				if (strcmp(buf2,""))
            	{
            		lcount += 1;
                	if ( lcount >= 3 )
                	{
                            strcat(buf,"	");
                            strcat(buf, buf2);
                            strcat(buf, "\n\r");
                            send_to_char(buf, ch);
                            lcount = 0;
                            str_cpy(buf, "");
                    }
                    else
                    {
                            if ( lcount > 1 )
                                strcat(buf,"	");
                            strcat(buf, buf2);
                	}
            	}
				

			}

			
		}
		buf[strlen(buf)] = '.'; /* hack off the final comma, replace it with a period. */
		send_to_char(buf,ch);
		send_to_char("\n\r",ch);
	}
	return;
}

void power_location( CHAR_DATA *ch, CHAR_DATA *victim, char *argument )
{
	ROOM_INDEX_DATA *chroom;
	ROOM_INDEX_DATA *victimroom;
	
	if (!has_planesight(ch,victim)){
		send_to_char("You are unable to locate them.\n\r",ch);
		return;
	}

	if (!IS_NPC(victim) && IS_IMMUNE(victim,IMM_SHIELDED) && !IS_ITEMAFF(ch,
		ITEMA_VISION))
	{
		send_to_char("You are unable to locate them.\n\r",ch);
		return;
	}
	
	if (!IS_NPC(victim) && IS_SET(victim->sphere_spaffect,AFSPHERE_SHIELD) && !IS_ITEMAFF(ch, ITEMA_VISION))
	{
		send_to_char("You are unable to locate them.\n\r",ch);
		return;
	}

	if (!IS_NPC(victim) && get_tribe(victim, TRIBE_SHADOW_LORDS) > 0 )
	{
		send_to_char("You are unable to locate them.\n\r",ch);
		return;
	}
	
    	chroom = ch->in_room;
	victimroom = victim->in_room;
	
	char_from_room(ch);
	char_to_room(ch,victimroom);
	
	do_look(ch,"auto");
	char_from_room(ch);
	char_to_room(ch,chroom);
	return;
}

void power_travel( CHAR_DATA *ch, CHAR_DATA *victim, char *argument )
{
	if ( victim == ch
		||   victim->in_room == NULL
		||   IS_NPC(ch)
		||   victim->level > 50
		||   (!IS_NPC(victim) && !IS_IMMUNE(victim, IMM_SUMMON) )
		||   IS_SET(ch->in_room->room_flags, ROOM_PRIVATE)
		||   IS_SET(ch->in_room->room_flags, ROOM_SOLITARY)
		||   IS_SET(ch->in_room->room_flags, ROOM_NO_RECALL)
		||   IS_SET(victim->in_room->room_flags, ROOM_PRIVATE)
		||   IS_SET(victim->in_room->room_flags, ROOM_SOLITARY)
		||   IS_SET(victim->in_room->room_flags, ROOM_NO_RECALL)
		||   victim->in_room->vnum == 1
		||   victim->in_room->vnum == 2
		||   victim->in_room->vnum == 1200
		||   (ch->pk_timer > 0 && is_tempsafe(ch)) 
		||   ( strstr(victim->in_room->area->builders, "Unlinked" ) )
		||   victim->in_room->vnum == ch->in_room->vnum)
	{
		send_to_char( "Your spell has fizzled.\n\r", ch );
		return;
	}
	
	send_to_char("You think of a different place.\n\r",ch);
	char_from_room( ch );
	char_to_room( ch, victim->in_room );
	
	act( "$n appears in front of $N.", ch, NULL, victim, TO_ROOM );
	act( "$N appears in front of you.", ch, NULL, victim, TO_VICT );
	do_look( ch,"auto");
	return;
}

void power_speed_time( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_SPEED_TIME) )
		return;
	af.spell_number = mage_affect_slot("Speedtime");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 3 * has_sphere(ch,SPHERE_TIME);
	af.bitvector = AFSPHERE_SPEED_TIME;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Speedtime")].on_msg, ch );
	return;
	
}

void power_dispel( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA *paf,*paf_next;
	
	for (paf = ch->sphere_affected; paf != NULL; paf = paf_next)
	{
		paf_next = paf->next;
		if (!str_cmp(argument,mage_affect_table[paf->spell_number].spell_name))        
		{
			/*
			 * Quick check for plane shift..
			 */
				
			sphere_remove(ch,paf);
			if (paf->type == TYPE_PLANE)
				shift_obj_plane(ch);
			send_to_char("You slide back in time to remove your spell affect.\n\r",ch);
			return;
		}
	} 
	send_to_char("You are not affected by that affect. \n\r",ch); 
		
}

void power_rip( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	int chance = 20;
	CHAR_DATA *mount;
	ROOM_INDEX_DATA *pRoomIndex;
	int to_room;
	
	if (IS_NPC(victim) || check_time_sence(victim))
	{
		chance = 10;
	}
	
	if ( victim->in_room == NULL
		||   IS_SET(victim->in_room->room_flags, ROOM_NO_RECALL)
		||   is_tempsafe(ch)
		||   IS_SET(victim->in_room->room_flags, ROOM_NO_TELEPORT)
		|| ( !IS_NPC(ch) && victim->fighting != NULL )
		||   victim == ch 
		||   number_percent() > chance )
	{
		send_to_char( "Your spell has fizzled.\n\r", ch );
		return;
	}

	for ( ; ; )
	{
		to_room = number_range( 0, 65535 );
		pRoomIndex = get_room_index( to_room );
		if ( pRoomIndex != NULL )
			if ( !IS_SET(pRoomIndex->room_flags, ROOM_PRIVATE)
				&&   !IS_SET(pRoomIndex->room_flags, ROOM_SOLITARY)
				&&   !IS_SET(pRoomIndex->room_flags, ROOM_NO_TELEPORT)
				&& ( !(strstr(pRoomIndex->area->builders, "Unlinked")))
				&&   to_room != 30008 && to_room != 30002 && to_room != 2
				&&   to_room != 1     && to_room != 1200)
				break;
	}
	
	act( "$n tears a hole in the air, and $N is ripped into another time and space..", ch, NULL, victim, TO_ROOM );
	act( "You tear a hole in the air, and $N is ripped into another time and space..", ch, NULL, victim, TO_CHAR );
	act( "$n tears a hole in the air, and you are ripped into another time and space..", ch, NULL, victim, TO_VICT );
	char_from_room( victim );
	char_to_room( victim, pRoomIndex );
	act( "$n slowly fades into existence.", victim, NULL, NULL, TO_ROOM );
	do_look( victim, "auto" );
	if ( (mount = ch->mount) == NULL ) return;
	char_from_room( mount );
	char_to_room( mount, ch->in_room );
	do_look( mount, "auto" );
	return;
}

void power_flames( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	char      arg [MAX_INPUT_LENGTH];
	SPHERE_DATA af;
	
	argument = one_argument( argument, arg );
	
	if (IS_SET(victim->sphere_spaffect,ADDED_FLAMES_PURE) )
		return;
	af.spell_number = mage_affect_slot("Flames of Purification");
	af.type      = TYPE_SPHERE_ADDED;
	af.duration  = 2 * has_sphere(ch,SPHERE_PRIME);
	af.bitvector = ADDED_FLAMES_PURE;
	sphere_to_char( victim, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Flames of Purification")].on_msg, victim );
	
    act( "$N whinces as flames engulf his body.", ch, NULL, victim, TO_ROOM );
	act( "$N whinces as flames engulf his body.", ch, NULL, victim, TO_CHAR );
	return;
}

void power_mist( CHAR_DATA *ch, CHAR_DATA *victim, char *argument )
{
	char buf [MAX_STRING_LENGTH]; 
	SPHERE_DATA af;
	
	if (IS_AFFECTED(ch, AFF_POLYMORPH))
	{
		send_to_char( "You can only turn in to mist from human form.\n\r", ch );
		return;
	}
	
	if (ch->stance[0] != -1) 
		do_stance(ch,"");
	if (ch->mounted == IS_RIDING) 
		do_dismount(ch,"");
	ch->pcdata->condition[COND_THIRST] -= number_range(40,50);
	act( "You transform into mist form.", ch, NULL, NULL, TO_CHAR );
	act( "$n transforms into a white mist.", ch, NULL, NULL, TO_ROOM );
	if (IS_EXTRA(ch, TIED_UP))
	{
		act("The ropes binding you fall through your ethereal form.",ch,NULL,NULL,TO_CHAR);
		act("The ropes binding $n fall through $s ethereal form.",ch,NULL,NULL,TO_ROOM);
		REMOVE_BIT(ch->extra, TIED_UP);
		REMOVE_BIT(ch->extra, GAGGED);
		REMOVE_BIT(ch->extra, BLINDFOLDED);
	}
	if (is_affected(ch, gsn_web))
	{
		act("The webbing entrapping $n falls through $s ethereal form.",ch,NULL,NULL,TO_ROOM);
		send_to_char("The webbing entrapping you falls through your ethereal form.\n\r",ch);
		affect_strip(ch, gsn_web);
	}
	clear_stats(ch);
	SET_BIT(ch->pcdata->powers[WOLF_POLYAFF], POLY_MIST);
	SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_CHANGED);
	SET_BIT(ch->affected_by, AFF_POLYMORPH);
	ch->plane = PLANE_ETHEREAL;
	shift_obj_plane(ch);
	sprintf(buf, "%s the white mist", ch->name->str);
	ch->morph = g_string_assign(ch->morph,buf);
	
	if (IS_SET(ch->sphere_spaffect,ADDED_POLY_MIST) )
		return;
	af.spell_number = mage_affect_slot("Mist Poly");
	af.type      = TYPE_SPHERE_ADDED;
	af.duration  = 10 * has_sphere(ch,SPHERE_MATTER);
	af.bitvector = ADDED_POLY_MIST;
	sphere_to_char( ch, &af );
	strip_player(ch);
	return;
	
}

void power_taintmind( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(victim->sphere_spaffect,AFSPHERE_TAINTED) )
		return;
	
	if (!IS_NPC(victim) && (victim->pcdata->willpower >= number_range(2,30)))
	{
		act("You shake off $N's mind powers.",victim,NULL,ch,TO_CHAR);
		act("$n shakes off $N's mind powers.",victim,NULL,ch,TO_NOTVICT);
		act("$n shakes off your attempt.",victim,NULL,ch,TO_VICT);
		return;
	}
	    
	af.spell_number = mage_affect_slot("Tainted");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_MIND);
	af.bitvector = AFSPHERE_TAINTED;
	sphere_to_char( victim, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Tainted")].on_msg, victim );
	send_to_char("There now tainted...\n\r",ch);
	return;
}

void power_falsepride( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(victim->sphere_spaffect,AFSPHERE_FALSE_PRIDE) )
		return;
	
	af.spell_number = mage_affect_slot("False Pride");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = has_sphere(ch,SPHERE_SPIRIT);
	af.bitvector = AFSPHERE_FALSE_PRIDE;
	sphere_to_char( victim, &af );
	send_to_char( mage_affect_table[mage_affect_slot("False Pride")].on_msg, victim );
	send_to_char("The have a false sence of pride now.\n\r",ch);
	return;
}

void power_darksight( CHAR_DATA *ch,CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sight,SIGHT_NIGHTSIGHT) )
		return;
	af.spell_number = mage_affect_slot("Night Sight");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 10 * has_sphere(ch,SPHERE_CORRESPONDENCE);
	af.bitvector = SIGHT_NIGHTSIGHT;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Night Sight")].on_msg, ch );
	return;
	
}

void power_squarecircle( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(ch->sphere_spaffect,AFSPHERE_SQUARE_CIRCLE) )
		return;
	af.spell_number = mage_affect_slot("Square Circle");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 3 * has_sphere(ch,SPHERE_ENTROPY);
	af.bitvector = AFSPHERE_SQUARE_CIRCLE;
	sphere_to_char( ch, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Square Circle")].on_msg, ch );
	return;
	
}

void power_confusemind( CHAR_DATA *ch,CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;
	
	if (IS_SET(victim->added, ADDED_CONFUSE) )
		return;
	
	if (!IS_NPC(victim) && (victim->pcdata->willpower >= number_range(2,30)))
	{
		act("You shake off $N's mind powers.",victim,NULL,ch,TO_CHAR);
		act("$n shakes off $N's mind powers.",victim,NULL,ch,TO_NOTVICT);
		act("$n shakes off your attempt.",victim,NULL,ch,TO_VICT);
		return;
	}
	    
	af.spell_number = mage_affect_slot("Confuse Mind");
	af.type      = TYPE_SPHERE_ADDED;
	af.duration  = has_sphere(ch,SPHERE_MIND)/3;
	af.bitvector = ADDED_CONFUSE;
	sphere_to_char( victim, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Confuse Mind")].on_msg, victim );
		
	send_to_char("There mind has confusion...\n\r",ch);
	return;
}



void power_slow_time( CHAR_DATA *ch, CHAR_DATA *victim, char * argument )
{
	SPHERE_DATA af;

	if (IS_NPC(victim))
	{
		send_to_char( "Your spell has fizzled.\n\r", ch );
		return;
	}

	if (check_time_sence(victim)){
		send_to_char("Your timing has no affect.\n\r",ch);
		return;
	}

	if (!IS_NPC(victim) && victim->pcdata->willpower >= number_range(10,50))
	{
		send_to_char( "Your spell has fizzled.\n\r", ch );
		return;

	}


	if (victim->level < 3 )
	{
		send_to_char("Go pick on someone your own size!\n\r",ch);
		send_to_char( "Your spell has fizzled.\n\r", ch );
		return;
	}

	if (IS_SET(victim->sphere_spaffect,AFSPHERE_SLOW_TIME) )
		return;
	af.spell_number = mage_affect_slot("Slowtime");
	af.type      = TYPE_SPHERE_SPAFFECT;
	af.duration  = 2 * has_sphere(ch,SPHERE_TIME);
	af.bitvector = AFSPHERE_SLOW_TIME;
	sphere_to_char( victim, &af );
	send_to_char( mage_affect_table[mage_affect_slot("Slowtime")].on_msg, victim );
	act( "You lag the hell out of $N", ch, NULL, victim, TO_CHAR );
	return;

}