Sync with L2jServer HighFive Jul 3rd 2015.

This commit is contained in:
MobiusDev
2015-07-03 21:10:51 +00:00
parent 9c11f00722
commit ac006cde6a
29 changed files with 311 additions and 268 deletions

View File

@@ -685,7 +685,7 @@ public class L2Attackable extends L2Npc
}
/**
* Add damage and hate to the attacker AggroInfo of the L2Attackable _aggroList.
* Adds damage and hate to the attacker aggression list for this character.
* @param attacker The L2Character that gave damages to this L2Attackable
* @param damage The number of damages given by the attacker L2Character
* @param aggro The hate (=damage) given by the attacker L2Character
@@ -697,13 +697,14 @@ public class L2Attackable extends L2Npc
return;
}
final L2PcInstance targetPlayer = attacker.getActingPlayer();
// Get the AggroInfo of the attacker L2Character from the _aggroList of the L2Attackable
final AggroInfo ai = getAggroList().computeIfAbsent(attacker, AggroInfo::new);
ai.addDamage(damage);
// traps does not cause aggro
// Traps does not cause aggro
// making this hack because not possible to determine if damage made by trap
// so just check for triggered trap here
final L2PcInstance targetPlayer = attacker.getActingPlayer();
if ((targetPlayer == null) || (targetPlayer.getTrap() == null) || !targetPlayer.getTrap().isTriggered())
{
ai.addHate(aggro);

View File

@@ -5387,7 +5387,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (newSkill.isPassive())
{
newSkill.applyEffects(this, null, this, false, true, false, 0);
newSkill.applyEffects(this, this, false, true, false, 0);
}
}
return oldSkill;
@@ -6070,8 +6070,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
}
}
// Notify AI
if (skill.isBad() && (skill.getTargetType() != L2TargetType.SELF) && !skill.hasEffectType(L2EffectType.HATE))
if (skill.isBad() && !skill.hasEffectType(L2EffectType.HATE))
{
for (L2Object target : targets)
{
@@ -6080,7 +6081,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
final L2Character creature = (L2Character) target;
if (creature.hasAI())
{
// notify target AI about the attack
// Notify target AI about the attack
creature.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this);
}
}

View File

@@ -33,7 +33,6 @@ import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.tasks.cubics.CubicAction;
import com.l2jserver.gameserver.model.actor.tasks.cubics.CubicDisappear;
@@ -356,7 +355,7 @@ public final class L2CubicInstance implements IIdentifiable
{
if (_owner.isOlympiadStart())
{
if (ownerTarget instanceof L2Playable)
if (ownerTarget.isPlayable())
{
final L2PcInstance targetPlayer = ownerTarget.getActingPlayer();
if ((targetPlayer != null) && (targetPlayer.getOlympiadGameId() == _owner.getOlympiadGameId()) && (targetPlayer.getOlympiadSide() != _owner.getOlympiadSide()))
@@ -372,23 +371,24 @@ public final class L2CubicInstance implements IIdentifiable
if (ownerTarget.isCharacter() && (ownerTarget != pet) && !_owner.hasServitor(ownerTarget.getObjectId()) && (ownerTarget != _owner))
{
// target mob which has aggro on you or your summon
if (ownerTarget instanceof L2Attackable)
if (ownerTarget.isAttackable())
{
if ((((L2Attackable) ownerTarget).getAggroList().get(_owner) != null) && !((L2Attackable) ownerTarget).isDead())
final L2Attackable attackable = (L2Attackable) ownerTarget;
if ((attackable.getAggroList().get(_owner) != null) && !attackable.isDead())
{
_target = (L2Character) ownerTarget;
return;
}
if (_owner.hasSummon())
{
if ((((L2Attackable) ownerTarget).getAggroList().get(pet) != null) && !((L2Attackable) ownerTarget).isDead())
if ((attackable.getAggroList().get(pet) != null) && !attackable.isDead())
{
_target = (L2Character) ownerTarget;
return;
}
for (L2Summon servitor : _owner.getServitors().values())
{
if ((((L2Attackable) ownerTarget).getAggroList().get(servitor) != null) && !((L2Attackable) ownerTarget).isDead())
if ((attackable.getAggroList().get(servitor) != null) && !attackable.isDead())
{
_target = (L2Character) ownerTarget;
return;
@@ -482,21 +482,21 @@ public final class L2CubicInstance implements IIdentifiable
if (skill.isBad())
{
byte shld = Formulas.calcShldUse(getOwner(), target, skill);
byte shld = Formulas.calcShldUse(_owner, target, skill);
boolean acted = Formulas.calcCubicSkillSuccess(this, target, skill, shld);
if (!acted)
{
getOwner().sendPacket(SystemMessageId.YOUR_ATTACK_HAS_FAILED);
_owner.sendPacket(SystemMessageId.YOUR_ATTACK_HAS_FAILED);
continue;
}
}
// Apply effects
skill.applyEffects(getOwner(), this, target, false, false, true, 0);
skill.applyEffects(_owner, target, false, false, true, 0);
// If this is a bad skill notify the duel manager, so it can be removed after the duel (player & target must be in the same duel).
if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (getOwner().getDuelId() == target.getActingPlayer().getDuelId()))
if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (_owner.getDuelId() == target.getActingPlayer().getDuelId()))
{
DuelManager.getInstance().onBuff(target.getActingPlayer(), skill);
}
@@ -504,11 +504,10 @@ public final class L2CubicInstance implements IIdentifiable
}
/**
* @param activeCubic
* @param skill
* @param targets
*/
public void useCubicMdam(L2CubicInstance activeCubic, Skill skill, L2Object[] targets)
public void useCubicMdam(Skill skill, L2Object[] targets)
{
for (L2Character target : (L2Character[]) targets)
{
@@ -529,9 +528,9 @@ public final class L2CubicInstance implements IIdentifiable
}
}
boolean mcrit = Formulas.calcMCrit(activeCubic.getOwner().getMCriticalHit(target, skill));
byte shld = Formulas.calcShldUse(activeCubic.getOwner(), target, skill);
int damage = (int) Formulas.calcMagicDam(activeCubic, target, skill, mcrit, shld);
boolean mcrit = Formulas.calcMCrit(_owner.getMCriticalHit(target, skill));
byte shld = Formulas.calcShldUse(_owner, target, skill);
int damage = (int) Formulas.calcMagicDam(this, target, skill, mcrit, shld);
if (Config.DEBUG)
{
@@ -554,14 +553,14 @@ public final class L2CubicInstance implements IIdentifiable
}
else
{
activeCubic.getOwner().sendDamageMessage(target, damage, mcrit, false, false);
target.reduceCurrentHp(damage, activeCubic.getOwner(), skill);
_owner.sendDamageMessage(target, damage, mcrit, false, false);
target.reduceCurrentHp(damage, _owner, skill);
}
}
}
}
public void useCubicDrain(L2CubicInstance activeCubic, Skill skill, L2Object[] targets)
public void useCubicDrain(Skill skill, L2Object[] targets)
{
if (Config.DEBUG)
{
@@ -575,10 +574,10 @@ public final class L2CubicInstance implements IIdentifiable
continue;
}
boolean mcrit = Formulas.calcMCrit(activeCubic.getOwner().getMCriticalHit(target, skill));
byte shld = Formulas.calcShldUse(activeCubic.getOwner(), target, skill);
boolean mcrit = Formulas.calcMCrit(_owner.getMCriticalHit(target, skill));
byte shld = Formulas.calcShldUse(_owner, target, skill);
int damage = (int) Formulas.calcMagicDam(activeCubic, target, skill, mcrit, shld);
int damage = (int) Formulas.calcMagicDam(this, target, skill, mcrit, shld);
if (Config.DEBUG)
{
_log.info("L2SkillDrain: useCubicSkill() -> damage = " + damage);
@@ -586,7 +585,7 @@ public final class L2CubicInstance implements IIdentifiable
// TODO: Unhardcode fixed value
double hpAdd = (0.4 * damage);
L2PcInstance owner = activeCubic.getOwner();
L2PcInstance owner = _owner;
double hp = ((owner.getCurrentHp() + hpAdd) > owner.getMaxHp() ? owner.getMaxHp() : (owner.getCurrentHp() + hpAdd));
owner.setCurrentHp(hp);
@@ -594,7 +593,7 @@ public final class L2CubicInstance implements IIdentifiable
// Check to see if we should damage the target
if ((damage > 0) && !target.isDead())
{
target.reduceCurrentHp(damage, activeCubic.getOwner(), skill);
target.reduceCurrentHp(damage, _owner, skill);
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
@@ -621,17 +620,17 @@ public final class L2CubicInstance implements IIdentifiable
continue;
}
byte shld = Formulas.calcShldUse(getOwner(), target, skill);
byte shld = Formulas.calcShldUse(_owner, target, skill);
if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.PARALYZE, L2EffectType.ROOT))
{
if (Formulas.calcCubicSkillSuccess(this, target, skill, shld))
{
// Apply effects
skill.applyEffects(getOwner(), this, target, false, false, true, 0);
skill.applyEffects(_owner, target, false, false, true, 0);
// If this is a bad skill notify the duel manager, so it can be removed after the duel (player & target must be in the same duel).
if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (getOwner().getDuelId() == target.getActingPlayer().getDuelId()))
if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (_owner.getDuelId() == target.getActingPlayer().getDuelId()))
{
DuelManager.getInstance().onBuff(target.getActingPlayer(), skill);
}
@@ -656,11 +655,11 @@ public final class L2CubicInstance implements IIdentifiable
{
if (target.isAttackable())
{
target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getOwner(), (int) ((150 * skill.getPower()) / (target.getLevel() + 7)));
target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _owner, (int) ((150 * skill.getPower()) / (target.getLevel() + 7)));
}
// Apply effects
skill.applyEffects(getOwner(), this, target, false, false, true, 0);
skill.applyEffects(_owner, target, false, false, true, 0);
if (Config.DEBUG)
{

View File

@@ -121,100 +121,102 @@ public final class CubicAction implements Runnable
}
else if (Rnd.get(1, 100) < _chance)
{
Skill skill = _cubic.getSkills().get(Rnd.get(_cubic.getSkills().size()));
if (skill != null)
final Skill skill = _cubic.getSkills().get(Rnd.get(_cubic.getSkills().size()));
if (skill == null)
{
if (skill.getId() == L2CubicInstance.SKILL_CUBIC_HEAL)
return;
}
if (skill.getId() == L2CubicInstance.SKILL_CUBIC_HEAL)
{
// friendly skill, so we look a target in owner's party
_cubic.cubicTargetForHeal();
}
else
{
// offensive skill, we look for an enemy target
_cubic.getCubicTarget();
if (!L2CubicInstance.isInCubicRange(_cubic.getOwner(), _cubic.getTarget()))
{
// friendly skill, so we look a target in owner's party
_cubic.cubicTargetForHeal();
_cubic.setTarget(null);
}
else
}
L2Character target = _cubic.getTarget();
if ((target != null) && !target.isDead())
{
if (Config.DEBUG)
{
// offensive skill, we look for an enemy target
_cubic.getCubicTarget();
if (!L2CubicInstance.isInCubicRange(_cubic.getOwner(), _cubic.getTarget()))
{
_cubic.setTarget(null);
}
_log.info("L2CubicInstance: Action.run();");
_log.info("Cubic ID: " + _cubic.getId() + " Target: " + target.getName() + " distance: " + target.calculateDistance(_cubic.getOwner(), true, false));
}
L2Character target = _cubic.getTarget();
if ((target != null) && !target.isDead())
_cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0));
L2Character[] targets =
{
target
};
if (skill.isContinuous())
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run();");
_log.info("Cubic ID: " + _cubic.getId() + " Target: " + target.getName() + " distance: " + target.calculateDistance(_cubic.getOwner(), true, false));
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0));
L2Character[] targets =
{
target
};
if (skill.isContinuous())
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicContinuous(skill, targets);
}
else
{
skill.activateSkill(_cubic.getOwner(), targets);
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run(); other handler");
}
}
if (skill.hasEffectType(L2EffectType.MAGICAL_ATTACK))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicMdam(_cubic, skill, targets);
}
else if (skill.hasEffectType(L2EffectType.HP_DRAIN))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDrain(_cubic, skill, targets);
}
else if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.ROOT, L2EffectType.PARALYZE))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDisabler(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.DMG_OVER_TIME, L2EffectType.DMG_OVER_TIME_PERCENT))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicContinuous(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.AGGRESSION))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDisabler(skill, targets);
}
// The cubic has done an action, increase the current count
_currentCount.incrementAndGet();
_cubic.useCubicContinuous(skill, targets);
}
else
{
skill.activateSkill(_cubic, targets);
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run(); other handler");
}
}
if (skill.hasEffectType(L2EffectType.MAGICAL_ATTACK))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicMdam(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.HP_DRAIN))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDrain(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.ROOT, L2EffectType.PARALYZE))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDisabler(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.DMG_OVER_TIME, L2EffectType.DMG_OVER_TIME_PERCENT))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicContinuous(skill, targets);
}
else if (skill.hasEffectType(L2EffectType.AGGRESSION))
{
if (Config.DEBUG)
{
_log.info("L2CubicInstance: Action.run() skill " + skill);
}
_cubic.useCubicDisabler(skill, targets);
}
// The cubic has done an action, increase the current count
_currentCount.incrementAndGet();
}
}
}

View File

@@ -56,35 +56,24 @@ public class CubicHeal implements Runnable
_cubic.cancelDisappear();
return;
}
try
{
Skill skill = null;
for (Skill sk : _cubic.getSkills())
final Skill skill = _cubic.getSkills().stream().filter(s -> s.getId() == L2CubicInstance.SKILL_CUBIC_HEAL).findFirst().orElse(null);
if (skill == null)
{
if (sk.getId() == L2CubicInstance.SKILL_CUBIC_HEAL)
{
skill = sk;
break;
}
return;
}
if (skill != null)
_cubic.cubicTargetForHeal();
final L2Character target = _cubic.getTarget();
if ((target != null) && !target.isDead())
{
_cubic.cubicTargetForHeal();
final L2Character target = _cubic.getTarget();
if ((target != null) && !target.isDead())
if ((target.getMaxHp() - target.getCurrentHp()) > skill.getPower())
{
if ((target.getMaxHp() - target.getCurrentHp()) > skill.getPower())
{
L2Character[] targets =
{
target
};
skill.activateSkill(_cubic.getOwner(), targets);
_cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0));
}
skill.activateSkill(_cubic, target);
_cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0));
}
}
}