Skip to content
Snippets Groups Projects
Commit 3860c804 authored by Adry85's avatar Adry85 Committed by Zoey76
Browse files

Minor improvements on effecthandlers.

parent f04c0d03
No related branches found
No related tags found
No related merge requests found
...@@ -74,9 +74,9 @@ public final class Backstab extends AbstractEffect ...@@ -74,9 +74,9 @@ public final class Backstab extends AbstractEffect
return; return;
} }
L2Character target = info.getEffected(); final L2Character target = info.getEffected();
L2Character activeChar = info.getEffector(); final L2Character activeChar = info.getEffector();
Skill skill = info.getSkill(); final Skill skill = info.getSkill();
boolean ss = skill.useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS); boolean ss = skill.useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS);
byte shld = Formulas.calcShldUse(activeChar, target, skill); byte shld = Formulas.calcShldUse(activeChar, target, skill);
double damage = Formulas.calcBackstabDamage(activeChar, target, skill, shld, ss, _power); double damage = Formulas.calcBackstabDamage(activeChar, target, skill, shld, ss, _power);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package handlers.effecthandlers; package handlers.effecthandlers;
import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.conditions.Condition; import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect; import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.BuffInfo;
...@@ -53,22 +54,23 @@ public final class CpDamPercent extends AbstractEffect ...@@ -53,22 +54,23 @@ public final class CpDamPercent extends AbstractEffect
return; return;
} }
if (info.getEffected().isPlayer() && info.getEffected().getActingPlayer().isFakeDeath()) final L2Character target = info.getEffected();
if (target.isPlayer() && target.getActingPlayer().isFakeDeath())
{ {
info.getEffected().stopFakeDeath(true); target.stopFakeDeath(true);
} }
int damage = (int) ((info.getEffected().getCurrentCp() * _power) / 100); double damage = (target.getCurrentCp() * _power) / 100;
// Manage attack or cast break of the target (calculating rate, sending message) // Manage attack or cast break of the target (calculating rate, sending message)
if (!info.getEffected().isRaid() && Formulas.calcAtkBreak(info.getEffected(), damage)) if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
{ {
info.getEffected().breakAttack(); target.breakAttack();
info.getEffected().breakCast(); target.breakCast();
} }
if (damage > 0) if (damage > 0)
{ {
info.getEffected().setCurrentCp(info.getEffected().getCurrentCp() - damage); target.setCurrentCp(target.getCurrentCp() - damage);
} }
} }
} }
\ No newline at end of file
...@@ -27,6 +27,7 @@ import com.l2jserver.gameserver.model.effects.L2EffectType; ...@@ -27,6 +27,7 @@ import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.CrystalType; import com.l2jserver.gameserver.model.items.type.CrystalType;
import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.stats.Formulas; import com.l2jserver.gameserver.model.stats.Formulas;
import com.l2jserver.gameserver.model.stats.Stats; import com.l2jserver.gameserver.model.stats.Stats;
import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.gameserver.network.SystemMessageId;
...@@ -62,8 +63,9 @@ public final class Heal extends AbstractEffect ...@@ -62,8 +63,9 @@ public final class Heal extends AbstractEffect
@Override @Override
public void onStart(BuffInfo info) public void onStart(BuffInfo info)
{ {
L2Character target = info.getEffected(); final L2Character target = info.getEffected();
L2Character activeChar = info.getEffector(); final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
if ((target == null) || target.isDead() || target.isDoor() || target.isInvul()) if ((target == null) || target.isDead() || target.isDoor() || target.isInvul())
{ {
return; return;
...@@ -72,18 +74,18 @@ public final class Heal extends AbstractEffect ...@@ -72,18 +74,18 @@ public final class Heal extends AbstractEffect
double amount = _power; double amount = _power;
double staticShotBonus = 0; double staticShotBonus = 0;
int mAtkMul = 1; int mAtkMul = 1;
boolean sps = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS); boolean sps = skill.isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
boolean bss = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS); boolean bss = skill.isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
if (((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())) || activeChar.isSummon()) if (((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())) || activeChar.isSummon())
{ {
staticShotBonus = info.getSkill().getMpConsume2(); // static bonus for spiritshots staticShotBonus = skill.getMpConsume2(); // static bonus for spiritshots
mAtkMul = bss ? 4 : 2; mAtkMul = bss ? 4 : 2;
staticShotBonus *= bss ? 2.4 : 1.0; staticShotBonus *= bss ? 2.4 : 1.0;
} }
else if ((sps || bss) && activeChar.isNpc()) else if ((sps || bss) && activeChar.isNpc())
{ {
staticShotBonus = 2.4 * info.getSkill().getMpConsume2(); // always blessed spiritshots staticShotBonus = 2.4 * skill.getMpConsume2(); // always blessed spiritshots
mAtkMul = 4; mAtkMul = 4;
} }
else else
...@@ -99,12 +101,12 @@ public final class Heal extends AbstractEffect ...@@ -99,12 +101,12 @@ public final class Heal extends AbstractEffect
mAtkMul = bss ? mAtkMul * 4 : mAtkMul + 1; mAtkMul = bss ? mAtkMul * 4 : mAtkMul + 1;
} }
if (!info.getSkill().isStatic()) if (!skill.isStatic())
{ {
amount += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null)); amount += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null));
amount = target.calcStat(Stats.HEAL_EFFECT, amount, null, null); amount = target.calcStat(Stats.HEAL_EFFECT, amount, null, null);
// Heal critic, since CT2.3 Gracia Final // Heal critic, since CT2.3 Gracia Final
if (info.getSkill().isMagic() && Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill()))) if (skill.isMagic() && Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill)))
{ {
amount *= 3; amount *= 3;
} }
...@@ -119,7 +121,7 @@ public final class Heal extends AbstractEffect ...@@ -119,7 +121,7 @@ public final class Heal extends AbstractEffect
if (target.isPlayer()) if (target.isPlayer())
{ {
if (info.getSkill().getId() == 4051) if (skill.getId() == 4051)
{ {
target.sendPacket(SystemMessageId.REJUVENATING_HP); target.sendPacket(SystemMessageId.REJUVENATING_HP);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package handlers.effecthandlers; package handlers.effecthandlers;
import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.conditions.Condition; import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect; import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.L2EffectType; import com.l2jserver.gameserver.model.effects.L2EffectType;
...@@ -61,14 +62,16 @@ public final class HpByLevel extends AbstractEffect ...@@ -61,14 +62,16 @@ public final class HpByLevel extends AbstractEffect
return; return;
} }
final L2Character activeChar = info.getEffector();
// Calculation // Calculation
final double abs = _power; final double abs = _power;
final double absorb = ((info.getEffector().getCurrentHp() + abs) > info.getEffector().getMaxHp() ? info.getEffector().getMaxHp() : (info.getEffector().getCurrentHp() + abs)); final double absorb = ((activeChar.getCurrentHp() + abs) > activeChar.getMaxHp() ? activeChar.getMaxHp() : (activeChar.getCurrentHp() + abs));
final int restored = (int) (absorb - info.getEffector().getCurrentHp()); final int restored = (int) (absorb - activeChar.getCurrentHp());
info.getEffector().setCurrentHp(absorb); activeChar.setCurrentHp(absorb);
// System message // System message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_RESTORED); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_RESTORED);
sm.addInt(restored); sm.addInt(restored);
info.getEffector().sendPacket(sm); activeChar.sendPacket(sm);
} }
} }
...@@ -25,6 +25,7 @@ import com.l2jserver.gameserver.model.conditions.Condition; ...@@ -25,6 +25,7 @@ import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect; import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.L2EffectType; import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.stats.Formulas; import com.l2jserver.gameserver.model.stats.Formulas;
/** /**
...@@ -59,20 +60,21 @@ public final class HpDrain extends AbstractEffect ...@@ -59,20 +60,21 @@ public final class HpDrain extends AbstractEffect
@Override @Override
public void onStart(BuffInfo info) public void onStart(BuffInfo info)
{ {
L2Character target = info.getEffected(); final L2Character target = info.getEffected();
L2Character activeChar = info.getEffector(); final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
// TODO: Unhardcode Cubic Skill to avoid double damage // TODO: Unhardcode Cubic Skill to avoid double damage
if (activeChar.isAlikeDead() || (info.getSkill().getId() == 4050)) if (activeChar.isAlikeDead() || (skill.getId() == 4050))
{ {
return; return;
} }
boolean sps = info.getSkill().useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS); boolean sps = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
boolean bss = info.getSkill().useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS); boolean bss = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill())); boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill));
byte shld = Formulas.calcShldUse(activeChar, target, info.getSkill()); byte shld = Formulas.calcShldUse(activeChar, target, skill);
double damage = Formulas.calcMagicDam(activeChar, target, info.getSkill(), shld, sps, bss, mcrit, _power); double damage = Formulas.calcMagicDam(activeChar, target, skill, shld, sps, bss, mcrit, _power);
double drain = 0; double drain = 0;
double cp = target.getCurrentCp(); double cp = target.getCurrentCp();
...@@ -104,8 +106,8 @@ public final class HpDrain extends AbstractEffect ...@@ -104,8 +106,8 @@ public final class HpDrain extends AbstractEffect
target.breakCast(); target.breakCast();
} }
activeChar.sendDamageMessage(target, (int) damage, mcrit, false, false); activeChar.sendDamageMessage(target, (int) damage, mcrit, false, false);
target.reduceCurrentHp(damage, activeChar, info.getSkill()); target.reduceCurrentHp(damage, activeChar, skill);
target.notifyDamageReceived(damage, activeChar, info.getSkill(), mcrit, false, false); target.notifyDamageReceived(damage, activeChar, skill, mcrit, false, false);
} }
} }
} }
\ No newline at end of file
...@@ -60,15 +60,14 @@ public final class MagicalAttackByAbnormal extends AbstractEffect ...@@ -60,15 +60,14 @@ public final class MagicalAttackByAbnormal extends AbstractEffect
@Override @Override
public void onStart(BuffInfo info) public void onStart(BuffInfo info)
{ {
final L2Character target = info.getEffected(); if (info.getEffector().isAlikeDead())
final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
if (activeChar.isAlikeDead())
{ {
return; return;
} }
final L2Character target = info.getEffected();
final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
if (target.isPlayer() && target.getActingPlayer().isFakeDeath()) if (target.isPlayer() && target.getActingPlayer().isFakeDeath())
{ {
target.stopFakeDeath(true); target.stopFakeDeath(true);
......
...@@ -25,6 +25,7 @@ import com.l2jserver.gameserver.model.conditions.Condition; ...@@ -25,6 +25,7 @@ import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect; import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.L2EffectType; import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.stats.Formulas; import com.l2jserver.gameserver.model.stats.Formulas;
import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage; import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
...@@ -84,19 +85,20 @@ public final class MagicalAttackMp extends AbstractEffect ...@@ -84,19 +85,20 @@ public final class MagicalAttackMp extends AbstractEffect
@Override @Override
public void onStart(BuffInfo info) public void onStart(BuffInfo info)
{ {
L2Character target = info.getEffected(); if (info.getEffector().isAlikeDead())
L2Character activeChar = info.getEffector();
if (activeChar.isAlikeDead())
{ {
return; return;
} }
boolean sps = info.getSkill().useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS); final L2Character target = info.getEffected();
boolean bss = info.getSkill().useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS); final L2Character activeChar = info.getEffector();
final byte shld = Formulas.calcShldUse(activeChar, target, info.getSkill()); final Skill skill = info.getSkill();
final boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill()));
double damage = Formulas.calcManaDam(activeChar, target, info.getSkill(), shld, sps, bss, mcrit, _power); boolean sps = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
boolean bss = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
final byte shld = Formulas.calcShldUse(activeChar, target, skill);
final boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, skill));
double damage = Formulas.calcManaDam(activeChar, target, skill, shld, sps, bss, mcrit, _power);
double mp = (damage > target.getCurrentMp() ? target.getCurrentMp() : damage); double mp = (damage > target.getCurrentMp() ? target.getCurrentMp() : damage);
if (damage > 0) if (damage > 0)
......
...@@ -60,15 +60,15 @@ public final class MagicalSoulAttack extends AbstractEffect ...@@ -60,15 +60,15 @@ public final class MagicalSoulAttack extends AbstractEffect
@Override @Override
public void onStart(BuffInfo info) public void onStart(BuffInfo info)
{ {
final L2Character target = info.getEffected(); if (info.getEffector().isAlikeDead())
final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
if (activeChar.isAlikeDead())
{ {
return; return;
} }
final L2Character target = info.getEffected();
final L2Character activeChar = info.getEffector();
final Skill skill = info.getSkill();
if (target.isPlayer() && target.getActingPlayer().isFakeDeath()) if (target.isPlayer() && target.getActingPlayer().isFakeDeath())
{ {
target.stopFakeDeath(true); target.stopFakeDeath(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment