Removal of TaskZoneSettings class.
This commit is contained in:
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.util.concurrent.Future;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +29,10 @@ import org.l2jmobius.gameserver.model.zone.ZoneType;
|
|||||||
public class DamageZone extends ZoneType
|
public class DamageZone extends ZoneType
|
||||||
{
|
{
|
||||||
private int _damagePerSec;
|
private int _damagePerSec;
|
||||||
private Future<?> _task;
|
|
||||||
|
private final int _startTask;
|
||||||
|
private final int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -38,6 +40,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
// Setup default damage
|
// Setup default damage
|
||||||
_damagePerSec = 100;
|
_damagePerSec = 100;
|
||||||
|
|
||||||
|
// Setup default start / reuse time
|
||||||
|
_startTask = 10;
|
||||||
|
_reuseTask = 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,16 +62,25 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if (_task == null)
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && (_damagePerSec != 0))
|
||||||
{
|
{
|
||||||
_task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), 10, 1000);
|
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty())
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
_task.cancel(true);
|
_task.cancel(true);
|
||||||
_task = null;
|
_task = null;
|
||||||
@@ -77,23 +92,27 @@ public class DamageZone extends ZoneType
|
|||||||
return _damagePerSec;
|
return _damagePerSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
protected ApplyDamage()
|
||||||
|
|
||||||
ApplyDamage(DamageZone zone)
|
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
if (getCharactersInside().isEmpty())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead() && (temp instanceof PlayerInstance))
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getDamagePerSecond(), null);
|
character.reduceCurrentHp(getDamagePerSecond(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,14 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.commons.util.StringUtil;
|
|
||||||
import org.l2jmobius.gameserver.data.SkillTable;
|
import org.l2jmobius.gameserver.data.SkillTable;
|
||||||
import org.l2jmobius.gameserver.model.Skill;
|
import org.l2jmobius.gameserver.model.Skill;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -46,8 +43,8 @@ public class EffectZone extends ZoneType
|
|||||||
private int _reuse;
|
private int _reuse;
|
||||||
boolean _enabled;
|
boolean _enabled;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
private Future<?> _task;
|
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -74,14 +71,19 @@ public class EffectZone extends ZoneType
|
|||||||
_initialDelay = Integer.parseInt(value);
|
_initialDelay = Integer.parseInt(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "reuse":
|
||||||
|
{
|
||||||
|
_reuse = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "defaultStatus":
|
case "defaultStatus":
|
||||||
{
|
{
|
||||||
_enabled = Boolean.parseBoolean(value);
|
_enabled = Boolean.parseBoolean(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reuse":
|
case "showDangerIcon":
|
||||||
{
|
{
|
||||||
_reuse = Integer.parseInt(value);
|
_isShowDangerIcon = Boolean.parseBoolean(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "skillIdLvl":
|
case "skillIdLvl":
|
||||||
@@ -93,7 +95,7 @@ public class EffectZone extends ZoneType
|
|||||||
final String[] skillSplit = skill.split("-");
|
final String[] skillSplit = skill.split("-");
|
||||||
if (skillSplit.length != 2)
|
if (skillSplit.length != 2)
|
||||||
{
|
{
|
||||||
LOGGER.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skill, "\""));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -105,22 +107,16 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (!skill.isEmpty())
|
if (!skill.isEmpty())
|
||||||
{
|
{
|
||||||
LOGGER.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skillSplit[0], "\"", skillSplit[1]));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "showDangerIcon":
|
|
||||||
{
|
|
||||||
_isShowDangerIcon = Boolean.parseBoolean(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
super.setParameter(name, value);
|
super.setParameter(name, value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,18 +124,23 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((_skills != null) && (_task == null))
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
if (_task == null)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
|
if (creature.isPlayer() && _isShowDangerIcon)
|
||||||
{
|
{
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
||||||
}
|
}
|
||||||
@@ -148,7 +149,7 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
|
if (creature.isPlayer() && _isShowDangerIcon)
|
||||||
{
|
{
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, false);
|
creature.setInsideZone(ZoneId.DANGER_AREA, false);
|
||||||
}
|
}
|
||||||
@@ -160,11 +161,6 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Skill getSkill(int skillId, int skillLevel)
|
|
||||||
{
|
|
||||||
return SkillTable.getInstance().getSkill(skillId, skillLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChance()
|
public int getChance()
|
||||||
{
|
{
|
||||||
return _chance;
|
return _chance;
|
||||||
@@ -226,9 +222,9 @@ public class EffectZone extends ZoneType
|
|||||||
_enabled = value;
|
_enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
if (_skills == null)
|
if (_skills == null)
|
||||||
{
|
{
|
||||||
@@ -239,35 +235,30 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (_enabled)
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
for (Creature temp : getCharactersInside())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
if (!(temp instanceof Playable))
|
final Skill skill = SkillTable.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && skill.checkCondition(character, character, false))
|
||||||
{
|
{
|
||||||
continue;
|
if (character.getFirstEffect(e.getKey()) == null)
|
||||||
}
|
|
||||||
|
|
||||||
if (Rnd.get(100) < _chance)
|
|
||||||
{
|
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
|
||||||
{
|
{
|
||||||
final Skill skill = getSkill(e.getKey(), e.getValue());
|
skill.getEffects(character, character);
|
||||||
if (skill == null)
|
|
||||||
{
|
|
||||||
LOGGER.warning("ATTENTION: Skill " + e.getKey() + " cannot be loaded.. Verify Skill definition into data/stats/skill folder...");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skill.checkCondition(temp, temp, false))
|
|
||||||
{
|
|
||||||
if (temp.getFirstEffect(e.getKey()) == null)
|
|
||||||
{
|
|
||||||
skill.getEffects(temp, temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import java.util.concurrent.Future;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +29,10 @@ import org.l2jmobius.gameserver.model.zone.ZoneType;
|
|||||||
public class DamageZone extends ZoneType
|
public class DamageZone extends ZoneType
|
||||||
{
|
{
|
||||||
private int _damagePerSec;
|
private int _damagePerSec;
|
||||||
private Future<?> _task;
|
|
||||||
|
private final int _startTask;
|
||||||
|
private final int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -38,6 +40,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
// Setup default damage
|
// Setup default damage
|
||||||
_damagePerSec = 100;
|
_damagePerSec = 100;
|
||||||
|
|
||||||
|
// Setup default start / reuse time
|
||||||
|
_startTask = 10;
|
||||||
|
_reuseTask = 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,16 +62,25 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if (_task == null)
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && (_damagePerSec != 0))
|
||||||
{
|
{
|
||||||
_task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), 10, 1000);
|
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty())
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
_task.cancel(true);
|
_task.cancel(true);
|
||||||
_task = null;
|
_task = null;
|
||||||
@@ -77,23 +92,27 @@ public class DamageZone extends ZoneType
|
|||||||
return _damagePerSec;
|
return _damagePerSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
protected ApplyDamage()
|
||||||
|
|
||||||
ApplyDamage(DamageZone zone)
|
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
if (getCharactersInside().isEmpty())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead() && (temp instanceof PlayerInstance))
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getDamagePerSecond(), null);
|
character.reduceCurrentHp(getDamagePerSecond(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,18 +24,15 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.commons.util.StringUtil;
|
|
||||||
import org.l2jmobius.gameserver.data.SkillTable;
|
import org.l2jmobius.gameserver.data.SkillTable;
|
||||||
import org.l2jmobius.gameserver.model.Skill;
|
import org.l2jmobius.gameserver.model.Skill;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -47,8 +44,8 @@ public class EffectZone extends ZoneType
|
|||||||
private int _reuse;
|
private int _reuse;
|
||||||
boolean _enabled;
|
boolean _enabled;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
private Future<?> _task;
|
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -75,14 +72,19 @@ public class EffectZone extends ZoneType
|
|||||||
_initialDelay = Integer.parseInt(value);
|
_initialDelay = Integer.parseInt(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "reuse":
|
||||||
|
{
|
||||||
|
_reuse = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "defaultStatus":
|
case "defaultStatus":
|
||||||
{
|
{
|
||||||
_enabled = Boolean.parseBoolean(value);
|
_enabled = Boolean.parseBoolean(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reuse":
|
case "showDangerIcon":
|
||||||
{
|
{
|
||||||
_reuse = Integer.parseInt(value);
|
_isShowDangerIcon = Boolean.parseBoolean(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "skillIdLvl":
|
case "skillIdLvl":
|
||||||
@@ -94,7 +96,7 @@ public class EffectZone extends ZoneType
|
|||||||
final String[] skillSplit = skill.split("-");
|
final String[] skillSplit = skill.split("-");
|
||||||
if (skillSplit.length != 2)
|
if (skillSplit.length != 2)
|
||||||
{
|
{
|
||||||
LOGGER.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skill, "\""));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -106,22 +108,16 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (!skill.isEmpty())
|
if (!skill.isEmpty())
|
||||||
{
|
{
|
||||||
LOGGER.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skillSplit[0], "\"", skillSplit[1]));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "showDangerIcon":
|
|
||||||
{
|
|
||||||
_isShowDangerIcon = Boolean.parseBoolean(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
super.setParameter(name, value);
|
super.setParameter(name, value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,33 +125,38 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((_skills != null) && (_task == null))
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
if (_task == null)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
|
if (creature.isPlayer() && _isShowDangerIcon)
|
||||||
{
|
{
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
||||||
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
|
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
|
if (creature.isPlayer() && _isShowDangerIcon)
|
||||||
{
|
{
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, false);
|
creature.setInsideZone(ZoneId.DANGER_AREA, false);
|
||||||
if (!creature.isInsideZone(ZoneId.DANGER_AREA))
|
if (!creature.isInsideZone(ZoneId.DANGER_AREA))
|
||||||
{
|
{
|
||||||
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
|
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,11 +167,6 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Skill getSkill(int skillId, int skillLevel)
|
|
||||||
{
|
|
||||||
return SkillTable.getInstance().getSkill(skillId, skillLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChance()
|
public int getChance()
|
||||||
{
|
{
|
||||||
return _chance;
|
return _chance;
|
||||||
@@ -232,9 +228,9 @@ public class EffectZone extends ZoneType
|
|||||||
_enabled = value;
|
_enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
if (_skills == null)
|
if (_skills == null)
|
||||||
{
|
{
|
||||||
@@ -245,35 +241,30 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (_enabled)
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
for (Creature temp : getCharactersInside())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
if (!(temp instanceof Playable))
|
final Skill skill = SkillTable.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && skill.checkCondition(character, character, false))
|
||||||
{
|
{
|
||||||
continue;
|
if (character.getFirstEffect(e.getKey()) == null)
|
||||||
}
|
|
||||||
|
|
||||||
if (Rnd.get(100) < _chance)
|
|
||||||
{
|
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
|
||||||
{
|
{
|
||||||
final Skill skill = getSkill(e.getKey(), e.getValue());
|
skill.getEffects(character, character);
|
||||||
if (skill == null)
|
|
||||||
{
|
|
||||||
LOGGER.warning("ATTENTION: Skill " + e.getKey() + " cannot be loaded.. Verify Skill definition into data/stats/skill folder...");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skill.checkCondition(temp, temp, false))
|
|
||||||
{
|
|
||||||
if (temp.getFirstEffect(e.getKey()) == null)
|
|
||||||
{
|
|
||||||
skill.getEffects(temp, temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -58,19 +58,8 @@ public class DamageZone extends ZoneType
|
|||||||
// no castle by default
|
// no castle by default
|
||||||
_castleId = 0;
|
_castleId = 0;
|
||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,22 +94,26 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() != null) || ((_damageHPPerSec == 0) && (_damageMPPerSec == 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
return;
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
}
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
|
||||||
if ((getCastle() != null) && (!getCastle().getSiege().isInProgress() || (player == null) || (player.getSiegeState() == 2)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
if (getSettings().getTask() == null)
|
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,15 +147,13 @@ public class DamageZone extends ZoneType
|
|||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,40 +164,49 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
{
|
{
|
||||||
siege = _castle.getSiege().isInProgress();
|
siege = _castle.getSiege().isInProgress();
|
||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.calcStat(Stat.DAMAGE_ZONE_VULN, 0, null, null) / 100);
|
final double multiplier = 1 + (character.calcStat(Stat.DAMAGE_ZONE_VULN, 0, null, null) / 100);
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,101 +54,106 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(String name, String value)
|
public void setParameter(String name, String value)
|
||||||
{
|
{
|
||||||
if (name.equals("chance"))
|
switch (name)
|
||||||
{
|
{
|
||||||
_chance = Integer.parseInt(value);
|
case "chance":
|
||||||
}
|
|
||||||
else if (name.equals("initialDelay"))
|
|
||||||
{
|
|
||||||
_initialDelay = Integer.parseInt(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("reuse"))
|
|
||||||
{
|
|
||||||
_reuse = Integer.parseInt(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("bypassSkillConditions"))
|
|
||||||
{
|
|
||||||
_bypassConditions = Boolean.parseBoolean(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("maxDynamicSkillCount"))
|
|
||||||
{
|
|
||||||
_skills = new ConcurrentHashMap<>(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
else if (name.equals("skillIdLvl"))
|
|
||||||
{
|
|
||||||
final String[] propertySplit = value.split(";");
|
|
||||||
_skills = new ConcurrentHashMap<>(propertySplit.length);
|
|
||||||
for (String skill : propertySplit)
|
|
||||||
{
|
{
|
||||||
final String[] skillSplit = skill.split("-");
|
_chance = Integer.parseInt(value);
|
||||||
if (skillSplit.length != 2)
|
break;
|
||||||
|
}
|
||||||
|
case "initialDelay":
|
||||||
|
{
|
||||||
|
_initialDelay = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "reuse":
|
||||||
|
{
|
||||||
|
_reuse = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "bypassSkillConditions":
|
||||||
|
{
|
||||||
|
_bypassConditions = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "maxDynamicSkillCount":
|
||||||
|
{
|
||||||
|
_skills = new ConcurrentHashMap<>(Integer.parseInt(value));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "showDangerIcon":
|
||||||
|
{
|
||||||
|
_isShowDangerIcon = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "skillIdLvl":
|
||||||
|
{
|
||||||
|
final String[] propertySplit = value.split(";");
|
||||||
|
_skills = new ConcurrentHashMap<>(propertySplit.length);
|
||||||
|
for (String skill : propertySplit)
|
||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
final String[] skillSplit = skill.split("-");
|
||||||
}
|
if (skillSplit.length != 2)
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_skills.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfe)
|
else
|
||||||
{
|
{
|
||||||
if (!skill.isEmpty())
|
try
|
||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
_skills.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
if (!skill.isEmpty())
|
||||||
|
{
|
||||||
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
super.setParameter(name, value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (name.equals("showDangerIcon"))
|
|
||||||
{
|
|
||||||
_isShowDangerIcon = Boolean.parseBoolean(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
super.setParameter(name, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((_skills != null) && (getSettings().getTask() == null))
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!creature.isPlayer())
|
|
||||||
|
if (creature.isPlayer())
|
||||||
{
|
{
|
||||||
return;
|
creature.setInsideZone(ZoneId.ALTERED, true);
|
||||||
|
if (_isShowDangerIcon)
|
||||||
|
{
|
||||||
|
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
||||||
|
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
creature.setInsideZone(ZoneId.ALTERED, true);
|
|
||||||
if (!_isShowDangerIcon)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
|
||||||
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,17 +171,14 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
|
||||||
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Skill getSkill(int skillId, int skillLevel)
|
|
||||||
{
|
|
||||||
return SkillData.getInstance().getSkill(skillId, skillLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChance()
|
public int getChance()
|
||||||
{
|
{
|
||||||
return _chance;
|
return _chance;
|
||||||
@@ -195,7 +196,10 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_skills = new ConcurrentHashMap<>(3);
|
if (_skills == null)
|
||||||
|
{
|
||||||
|
_skills = new ConcurrentHashMap<>(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_skills.put(skillId, skillLevel);
|
_skills.put(skillId, skillLevel);
|
||||||
@@ -219,10 +223,14 @@ public class EffectZone extends ZoneType
|
|||||||
|
|
||||||
public int getSkillLevel(int skillId)
|
public int getSkillLevel(int skillId)
|
||||||
{
|
{
|
||||||
return (_skills == null) || !_skills.containsKey(skillId) ? 0 : _skills.get(skillId);
|
if ((_skills == null) || !_skills.containsKey(skillId))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -235,18 +243,30 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
for (Creature temp : getCharactersInside())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = getSkill(e.getKey(), e.getValue());
|
if (!character.isAffectedBySkill(skill.getId()))
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(temp, temp, false)) && !temp.isAffectedBySkill(e.getKey()))
|
|
||||||
{
|
{
|
||||||
skill.applyEffects(temp, temp);
|
skill.applyEffects(character, character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -58,19 +58,8 @@ public class DamageZone extends ZoneType
|
|||||||
// no castle by default
|
// no castle by default
|
||||||
_castleId = 0;
|
_castleId = 0;
|
||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,22 +94,26 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() != null) || ((_damageHPPerSec == 0) && (_damageMPPerSec == 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
return;
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
}
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
|
||||||
if ((getCastle() != null) && (!getCastle().getSiege().isInProgress() || (player == null) || (player.getSiegeState() == 2)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
if (getSettings().getTask() == null)
|
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,15 +147,13 @@ public class DamageZone extends ZoneType
|
|||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,40 +164,49 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
{
|
{
|
||||||
siege = _castle.getSiege().isInProgress();
|
siege = _castle.getSiege().isInProgress();
|
||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.calcStat(Stat.DAMAGE_ZONE_VULN, 0, null, null) / 100);
|
final double multiplier = 1 + (character.calcStat(Stat.DAMAGE_ZONE_VULN, 0, null, null) / 100);
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,101 +54,106 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(String name, String value)
|
public void setParameter(String name, String value)
|
||||||
{
|
{
|
||||||
if (name.equals("chance"))
|
switch (name)
|
||||||
{
|
{
|
||||||
_chance = Integer.parseInt(value);
|
case "chance":
|
||||||
}
|
|
||||||
else if (name.equals("initialDelay"))
|
|
||||||
{
|
|
||||||
_initialDelay = Integer.parseInt(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("reuse"))
|
|
||||||
{
|
|
||||||
_reuse = Integer.parseInt(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("bypassSkillConditions"))
|
|
||||||
{
|
|
||||||
_bypassConditions = Boolean.parseBoolean(value);
|
|
||||||
}
|
|
||||||
else if (name.equals("maxDynamicSkillCount"))
|
|
||||||
{
|
|
||||||
_skills = new ConcurrentHashMap<>(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
else if (name.equals("skillIdLvl"))
|
|
||||||
{
|
|
||||||
final String[] propertySplit = value.split(";");
|
|
||||||
_skills = new ConcurrentHashMap<>(propertySplit.length);
|
|
||||||
for (String skill : propertySplit)
|
|
||||||
{
|
{
|
||||||
final String[] skillSplit = skill.split("-");
|
_chance = Integer.parseInt(value);
|
||||||
if (skillSplit.length != 2)
|
break;
|
||||||
|
}
|
||||||
|
case "initialDelay":
|
||||||
|
{
|
||||||
|
_initialDelay = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "reuse":
|
||||||
|
{
|
||||||
|
_reuse = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "bypassSkillConditions":
|
||||||
|
{
|
||||||
|
_bypassConditions = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "maxDynamicSkillCount":
|
||||||
|
{
|
||||||
|
_skills = new ConcurrentHashMap<>(Integer.parseInt(value));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "showDangerIcon":
|
||||||
|
{
|
||||||
|
_isShowDangerIcon = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "skillIdLvl":
|
||||||
|
{
|
||||||
|
final String[] propertySplit = value.split(";");
|
||||||
|
_skills = new ConcurrentHashMap<>(propertySplit.length);
|
||||||
|
for (String skill : propertySplit)
|
||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
final String[] skillSplit = skill.split("-");
|
||||||
}
|
if (skillSplit.length != 2)
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_skills.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\"");
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfe)
|
else
|
||||||
{
|
{
|
||||||
if (!skill.isEmpty())
|
try
|
||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
_skills.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
if (!skill.isEmpty())
|
||||||
|
{
|
||||||
|
LOGGER.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
super.setParameter(name, value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (name.equals("showDangerIcon"))
|
|
||||||
{
|
|
||||||
_isShowDangerIcon = Boolean.parseBoolean(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
super.setParameter(name, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((_skills != null) && (getSettings().getTask() == null))
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
synchronized (this)
|
||||||
|
{
|
||||||
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!creature.isPlayer())
|
|
||||||
|
if (creature.isPlayer())
|
||||||
{
|
{
|
||||||
return;
|
creature.setInsideZone(ZoneId.ALTERED, true);
|
||||||
|
if (_isShowDangerIcon)
|
||||||
|
{
|
||||||
|
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
||||||
|
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
creature.setInsideZone(ZoneId.ALTERED, true);
|
|
||||||
if (!_isShowDangerIcon)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
creature.setInsideZone(ZoneId.DANGER_AREA, true);
|
|
||||||
creature.sendPacket(new EtcStatusUpdate(creature.getActingPlayer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,17 +171,14 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
|
||||||
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Skill getSkill(int skillId, int skillLevel)
|
|
||||||
{
|
|
||||||
return SkillData.getInstance().getSkill(skillId, skillLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChance()
|
public int getChance()
|
||||||
{
|
{
|
||||||
return _chance;
|
return _chance;
|
||||||
@@ -195,7 +196,10 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_skills = new ConcurrentHashMap<>(3);
|
if (_skills == null)
|
||||||
|
{
|
||||||
|
_skills = new ConcurrentHashMap<>(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_skills.put(skillId, skillLevel);
|
_skills.put(skillId, skillLevel);
|
||||||
@@ -219,10 +223,14 @@ public class EffectZone extends ZoneType
|
|||||||
|
|
||||||
public int getSkillLevel(int skillId)
|
public int getSkillLevel(int skillId)
|
||||||
{
|
{
|
||||||
return (_skills == null) || !_skills.containsKey(skillId) ? 0 : _skills.get(skillId);
|
if ((_skills == null) || !_skills.containsKey(skillId))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -235,18 +243,30 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
for (Creature temp : getCharactersInside())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = getSkill(e.getKey(), e.getValue());
|
if (!character.isAffectedBySkill(skill.getId()))
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(temp, temp, false)) && !temp.isAffectedBySkill(e.getKey()))
|
|
||||||
{
|
{
|
||||||
skill.applyEffects(temp, temp);
|
skill.applyEffects(character, character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +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.model.zone;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic task zone settings implementation.
|
|
||||||
* @author UnAfraid
|
|
||||||
*/
|
|
||||||
public class TaskZoneSettings extends AbstractZoneSettings
|
|
||||||
{
|
|
||||||
private Future<?> _task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the task.
|
|
||||||
* @return the task
|
|
||||||
*/
|
|
||||||
public Future<?> getTask()
|
|
||||||
{
|
|
||||||
return _task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task.
|
|
||||||
* @param task the new task
|
|
||||||
*/
|
|
||||||
public void setTask(Future<?> task)
|
|
||||||
{
|
|
||||||
_task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
if (_task != null)
|
|
||||||
{
|
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,16 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.zone.type;
|
package org.l2jmobius.gameserver.model.zone.type;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
private int _startTask;
|
private int _startTask;
|
||||||
private int _reuseTask;
|
private int _reuseTask;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public DamageZone(int id)
|
public DamageZone(int id)
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,6 @@ public class DamageZone extends ZoneType
|
|||||||
_castle = null;
|
_castle = null;
|
||||||
|
|
||||||
setTargetType(InstanceType.Playable); // default only playabale
|
setTargetType(InstanceType.Playable); // default only playabale
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +94,14 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(Creature creature)
|
protected void onEnter(Creature creature)
|
||||||
{
|
{
|
||||||
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
Future<?> task = _task;
|
||||||
|
if ((task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
|
||||||
{
|
{
|
||||||
final PlayerInstance player = creature.getActingPlayer();
|
final PlayerInstance player = creature.getActingPlayer();
|
||||||
if (getCastle() != null) // Castle zone
|
final Castle castle = getCastle();
|
||||||
|
if (castle != null) // Castle zone
|
||||||
{
|
{
|
||||||
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
if (!(castle.getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +109,10 @@ public class DamageZone extends ZoneType
|
|||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplyDamage(), _startTask, _reuseTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +121,10 @@ public class DamageZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(Creature creature)
|
protected void onExit(Creature creature)
|
||||||
{
|
{
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +144,16 @@ public class DamageZone extends ZoneType
|
|||||||
{
|
{
|
||||||
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
_castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _castle;
|
return _castle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplyDamage implements Runnable
|
private class ApplyDamage implements Runnable
|
||||||
{
|
{
|
||||||
private final DamageZone _dmgZone;
|
|
||||||
private final Castle _castle;
|
private final Castle _castle;
|
||||||
|
|
||||||
protected ApplyDamage(DamageZone zone)
|
protected ApplyDamage()
|
||||||
{
|
{
|
||||||
_dmgZone = zone;
|
_castle = getCastle();
|
||||||
_castle = zone.getCastle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,6 +164,13 @@ public class DamageZone extends ZoneType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean siege = false;
|
boolean siege = false;
|
||||||
|
|
||||||
if (_castle != null)
|
if (_castle != null)
|
||||||
@@ -183,34 +179,34 @@ public class DamageZone extends ZoneType
|
|||||||
// castle zones active only during siege
|
// castle zones active only during siege
|
||||||
if (!siege)
|
if (!siege)
|
||||||
{
|
{
|
||||||
_dmgZone.getSettings().clear();
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature temp : _dmgZone.getCharactersInside())
|
for (Creature character : getCharactersInside())
|
||||||
{
|
{
|
||||||
if ((temp != null) && !temp.isDead())
|
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||||
{
|
{
|
||||||
if (siege)
|
if (siege)
|
||||||
{
|
{
|
||||||
// during siege defenders not affected
|
// during siege defenders not affected
|
||||||
final PlayerInstance player = temp.getActingPlayer();
|
final PlayerInstance player = character.getActingPlayer();
|
||||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final double multiplier = 1 + (temp.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
final double multiplier = 1 + (character.getStat().getValue(Stat.DAMAGE_ZONE_VULN, 0) / 100);
|
||||||
|
|
||||||
if (getHPDamagePerSecond() != 0)
|
if (getHPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||||
}
|
}
|
||||||
if (getMPDamagePerSecond() != 0)
|
if (getMPDamagePerSecond() != 0)
|
||||||
{
|
{
|
||||||
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
|
character.reduceCurrentMp(getMPDamagePerSecond() * multiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,20 @@ package org.l2jmobius.gameserver.model.zone.type;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.zone.AbstractZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.TaskZoneSettings;
|
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* another type of damage zone with skills
|
* Another type of damage zone with skills.
|
||||||
* @author kerberos
|
* @author kerberos
|
||||||
*/
|
*/
|
||||||
public class EffectZone extends ZoneType
|
public class EffectZone extends ZoneType
|
||||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
|||||||
protected boolean _bypassConditions;
|
protected boolean _bypassConditions;
|
||||||
private boolean _isShowDangerIcon;
|
private boolean _isShowDangerIcon;
|
||||||
protected Map<Integer, Integer> _skills;
|
protected Map<Integer, Integer> _skills;
|
||||||
|
private volatile Future<?> _task;
|
||||||
|
|
||||||
public EffectZone(int id)
|
public EffectZone(int id)
|
||||||
{
|
{
|
||||||
@@ -55,18 +54,6 @@ public class EffectZone extends ZoneType
|
|||||||
setTargetType(InstanceType.Playable); // default only playable
|
setTargetType(InstanceType.Playable); // default only playable
|
||||||
_bypassConditions = false;
|
_bypassConditions = false;
|
||||||
_isShowDangerIcon = true;
|
_isShowDangerIcon = true;
|
||||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
|
||||||
if (settings == null)
|
|
||||||
{
|
|
||||||
settings = new TaskZoneSettings();
|
|
||||||
}
|
|
||||||
setSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskZoneSettings getSettings()
|
|
||||||
{
|
|
||||||
return (TaskZoneSettings) super.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,13 +131,15 @@ public class EffectZone extends ZoneType
|
|||||||
{
|
{
|
||||||
if (_skills != null)
|
if (_skills != null)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
Future<?> task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (getSettings().getTask() == null)
|
task = _task;
|
||||||
|
if (task == null)
|
||||||
{
|
{
|
||||||
getSettings().setTask(ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
|
_task = task = ThreadPool.scheduleAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +172,10 @@ public class EffectZone extends ZoneType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCharactersInside().isEmpty() && (getSettings().getTask() != null))
|
if (getCharactersInside().isEmpty() && (_task != null))
|
||||||
{
|
{
|
||||||
getSettings().clear();
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class EffectZone extends ZoneType
|
|||||||
return _skills.get(skillId);
|
return _skills.get(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ApplySkill implements Runnable
|
private class ApplySkill implements Runnable
|
||||||
{
|
{
|
||||||
protected ApplySkill()
|
protected ApplySkill()
|
||||||
{
|
{
|
||||||
@@ -253,25 +243,34 @@ public class EffectZone extends ZoneType
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
getCharactersInside().forEach(character ->
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCharactersInside().isEmpty())
|
||||||
|
{
|
||||||
|
_task.cancel(false);
|
||||||
|
_task = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Creature character : getCharactersInside())
|
||||||
|
{
|
||||||
|
if ((character != null) && character.isPlayer() && !character.isDead() && (Rnd.get(100) < _chance))
|
||||||
{
|
{
|
||||||
if ((character != null) && !character.isDead() && (Rnd.get(100) < _chance))
|
for (Entry<Integer, Integer> e : _skills.entrySet())
|
||||||
{
|
{
|
||||||
for (Entry<Integer, Integer> e : _skills.entrySet())
|
final Skill skill = SkillData.getInstance().getSkill(e.getKey().intValue(), e.getValue().intValue());
|
||||||
|
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, false)))
|
||||||
{
|
{
|
||||||
final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
|
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
||||||
if ((skill != null) && (_bypassConditions || skill.checkCondition(character, character, true)))
|
|
||||||
{
|
{
|
||||||
if (character.getAffectedSkillLevel(skill.getId()) < skill.getLevel())
|
skill.activateSkill(character, character);
|
||||||
{
|
|
||||||
skill.activateSkill(character, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user