Quellcode durchsuchen

Small adjustment for SkillSuccess Formula.
ConfuseMobOnly was ignoring SkillChance and had 100% Landrate on Raids ..

- 100% Resist should be 100% :-)

nBd vor 17 Jahren
Ursprung
Commit
640e285ba2

+ 31 - 10
L2_GameServer/java/net/sf/l2j/gameserver/handler/skillhandlers/Disablers.java

@@ -263,7 +263,7 @@ public class Disablers implements ISkillHandler
                     }
                     else
                     {
-                        if (activeChar instanceof L2PcInstance)
+                    	if (activeChar instanceof L2PcInstance)
                         {
                             SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                             sm.addCharName(target);
@@ -274,19 +274,40 @@ public class Disablers implements ISkillHandler
                     break;
                 }
                 case CONFUSE_MOB_ONLY:
-                {
-                    // do nothing if not on mob
-                    if (target instanceof L2Attackable)
-                    	skill.getEffects(activeChar, target);
-                    else
-                    	activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
-                    break;
-                }
+				{
+					// do nothing if not on mob
+					if (target instanceof L2Attackable)
+					{
+						if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
+						{
+							L2Effect[] effects = target.getAllEffects();
+							for (L2Effect e : effects)
+							{
+								if (e.getSkill().getSkillType() == type)
+									e.exit();
+							}
+							skill.getEffects(activeChar, target);
+						}
+						else
+						{
+							if (activeChar instanceof L2PcInstance)
+							{
+								SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
+								sm.addCharName(target);
+								sm.addSkillName(skill);
+								activeChar.sendPacket(sm);
+							}
+						}
+					}
+					else
+						activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
+					break;
+				}
                 case AGGDAMAGE:
                 {
                     if (target instanceof L2Attackable)
                         target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) ((150*skill.getPower())/(target.getLevel()+7)));
-                    //TODO [Nemesiss] should this have 100% chance?
+                    // TODO [Nemesiss] should this have 100% chance?
                     skill.getEffects(activeChar, target);
                     break;
                 }

+ 17 - 10
L2_GameServer/java/net/sf/l2j/gameserver/skills/Formulas.java

@@ -1822,6 +1822,7 @@ public final class Formulas
 						multiplier = target.calcStat(Stats.DERANGEMENT_VULN, multiplier, target, null);
 						break;
 					case CONFUSION:
+					case CONFUSE_MOB_ONLY:
 						multiplier = target.calcStat(Stats.CONFUSION_VULN, multiplier, target, null);
 						break;
 					case DEBUFF:
@@ -1857,6 +1858,7 @@ public final class Formulas
 			case FEAR:
 			case BETRAY:
 			case CONFUSION:
+			case CONFUSE_MOB_ONLY:
 			case AGGREDUCE_CHAR:
 			case PARALYZE:
 				multiplier = 2 - Math.sqrt(MENbonus[target.getMEN()]);
@@ -1869,8 +1871,7 @@ public final class Formulas
 		return multiplier;
 	}
 
-	public boolean calcSkillSuccess(L2Character attacker, L2Character target, L2Skill skill, boolean ss,
-									boolean sps, boolean bss)
+	public boolean calcSkillSuccess(L2Character attacker, L2Character target, L2Skill skill, boolean ss, boolean sps, boolean bss)
 	{
 		SkillType type = skill.getSkillType();
 
@@ -1909,8 +1910,8 @@ public final class Formulas
 
 		// TODO: Temporary fix for NPC skills with MagicLevel not set
 		// int lvlmodifier = (skill.getMagicLevel() - target.getLevel()) * lvlDepend;
-		int lvlmodifier = ((skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel()) - target.getLevel())
-			* lvlDepend;
+		int lvlmodifier = ((skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel()) - target.getLevel()) * lvlDepend;
+		
 		double statmodifier = calcSkillStatModifier(type, target);
 		double resmodifier = calcSkillVulnerability(target, skill);
 
@@ -1919,20 +1920,26 @@ public final class Formulas
 		else if (sps) ssmodifier = 150;
 		else if (ss) ssmodifier = 150;
 
-		int rate = (int) ((value * statmodifier + lvlmodifier) * resmodifier);
-		if (skill.isMagic())
-			rate = (int) (rate * Math.pow((double) attacker.getMAtk(target, skill)
-				/ target.getMDef(attacker, skill), 0.2));
+		// Calculate BaseRate.
+		int rate = (int) ((value * statmodifier + lvlmodifier));
 
-		if (rate > 99) rate = 99;
-		else if (rate < 1) rate = 1;
+		// Add Matk/Mdef Bonus
+		if (skill.isMagic())
+			rate = (int) (rate * Math.pow((double) attacker.getMAtk(target, skill) / target.getMDef(attacker, skill), 0.2));
 
+		// Add Bonus for Sps/SS
 		if (ssmodifier != 100)
 		{
 			if (rate > 10000 / (100 + ssmodifier)) rate = 100 - (100 - rate) * 100 / ssmodifier;
 			else rate = rate * ssmodifier / 100;
 		}
 
+		if (rate > 99) rate = 99;
+		else if (rate < 1) rate = 1;
+
+		//Finaly apply resists.
+		rate *= resmodifier;
+
 		if (Config.DEVELOPER)
 			_log.info(skill.getName()
 				+ ": "