Commit 0c7f363d authored by bozimmerman's avatar bozimmerman

Certain teleporting magic fails if the caster can not go to the destination.StdAbility.java


git-svn-id: svn://192.168.1.10/public/CoffeeMud@15483 0d6f1817-ed0e-0410-87c9-987e46238f29
parent 59e62daa
......@@ -128,14 +128,13 @@ public class Chant_GroveWalk extends Chant
if((mob.location().okMessage(mob,msg))&&(newRoom.okMessage(mob,msg)))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> emerge(s) from around the stones."));
final CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> disappear(s) around the stones."));
if(thisRoom.okMessage(follower,leaveMsg)&&newRoom.okMessage(follower,enterMsg))
......@@ -151,6 +150,9 @@ public class Chant_GroveWalk extends Chant
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
......
......@@ -154,14 +154,13 @@ public class Chant_PlantPass extends Chant
if((mob.location().okMessage(mob,msg))&&(newRoom.okMessage(mob,msg)))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> emerge(s) from the @x1.",otherPlant.name()));
final CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> <S-IS-ARE> sucked into @x1.",myPlant.name()));
if(thisRoom.okMessage(follower,leaveMsg)&&newRoom.okMessage(follower,enterMsg))
......@@ -177,6 +176,9 @@ public class Chant_PlantPass extends Chant
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
}
......
......@@ -1392,7 +1392,7 @@ public class PlanarAbility extends StdAbility
if((mob.location().okMessage(mob,msg))&&(target.okMessage(mob,msg)))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
......@@ -1400,9 +1400,8 @@ public class PlanarAbility extends StdAbility
A.setMiscText(planeName);
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,target,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,("<S-NAME> fade(s) into view.")+CMLib.protocol().msp("appear.wav",10));
final CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> fade(s) away."));
if(thisRoom.okMessage(follower,leaveMsg)&&target.okMessage(follower,enterMsg))
......@@ -1418,6 +1417,9 @@ public class PlanarAbility extends StdAbility
((Room)enterMsg.target()).send(follower,enterMsg);
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
// return whether it worked
......
......@@ -149,14 +149,13 @@ public class Prayer_CorpseWalk extends Prayer
if((mob.location().okMessage(mob,msg))&&(newRoom.okMessage(mob,msg)))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
if(corpseItem != null)
{
final CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> emerge(s) from @x1.",corpseItem.name()));
......@@ -174,6 +173,9 @@ public class Prayer_CorpseWalk extends Prayer
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
}
......
......@@ -124,14 +124,13 @@ public class Spell_ClanHome extends Spell
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,clanHomeRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> appears in a puff of red smoke."));
final CMMsg leaveMsg=CMClass.getMsg(follower,thisRoom,this,CMMsg.MSG_LEAVE|CMMsg.MASK_MAGIC,L("<S-NAME> disappear(s) in a puff of red smoke."));
if(thisRoom.okMessage(follower,leaveMsg)&&clanHomeRoom.okMessage(follower,enterMsg))
......@@ -147,6 +146,9 @@ public class Spell_ClanHome extends Spell
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
......
......@@ -175,14 +175,13 @@ public class Spell_Cogniportive extends Spell
mob.location().showHappens(CMMsg.MSG_OK_VISUAL,L("Strange fizzled sparks fly from @x1.",me.name()));
else
{
final Set<MOB> h=properTargets(mob,null,false);
final List<MOB> h=properTargetList(mob,null,false);
if(h==null)
return;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,home,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,L("<S-NAME> appears in a puff of smoke."));
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.isInhabitant(follower)
......@@ -201,6 +200,9 @@ public class Spell_Cogniportive extends Spell
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
}
......
......@@ -179,14 +179,13 @@ public class Spell_Flagportation extends Spell
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
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!=null)&&newRoom.okMessage(follower,enterMsg))
......@@ -202,6 +201,9 @@ public class Spell_Flagportation extends Spell
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
// return whether it worked
......
......@@ -181,14 +181,13 @@ public class Spell_Gate extends Spell
if((mob.location().okMessage(mob,msg))&&(newRoom!=null)&&(newRoom.okMessage(mob,msg)))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
final CMMsg enterMsg=CMClass.getMsg(follower,newRoom,this,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,null,CMMsg.MSG_ENTER,("<S-NAME> appear(s) in a burst of light.")+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 burst of light."));
if(thisRoom.okMessage(follower,leaveMsg)&&newRoom.okMessage(follower,enterMsg))
......@@ -204,6 +203,9 @@ public class Spell_Gate extends Spell
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
......
......@@ -169,14 +169,13 @@ public class Spell_Teleport extends Spell
if(mob.location().okMessage(mob,msg)&&(newRoom!=null))
{
mob.location().send(mob,msg);
final Set<MOB> h=properTargets(mob,givenTarget,false);
final List<MOB> h=properTargetList(mob,givenTarget,false);
if(h==null)
return false;
final Room thisRoom=mob.location();
for (final Object element : h)
for (final MOB follower : h)
{
final MOB follower=(MOB)element;
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))
......@@ -192,6 +191,9 @@ public class Spell_Teleport extends Spell
follower.tell(L("\n\r\n\r"));
CMLib.commands().postLook(follower,true);
}
else
if(follower==mob)
break;
}
}
......
......@@ -1524,6 +1524,19 @@ public class StdAbility implements Ability
return h;
}
protected List<MOB> properTargetList(MOB mob, Environmental givenTarget, boolean auto)
{
final Set<MOB> h=properTargets(mob,givenTarget,auto);
final List<MOB> list=new ArrayList<MOB>(h.size());
if(h.contains(mob))
{
h.remove(mob);
list.add(mob);
}
list.addAll(h);
return list;
}
protected int adjustMaliciousTickdownTime(final MOB mob, final Physical target, final int baseTicks, final int asLevel)
{
int tickDown = baseTicks;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment