浏览代码

BETA: Cubic related fixes:
* Moving cubics from map to list.
* Removed cubic summon related code from L2SkillSummon.
* Removed from L2SkillSummon, it wasn't called from any place!
* Retail like system message when a player already have a summon.

Zoey76 12 年之前
父节点
当前提交
dc9edd9963

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java

@@ -464,7 +464,7 @@ public final class L2CubicInstance
 				if (_owner.isDead() || !_owner.isOnline())
 				{
 					stopAction();
-					_owner.delCubic(_id);
+					_owner.getCubics().remove(this);
 					_owner.broadcastUserInfo();
 					cancelDisappear();
 					return;
@@ -972,7 +972,7 @@ public final class L2CubicInstance
 			if (_owner.isDead() || !_owner.isOnline())
 			{
 				stopAction();
-				_owner.delCubic(_id);
+				_owner.getCubics().remove(this);
 				_owner.broadcastUserInfo();
 				cancelDisappear();
 				return;
@@ -1035,7 +1035,7 @@ public final class L2CubicInstance
 		public void run()
 		{
 			stopAction();
-			_owner.delCubic(_id);
+			_owner.getCubics().remove(this);
 			_owner.broadcastUserInfo();
 		}
 	}

+ 25 - 41
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -224,7 +225,6 @@ import com.l2jserver.gameserver.model.quest.State;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 import com.l2jserver.gameserver.model.skills.L2SkillType;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSiegeFlag;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSummon;
 import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
 import com.l2jserver.gameserver.model.stats.Env;
 import com.l2jserver.gameserver.model.stats.Formulas;
@@ -792,7 +792,7 @@ public final class L2PcInstance extends L2Playable
 	
 	protected boolean _inventoryDisable = false;
 	
-	private final FastMap<Integer, L2CubicInstance> _cubics = new FastMap<>();
+	private final List<L2CubicInstance> _cubics = new CopyOnWriteArrayList<>();
 	
 	/** Active shots. */
 	protected FastSet<Integer> _activeSoulShots = new FastSet<Integer>().shared();
@@ -1163,8 +1163,6 @@ public final class L2PcInstance extends L2Playable
 		_radar = new L2Radar(this);
 		
 		startVitalityTask();
-		
-		_cubics.shared();
 	}
 	
 	@Override
@@ -4407,21 +4405,10 @@ public final class L2PcInstance extends L2Playable
 			return false;
 		}
 		
-		switch (skill.getSkillType())
+		if ((skill.getSkillType() == L2SkillType.SUMMON) && (hasSummon() || isMounted() || inObserverMode()))
 		{
-			case SUMMON:
-			{
-				if (!((L2SkillSummon) skill).isCubic() && (hasSummon() || isMounted() || CharSummonTable.getInstance().getPets().contains(getObjectId()) || CharSummonTable.getInstance().getPets().contains(getObjectId())))
-				{
-					if (Config.DEBUG)
-					{
-						_log.fine("player has a pet already. ignore summon skill");
-					}
-					
-					sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
-					return false;
-				}
-			}
+			sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
+			return false;
 		}
 		
 		// TODO: Should possibly be checked only in L2PcInstance's useMagic
@@ -5671,7 +5658,7 @@ public final class L2PcInstance extends L2Playable
 		// Unsummon Cubics
 		if (!_cubics.isEmpty())
 		{
-			for (L2CubicInstance cubic : _cubics.values())
+			for (L2CubicInstance cubic : _cubics)
 			{
 				cubic.stopAction();
 				cubic.cancelDisappear();
@@ -9759,7 +9746,7 @@ public final class L2PcInstance extends L2Playable
 	{
 		if (!_cubics.isEmpty())
 		{
-			for (L2CubicInstance cubic : _cubics.values())
+			for (L2CubicInstance cubic : _cubics)
 			{
 				cubic.stopAction();
 				cubic.cancelDisappear();
@@ -9773,17 +9760,14 @@ public final class L2PcInstance extends L2Playable
 	{
 		if (!_cubics.isEmpty())
 		{
-			final Iterator<L2CubicInstance> iter = _cubics.values().iterator();
-			L2CubicInstance cubic;
 			boolean broadcast = false;
-			while (iter.hasNext())
+			for (L2CubicInstance cubic : _cubics)
 			{
-				cubic = iter.next();
 				if (cubic.givenByOther())
 				{
 					cubic.stopAction();
 					cubic.cancelDisappear();
-					iter.remove();
+					_cubics.remove(cubic);
 					broadcast = true;
 				}
 			}
@@ -9833,13 +9817,13 @@ public final class L2PcInstance extends L2Playable
 		return _inventoryDisable;
 	}
 	
-	public FastMap<Integer, L2CubicInstance> getCubics()
+	public List<L2CubicInstance> getCubics()
 	{
 		return _cubics;
 	}
 	
 	/**
-	 * Add a L2CubicInstance to the L2PcInstance _cubics.
+	 * Add a cubic to this player.
 	 * @param id
 	 * @param level
 	 * @param cubicPower
@@ -9851,24 +9835,24 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public void addCubic(int id, int level, double cubicPower, int cubicDelay, int cubicSkillChance, int cubicMaxCount, int cubicDuration, boolean givenByOther)
 	{
-		_cubics.put(id, new L2CubicInstance(this, id, level, (int) cubicPower, cubicDelay, cubicSkillChance, cubicMaxCount, cubicDuration, givenByOther));
+		_cubics.add(new L2CubicInstance(this, id, level, (int) cubicPower, cubicDelay, cubicSkillChance, cubicMaxCount, cubicDuration, givenByOther));
 	}
 	
 	/**
-	 * @param id a L2CubicInstance from the L2PcInstance _cubics.
+	 * Get the player cubic by NPC Id, if any.
+	 * @param id the NPC id
+	 * @return the cubic with the given NPC id, {@code null} otherwise
 	 */
-	public void delCubic(int id)
+	public L2CubicInstance getCubicById(int id)
 	{
-		_cubics.remove(id);
-	}
-	
-	/**
-	 * @param id
-	 * @return the L2CubicInstance corresponding to the Identifier of the L2PcInstance _cubics.
-	 */
-	public L2CubicInstance getCubic(int id)
-	{
-		return _cubics.get(id);
+		for (L2CubicInstance c : _cubics)
+		{
+			if (c.getId() == id)
+			{
+				return c;
+			}
+		}
+		return null;
 	}
 	
 	/**
@@ -10135,7 +10119,7 @@ public final class L2PcInstance extends L2Playable
 		
 		if (!_cubics.isEmpty())
 		{
-			for (L2CubicInstance cubic : _cubics.values())
+			for (L2CubicInstance cubic : _cubics)
 			{
 				cubic.stopAction();
 				cubic.cancelDisappear();

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

@@ -29,7 +29,6 @@ public enum L2EffectType
 	CANCEL,
 	CANCEL_ALL,
 	CANCEL_DEBUFF,
-	CHANCE_SKILL_TRIGGER,
 	CHARM_OF_LUCK,
 	CHARMOFCOURAGE,
 	CLAN_GATE,
@@ -38,6 +37,7 @@ public enum L2EffectType
 	CPHEAL,
 	CPHEAL_OVER_TIME,
 	CPHEAL_PERCENT,
+	CUBIC_MASTERY,
 	DAMAGE_TRANSFER,
 	DEBUFF,
 	DISARM,

+ 7 - 181
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillSummon.java

@@ -18,43 +18,23 @@
  */
 package com.l2jserver.gameserver.model.skills.l2skills;
 
-import com.l2jserver.Config;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
 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.L2CubicInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.gameserver.model.skills.L2Skill;
-import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
-import com.l2jserver.gameserver.network.SystemMessageId;
 
 public class L2SkillSummon extends L2Skill
 {
-	public static final int SKILL_CUBIC_MASTERY = 143;
-	
 	private final float _expPenalty;
-	private final boolean _isCubic;
-	
-	// cubic AI
-	// Power for a cubic
-	private final int _cubicPower;
-	// Duration for a cubic
-	private final int _cubicDuration;
-	// Activation time for a cubic
-	private final int _cubicDelay;
-	// Maximum casts made by the cubic until it goes idle
-	private final int _cubicMaxCount;
-	// Activation chance for a cubic
-	private final int _cubicSkillChance;
-	
-	// What is the total lifetime of summons (in millisecs)
+	// What is the total lifetime of summons (in milliseconds)
 	private final int _summonTotalLifeTime;
 	// How much lifetime is lost per second of idleness (non-fighting)
 	private final int _summonTimeLostIdle;
@@ -78,13 +58,6 @@ public class L2SkillSummon extends L2Skill
 		super(set);
 		
 		_expPenalty = set.getFloat("expPenalty", 0.f);
-		_isCubic = set.getBool("isCubic", false);
-		
-		_cubicPower = set.getInteger("cubicPower", 0);
-		_cubicDuration = set.getInteger("cubicDuration", 0);
-		_cubicDelay = set.getInteger("cubicDelay", 0);
-		_cubicMaxCount = set.getInteger("cubicMaxCount", -1);
-		_cubicSkillChance = set.getInteger("cubicSkillChance", 0);
 		
 		_summonTotalLifeTime = set.getInteger("summonTotalLifeTime", 1200000); // 20 minutes default
 		_summonTimeLostIdle = set.getInteger("summonTimeLostIdle", 0);
@@ -99,163 +72,22 @@ public class L2SkillSummon extends L2Skill
 		_elementalSharePercent = set.getDouble("inheritPercent", 1);
 	}
 	
-	public boolean checkCondition(L2Character activeChar)
-	{
-		if (activeChar.isPlayer())
-		{
-			L2PcInstance player = activeChar.getActingPlayer();
-			
-			if (isCubic())
-			{
-				if (getTargetType() != L2TargetType.SELF)
-				{
-					return true; // Player is always able to cast mass cubic skill
-				}
-				int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
-				if (mastery < 0)
-				{
-					mastery = 0;
-				}
-				int count = player.getCubics().size();
-				if (count > mastery)
-				{
-					activeChar.sendMessage("You already have " + count + " cubic(s).");
-					return false;
-				}
-			}
-			else
-			{
-				if (player.inObserverMode())
-				{
-					return false;
-				}
-				if (player.hasSummon())
-				{
-					activeChar.sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
-					return false;
-				}
-			}
-		}
-		return super.checkCondition(activeChar, null, false);
-	}
-	
 	@Override
 	public void useSkill(L2Character caster, L2Object[] targets)
 	{
-		if (caster.isAlikeDead() || !caster.isPlayer())
-		{
-			return;
-		}
-		
-		L2PcInstance activeChar = caster.getActingPlayer();
-		
-		if (getNpcId() == 0)
-		{
-			activeChar.sendMessage("Summon skill " + getId() + " not described yet");
-			return;
-		}
-		
-		if (_isCubic)
+		if ((caster == null) || caster.isAlikeDead() || !caster.isPlayer())
 		{
-			// Gnacik :
-			// If skill is enchanted calculate cubic skill level based on enchant
-			// 8 at 101 (+1 Power)
-			// 12 at 130 (+30 Power)
-			// Because 12 is max 5115-5117 skills
-			// TODO: make better method of calculation, dunno how its calculated on offi
-			int _cubicSkillLevel = getLevel();
-			if (_cubicSkillLevel > 100)
-			{
-				_cubicSkillLevel = ((getLevel() - 100) / 7) + 8;
-			}
-			
-			if (targets.length > 1) // Mass cubic skill
-			{
-				for (L2Object obj : targets)
-				{
-					if (!obj.isPlayer())
-					{
-						continue;
-					}
-					L2PcInstance player = obj.getActingPlayer();
-					int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
-					if (mastery < 0)
-					{
-						mastery = 0;
-					}
-					if ((mastery == 0) && !player.getCubics().isEmpty())
-					{
-						// Player can have only 1 cubic - we should replace old cubic with new one
-						for (L2CubicInstance c : player.getCubics().values())
-						{
-							c.stopAction();
-						}
-						player.getCubics().clear();
-					}
-					// TODO: Should remove first cubic summoned and replace with new cubic
-					if (player.getCubics().containsKey(getNpcId()))
-					{
-						L2CubicInstance cubic = player.getCubic(getNpcId());
-						cubic.stopAction();
-						cubic.cancelDisappear();
-						player.delCubic(getNpcId());
-					}
-					if (player.getCubics().size() > mastery)
-					{
-						continue;
-					}
-					if (player == activeChar)
-					{
-						player.addCubic(getNpcId(), _cubicSkillLevel, _cubicPower, _cubicDelay, _cubicSkillChance, _cubicMaxCount, _cubicDuration, false);
-					}
-					else
-					{
-						player.addCubic(getNpcId(), _cubicSkillLevel, _cubicPower, _cubicDelay, _cubicSkillChance, _cubicMaxCount, _cubicDuration, true);
-					}
-					player.broadcastUserInfo();
-				}
-			}
-			else
-			// Normal cubic skill
-			{
-				int mastery = activeChar.getSkillLevel(SKILL_CUBIC_MASTERY);
-				if (mastery < 0)
-				{
-					mastery = 0;
-				}
-				if (activeChar.getCubics().containsKey(getNpcId()))
-				{
-					L2CubicInstance cubic = activeChar.getCubic(getNpcId());
-					cubic.stopAction();
-					cubic.cancelDisappear();
-					activeChar.delCubic(getNpcId());
-				}
-				if (activeChar.getCubics().size() > mastery)
-				{
-					if (Config.DEBUG)
-					{
-						_log.fine("player can't summon any more cubics. ignore summon skill");
-					}
-					activeChar.sendPacket(SystemMessageId.CUBIC_SUMMONING_FAILED);
-					return;
-				}
-				activeChar.addCubic(getNpcId(), _cubicSkillLevel, _cubicPower, _cubicDelay, _cubicSkillChance, _cubicMaxCount, _cubicDuration, false);
-				activeChar.broadcastUserInfo();
-			}
 			return;
 		}
 		
-		if (activeChar.hasSummon() || activeChar.isMounted())
+		final L2PcInstance activeChar = caster.getActingPlayer();
+		if (getNpcId() <= 0)
 		{
-			if (Config.DEBUG)
-			{
-				_log.fine("player has a pet already. ignore summon skill");
-			}
+			activeChar.sendMessage("Summon skill " + getId() + " not implemented yet.");
 			return;
 		}
 		
-		L2ServitorInstance summon;
-		L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(getNpcId());
+		final L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(getNpcId());
 		if (summonTemplate == null)
 		{
 			_log.warning("Summon attempt for nonexisting NPC ID:" + getNpcId() + ", skill ID:" + getId());
@@ -263,6 +95,7 @@ public class L2SkillSummon extends L2Skill
 		}
 		
 		final int id = IdFactory.getInstance().getNextId();
+		L2ServitorInstance summon;
 		if (summonTemplate.isType("L2SiegeSummon"))
 		{
 			summon = new L2SiegeSummonInstance(id, summonTemplate, activeChar, this);
@@ -300,16 +133,9 @@ public class L2SkillSummon extends L2Skill
 		{
 			activeChar.setPet(summon);
 		}
-		
-		// L2World.getInstance().storeObject(summon);
 		summon.spawnMe(activeChar.getX() + 20, activeChar.getY() + 20, activeChar.getZ());
 	}
 	
-	public final boolean isCubic()
-	{
-		return _isCubic;
-	}
-	
 	public final int getTotalLifeTime()
 	{
 		return _summonTotalLifeTime;

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java

@@ -23,6 +23,7 @@ import com.l2jserver.gameserver.datatables.NpcTable;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.PcCondOverride;
 import com.l2jserver.gameserver.model.actor.L2Decoy;
+import com.l2jserver.gameserver.model.actor.instance.L2CubicInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.gameserver.model.effects.AbnormalEffect;
@@ -316,9 +317,9 @@ public class CharInfo extends L2GameServerPacket
 			writeC(_activeChar.getPrivateStoreType()); // 1 - sellshop
 			
 			writeH(_activeChar.getCubics().size());
-			for (int id : _activeChar.getCubics().keySet())
+			for (L2CubicInstance c : _activeChar.getCubics())
 			{
-				writeH(id);
+				writeH(c.getId());
 			}
 			
 			writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java

@@ -25,6 +25,7 @@ import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
 import com.l2jserver.gameserver.model.Elementals;
 import com.l2jserver.gameserver.model.PcCondOverride;
+import com.l2jserver.gameserver.model.actor.instance.L2CubicInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.gameserver.model.effects.AbnormalEffect;
@@ -272,9 +273,9 @@ public final class UserInfo extends L2GameServerPacket
 		writeD(_activeChar.getPvpKills());
 		
 		writeH(_activeChar.getCubics().size());
-		for (int id : _activeChar.getCubics().keySet())
+		for (L2CubicInstance c : _activeChar.getCubics())
 		{
-			writeH(id);
+			writeH(c.getId());
 		}
 		
 		writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/taskmanager/AttackStanceTaskManager.java

@@ -58,7 +58,7 @@ public class AttackStanceTaskManager
 		if ((actor != null) && actor.isPlayable())
 		{
 			final L2PcInstance player = actor.getActingPlayer();
-			for (L2CubicInstance cubic : player.getCubics().values())
+			for (L2CubicInstance cubic : player.getCubics())
 			{
 				if (cubic.getId() != L2CubicInstance.LIFE_CUBIC)
 				{