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;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||
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.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.siege.Castle;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -42,6 +41,7 @@ public class DamageZone extends ZoneType
|
||||
|
||||
private int _startTask;
|
||||
private int _reuseTask;
|
||||
private volatile Future<?> _task;
|
||||
|
||||
public DamageZone(int id)
|
||||
{
|
||||
@@ -58,19 +58,8 @@ public class DamageZone extends ZoneType
|
||||
// no castle by default
|
||||
_castleId = 0;
|
||||
_castle = null;
|
||||
|
||||
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
|
||||
@@ -105,22 +94,26 @@ public class DamageZone extends ZoneType
|
||||
@Override
|
||||
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();
|
||||
if ((getCastle() != null) && (!getCastle().getSiege().isInProgress() || (player == null) || (player.getSiegeState() == 2)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
if (getSettings().getTask() == null)
|
||||
final PlayerInstance player = creature.getActingPlayer();
|
||||
final Castle castle = getCastle();
|
||||
if (castle != null) // Castle zone
|
||||
{
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
private final class ApplyDamage implements Runnable
|
||||
private class ApplyDamage implements Runnable
|
||||
{
|
||||
private final DamageZone _dmgZone;
|
||||
private final Castle _castle;
|
||||
|
||||
protected ApplyDamage(DamageZone zone)
|
||||
protected ApplyDamage()
|
||||
{
|
||||
_dmgZone = zone;
|
||||
_castle = zone.getCastle();
|
||||
_castle = getCastle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,40 +164,49 @@ public class DamageZone extends ZoneType
|
||||
return;
|
||||
}
|
||||
|
||||
if (getCharactersInside().isEmpty())
|
||||
{
|
||||
_task.cancel(false);
|
||||
_task = null;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean siege = false;
|
||||
|
||||
if (_castle != null)
|
||||
{
|
||||
siege = _castle.getSiege().isInProgress();
|
||||
// castle zones active only during siege
|
||||
if (!siege)
|
||||
{
|
||||
_dmgZone.getSettings().clear();
|
||||
_task.cancel(false);
|
||||
_task = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Creature temp : _dmgZone.getCharactersInside())
|
||||
for (Creature character : getCharactersInside())
|
||||
{
|
||||
if ((temp != null) && !temp.isDead())
|
||||
if ((character != null) && character.isPlayer() && !character.isDead())
|
||||
{
|
||||
if (siege)
|
||||
{
|
||||
// during siege defenders not affected
|
||||
final PlayerInstance player = temp.getActingPlayer();
|
||||
final PlayerInstance player = character.getActingPlayer();
|
||||
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
|
||||
{
|
||||
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)
|
||||
{
|
||||
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, temp, null);
|
||||
character.reduceCurrentHp(getHPDamagePerSecond() * multiplier, character, null);
|
||||
}
|
||||
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.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||
import org.l2jmobius.gameserver.enums.InstanceType;
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
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.ZoneType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
|
||||
/**
|
||||
* another type of damage zone with skills
|
||||
* Another type of damage zone with skills.
|
||||
* @author kerberos
|
||||
*/
|
||||
public class EffectZone extends ZoneType
|
||||
@@ -45,6 +43,7 @@ public class EffectZone extends ZoneType
|
||||
protected boolean _bypassConditions;
|
||||
private boolean _isShowDangerIcon;
|
||||
protected Map<Integer, Integer> _skills;
|
||||
private volatile Future<?> _task;
|
||||
|
||||
public EffectZone(int id)
|
||||
{
|
||||
@@ -55,101 +54,106 @@ public class EffectZone extends ZoneType
|
||||
setTargetType(InstanceType.Playable); // default only playable
|
||||
_bypassConditions = false;
|
||||
_isShowDangerIcon = true;
|
||||
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
|
||||
if (settings == null)
|
||||
{
|
||||
settings = new TaskZoneSettings();
|
||||
}
|
||||
setSettings(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskZoneSettings getSettings()
|
||||
{
|
||||
return (TaskZoneSettings) super.getSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(String name, String value)
|
||||
{
|
||||
if (name.equals("chance"))
|
||||
switch (name)
|
||||
{
|
||||
_chance = Integer.parseInt(value);
|
||||
}
|
||||
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)
|
||||
case "chance":
|
||||
{
|
||||
final String[] skillSplit = skill.split("-");
|
||||
if (skillSplit.length != 2)
|
||||
_chance = Integer.parseInt(value);
|
||||
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 + "\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
final String[] skillSplit = skill.split("-");
|
||||
if (skillSplit.length != 2)
|
||||
{
|
||||
_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
|
||||
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
|
||||
@@ -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()
|
||||
{
|
||||
return _chance;
|
||||
@@ -195,7 +196,10 @@ public class EffectZone extends ZoneType
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
_skills = new ConcurrentHashMap<>(3);
|
||||
if (_skills == null)
|
||||
{
|
||||
_skills = new ConcurrentHashMap<>(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
_skills.put(skillId, skillLevel);
|
||||
@@ -219,10 +223,14 @@ public class EffectZone extends ZoneType
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -235,18 +243,30 @@ public class EffectZone extends ZoneType
|
||||
@Override
|
||||
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 ((skill != null) && (_bypassConditions || skill.checkCondition(temp, temp, false)) && !temp.isAffectedBySkill(e.getKey()))
|
||||
if (!character.isAffectedBySkill(skill.getId()))
|
||||
{
|
||||
skill.applyEffects(temp, temp);
|
||||
skill.applyEffects(character, character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user