Переглянути джерело

BETA: Fixed Lethal Formula to match retail, also fixed sysmsgs and improved the code a bit (with the help of Zoey76).

Reported by: _DS_, Decad, Konstantinos
Reviewed by: Zoey76
Tested by: oscard, Konstantinos, JMD
MELERIX 12 роки тому
батько
коміт
dfda53e45b

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

@@ -217,8 +217,8 @@ public abstract class L2Skill implements IChanceSkillTrigger
 	private final boolean _isSevenSigns;
 	
 	private final int _baseCritRate; // percent of success for skill critical hit (especially for PDAM & BLOW - they're not affected by rCrit values or buffs). Default loads -1 for all other skills but 0 to PDAM & BLOW
-	private final int _lethalEffect1; // percent of success for lethal 1st effect (hit cp to 1 or if mob hp to 50%) (only for PDAM skills)
-	private final int _lethalEffect2; // percent of success for lethal 2nd effect (hit cp,hp to 1 or if mob hp to 1) (only for PDAM skills)
+	private final int _halfKillRate;
+	private final int _lethalStrikeRate;
 	private final boolean _directHpDmg; // If true then dmg is being make directly
 	private final boolean _isTriggeredSkill; // If true the skill will take activation buff slot instead of a normal buff slot
 	private final float _sSBoost; // If true skill will have SoulShot boost (power*2)
@@ -477,8 +477,8 @@ public abstract class L2Skill implements IChanceSkillTrigger
 		_isClanSkill = SkillTreesData.getInstance().isClanSkill(_id, _level);
 		
 		_baseCritRate = set.getInteger("baseCritRate", ((_skillType == L2SkillType.PDAM) || (_skillType == L2SkillType.BLOW)) ? 0 : -1);
-		_lethalEffect1 = set.getInteger("lethal1", 0);
-		_lethalEffect2 = set.getInteger("lethal2", 0);
+		_halfKillRate = set.getInteger("halfKillRate", 0);
+		_lethalStrikeRate = set.getInteger("lethalStrikeRate", 0);
 		
 		_directHpDmg = set.getBool("dmgDirectlyToHp", false);
 		_isTriggeredSkill = set.getBool("isTriggeredSkill", false);
@@ -1115,14 +1115,14 @@ public abstract class L2Skill implements IChanceSkillTrigger
 		return _baseCritRate;
 	}
 	
-	public final int getLethalChance1()
+	public final int getHalfKillRate()
 	{
-		return _lethalEffect1;
+		return _halfKillRate;
 	}
 	
-	public final int getLethalChance2()
+	public final int getLethalStrikeRate()
 	{
-		return _lethalEffect2;
+		return _lethalStrikeRate;
 	}
 	
 	public final boolean getDmgDirectlyToHP()

+ 29 - 63
L2J_Server_BETA/java/com/l2jserver/gameserver/model/stats/Formulas.java

@@ -1238,91 +1238,57 @@ public final class Formulas
 	 */
 	public static final double calcLethal(L2Character activeChar, L2Character target, int baseLethal, int magiclvl)
 	{
-		double chance = 0;
-		if (magiclvl > 0)
-		{
-			float delta = ((magiclvl + activeChar.getLevel()) / 2) - 1 - target.getLevel();
-			
-			// delta [-3,infinite)
-			if (delta >= -3)
-			{
-				chance = (baseLethal * ((double) activeChar.getLevel() / target.getLevel()));
-			}
-			// delta [-9, -3[
-			else if ((delta < -3) && (delta >= -9))
-			{
-				// baseLethal
-				// chance = -1 * -----------
-				// (delta / 3)
-				chance = (-3) * (baseLethal / delta);
-			}
-			// delta [-infinite,-9[
-			else
-			{
-				chance = baseLethal / 15.0;
-			}
-		}
-		else
-		{
-			chance = (baseLethal * ((double) activeChar.getLevel() / target.getLevel()));
-		}
-		return 10 * activeChar.calcStat(Stats.LETHAL_RATE, chance, target, null);
+		// Lvl Bonus Modifier.
+		int attackerLvl = magiclvl > 0 ? magiclvl : activeChar.getLevel();
+		double lvlMod = 1 + ((attackerLvl - target.getLevel()) / 100.);
+		double chance = baseLethal * lvlMod;
+		
+		return activeChar.calcStat(Stats.LETHAL_RATE, chance, target, null);
 	}
 	
 	public static final boolean calcLethalHit(L2Character activeChar, L2Character target, L2Skill skill)
 	{
-		if (target.isLethalable() && !target.isInvul())
+		if ((((skill.getLethalStrikeRate() > 0) || (skill.getHalfKillRate() > 0)) && (target.isLethalable() && !target.isInvul())) || (activeChar.isPlayer() && activeChar.getAccessLevel().canGiveDamage()))
 		{
-			// 2nd lethal effect activate (cp,hp to 1 or if target is npc then hp to 1)
-			if ((skill.getLethalChance2() > 0) && (Rnd.get(1000) < calcLethal(activeChar, target, skill.getLethalChance2(), skill.getMagicLevel())))
+			// Lethal Strike
+			if (Rnd.get(100) < calcLethal(activeChar, target, skill.getLethalStrikeRate(), skill.getMagicLevel()))
 			{
-				if (target.isNpc())
+				// for Players CP and HP is set to 1.
+				if (target.isPlayer())
 				{
-					target.reduceCurrentHp(target.getCurrentHp() - 1, activeChar, skill);
+					target.setCurrentCp(1);
+					target.setCurrentHp(1);
+					target.sendPacket(SystemMessageId.LETHAL_STRIKE);
 				}
-				else if (target.isPlayer()) // If is a active player set his HP and CP to 1
+				// for Monsters HP is set to 1.
+				else if (target.isMonster() || target.isSummon())
 				{
-					L2PcInstance player = target.getActingPlayer();
-					if (!player.isInvul())
-					{
-						if (!(activeChar.isPlayer() && (activeChar.isGM() && !activeChar.getAccessLevel().canGiveDamage())))
-						{
-							player.setCurrentHp(1);
-							player.setCurrentCp(1);
-							player.sendPacket(SystemMessageId.LETHAL_STRIKE_SUCCESSFUL);
-						}
-					}
+					target.setCurrentHp(1);
 				}
-				activeChar.sendPacket(SystemMessageId.LETHAL_STRIKE);
+				activeChar.sendPacket(SystemMessageId.LETHAL_STRIKE_SUCCESSFUL);
 			}
-			else if ((skill.getLethalChance1() > 0) && (Rnd.get(1000) < calcLethal(activeChar, target, skill.getLethalChance1(), skill.getMagicLevel())))
+			// Half-Kill
+			else if (Rnd.get(100) < calcLethal(activeChar, target, skill.getHalfKillRate(), skill.getMagicLevel()))
 			{
-				if (target.isMonster())
+				// for Players CP is set to 1.
+				if (target.isPlayer())
 				{
-					target.reduceCurrentHp(target.getCurrentHp() / 2, activeChar, skill);
-					activeChar.sendPacket(SystemMessageId.HALF_KILL);
+					target.setCurrentCp(1);
+					target.sendPacket(SystemMessageId.HALF_KILL);
+					target.sendPacket(SystemMessageId.CP_DISAPPEARS_WHEN_HIT_WITH_A_HALF_KILL_SKILL);
 				}
-				else if (target.isPlayer())
+				// for Monsters HP is set to 50%.
+				else if (target.isMonster() || target.isSummon())
 				{
-					L2PcInstance player = target.getActingPlayer();
-					if (!((activeChar.isPlayer()) && (activeChar.isGM() && !activeChar.getAccessLevel().canGiveDamage())))
-					{
-						player.setCurrentCp(1); // Set CP to 1
-						player.sendPacket(SystemMessageId.CP_DISAPPEARS_WHEN_HIT_WITH_A_HALF_KILL_SKILL);
-						activeChar.sendPacket(SystemMessageId.HALF_KILL);
-					}
+					target.setCurrentHp(target.getCurrentHp() * 0.5);
 				}
-			}
-			else
-			{
-				return false;
+				activeChar.sendPacket(SystemMessageId.HALF_KILL);
 			}
 		}
 		else
 		{
 			return false;
 		}
-		
 		return true;
 	}