Browse Source

BETA: Shot checks on skillhandlers and effecthandlers cleanup.

Nik 13 years ago
parent
commit
d79c0fdff5

+ 25 - 44
L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Heal.java

@@ -15,8 +15,6 @@
 package handlers.effecthandlers;
 
 import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.effects.EffectTemplate;
 import com.l2jserver.gameserver.model.effects.L2Effect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
@@ -54,28 +52,35 @@ public class Heal extends L2Effect
 			return false;
 		
 		double amount = calc();
-		final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
 		double staticShotBonus = 0;
 		int mAtkMul = 1;
+		boolean sps = activeChar.isSpiritshotCharged(getSkill());
+		boolean bss = activeChar.isBlessedSpiritshotCharged(getSkill());
 		
-		if (weaponInst != null && weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
+		if ((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass()) || activeChar.isSummon())
 		{
-			if (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())
+			staticShotBonus = getSkill().getMpConsume(); // static bonus for spiritshots
+			
+			if (bss)
 			{
-				staticShotBonus = getSkill().getMpConsume(); // static bonus for spiritshots
-				
-				if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-				{
-					mAtkMul = 4;
-					staticShotBonus *= 2.4; // static bonus for blessed spiritshots
-				}
-				else
-					mAtkMul = 2;
+				mAtkMul = 4;
+				staticShotBonus *= 2.4; // static bonus for blessed spiritshots
 			}
 			else
+				mAtkMul = 2;
+		}
+		else if ((sps || bss) && activeChar.isNpc())
+		{
+			staticShotBonus = 2.4 * getSkill().getMpConsume(); // always blessed spiritshots
+			mAtkMul = 4;
+		}
+		else
+		{
+			// no static bonus
+			// grade dynamic bonus
+			final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
+			if (weaponInst != null)
 			{
-				// no static bonus
-				// grade dynamic bonus
 				switch (weaponInst.getItem().getItemGrade())
 				{
 					case L2Item.CRYSTAL_S84:
@@ -85,36 +90,12 @@ public class Heal extends L2Effect
 						mAtkMul = 2;
 						break;
 				}
-				// shot dynamic bonus
-				if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-					mAtkMul *= 4; // 16x/8x/4x s84/s80/other
-				else
-					mAtkMul += 1; // 5x/3x/1x s84/s80/other
-			}
-			
-			weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-		}
-		// If there is no weapon equipped, check for an active summon.
-		else if (activeChar.isSummon() && ((L2Summon) activeChar).getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
-		{
-			staticShotBonus = getSkill().getMpConsume(); // static bonus for spiritshots
-			
-			if (((L2Summon) activeChar).getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-			{
-				staticShotBonus *= 2.4; // static bonus for blessed spiritshots
-				mAtkMul = 4;
 			}
+			// shot dynamic bonus
+			if (bss)
+				mAtkMul *= 4; // 16x/8x/4x s84/s80/other
 			else
-				mAtkMul = 2;
-			
-			((L2Summon) activeChar).setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-		}
-		else if (activeChar.isNpc() && ((L2Npc) activeChar)._spiritshotcharged)
-		{
-			staticShotBonus = 2.4 * getSkill().getMpConsume(); // always blessed spiritshots
-			mAtkMul = 4;
-			
-			((L2Npc) activeChar)._spiritshotcharged = false;
+				mAtkMul += 1; // 5x/3x/1x s84/s80/other
 		}
 		
 		if (!getSkill().isStaticHeal())

+ 3 - 20
L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/SignetMDam.java

@@ -30,7 +30,6 @@ import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.gameserver.model.effects.EffectTemplate;
 import com.l2jserver.gameserver.model.effects.L2Effect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
-import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.skills.l2skills.L2SkillSignetCasttime;
 import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
 import com.l2jserver.gameserver.model.stats.Env;
@@ -100,24 +99,8 @@ public class SignetMDam extends L2Effect
 		
 		L2PcInstance caster = getEffector().getActingPlayer();
 		
-		boolean ss = false;
-		boolean bss = false;
-		
-		L2ItemInstance weaponInst = caster.getActiveWeaponInstance();
-		if (weaponInst != null)
-		{
-			switch (weaponInst.getChargedSpiritshot())
-			{
-				case L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT:
-					weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-					bss = true;
-					break;
-				case L2ItemInstance.CHARGED_SPIRITSHOT:
-					weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-					ss = true;
-					break;
-			}
-		}
+		boolean sps = caster.isSpiritshotCharged(getSkill());
+		boolean bss = caster.isBlessedSpiritshotCharged(getSkill());
 		
 		FastList<L2Character> targets = new FastList<>();
 		
@@ -158,7 +141,7 @@ public class SignetMDam extends L2Effect
 			{
 				boolean mcrit = Formulas.calcMCrit(caster.getMCriticalHit(target, getSkill()));
 				byte shld = Formulas.calcShldUse(caster, target, getSkill());
-				int mdam = (int) Formulas.calcMagicDam(caster, target, getSkill(), shld, ss, bss, mcrit);
+				int mdam = (int) Formulas.calcMagicDam(caster, target, getSkill(), shld, sps, bss, mcrit);
 				
 				if (target.isSummon())
 					target.broadcastStatusUpdate();

+ 4 - 61
L2J_DataPack_BETA/dist/game/data/scripts/handlers/skillhandlers/Continuous.java

@@ -21,12 +21,10 @@ import com.l2jserver.gameserver.handler.ISkillHandler;
 import com.l2jserver.gameserver.instancemanager.DuelManager;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.instance.L2ClanHallManagerInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.effects.L2Effect;
-import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 import com.l2jserver.gameserver.model.skills.L2SkillType;
 import com.l2jserver.gameserver.model.stats.Env;
@@ -73,15 +71,14 @@ public class Continuous implements ISkillHandler
 				skill = sk;
 		}
 		
+		boolean ss = activeChar.isSoulshotCharged(skill);
+		boolean sps = activeChar.isSpiritshotCharged(skill);
+		boolean bss = activeChar.isBlessedSpiritshotCharged(skill);
+		
 		for (L2Character target: (L2Character[]) targets)
 		{
-			boolean ss = false;
-			boolean sps = false;
-			boolean bss = false;
 			byte shld = 0;
 			
-			L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
-			
 			if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
 				target = activeChar;
 			
@@ -116,60 +113,6 @@ public class Continuous implements ISkillHandler
 			
 			if (skill.isOffensive() || skill.isDebuff())
 			{
-				if (weaponInst != null)
-				{
-					if (skill.isMagic())
-					{
-						if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-						{
-							bss = true;
-							if (skill.getId() != 1020) // vitalize
-								weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-						}
-						else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-						{
-							sps = true;
-							if (skill.getId() != 1020) // vitalize
-								weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-						}
-					}
-					else if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
-					{
-						ss = true;
-						if (skill.getId() != 1020) // vitalize
-							weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
-					}
-				}
-				else if (activeChar.isSummon())
-				{
-					L2Summon activeSummon = (L2Summon) activeChar;
-					if (skill.isMagic())
-					{
-						if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-						{
-							bss = true;
-							activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-						}
-						else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-						{
-							sps = true;
-							activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-						}
-					}
-					else if (activeSummon.getChargedSoulShot() == L2ItemInstance.CHARGED_SOULSHOT)
-					{
-						ss = true;
-						activeSummon.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
-					}
-				}
-				else if (activeChar.isNpc())
-				{
-					ss = ((L2Npc) activeChar)._soulshotcharged;
-					((L2Npc) activeChar)._soulshotcharged = false;
-					bss = ((L2Npc) activeChar)._spiritshotcharged;
-					((L2Npc) activeChar)._spiritshotcharged = false;
-				}
-				
 				shld = Formulas.calcShldUse(activeChar, target, skill);
 				acted = Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss);
 			}

+ 5 - 51
L2J_DataPack_BETA/dist/game/data/scripts/handlers/skillhandlers/CpDamPercent.java

@@ -17,9 +17,6 @@ package handlers.skillhandlers;
 import com.l2jserver.gameserver.handler.ISkillHandler;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.L2Summon;
-import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 import com.l2jserver.gameserver.model.skills.L2SkillType;
 import com.l2jserver.gameserver.model.stats.Env;
@@ -38,54 +35,9 @@ public class CpDamPercent implements ISkillHandler
 		if (activeChar.isAlikeDead())
 			return;
 		
-		boolean ss = false;
-		boolean sps = false;
-		boolean bss = false;
-		
-		L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
-		
-		if (weaponInst != null)
-		{
-			if (skill.isMagic())
-			{
-				if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-				{
-					bss = true;
-				}
-				else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-				{
-					sps = true;
-				}
-			}
-			else if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
-			{
-				ss = true;
-			}
-		}
-		// If there is no weapon equipped, check for an active summon.
-		else if (activeChar.isSummon())
-		{
-			L2Summon activeSummon = (L2Summon) activeChar;
-			
-			if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-			{
-				bss = true;
-				activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-			}
-			else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-			{
-				ss = true;
-				activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-			}
-		}
-		else if (activeChar.isNpc())
-		{
-			ss = ((L2Npc) activeChar)._soulshotcharged;
-			((L2Npc) activeChar)._soulshotcharged = false;
-			bss = ((L2Npc) activeChar)._spiritshotcharged;
-			((L2Npc) activeChar)._spiritshotcharged = false;
-		}
-		
+		boolean ss = activeChar.isSoulshotCharged(skill);
+		boolean sps = activeChar.isSpiritshotCharged(skill);
+		boolean bss = activeChar.isBlessedSpiritshotCharged(skill);
 		for (L2Character target: (L2Character[]) targets)
 		{
 			if (activeChar.isPlayer() && target.isPlayer() && target.getActingPlayer().isFakeDeath())
@@ -111,6 +63,8 @@ public class CpDamPercent implements ISkillHandler
 			activeChar.sendDamageMessage(target, damage, false, false, false);
 			target.setCurrentCp(target.getCurrentCp() - damage);
 		}
+		
+		activeChar.spsUncharge(skill);
 	}
 	
 	@Override

+ 5 - 55
L2J_DataPack_BETA/dist/game/data/scripts/handlers/skillhandlers/Disablers.java

@@ -25,12 +25,10 @@ import com.l2jserver.gameserver.handler.SkillHandler;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.L2Attackable;
 import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
 import com.l2jserver.gameserver.model.effects.L2Effect;
-import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 import com.l2jserver.gameserver.model.skills.L2SkillType;
 import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
@@ -76,59 +74,9 @@ public class Disablers implements ISkillHandler
 		L2SkillType type = skill.getSkillType();
 		
 		byte shld = 0;
-		boolean ss = false;
-		boolean sps = false;
-		boolean bss = false;
-		
-		L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
-		if (weaponInst != null)
-		{
-			if (skill.isMagic())
-			{
-				if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-				{
-					bss = true;
-					if (skill.getId() != 1020) // vitalize
-						weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-				}
-				else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-				{
-					sps = true;
-					if (skill.getId() != 1020) // vitalize
-						weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-				}
-			}
-			else
-				ss = true;
-		}
-		// If there is no weapon equipped, check for an active summon.
-		else if (activeChar.isSummon())
-		{
-			L2Summon activeSummon = (L2Summon) activeChar;
-			
-			if (skill.isMagic())
-			{
-				if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-				{
-					bss = true;
-					activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-				}
-				else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
-				{
-					sps = true;
-					activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-				}
-			}
-			else
-				ss = true;
-		}
-		else if (activeChar.isNpc())
-		{
-			ss = ((L2Npc) activeChar)._soulshotcharged;
-			((L2Npc) activeChar)._soulshotcharged = false;
-			bss = ((L2Npc) activeChar)._spiritshotcharged;
-			((L2Npc) activeChar)._spiritshotcharged = false;
-		}
+		boolean ss = activeChar.isSoulshotCharged(skill);
+		boolean sps = activeChar.isSpiritshotCharged(skill);
+		boolean bss = activeChar.isBlessedSpiritshotCharged(skill);
 		
 		for (L2Object obj: targets)
 		{
@@ -603,6 +551,8 @@ public class Disablers implements ISkillHandler
 			}
 			skill.getEffectsSelf(activeChar);
 		}
+		
+		activeChar.spsUncharge(skill);
 	} //end void
 	
 	/**

+ 26 - 44
L2J_DataPack_BETA/dist/game/data/scripts/handlers/skillhandlers/Heal.java

@@ -18,8 +18,6 @@ import com.l2jserver.gameserver.handler.ISkillHandler;
 import com.l2jserver.gameserver.handler.SkillHandler;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
 import com.l2jserver.gameserver.model.items.L2Item;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -49,33 +47,40 @@ public class Heal implements ISkillHandler
 			handler.useSkill(activeChar, skill, targets);
 		
 		double power = skill.getPower();
+		boolean sps = activeChar.isSpiritshotCharged(skill);
+		boolean bss = activeChar.isBlessedSpiritshotCharged(skill);
 		
 		switch (skill.getSkillType())
 		{
 			case HEAL_STATIC:
 				break;
 			default:
-				final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
 				double staticShotBonus = 0;
 				int mAtkMul = 1; // mAtk multiplier
-				if (weaponInst != null && weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
+				if ((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass()) || activeChar.isSummon())
 				{
-					if (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())
+					staticShotBonus = skill.getMpConsume(); // static bonus for spiritshots
+					
+					if (bss)
 					{
-						staticShotBonus = skill.getMpConsume(); // static bonus for spiritshots
-						
-						if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-						{
-							mAtkMul = 4;
-							staticShotBonus *= 2.4; // static bonus for blessed spiritshots
-						}
-						else
-							mAtkMul = 2;
+						mAtkMul = 4;
+						staticShotBonus *= 2.4; // static bonus for blessed spiritshots
 					}
 					else
+						mAtkMul = 2;
+				}
+				else if ((sps || bss) && activeChar.isNpc())
+				{
+					staticShotBonus = 2.4 * skill.getMpConsume(); // always blessed spiritshots
+					mAtkMul = 4;
+				}
+				else
+				{
+					// no static bonus
+					// grade dynamic bonus
+					final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
+					if (weaponInst != null)
 					{
-						// no static bonus
-						// grade dynamic bonus
 						switch (weaponInst.getItem().getItemGrade())
 						{
 							case L2Item.CRYSTAL_S84:
@@ -85,39 +90,16 @@ public class Heal implements ISkillHandler
 								mAtkMul = 2;
 								break;
 						}
-						// shot dynamic bonus
-						if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-							mAtkMul *= 4; // 16x/8x/4x s84/s80/other
-						else
-							mAtkMul += 1; // 5x/3x/1x s84/s80/other
-					}
-					
-					weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
-				}
-				// If there is no weapon equipped, check for an active summon.
-				else if (activeChar.isSummon() && ((L2Summon)activeChar).getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
-				{
-					staticShotBonus = skill.getMpConsume(); // static bonus for spiritshots
-					
-					if (((L2Summon)activeChar).getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
-					{
-						staticShotBonus *= 2.4; // static bonus for blessed spiritshots
-						mAtkMul = 4;
 					}
+					// shot dynamic bonus
+					if (bss)
+						mAtkMul *= 4; // 16x/8x/4x s84/s80/other
 					else
-						mAtkMul = 2;
-					
-					((L2Summon)activeChar).setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
-				}
-				else if (activeChar.isNpc() && ((L2Npc)activeChar)._spiritshotcharged)
-				{
-					staticShotBonus = 2.4 * skill.getMpConsume(); // always blessed spiritshots
-					mAtkMul = 4;
-					
-					((L2Npc)activeChar)._spiritshotcharged = false;
+						mAtkMul += 1; // 5x/3x/1x s84/s80/other
 				}
 				
 				power += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null));
+				activeChar.spsUncharge(skill);
 		}
 		
 		double hp;