فهرست منبع

BETA: Removing hardcoded skill implementations:
* Removed L2SkillSpawn.
* Removed L2SkillCreateItem.
* Removed L2SkillDecoy.
* Removed some skill types.
* Removed some effect types.
* Minor cleanup in L2DecoyInstance.
* Added support for effect parameters!

Zoey76 12 سال پیش
والد
کامیت
d682acedfd

+ 32 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/engines/DocumentBase.java

@@ -292,9 +292,10 @@ public abstract class DocumentBase
 			set.set(att.getNodeName(), getValue(att.getNodeValue(), template));
 		}
 		
+		final StatsSet parameters = parseParameters(n.getFirstChild(), template);
 		final Lambda lambda = getLambda(n, template);
 		final Condition applayCond = parseCondition(n.getFirstChild(), template);
-		final EffectTemplate effectTemplate = new EffectTemplate(attachCond, applayCond, lambda, set);
+		final EffectTemplate effectTemplate = new EffectTemplate(attachCond, applayCond, lambda, set, parameters);
 		parseTemplate(n, effectTemplate);
 		if (template instanceof L2Item)
 		{
@@ -318,6 +319,36 @@ public abstract class DocumentBase
 		}
 	}
 	
+	/**
+	 * Parse effect's parameters.
+	 * @param n the node to start the parsing
+	 * @param template the effect template
+	 * @return the list of parameters if any, {@code null} otherwise
+	 */
+	private StatsSet parseParameters(Node n, Object template)
+	{
+		StatsSet parameters = null;
+		while ((n != null))
+		{
+			// Parse all parameters.
+			if ((n.getNodeType() == Node.ELEMENT_NODE) && "param".equals(n.getNodeName()))
+			{
+				if (parameters == null)
+				{
+					parameters = new StatsSet();
+				}
+				NamedNodeMap params = n.getAttributes();
+				for (int i = 0; i < params.getLength(); i++)
+				{
+					Node att = params.item(i);
+					parameters.set(att.getNodeName(), getValue(att.getNodeValue(), template));
+				}
+			}
+			n = n.getNextSibling();
+		}
+		return parameters;
+	}
+	
 	protected Condition parseCondition(Node n, Object template)
 	{
 		while ((n != null) && (n.getNodeType() != Node.ELEMENT_NODE))

+ 5 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2DecoyInstance.java

@@ -28,7 +28,6 @@ import com.l2jserver.gameserver.model.actor.L2Decoy;
 import com.l2jserver.gameserver.model.actor.knownlist.DecoyKnownList;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.gameserver.model.skills.L2Skill;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillDecoy;
 import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
 
 public class L2DecoyInstance extends L2Decoy
@@ -38,22 +37,14 @@ public class L2DecoyInstance extends L2Decoy
 	private Future<?> _DecoyLifeTask;
 	private Future<?> _HateSpam;
 	
-	public L2DecoyInstance(int objectId, L2NpcTemplate template, L2PcInstance owner, L2Skill skill)
+	public L2DecoyInstance(int objectId, L2NpcTemplate template, L2PcInstance owner, int totalLifeTime)
 	{
 		super(objectId, template, owner);
 		setInstanceType(InstanceType.L2DecoyInstance);
-		if (skill != null)
-		{
-			_totalLifeTime = ((L2SkillDecoy) skill).getTotalLifeTime();
-		}
-		else
-		{
-			_totalLifeTime = 20000;
-		}
+		_totalLifeTime = totalLifeTime;
 		_timeRemaining = _totalLifeTime;
-		int delay = 1000;
 		int skilllevel = getTemplate().getIdTemplate() - 13070;
-		_DecoyLifeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new DecoyLifetime(getOwner(), this), delay, delay);
+		_DecoyLifeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new DecoyLifetime(getOwner(), this), 1000, 1000);
 		_HateSpam = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new HateSpam(this, SkillTable.getInstance().getInfo(5272, skilllevel)), 2000, 5000);
 	}
 	
@@ -103,9 +94,8 @@ public class L2DecoyInstance extends L2Decoy
 		{
 			try
 			{
-				double newTimeRemaining;
 				_Decoy.decTimeRemaining(1000);
-				newTimeRemaining = _Decoy.getTimeRemaining();
+				double newTimeRemaining = _Decoy.getTimeRemaining();
 				if (newTimeRemaining < 0)
 				{
 					_Decoy.unSummon(_activeChar);
@@ -118,10 +108,9 @@ public class L2DecoyInstance extends L2Decoy
 		}
 	}
 	
-	static class HateSpam implements Runnable
+	private static class HateSpam implements Runnable
 	{
 		private final L2DecoyInstance _activeChar;
-		
 		private final L2Skill _skill;
 		
 		HateSpam(L2DecoyInstance activeChar, L2Skill Hate)

+ 21 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/EffectTemplate.java

@@ -59,8 +59,9 @@ public class EffectTemplate
 	private final int _triggeredId;
 	private final int _triggeredLevel;
 	private final ChanceCondition _chanceCondition;
+	private final StatsSet _parameters;
 	
-	public EffectTemplate(Condition attachCond, Condition applyCond, Lambda lambda, StatsSet set)
+	public EffectTemplate(Condition attachCond, Condition applyCond, Lambda lambda, StatsSet set, StatsSet params)
 	{
 		_attachCond = attachCond;
 		// _applyCond = applyCond;
@@ -81,6 +82,7 @@ public class EffectTemplate
 		_triggeredId = set.getInteger("triggeredId", 0);
 		_triggeredLevel = set.getInteger("triggeredLevel", 1);
 		_chanceCondition = ChanceCondition.parse(set.getString("chanceType", null), set.getInteger("activationChance", -1), set.getInteger("activationMinDamage", -1), set.getString("activationElements", null), set.getString("activationSkills", null), set.getBool("pvpChanceOnly", false));
+		_parameters = params;
 		_handler = EffectHandler.getInstance().getHandler(_name);
 		if (_handler == null)
 		{
@@ -238,4 +240,22 @@ public class EffectTemplate
 	{
 		return _chanceCondition;
 	}
+	
+	/**
+	 * Get the parameters.
+	 * @return the parameters of this effect template
+	 */
+	public StatsSet getParameters()
+	{
+		return _parameters;
+	}
+	
+	/**
+	 * Verify if this effect template has parameters.
+	 * @return {@code true} if this effect template has parameters, {@code false} otherwise
+	 */
+	public boolean hasParameters()
+	{
+		return _parameters != null;
+	}
 }

+ 0 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2EffectType.java

@@ -93,11 +93,9 @@ public enum L2EffectType
 	SPOIL,
 	STATIC_DAMAGE,
 	STUN,
-	SUMMON_AGATHION,
 	SUMMON_PET,
 	TARGET_ME,
 	THROW_UP,
 	TRANSFORMATION,
-	UNSUMMON_AGATHION,
 	WARP
 }

+ 0 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/L2SkillType.java

@@ -21,14 +21,11 @@ package com.l2jserver.gameserver.model.skills;
 import java.lang.reflect.Constructor;
 
 import com.l2jserver.gameserver.model.StatsSet;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillCreateItem;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillDecoy;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillDefault;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillLearnSkill;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSiegeFlag;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSignet;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSignetCasttime;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSpawn;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSummon;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillTeleport;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillTrap;
@@ -89,15 +86,12 @@ public enum L2SkillType
 	// Creation
 	COMMON_CRAFT,
 	DWARVEN_CRAFT,
-	CREATE_ITEM(L2SkillCreateItem.class),
 	LEARN_SKILL(L2SkillLearnSkill.class),
 	// Summons
 	SUMMON(L2SkillSummon.class),
 	FEED_PET,
 	ERASE,
 	BETRAY,
-	DECOY(L2SkillDecoy.class),
-	SPAWN(L2SkillSpawn.class),
 	
 	BUFF,
 	DEBUFF,

+ 0 - 79
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillCreateItem.java

@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2004-2013 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 com.l2jserver.gameserver.model.skills.l2skills;
-
-import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.StatsSet;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.skills.L2Skill;
-import com.l2jserver.gameserver.network.SystemMessageId;
-import com.l2jserver.gameserver.network.serverpackets.PetItemList;
-import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
-import com.l2jserver.util.Rnd;
-
-/**
- * @author Nemesiss
- */
-public class L2SkillCreateItem extends L2Skill
-{
-	private final int[] _createItemId;
-	private final int _createItemCount;
-	private final int _randomCount;
-	
-	public L2SkillCreateItem(StatsSet set)
-	{
-		super(set);
-		_createItemId = set.getIntegerArray("create_item_id", ";");
-		_createItemCount = set.getInteger("create_item_count", 0);
-		_randomCount = set.getInteger("random_count", 1);
-	}
-	
-	@Override
-	public void useSkill(L2Character activeChar, L2Object[] targets)
-	{
-		L2PcInstance player = activeChar.getActingPlayer();
-		if (activeChar.isAlikeDead())
-		{
-			return;
-		}
-		if (activeChar.isPlayable())
-		{
-			if ((_createItemId == null) || (_createItemCount == 0))
-			{
-				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
-				sm.addSkillName(this);
-				player.sendPacket(sm);
-				return;
-			}
-			
-			int count = _createItemCount + Rnd.nextInt(_randomCount);
-			int rndid = Rnd.nextInt(_createItemId.length);
-			if (activeChar.isPlayer())
-			{
-				player.addItem("Skill", _createItemId[rndid], count, activeChar, true);
-			}
-			else if (activeChar.isPet())
-			{
-				activeChar.getInventory().addItem("Skill", _createItemId[rndid], count, player, activeChar);
-				player.sendPacket(new PetItemList(activeChar.getInventory().getItems()));
-			}
-		}
-	}
-}

+ 0 - 79
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillDecoy.java

@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2004-2013 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 com.l2jserver.gameserver.model.skills.l2skills;
-
-import com.l2jserver.gameserver.datatables.NpcTable;
-import com.l2jserver.gameserver.idfactory.IdFactory;
-import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.StatsSet;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.instance.L2DecoyInstance;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
-import com.l2jserver.gameserver.model.skills.L2Skill;
-
-public class L2SkillDecoy extends L2Skill
-{
-	private final int _summonTotalLifeTime;
-	
-	public L2SkillDecoy(StatsSet set)
-	{
-		super(set);
-		_summonTotalLifeTime = set.getInteger("summonTotalLifeTime", 20000);
-	}
-	
-	@Override
-	public void useSkill(L2Character caster, L2Object[] targets)
-	{
-		if (caster.isAlikeDead() || !caster.isPlayer())
-		{
-			return;
-		}
-		
-		if (getNpcId() == 0)
-		{
-			return;
-		}
-		
-		final L2PcInstance activeChar = caster.getActingPlayer();
-		if (activeChar.inObserverMode())
-		{
-			return;
-		}
-		
-		if (activeChar.hasSummon() || activeChar.isMounted())
-		{
-			return;
-		}
-		
-		final L2NpcTemplate DecoyTemplate = NpcTable.getInstance().getTemplate(getNpcId());
-		final L2DecoyInstance decoy = new L2DecoyInstance(IdFactory.getInstance().getNextId(), DecoyTemplate, activeChar, this);
-		decoy.setCurrentHp(decoy.getMaxHp());
-		decoy.setCurrentMp(decoy.getMaxMp());
-		decoy.setHeading(activeChar.getHeading());
-		activeChar.setDecoy(decoy);
-		decoy.setInstanceId(activeChar.getInstanceId());
-		decoy.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
-	}
-	
-	public final int getTotalLifeTime()
-	{
-		return _summonTotalLifeTime;
-	}
-}

+ 0 - 109
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillSpawn.java

@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2004-2013 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 com.l2jserver.gameserver.model.skills.l2skills;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.l2jserver.gameserver.datatables.NpcTable;
-import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.L2Spawn;
-import com.l2jserver.gameserver.model.StatsSet;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
-import com.l2jserver.gameserver.model.skills.L2Skill;
-import com.l2jserver.util.Rnd;
-
-/**
- * @author Zoey76
- */
-public class L2SkillSpawn extends L2Skill
-{
-	private static final Logger _log = Logger.getLogger(L2SkillSpawn.class.getName());
-	
-	private final int _despawnDelay;
-	private final boolean _summonSpawn;
-	private final boolean _randomOffset;
-	
-	public L2SkillSpawn(StatsSet set)
-	{
-		super(set);
-		_despawnDelay = set.getInteger("despawnDelay", 0);
-		_summonSpawn = set.getBool("isSummonSpawn", false);
-		_randomOffset = set.getBool("randomOffset", true);
-	}
-	
-	@Override
-	public void useSkill(L2Character caster, L2Object[] targets)
-	{
-		if (caster.isAlikeDead())
-		{
-			return;
-		}
-		
-		if (getNpcId() == 0)
-		{
-			_log.warning("NPC ID not defined for skill ID:" + getId());
-			return;
-		}
-		
-		final L2NpcTemplate template = NpcTable.getInstance().getTemplate(getNpcId());
-		if (template == null)
-		{
-			_log.warning("Spawn of the nonexisting NPC ID:" + getNpcId() + ", skill ID:" + getId());
-			return;
-		}
-		
-		L2Spawn spawn;
-		try
-		{
-			spawn = new L2Spawn(template);
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.WARNING, "Exception in L2SkillSpawn: " + e.getMessage(), e);
-			return;
-		}
-		
-		int x = caster.getX();
-		int y = caster.getY();
-		if (_randomOffset)
-		{
-			x += (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20));
-			y += (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20));
-		}
-		
-		spawn.setLocx(x);
-		spawn.setLocy(y);
-		spawn.setLocz(caster.getZ());
-		spawn.setHeading(caster.getHeading());
-		spawn.stopRespawn();
-		
-		final L2Npc npc = spawn.doSpawn(_summonSpawn);
-		npc.setName(template.getName());
-		npc.setTitle(caster.getName());
-		npc.setSummoner(caster);
-		if (_despawnDelay > 0)
-		{
-			npc.scheduleDespawn(_despawnDelay);
-		}
-		npc.setIsRunning(false); // Broadcast info
-	}
-}