Procházet zdrojové kódy

BETA: Implementing Summon Agathion effect:
* General cleanup.
* L2Effect shouldn't call onExit() right way if onActionTime() && _startConditionsCorrect yields true.
* Removed L2SkillAgathion hardcoded skill handler...
* Removed skill type AGATHION.

Zoey76 před 12 roky
rodič
revize
cd175f787e

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -178,8 +178,8 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			return false;
 		}
 		
-		// Check if the target is a L2PlayableInstance
-		if (target instanceof L2Playable)
+		// Check if the target is a L2Playable
+		if (target.isPlayable())
 		{
 			// Check if the AI isn't a Raid Boss, can See Silent Moving players and the target isn't in silent move mode
 			if (!(me.isRaid()) && !(me.canSeeThroughSilentMove()) && ((L2Playable) target).isSilentMoving())

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2ControllableMobAI.java

@@ -417,8 +417,8 @@ public class L2ControllableMobAI extends L2AttackableAI
 			return false;
 		}
 		
-		// Check if the target is a L2PlayableInstance
-		if (target instanceof L2Playable)
+		// Check if the target is a L2Playable
+		if (target.isPlayable())
 		{
 			// Check if the target isn't in silent move mode
 			if (((L2Playable) target).isSilentMoving())

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/handler/IItemHandler.java

@@ -28,7 +28,7 @@ public interface IItemHandler
 	
 	/**
 	 * Launch task associated to the item.
-	 * @param playable L2PlayableInstance designating the player
+	 * @param playable the non-NPC character using the item
 	 * @param item L2ItemInstance designating the item to use
 	 * @param forceUse ctrl hold on item use
 	 * @return {@code true} if the item all conditions are met and the item is used, {@code false} otherwise.

+ 5 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2WorldRegion.java

@@ -38,19 +38,19 @@ import com.l2jserver.gameserver.model.zone.type.L2PeaceZone;
 
 public final class L2WorldRegion
 {
-	private static Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
+	private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
 	
-	/** L2ObjectHashSet(L2PlayableInstance) containing L2PlayableInstance of all player & summon in game in this L2WorldRegion */
+	/** Map containing all playable characters in game in this world region. */
 	private final Map<Integer, L2Playable> _allPlayable;
 	
-	/** L2ObjectHashSet(L2Object) containing L2Object visible in this L2WorldRegion */
+	/** Map containing visible objects in this world region. */
 	private final Map<Integer, L2Object> _visibleObjects;
 	
 	private final List<L2WorldRegion> _surroundingRegions;
 	private final int _tileX, _tileY;
 	private boolean _active = false;
 	private ScheduledFuture<?> _neighborsTask = null;
-	private final FastList<L2ZoneType> _zones;
+	private final List<L2ZoneType> _zones;
 	
 	public L2WorldRegion(int pTileX, int pTileY)
 	{
@@ -73,7 +73,7 @@ public final class L2WorldRegion
 		_zones = new FastList<>();
 	}
 	
-	public FastList<L2ZoneType> getZones()
+	public List<L2ZoneType> getZones()
 	{
 		return _zones;
 	}

+ 2 - 9
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -90,7 +90,6 @@ import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 import com.l2jserver.gameserver.model.skills.L2SkillType;
 import com.l2jserver.gameserver.model.skills.funcs.Func;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillAgathion;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillMount;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSummon;
 import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
@@ -2340,7 +2339,7 @@ public abstract class L2Character extends L2Object
 				((L2Playable) this).stopNoblesseBlessing(null);
 			}
 		}
-		// Same thing if the Character isn't a Noblesse Blessed L2PlayableInstance
+		// Same thing if the Character isn't a Noblesse Blessed L2Playable
 		else if (isPlayable() && ((L2Playable) this).isNoblesseBlessed())
 		{
 			((L2Playable) this).stopNoblesseBlessing(null);
@@ -5000,7 +4999,7 @@ public abstract class L2Character extends L2Object
 			
 			// Movement checks:
 			// when geodata == 2, for all characters except mobs returning home (could be changed later to teleport if pathfinding fails)
-			// when geodata == 1, for l2playableinstance and l2riftinstance only
+			// when geodata == 1, for L2Playable and L2RiftInvaderInstance only
 			if (((Config.GEODATA == 2) && !(isL2Attackable() && ((L2Attackable) this).isReturningToSpawnPoint())) || (isPlayer() && !(isInVehicle && (distance > 1500))) || (isSummon() && !(getAI().getIntention() == AI_INTENTION_FOLLOW)) // assuming intention_follow only when following owner
 				|| isAfraid() || (this instanceof L2RiftInvaderInstance))
 			{
@@ -6224,12 +6223,6 @@ public abstract class L2Character extends L2Object
 				}
 			}
 			
-			if ((oldSkill instanceof L2SkillAgathion) && isPlayer() && (getActingPlayer().getAgathionId() > 0))
-			{
-				getActingPlayer().setAgathionId(0);
-				getActingPlayer().broadcastUserInfo();
-			}
-			
 			if ((oldSkill instanceof L2SkillMount) && isPlayer() && getActingPlayer().isMounted())
 			{
 				getActingPlayer().dismount();

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Npc.java

@@ -631,7 +631,7 @@ public class L2Npc extends L2Character
 	 * <ul>
 	 * <li>object is a L2FolkInstance : 0 (don't remember it)</li>
 	 * <li>object is a L2Character : 0 (don't remember it)</li>
-	 * <li>object is a L2PlayableInstance : 1500</li>
+	 * <li>object is a L2Playable : 1500</li>
 	 * <li>others : 500</li>
 	 * <ul>
 	 * @param object The Object to add to _knownObject
@@ -662,7 +662,7 @@ public class L2Npc extends L2Character
 	 * <ul>
 	 * <li>object is not a L2Character : 0 (don't remember it)</li>
 	 * <li>object is a L2FolkInstance : 0 (don't remember it)</li>
-	 * <li>object is a L2PlayableInstance : 3000</li>
+	 * <li>object is a L2Playable : 3000</li>
 	 * <li>others : 1000</li>
 	 * </ul>
 	 * @param object The Object to remove from _knownObject

+ 11 - 26
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Playable.java

@@ -27,7 +27,8 @@ import com.l2jserver.gameserver.model.quest.QuestState;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 
 /**
- * This class represents all Playable characters in the world. L2PlayableInstance:
+ * This class represents all Playable characters in the world.<br>
+ * L2Playable:
  * <ul>
  * <li>L2PcInstance</li>
  * <li>L2Summon</li>
@@ -38,13 +39,13 @@ public abstract class L2Playable extends L2Character
 	private L2Character _lockedTarget = null;
 	
 	/**
-	 * Constructor of L2PlayableInstance (use L2Character constructor).<br>
+	 * Constructor of L2Playable.<br>
 	 * <B><U> Actions</U> :</B>
 	 * <ul>
-	 * <li>Call the L2Character constructor to create an empty _skills slot and link copy basic Calculator set to this L2PlayableInstance</li>
+	 * <li>Call the L2Character constructor to create an empty _skills slot and link copy basic Calculator set to this L2Playable</li>
 	 * </ul>
 	 * @param objectId Identifier of the object to initialized
-	 * @param template The L2CharTemplate to apply to the L2PlayableInstance
+	 * @param template The L2CharTemplate to apply to the L2Playable
 	 */
 	public L2Playable(int objectId, L2CharTemplate template)
 	{
@@ -134,7 +135,7 @@ public abstract class L2Playable extends L2Character
 				stopNoblesseBlessing(null);
 			}
 		}
-		// Same thing if the Character isn't a Noblesse Blessed L2PlayableInstance
+		// Same thing if the Character isn't a Noblesse Blessed L2Playable
 		else if (isNoblesseBlessed())
 		{
 			stopNoblesseBlessing(null);
@@ -195,42 +196,26 @@ public abstract class L2Playable extends L2Character
 		}
 		if (!target.isPlayable())
 		{
-			return false; // Target is not a L2PlayableInstance
-		}
-		
-		L2PcInstance player = null;
-		if (this instanceof L2PcInstance)
-		{
-			player = (L2PcInstance) this;
-		}
-		else if (isSummon())
-		{
-			player = ((L2Summon) this).getOwner();
+			return false; // Target is not a L2Playable
 		}
 		
+		final L2PcInstance player = getActingPlayer();
 		if (player == null)
 		{
 			return false; // Active player is null
 		}
+		
 		if (player.getKarma() != 0)
 		{
 			return false; // Active player has karma
 		}
 		
-		L2PcInstance targetPlayer = null;
-		if (target instanceof L2PcInstance)
-		{
-			targetPlayer = (L2PcInstance) target;
-		}
-		else if (target instanceof L2Summon)
-		{
-			targetPlayer = ((L2Summon) target).getOwner();
-		}
-		
+		final L2PcInstance targetPlayer = target.getActingPlayer();
 		if (targetPlayer == null)
 		{
 			return false; // Target player is null
 		}
+		
 		if (targetPlayer == this)
 		{
 			return false; // Target player is self

+ 19 - 19
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2Effect.java

@@ -42,10 +42,6 @@ import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
 import com.l2jserver.gameserver.network.serverpackets.PartySpelled;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 
-/**
- * This class ...
- * @version $Revision: 1.1.2.1.2.12 $ $Date: 2005/04/11 10:06:07 $
- */
 public abstract class L2Effect implements IChanceSkillTrigger
 {
 	protected static final Logger _log = Logger.getLogger(L2Effect.class.getName());
@@ -183,17 +179,15 @@ public abstract class L2Effect implements IChanceSkillTrigger
 		_effectPower = template.effectPower;
 		_effectSkillType = template.effectType;
 		
-		/*
-		 * Commented out by DrHouse: scheduleEffect can call onStart before effect is completly initialized on constructor (child classes constructor)
-		 */
+		// Commented out by DrHouse:
+		// scheduleEffect can call onStart before effect is completely initialized on constructor (child classes constructor)
 		// scheduleEffect();
 	}
 	
 	/**
 	 * Special constructor to "steal" buffs. Must be implemented on every child class that can be stolen.<br>
-	 * <br>
-	 * <font color="FF0000"><b>WARNING: scheduleEffect nolonger inside constructor</b></font> <br>
-	 * So you must call it explicitly
+	 * <font color="FF0000"><b>WARNING: scheduleEffect no longer inside constructor</b></font><br>
+	 * So you must call it explicitly.
 	 * @param env
 	 * @param effect
 	 */
@@ -218,9 +212,8 @@ public abstract class L2Effect implements IChanceSkillTrigger
 		_periodFirstTime = effect.getTime();
 		_icon = _template.icon;
 		
-		/*
-		 * Commented out by DrHouse: scheduleEffect can call onStart before effect is completly initialized on constructor (child classes constructor)
-		 */
+		// Commented out by DrHouse:
+		// scheduleEffect can call onStart before effect is completly initialized on constructor (child classes constructor)
 		// scheduleEffect();
 	}
 	
@@ -376,7 +369,12 @@ public abstract class L2Effect implements IChanceSkillTrigger
 	}
 	
 	/**
-	 * Stop the L2Effect task and send Server->Client update packet. <B><U> Actions</U> :</B> <li>Cancel the effect in the the abnormal effect map of the L2Character</li> <li>Stop the task of the L2Effect, remove it and update client magic icon</li>
+	 * Stop the L2Effect task and send Server->Client update packet.<br>
+	 * <B><U>Actions</U>:</B>
+	 * <ul>
+	 * <li>Cancel the effect in the the abnormal effect map of the L2Character</li>
+	 * <li>Stop the task of the L2Effect, remove it and update client magic icon</li>
+	 * </ul>
 	 */
 	public final void exit()
 	{
@@ -425,8 +423,8 @@ public abstract class L2Effect implements IChanceSkillTrigger
 	public abstract L2EffectType getEffectType();
 	
 	/**
-	 * Notify started
-	 * @return
+	 * Notify started.
+	 * @return {@code true} if all the start conditions are meet, {@code false} otherwise
 	 */
 	public boolean onStart()
 	{
@@ -498,14 +496,16 @@ public abstract class L2Effect implements IChanceSkillTrigger
 				{
 					_count--;
 					if (getInUse())
-					{ // effect has to be in use
-						if (onActionTime() && _startConditionsCorrect && (_count > 0))
+					{
+						// effect has to be in use
+						if (onActionTime() && _startConditionsCorrect && (_count >= 0))
 						{
 							return; // false causes effect to finish right away
 						}
 					}
 					else if (_count > 0)
-					{ // do not finish it yet, in case reactivated
+					{
+						// do not finish it yet, in case reactivated
 						return;
 					}
 				}

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

@@ -81,5 +81,7 @@ public enum L2EffectType
 	BLOCK_RESURRECTION,
 	DAMAGE_TRANSFER,
 	RESTORATION_RANDOM,
-	HARVESTING
+	HARVESTING,
+	UNSUMMON_AGATHION,
+	SUMMON_AGATHION
 }

+ 11 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/L2Skill.java

@@ -250,6 +250,8 @@ public abstract class L2Skill implements IChanceSkillTrigger
 	private final int _maxTargets;
 	private final boolean _isStaticHeal;
 	
+	protected int _npcId = 0;
+	
 	protected L2Skill(StatsSet set)
 	{
 		_id = set.getInteger("skill_id");
@@ -526,6 +528,7 @@ public abstract class L2Skill implements IChanceSkillTrigger
 		}
 		_maxTargets = set.getInteger("maxTargets", -1);
 		_isStaticHeal = set.getBool("isStaticHeal", false);
+		_npcId = set.getInteger("npcId", 0);
 	}
 	
 	public abstract void useSkill(L2Character caster, L2Object[] targets);
@@ -2161,4 +2164,12 @@ public abstract class L2Skill implements IChanceSkillTrigger
 	{
 		return _isStaticHeal;
 	}
+	
+	/**
+	 * @return the _npcId
+	 */
+	public int getNpcId()
+	{
+		return _npcId;
+	}
 }

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

@@ -17,7 +17,6 @@ package com.l2jserver.gameserver.model.skills;
 import java.lang.reflect.Constructor;
 
 import com.l2jserver.gameserver.model.StatsSet;
-import com.l2jserver.gameserver.model.skills.l2skills.L2SkillAgathion;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillAppearance;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillChangeWeapon;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillChargeDmg;
@@ -123,7 +122,6 @@ public enum L2SkillType
 	DELUXE_KEY_UNLOCK,
 	SOW,
 	GET_PLAYER,
-	AGATHION(L2SkillAgathion.class),
 	MOUNT(L2SkillMount.class),
 	INSTANT_JUMP,
 	DETECTION,

+ 0 - 53
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillAgathion.java

@@ -1,53 +0,0 @@
-/*
- * 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 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;
-
-public class L2SkillAgathion extends L2Skill
-{
-	private final int _npcId;
-	
-	public L2SkillAgathion(StatsSet set)
-	{
-		super(set);
-		_npcId = set.getInteger("npcId", 0);
-	}
-	
-	@Override
-	public void useSkill(L2Character caster, L2Object[] targets)
-	{
-		if (caster.isAlikeDead() || !caster.isPlayer())
-		{
-			return;
-		}
-		
-		L2PcInstance activeChar = caster.getActingPlayer();
-		
-		if (activeChar.isInOlympiadMode())
-		{
-			activeChar.sendPacket(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
-			return;
-		}
-		
-		activeChar.setAgathionId(_npcId);
-		activeChar.broadcastUserInfo();
-	}
-}

+ 2 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillChangeWeapon.java

@@ -53,15 +53,13 @@ public class L2SkillChangeWeapon extends L2Skill
 			return;
 		}
 		
-		L2PcInstance player = caster.getActingPlayer();
-		
+		final L2PcInstance player = caster.getActingPlayer();
 		if (player.isEnchanting())
 		{
 			return;
 		}
 		
-		L2Weapon weaponItem = player.getActiveWeaponItem();
-		
+		final L2Weapon weaponItem = player.getActiveWeaponItem();
 		if (weaponItem == null)
 		{
 			return;

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

@@ -35,7 +35,6 @@ public class L2SkillSummon extends L2Skill
 {
 	public static final int SKILL_CUBIC_MASTERY = 143;
 	
-	private final int _npcId;
 	private final float _expPenalty;
 	private final boolean _isCubic;
 	
@@ -72,7 +71,6 @@ public class L2SkillSummon extends L2Skill
 	{
 		super(set);
 		
-		_npcId = set.getInteger("npcId", 0); // default for undescribed skills
 		_expPenalty = set.getFloat("expPenalty", 0.f);
 		_isCubic = set.getBool("isCubic", false);
 		
@@ -349,11 +347,6 @@ public class L2SkillSummon extends L2Skill
 		return _itemConsumeTime;
 	}
 	
-	public final int getNpcId()
-	{
-		return _npcId;
-	}
-	
 	public final float getExpPenalty()
 	{
 		return _expPenalty;