Dropped WarpedSpaceManager class.
This commit is contained in:
parent
a8c77b8795
commit
11a8af106c
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -1219,12 +1219,27 @@
|
||||
<skill id="30519" toLevel="1" name="Warped Space">
|
||||
<!-- Creates a warped space where the enemy is trapped and their abilities are decreased. Requires a fist weapon. -->
|
||||
<icon>icon.skill30519</icon>
|
||||
<operateType>A1</operateType>
|
||||
<abnormalLevel>1</abnormalLevel>
|
||||
<abnormalTime>10</abnormalTime>
|
||||
<abnormalType>ROOT_PHYSICALLY</abnormalType>
|
||||
<abnormalVisualEffect>ROOT</abnormalVisualEffect>
|
||||
<activateRate>80</activateRate>
|
||||
<basicProperty>MAGIC</basicProperty>
|
||||
<affectLimit>10-10</affectLimit>
|
||||
<affectRange>150</affectRange>
|
||||
<isDebuff>true</isDebuff>
|
||||
<operateType>A2</operateType>
|
||||
<magicLevel>98</magicLevel>
|
||||
<mpConsume>772</mpConsume>
|
||||
<hitTime>2500</hitTime>
|
||||
<coolTime>500</coolTime>
|
||||
<effectPoint>-707</effectPoint>
|
||||
<reuseDelay>600000</reuseDelay>
|
||||
<magicCriticalRate>5</magicCriticalRate>
|
||||
<trait>HOLD</trait>
|
||||
<targetType>SELF</targetType>
|
||||
<affectScope>POINT_BLANK</affectScope>
|
||||
<affectObject>NOT_FRIEND</affectObject>
|
||||
<conditions>
|
||||
<condition name="EquipWeapon">
|
||||
<weaponType>
|
||||
@ -1233,9 +1248,9 @@
|
||||
</condition>
|
||||
</conditions>
|
||||
<effects>
|
||||
<effect name="SummonNpc">
|
||||
<npcId>13432</npcId> <!-- Gravity Core -->
|
||||
<npcCount>1</npcCount>
|
||||
<effect name="Root" />
|
||||
<effect name="DefenceTrait">
|
||||
<HOLD>100</HOLD>
|
||||
</effect>
|
||||
</effects>
|
||||
</skill>
|
||||
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.GravitoryCore;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class GravityCore extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int GRAVITY_CORE = 13432; // Gravity Core
|
||||
|
||||
private GravityCore()
|
||||
{
|
||||
addSpawnId(GRAVITY_CORE);
|
||||
addDespawnId(GRAVITY_CORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if (event.equals("DELETE_ME") && (npc != null))
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(Npc npc)
|
||||
{
|
||||
final Creature summoner = npc.getSummoner();
|
||||
if ((summoner != null) && summoner.isPlayer())
|
||||
{
|
||||
final PlayerInstance player = summoner.getActingPlayer();
|
||||
final SkillHolder skill = npc.getParameters().getSkillHolder("skill");
|
||||
if (skill != null)
|
||||
{
|
||||
npc.doCast(skill.getSkill());
|
||||
}
|
||||
|
||||
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
|
||||
startQuestTimer("DELETE_ME", despawnTime, npc, player);
|
||||
|
||||
WarpedSpaceManager.getInstance().addWarpedSpace(npc, 100);
|
||||
}
|
||||
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNpcDespawn(Npc npc)
|
||||
{
|
||||
WarpedSpaceManager.getInstance().removeWarpedSpace(npc);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new GravityCore();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import org.l2jmobius.gameserver.geoengine.geodata.Cell;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.IRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.NullRegion;
|
||||
import org.l2jmobius.gameserver.geoengine.geodata.Region;
|
||||
import org.l2jmobius.gameserver.instancemanager.WarpedSpaceManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -634,10 +633,6 @@ public class GeoEngine
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(x, y, z, tx, ty, tz, instance))
|
||||
{
|
||||
return new Location(x, y, getHeight(x, y, z));
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
@ -704,10 +699,6 @@ public class GeoEngine
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(fromX, fromY, fromZ, toX, toY, toZ, instance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LinePointIterator pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);
|
||||
// First point is guaranteed to be available.
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.holders.WarpedSpaceHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class WarpedSpaceManager
|
||||
{
|
||||
private Map<Creature, WarpedSpaceHolder> _warpedSpace = null;
|
||||
|
||||
public void addWarpedSpace(Creature creature, int radius)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_warpedSpace == null)
|
||||
{
|
||||
_warpedSpace = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
_warpedSpace.put(creature, new WarpedSpaceHolder(creature, radius));
|
||||
}
|
||||
|
||||
public void removeWarpedSpace(Creature creature)
|
||||
{
|
||||
_warpedSpace.remove(creature);
|
||||
}
|
||||
|
||||
public boolean checkForWarpedSpace(int originX, int originY, int originZ, int destinationX, int destinationY, int destinationZ, Instance instance)
|
||||
{
|
||||
if (_warpedSpace != null)
|
||||
{
|
||||
for (WarpedSpaceHolder holder : _warpedSpace.values())
|
||||
{
|
||||
final Creature creature = holder.getCreature();
|
||||
if (creature.getInstanceWorld() != instance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int radius = creature.getTemplate().getCollisionRadius();
|
||||
final boolean originInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), originX, originY, originZ, false, false) <= (holder.getRange() + radius);
|
||||
final boolean destinationInRange = Util.calculateDistance(creature.getX(), creature.getY(), creature.getZ(), destinationX, destinationY, destinationZ, false, false) <= (holder.getRange() + radius);
|
||||
return destinationInRange ? !originInRange : originInRange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WarpedSpaceManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WarpedSpaceManager INSTANCE = new WarpedSpaceManager();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user