<NME> Spell_Teleport.java
<BEF> package com.planet_ink.coffee_mud.Abilities.Spells;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;

import java.util.*;

/*
   Copyright 2001-2022 Bo Zimmerman
			return false;
		}
		String areaName=Util.combine(commands,0).trim().toUpperCase();
		int numRooms=0;
		for(int m=0;m<CMMap.numRooms();m++)
		{
			Room room=CMMap.getRoom(m);
			if(room.getArea().name().toUpperCase().startsWith(areaName))
				numRooms++;
		}

		if(numRooms==0)
		{
			mob.tell("You don't know of an area called '"+Util.combine(commands,0)+"'.");
			return false;
	public String ID()
	{
		return "Spell_Teleport";
		int tries=0;
		while((tries<20)&&(newRoom==null))
		{
			int roomNum=Dice.roll(1,numRooms,-1);
			for(int m=0;m<CMMap.numRooms();m++)
			{
				Room room=CMMap.getRoom(m);
				if(room.getArea().name().toUpperCase().startsWith(areaName))
				{
					if(roomNum==0)
					{
						newRoom=room;
						break;
					}
					else
						roomNum--;
				}
			}
			FullMsg enterMsg=new FullMsg(mob,newRoom,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null);
			Session session=mob.session();
			mob.setSession(null);
		return localizedName;
	}

	@Override
	protected int canTargetCode()
	{
		return 0;
	}

	@Override
	public int classificationCode()
	{
		return Ability.ACODE_SPELL|Ability.DOMAIN_CONJURATION;
	}

	@Override
	public long flags()
	{
		return Ability.FLAG_TRANSPORTING;
	}

	@Override
	public int abstractQuality()
	{
		return Ability.QUALITY_INDIFFERENT;
	}

	private boolean isBadRoom(final Room room, final MOB mob, final Room newRoom)
	{
		return (room==null)
		||(room==newRoom)
		||(room.getArea()==newRoom.getArea())
		||(room==mob.location())
		||(!CMLib.flags().canAccess(mob,room))
		||(CMLib.law().getLandTitle(room)!=null);
	}

	@Override
	public boolean invoke(final MOB mob, final List<String> commands, final Physical givenTarget, final boolean auto, final int asLevel)
	{

		if((auto||mob.isMonster())&&((commands.size()<1)||((commands.get(0)).equals(mob.name()))))
		{
			commands.clear();
			if((text().length()>0)&&(CMLib.map().findArea(text())!=null))
				commands.add(text());
			else
				commands.add(CMLib.map().getRandomArea().Name());
		}
		if(commands.size()<1)
		{
			mob.tell(L("Teleport to what area?"));
			return false;
		}
		final String areaName=CMParms.combine(commands,0).trim().toUpperCase();
		final Area A=CMLib.map().findArea(areaName);
		final Vector<Room> candidates=new Vector<Room>();
		if(A!=null)
			candidates.addAll(new XVector<Room>(A.getProperMap()));
		for(int c=candidates.size()-1;c>=0;c--)
		{
			if(!CMLib.flags().canAccess(mob,candidates.elementAt(c)))
				candidates.removeElementAt(c);
		}

		if(candidates.size()==0)
		{
			mob.tell(L("You don't know of an area called '@x1'.",CMParms.combine(commands,0)));
			return false;
		}

		if(CMLib.flags().isSitting(mob)||CMLib.flags().isSleeping(mob))
		{
			mob.tell(L("You need to stand up!"));
			return false;
		}

		Room newRoom=null;
		int tries=0;
		while((tries<20)&&(newRoom==null))
		{
			newRoom=candidates.elementAt(CMLib.dice().roll(1,candidates.size(),-1));
			if(((newRoom.roomID().length()==0)&&(CMLib.dice().rollPercentage()>50))
			||((newRoom.domainType()==Room.DOMAIN_OUTDOORS_AIR)&&(CMLib.dice().rollPercentage()>10)))
			{
				newRoom=null;
				continue;
			}
			final CMMsg enterMsg=CMClass.getMsg(mob,newRoom,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null);
			final Session session=mob.session();
			mob.setSession(null);
			if(!newRoom.okMessage(mob,enterMsg))
				newRoom=null;
			else
				newRoom=(Room)enterMsg.target();
			mob.setSession(session);
			tries++;
		}

		if(newRoom==null)
		{
			mob.tell(L("Your magic seems unable to take you to that area."));
			return false;
		}

		if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
			return false;

		final boolean success=proficiencyCheck(mob,0,auto);
		if(!success)
		{
			Room room=null;
			int x=0;
			while(isBadRoom(room,mob,newRoom) && ((++x)<1000))
				room=CMLib.map().getRandomRoom();
			if(isBadRoom(room,mob,newRoom))
				beneficialWordsFizzle(mob,null,L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell."));
			newRoom=room;
		}

		final CMMsg msg=CMClass.getMsg(mob,null,this,CMMsg.MASK_MOVE|verbalCastCode(mob,newRoom,auto),L("^S<S-NAME> invoke(s) a teleportation spell.^?"));
		if(mob.location().okMessage(mob,msg)&&(newRoom!=null))
		{
			mob.location().send(mob,msg);
			final List<MOB> h=properTargetList(mob,givenTarget,false);
			if(h==null)
				return false;

			final Room thisRoom=mob.location();
			for (final MOB follower : h)
			{
				final CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> appears in a puff of smoke.@x1",CMLib.protocol().msp("appear.wav",10)));
				final CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> disappear(s) in a puff of smoke."));
				if(thisRoom.okMessage(follower,leaveMsg)&&newRoom.okMessage(follower,enterMsg))
				{
					if(follower.isInCombat())
					{
						CMLib.commands().postFlee(follower,("NOWHERE"));
						follower.makePeace(false);
					}
					thisRoom.send(follower,leaveMsg);
					((Room)enterMsg.target()).bringMobHere(follower,false);
					((Room)enterMsg.target()).send(follower,enterMsg);
					follower.tell(L("\n\r\n\r"));
					CMLib.commands().postLook(follower,true);
				}
				else
				if(follower==mob)
					break;
			}
		}

		// return whether it worked
		return success;
	}
}

<MSG> 

git-svn-id: svn://192.168.1.10/public/CoffeeMud@1518 0d6f1817-ed0e-0410-87c9-987e46238f29

<DFF> @@ -22,15 +22,17 @@ public class Spell_Teleport extends Spell
 			return false;
 		}
 		String areaName=Util.combine(commands,0).trim().toUpperCase();
-		int numRooms=0;
+		Vector candidates=new Vector();
 		for(int m=0;m<CMMap.numRooms();m++)
 		{
 			Room room=CMMap.getRoom(m);
-			if(room.getArea().name().toUpperCase().startsWith(areaName))
-				numRooms++;
+			if((room.getArea().name().toUpperCase().startsWith(areaName))
+			&&(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))
+			   ||(mob.isASysOp(room))))
+				candidates.addElement(room);
 		}
 
-		if(numRooms==0)
+		if(candidates.size()==0)
 		{
 			mob.tell("You don't know of an area called '"+Util.combine(commands,0)+"'.");
 			return false;
@@ -40,21 +42,7 @@ public class Spell_Teleport extends Spell
 		int tries=0;
 		while((tries<20)&&(newRoom==null))
 		{
-			int roomNum=Dice.roll(1,numRooms,-1);
-			for(int m=0;m<CMMap.numRooms();m++)
-			{
-				Room room=CMMap.getRoom(m);
-				if(room.getArea().name().toUpperCase().startsWith(areaName))
-				{
-					if(roomNum==0)
-					{
-						newRoom=room;
-						break;
-					}
-					else
-						roomNum--;
-				}
-			}
+			newRoom=(Room)candidates.elementAt(Dice.roll(1,candidates.size(),-1));
 			FullMsg enterMsg=new FullMsg(mob,newRoom,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null);
 			Session session=mob.session();
 			mob.setSession(null);

{'commit': 'diff --git a/com/planet_ink/coffee_mud/Abilities/Druid/Chant_DistantGrowth.java b/com/planet_ink/coffee_mud/Abilities/Druid/Chant_DistantGrowth.java\nindex c3f16f0ab3..4e2526418f 100644\n--- a/com/planet_ink/coffee_mud/Abilities/Druid/Chant_DistantGrowth.java\n+++ b/com/planet_ink/coffee_mud/Abilities/Druid/Chant_DistantGrowth.java\n@@ -29,7 +29,9 @@ public class Chant_DistantGrowth extends Chant\n \t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n \t\t{\r\n \t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\tif(CoffeeUtensils.containsString(room.displayText().toUpperCase(),areaName))\r\n+\t\t\tif((CoffeeUtensils.containsString(room.displayText().toUpperCase(),areaName))\r\n+\t\t\t&&(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))\r\n+\t\t\t   ||(mob.isASysOp(room))))\r\n \t\t\t{\r\n \t\t\t   anyRoom=room;\r\n \t\t\t   if((room.domainType()&Room.INDOORS)==0)\r\ndiff --git a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Gate.java b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Gate.java\nindex 39e91eeb0e..598f0ec25e 100644\n--- a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Gate.java\n+++ b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Gate.java\n@@ -33,9 +33,13 @@ public class Spell_Gate extends Spell\n \t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n \t\t{\r\n \t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\ttarget=room.fetchInhabitant(areaName);\r\n-\t\t\tif(target!=null)\r\n-\t\t\t\tcandidates.addElement(target);\r\n+\t\t\tif(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))\r\n+\t\t\t   ||(mob.isASysOp(room)))\r\n+\t\t\t{\r\n+\t\t\t\ttarget=room.fetchInhabitant(areaName);\r\n+\t\t\t\tif(target!=null)\r\n+\t\t\t\t\tcandidates.addElement(target);\r\n+\t\t\t}\r\n \t\t}\r\n \t\tRoom newRoom=null;\r\n \t\tif(candidates.size()>0)\r\ndiff --git a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Summon.java b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Summon.java\nindex 0bc2340d86..a230fdcedb 100644\n--- a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Summon.java\n+++ b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Summon.java\n@@ -34,11 +34,15 @@ public class Spell_Summon extends Spell\n \t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n \t\t{\r\n \t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\ttarget=room.fetchInhabitant(areaName);\r\n-\t\t\tif(target!=null)\r\n+\t\t\tif(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))\r\n+\t\t\t   ||(mob.isASysOp(room)))\r\n \t\t\t{\r\n-\t\t\t\toldRoom=room;\r\n-\t\t\t\tbreak;\r\n+\t\t\t\ttarget=room.fetchInhabitant(areaName);\r\n+\t\t\t\tif(target!=null)\r\n+\t\t\t\t{\r\n+\t\t\t\t\toldRoom=room;\r\n+\t\t\t\t\tbreak;\r\n+\t\t\t\t}\r\n \t\t\t}\r\n \t\t}\r\n \r\ndiff --git a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java\nindex 8d20384fd3..f2a653d3ae 100644\n--- a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java\n+++ b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java\n@@ -22,15 +22,17 @@ public class Spell_Teleport extends Spell\n \t\t\treturn false;\r\n \t\t}\r\n \t\tString areaName=Util.combine(commands,0).trim().toUpperCase();\r\n-\t\tint numRooms=0;\r\n+\t\tVector candidates=new Vector();\r\n \t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n \t\t{\r\n \t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n-\t\t\t\tnumRooms++;\r\n+\t\t\tif((room.getArea().name().toUpperCase().startsWith(areaName))\r\n+\t\t\t&&(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))\r\n+\t\t\t   ||(mob.isASysOp(room))))\r\n+\t\t\t\tcandidates.addElement(room);\r\n \t\t}\r\n \r\n-\t\tif(numRooms==0)\r\n+\t\tif(candidates.size()==0)\r\n \t\t{\r\n \t\t\tmob.tell("You don\'t know of an area called \'"+Util.combine(commands,0)+"\'.");\r\n \t\t\treturn false;\r\n@@ -40,21 +42,7 @@ public class Spell_Teleport extends Spell\n \t\tint tries=0;\r\n \t\twhile((tries<20)&&(newRoom==null))\r\n \t\t{\r\n-\t\t\tint roomNum=Dice.roll(1,numRooms,-1);\r\n-\t\t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n-\t\t\t{\r\n-\t\t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n-\t\t\t\t{\r\n-\t\t\t\t\tif(roomNum==0)\r\n-\t\t\t\t\t{\r\n-\t\t\t\t\t\tnewRoom=room;\r\n-\t\t\t\t\t\tbreak;\r\n-\t\t\t\t\t}\r\n-\t\t\t\t\telse\r\n-\t\t\t\t\t\troomNum--;\r\n-\t\t\t\t}\r\n-\t\t\t}\r\n+\t\t\tnewRoom=(Room)candidates.elementAt(Dice.roll(1,candidates.size(),-1));\r\n \t\t\tFullMsg enterMsg=new FullMsg(mob,newRoom,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null);\r\n \t\t\tSession session=mob.session();\r\n \t\t\tmob.setSession(null);\r\ndiff --git a/com/planet_ink/coffee_mud/Commands/base/BasicSenses.java b/com/planet_ink/coffee_mud/Commands/base/BasicSenses.java\nindex 57926c7ecc..168997bf71 100644\n--- a/com/planet_ink/coffee_mud/Commands/base/BasicSenses.java\n+++ b/com/planet_ink/coffee_mud/Commands/base/BasicSenses.java\n@@ -479,7 +479,8 @@ public class BasicSenses\n \t\t\tfor(int a=0;a<CMMap.numAreas();a++)\r\n \t\t\t{\r\n \t\t\t\tArea A=(Area)CMMap.getArea(a);\r\n-\t\t\t\ttellMe.append(Util.padRight(A.name(),20)+": "+A.weatherDescription(room)+"\\n\\r");\r\n+\t\t\t\tif(!Sense.isHidden(A))\r\n+\t\t\t\t\ttellMe.append(Util.padRight(A.name(),20)+": "+A.weatherDescription(room)+"\\n\\r");\r\n \t\t\t}\r\n \t\t\tmob.tell(tellMe.toString());\r\n \t\t\treturn;\r\n', 'commit_subject': '', 'repo_name': 'bozimmerman/CoffeeMud', 'committer': {'name': 'bozimmerman', 'email': 'dc45fe023482b3b890b5e574e53c1d051f45b1ef@zimmers.net', 'time_sec': '1046724604', 'tz_offset': '0', 'date': {'seconds': '1046724604'}}, 'commit_tree': 'bbe0fde02ea8fdfebaf1137bccac2b20abbda462', 'commit_message': '\n\ngit-svn-id: svn://192.168.1.10/public/CoffeeMud@1518 0d6f1817-ed0e-0410-87c9-987e46238f29\n', 'language_name': 'Shell', 'license': 'apache-2.0', 'hunks': '@@ -22,15 +22,17 @@ public class Spell_Teleport extends Spell\n \t\t\treturn false;\r\n \t\t}\r\n \t\tString areaName=Util.combine(commands,0).trim().toUpperCase();\r\n-\t\tint numRooms=0;\r\n+\t\tVector candidates=new Vector();\r\n \t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n \t\t{\r\n \t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n-\t\t\t\tnumRooms++;\r\n+\t\t\tif((room.getArea().name().toUpperCase().startsWith(areaName))\r\n+\t\t\t&&(((!Sense.isHidden(room.getArea()))&&(!Sense.isHidden(room)))\r\n+\t\t\t   ||(mob.isASysOp(room))))\r\n+\t\t\t\tcandidates.addElement(room);\r\n \t\t}\r\n \r\n-\t\tif(numRooms==0)\r\n+\t\tif(candidates.size()==0)\r\n \t\t{\r\n \t\t\tmob.tell("You don\'t know of an area called \'"+Util.combine(commands,0)+"\'.");\r\n \t\t\treturn false;\r\n@@ -40,21 +42,7 @@ public class Spell_Teleport extends Spell\n \t\tint tries=0;\r\n \t\twhile((tries<20)&&(newRoom==null))\r\n \t\t{\r\n-\t\t\tint roomNum=Dice.roll(1,numRooms,-1);\r\n-\t\t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n-\t\t\t{\r\n-\t\t\t\tRoom room=CMMap.getRoom(m);\r\n-\t\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n-\t\t\t\t{\r\n-\t\t\t\t\tif(roomNum==0)\r\n-\t\t\t\t\t{\r\n-\t\t\t\t\t\tnewRoom=room;\r\n-\t\t\t\t\t\tbreak;\r\n-\t\t\t\t\t}\r\n-\t\t\t\t\telse\r\n-\t\t\t\t\t\troomNum--;\r\n-\t\t\t\t}\r\n-\t\t\t}\r\n+\t\t\tnewRoom=(Room)candidates.elementAt(Dice.roll(1,candidates.size(),-1));\r\n \t\t\tFullMsg enterMsg=new FullMsg(mob,newRoom,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null);\r\n \t\t\tSession session=mob.session();\r\n \t\t\tmob.setSession(null);\r\n', 'addition_count': 7, 'deletion_count': 19, 'src_file': 'a/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java', 'tgt_file': 'b/com/planet_ink/coffee_mud/Abilities/Spells/Spell_Teleport.java', 'file_extension': '.java', 'before_file': 'package com.planet_ink.coffee_mud.Abilities.Spells;\nimport com.planet_ink.coffee_mud.core.interfaces.*;\nimport com.planet_ink.coffee_mud.core.*;\nimport com.planet_ink.coffee_mud.core.collections.*;\nimport com.planet_ink.coffee_mud.Abilities.interfaces.*;\nimport com.planet_ink.coffee_mud.Areas.interfaces.*;\nimport com.planet_ink.coffee_mud.Behaviors.interfaces.*;\nimport com.planet_ink.coffee_mud.CharClasses.interfaces.*;\nimport com.planet_ink.coffee_mud.Commands.interfaces.*;\nimport com.planet_ink.coffee_mud.Common.interfaces.*;\nimport com.planet_ink.coffee_mud.Exits.interfaces.*;\nimport com.planet_ink.coffee_mud.Items.interfaces.*;\nimport com.planet_ink.coffee_mud.Libraries.interfaces.*;\nimport com.planet_ink.coffee_mud.Locales.interfaces.*;\nimport com.planet_ink.coffee_mud.MOBS.interfaces.*;\nimport com.planet_ink.coffee_mud.Races.interfaces.*;\n\nimport java.util.*;\n\n/*\n   Copyright 2001-2022 Bo Zimmerman\n\t\t\treturn false;\r\n\t\t}\r\n\t\tString areaName=Util.combine(commands,0).trim().toUpperCase();\r\n\t\tint numRooms=0;\r\n\t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n\t\t{\r\n\t\t\tRoom room=CMMap.getRoom(m);\r\n\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n\t\t\t\tnumRooms++;\r\n\t\t}\r\n\r\n\t\tif(numRooms==0)\r\n\t\t{\r\n\t\t\tmob.tell("You don\'t know of an area called \'"+Util.combine(commands,0)+"\'.");\r\n\t\t\treturn false;\r\n\tpublic String ID()\n\t{\n\t\treturn "Spell_Teleport";\n\t\tint tries=0;\r\n\t\twhile((tries<20)&&(newRoom==null))\r\n\t\t{\r\n\t\t\tint roomNum=Dice.roll(1,numRooms,-1);\r\n\t\t\tfor(int m=0;m<CMMap.numRooms();m++)\r\n\t\t\t{\r\n\t\t\t\tRoom room=CMMap.getRoom(m);\r\n\t\t\t\tif(room.getArea().name().toUpperCase().startsWith(areaName))\r\n\t\t\t\t{\r\n\t\t\t\t\tif(roomNum==0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnewRoom=room;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\troomNum--;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tFullMsg enterMsg=new FullMsg(mob,newRoom,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null,Affect.MSG_ENTER,null);\r\n\t\t\tSession session=mob.session();\r\n\t\t\tmob.setSession(null);\r\n\t\treturn localizedName;\n\t}\n\n\t@Override\n\tprotected int canTargetCode()\n\t{\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic int classificationCode()\n\t{\n\t\treturn Ability.ACODE_SPELL|Ability.DOMAIN_CONJURATION;\n\t}\n\n\t@Override\n\tpublic long flags()\n\t{\n\t\treturn Ability.FLAG_TRANSPORTING;\n\t}\n\n\t@Override\n\tpublic int abstractQuality()\n\t{\n\t\treturn Ability.QUALITY_INDIFFERENT;\n\t}\n\n\tprivate boolean isBadRoom(final Room room, final MOB mob, final Room newRoom)\n\t{\n\t\treturn (room==null)\n\t\t||(room==newRoom)\n\t\t||(room.getArea()==newRoom.getArea())\n\t\t||(room==mob.location())\n\t\t||(!CMLib.flags().canAccess(mob,room))\n\t\t||(CMLib.law().getLandTitle(room)!=null);\n\t}\n\n\t@Override\n\tpublic boolean invoke(final MOB mob, final List<String> commands, final Physical givenTarget, final boolean auto, final int asLevel)\n\t{\n\n\t\tif((auto||mob.isMonster())&&((commands.size()<1)||((commands.get(0)).equals(mob.name()))))\n\t\t{\n\t\t\tcommands.clear();\n\t\t\tif((text().length()>0)&&(CMLib.map().findArea(text())!=null))\n\t\t\t\tcommands.add(text());\n\t\t\telse\n\t\t\t\tcommands.add(CMLib.map().getRandomArea().Name());\n\t\t}\n\t\tif(commands.size()<1)\n\t\t{\n\t\t\tmob.tell(L("Teleport to what area?"));\n\t\t\treturn false;\n\t\t}\n\t\tfinal String areaName=CMParms.combine(commands,0).trim().toUpperCase();\n\t\tfinal Area A=CMLib.map().findArea(areaName);\n\t\tfinal Vector<Room> candidates=new Vector<Room>();\n\t\tif(A!=null)\n\t\t\tcandidates.addAll(new XVector<Room>(A.getProperMap()));\n\t\tfor(int c=candidates.size()-1;c>=0;c--)\n\t\t{\n\t\t\tif(!CMLib.flags().canAccess(mob,candidates.elementAt(c)))\n\t\t\t\tcandidates.removeElementAt(c);\n\t\t}\n\n\t\tif(candidates.size()==0)\n\t\t{\n\t\t\tmob.tell(L("You don\'t know of an area called \'@x1\'.",CMParms.combine(commands,0)));\n\t\t\treturn false;\n\t\t}\n\n\t\tif(CMLib.flags().isSitting(mob)||CMLib.flags().isSleeping(mob))\n\t\t{\n\t\t\tmob.tell(L("You need to stand up!"));\n\t\t\treturn false;\n\t\t}\n\n\t\tRoom newRoom=null;\n\t\tint tries=0;\n\t\twhile((tries<20)&&(newRoom==null))\n\t\t{\n\t\t\tnewRoom=candidates.elementAt(CMLib.dice().roll(1,candidates.size(),-1));\n\t\t\tif(((newRoom.roomID().length()==0)&&(CMLib.dice().rollPercentage()>50))\n\t\t\t||((newRoom.domainType()==Room.DOMAIN_OUTDOORS_AIR)&&(CMLib.dice().rollPercentage()>10)))\n\t\t\t{\n\t\t\t\tnewRoom=null;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfinal CMMsg enterMsg=CMClass.getMsg(mob,newRoom,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null);\n\t\t\tfinal Session session=mob.session();\n\t\t\tmob.setSession(null);\n\t\t\tif(!newRoom.okMessage(mob,enterMsg))\n\t\t\t\tnewRoom=null;\n\t\t\telse\n\t\t\t\tnewRoom=(Room)enterMsg.target();\n\t\t\tmob.setSession(session);\n\t\t\ttries++;\n\t\t}\n\n\t\tif(newRoom==null)\n\t\t{\n\t\t\tmob.tell(L("Your magic seems unable to take you to that area."));\n\t\t\treturn false;\n\t\t}\n\n\t\tif(!super.invoke(mob,commands,givenTarget,auto,asLevel))\n\t\t\treturn false;\n\n\t\tfinal boolean success=proficiencyCheck(mob,0,auto);\n\t\tif(!success)\n\t\t{\n\t\t\tRoom room=null;\n\t\t\tint x=0;\n\t\t\twhile(isBadRoom(room,mob,newRoom) && ((++x)<1000))\n\t\t\t\troom=CMLib.map().getRandomRoom();\n\t\t\tif(isBadRoom(room,mob,newRoom))\n\t\t\t\tbeneficialWordsFizzle(mob,null,L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell."));\n\t\t\tnewRoom=room;\n\t\t}\n\n\t\tfinal CMMsg msg=CMClass.getMsg(mob,null,this,CMMsg.MASK_MOVE|verbalCastCode(mob,newRoom,auto),L("^S<S-NAME> invoke(s) a teleportation spell.^?"));\n\t\tif(mob.location().okMessage(mob,msg)&&(newRoom!=null))\n\t\t{\n\t\t\tmob.location().send(mob,msg);\n\t\t\tfinal List<MOB> h=properTargetList(mob,givenTarget,false);\n\t\t\tif(h==null)\n\t\t\t\treturn false;\n\n\t\t\tfinal Room thisRoom=mob.location();\n\t\t\tfor (final MOB follower : h)\n\t\t\t{\n\t\t\t\tfinal CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> appears in a puff of smoke.@x1",CMLib.protocol().msp("appear.wav",10)));\n\t\t\t\tfinal CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> disappear(s) in a puff of smoke."));\n\t\t\t\tif(thisRoom.okMessage(follower,leaveMsg)&&newRoom.okMessage(follower,enterMsg))\n\t\t\t\t{\n\t\t\t\t\tif(follower.isInCombat())\n\t\t\t\t\t{\n\t\t\t\t\t\tCMLib.commands().postFlee(follower,("NOWHERE"));\n\t\t\t\t\t\tfollower.makePeace(false);\n\t\t\t\t\t}\n\t\t\t\t\tthisRoom.send(follower,leaveMsg);\n\t\t\t\t\t((Room)enterMsg.target()).bringMobHere(follower,false);\n\t\t\t\t\t((Room)enterMsg.target()).send(follower,enterMsg);\n\t\t\t\t\tfollower.tell(L("\\n\\r\\n\\r"));\n\t\t\t\t\tCMLib.commands().postLook(follower,true);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\tif(follower==mob)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// return whether it worked\n\t\treturn success;\n\t}\n}\n', 'message': '\n\ngit-svn-id: svn://192.168.1.10/public/CoffeeMud@1518 0d6f1817-ed0e-0410-87c9-987e46238f29\n', 'author_name': 'bozimmerman', 'lang': 'java'}