|
@@ -33,6 +33,7 @@ import com.l2jserver.gameserver.datatables.NpcData;
|
|
import com.l2jserver.gameserver.engines.DocumentParser;
|
|
import com.l2jserver.gameserver.engines.DocumentParser;
|
|
import com.l2jserver.gameserver.model.L2Spawn;
|
|
import com.l2jserver.gameserver.model.L2Spawn;
|
|
import com.l2jserver.gameserver.model.L2Territory;
|
|
import com.l2jserver.gameserver.model.L2Territory;
|
|
|
|
+import com.l2jserver.gameserver.model.Location;
|
|
import com.l2jserver.gameserver.model.actor.L2Npc;
|
|
import com.l2jserver.gameserver.model.actor.L2Npc;
|
|
import com.l2jserver.util.Rnd;
|
|
import com.l2jserver.util.Rnd;
|
|
|
|
|
|
@@ -152,14 +153,14 @@ public class TarBeetleSpawn extends DocumentParser
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public int[] getRandomPoint()
|
|
|
|
|
|
+ public Location getRandomPoint()
|
|
{
|
|
{
|
|
- int[] loc = super.getRandomPoint();
|
|
|
|
- while (isInsideBannedZone(loc))
|
|
|
|
|
|
+ Location location = super.getRandomPoint();
|
|
|
|
+ while ((location != null) && isInsideBannedZone(location))
|
|
{
|
|
{
|
|
- loc = super.getRandomPoint();
|
|
|
|
|
|
+ location = super.getRandomPoint();
|
|
}
|
|
}
|
|
- return loc;
|
|
|
|
|
|
+ return location;
|
|
}
|
|
}
|
|
|
|
|
|
public final void addBannedZone(Zone bZone)
|
|
public final void addBannedZone(Zone bZone)
|
|
@@ -171,13 +172,13 @@ public class TarBeetleSpawn extends DocumentParser
|
|
_bannedZones.add(bZone);
|
|
_bannedZones.add(bZone);
|
|
}
|
|
}
|
|
|
|
|
|
- private final boolean isInsideBannedZone(int[] loc)
|
|
|
|
|
|
+ private final boolean isInsideBannedZone(Location location)
|
|
{
|
|
{
|
|
if (_bannedZones != null)
|
|
if (_bannedZones != null)
|
|
{
|
|
{
|
|
for (Zone z : _bannedZones)
|
|
for (Zone z : _bannedZones)
|
|
{
|
|
{
|
|
- if (z.isInside(loc[0], loc[1]))
|
|
|
|
|
|
+ if (z.isInside(location.getX(), location.getY()))
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -223,21 +224,24 @@ public class TarBeetleSpawn extends DocumentParser
|
|
{
|
|
{
|
|
while (_spawn.size() < _maxNpcCount)
|
|
while (_spawn.size() < _maxNpcCount)
|
|
{
|
|
{
|
|
- final int[] loc = _zones.get(Rnd.get(_zones.size())).getRandomPoint();
|
|
|
|
- final L2Spawn spawn = new L2Spawn(NpcData.getInstance().getTemplate(18804));
|
|
|
|
- spawn.setHeading(Rnd.get(65535));
|
|
|
|
- spawn.setX(loc[0]);
|
|
|
|
- spawn.setY(loc[1]);
|
|
|
|
- spawn.setZ(GeoData.getInstance().getSpawnHeight(loc[0], loc[1], loc[2], loc[3]));
|
|
|
|
-
|
|
|
|
- final L2Npc npc = spawn.doSpawn();
|
|
|
|
- npc.setIsNoRndWalk(true);
|
|
|
|
- npc.setIsImmobilized(true);
|
|
|
|
- npc.setIsInvul(true);
|
|
|
|
- npc.disableCoreAI(true);
|
|
|
|
- npc.setScriptValue(5);
|
|
|
|
- npc.getVariables().set("zoneIndex", _index);
|
|
|
|
- _spawn.add(npc);
|
|
|
|
|
|
+ final Location location = _zones.get(Rnd.get(_zones.size())).getRandomPoint();
|
|
|
|
+ if (location != null)
|
|
|
|
+ {
|
|
|
|
+ final L2Spawn spawn = new L2Spawn(NpcData.getInstance().getTemplate(18804));
|
|
|
|
+ spawn.setHeading(Rnd.get(65535));
|
|
|
|
+ spawn.setX(location.getX());
|
|
|
|
+ spawn.setY(location.getY());
|
|
|
|
+ spawn.setZ(GeoData.getInstance().getSpawnHeight(location));
|
|
|
|
+
|
|
|
|
+ final L2Npc npc = spawn.doSpawn();
|
|
|
|
+ npc.setIsNoRndWalk(true);
|
|
|
|
+ npc.setIsImmobilized(true);
|
|
|
|
+ npc.setIsInvul(true);
|
|
|
|
+ npc.disableCoreAI(true);
|
|
|
|
+ npc.setScriptValue(5);
|
|
|
|
+ npc.getVariables().set("zoneIndex", _index);
|
|
|
|
+ _spawn.add(npc);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|