Sync with L2jUnity (7db5b4f).

This commit is contained in:
MobiusDev
2016-12-04 21:28:20 +00:00
parent 9e1d3569f0
commit b9d3c99cf1
412 changed files with 13806 additions and 10065 deletions

View File

@@ -40,6 +40,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("AddTeleportBookmarkSlot", AddTeleportBookmarkSlot::new);
EffectHandler.getInstance().registerHandler("AreaDamage", AreaDamage::new);
EffectHandler.getInstance().registerHandler("AttackAttribute", AttackAttribute::new);
EffectHandler.getInstance().registerHandler("AttackAttributeAdd", AttackAttributeAdd::new);
EffectHandler.getInstance().registerHandler("AttackBehind", AttackBehind::new);
EffectHandler.getInstance().registerHandler("AttackTrait", AttackTrait::new);
EffectHandler.getInstance().registerHandler("Backstab", Backstab::new);
@@ -117,7 +118,6 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("DispelBySlotProbability", DispelBySlotProbability::new);
EffectHandler.getInstance().registerHandler("DoubleCast", DoubleCast::new);
EffectHandler.getInstance().registerHandler("EnableCloak", EnableCloak::new);
EffectHandler.getInstance().registerHandler("EnemyCharge", EnemyCharge::new);
EffectHandler.getInstance().registerHandler("EnergyAttack", EnergyAttack::new);
EffectHandler.getInstance().registerHandler("EnlargeAbnormalSlot", EnlargeAbnormalSlot::new);
EffectHandler.getInstance().registerHandler("EnlargeSlot", EnlargeSlot::new);
@@ -131,7 +131,6 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("Feed", Feed::new);
EffectHandler.getInstance().registerHandler("Flag", Flag::new);
EffectHandler.getInstance().registerHandler("FlipBlock", FlipBlock::new);
EffectHandler.getInstance().registerHandler("FlyMove", FlyMove::new);
EffectHandler.getInstance().registerHandler("FocusEnergy", FocusEnergy::new);
EffectHandler.getInstance().registerHandler("FocusMomentum", FocusMomentum::new);
EffectHandler.getInstance().registerHandler("FocusMaxMomentum", FocusMaxMomentum::new);
@@ -249,6 +248,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("RealDamage", RealDamage::new);
EffectHandler.getInstance().registerHandler("RebalanceHP", RebalanceHP::new);
EffectHandler.getInstance().registerHandler("Recovery", Recovery::new);
EffectHandler.getInstance().registerHandler("ReduceDamage", ReduceDamage::new);
EffectHandler.getInstance().registerHandler("ReduceCancel", ReduceCancel::new);
EffectHandler.getInstance().registerHandler("ReduceDropPenalty", ReduceDropPenalty::new);
EffectHandler.getInstance().registerHandler("ReflectMagic", ReflectMagic::new);
@@ -314,7 +314,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("TeleportToNpc", TeleportToNpc::new);
EffectHandler.getInstance().registerHandler("TeleportToSummon", TeleportToSummon::new);
EffectHandler.getInstance().registerHandler("TeleportToTarget", TeleportToTarget::new);
EffectHandler.getInstance().registerHandler("ThrowUp", ThrowUp::new);
EffectHandler.getInstance().registerHandler("FlyAway", FlyAway::new);
EffectHandler.getInstance().registerHandler("TransferDamageToPlayer", TransferDamageToPlayer::new);
EffectHandler.getInstance().registerHandler("TransferDamageToSummon", TransferDamageToSummon::new);
EffectHandler.getInstance().registerHandler("TransferHate", TransferHate::new);

View File

@@ -0,0 +1,86 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* @author Sdw
*/
public class AttackAttributeAdd extends AbstractEffect
{
private final double _amount;
public AttackAttributeAdd(StatsSet params)
{
_amount = params.getDouble("amount", 0);
}
@Override
public void pump(L2Character effected, Skill skill)
{
Stats stat = Stats.FIRE_POWER;
AttributeType maxAttribute = AttributeType.FIRE;
int maxValue = 0;
for (AttributeType attribute : AttributeType.values())
{
final int attributeValue = effected.getStat().getAttackElementValue(attribute);
if ((attributeValue > 0) && (attributeValue > maxValue))
{
maxAttribute = attribute;
maxValue = attributeValue;
}
}
switch (maxAttribute)
{
case WATER:
{
stat = Stats.WATER_POWER;
break;
}
case WIND:
{
stat = Stats.WIND_POWER;
break;
}
case EARTH:
{
stat = Stats.EARTH_POWER;
break;
}
case HOLY:
{
stat = Stats.HOLY_POWER;
break;
}
case DARK:
{
stat = Stats.DARK_POWER;
break;
}
}
effected.getStat().mergeAdd(stat, _amount);
}
}

View File

@@ -37,7 +37,7 @@ public final class CallSkill extends AbstractEffect
public CallSkill(StatsSet params)
{
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel", 1));
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel", 1), params.getInt("skillSubLevel", 0));
_skillLevelScaleTo = params.getInt("skillLevelScaleTo", 0);
}

View File

@@ -35,7 +35,7 @@ public final class CallSkillOnActionTime extends AbstractEffect
public CallSkillOnActionTime(StatsSet params)
{
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel", 1));
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel", 1), params.getInt("skillSubLevel", 0));
setTicks(params.getInt("ticks"));
}

View File

@@ -1,109 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import com.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
/**
* Enemy Charge effect implementation.
*/
public final class EnemyCharge extends AbstractEffect
{
private final int _speed;
private final int _delay;
private final int _animationSpeed;
public EnemyCharge(StatsSet params)
{
_speed = params.getInt("speed", 0);
_delay = params.getInt("delay", 0);
_animationSpeed = params.getInt("animationSpeed", 0);
}
@Override
public boolean isInstant()
{
return true;
}
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
if (effected.isMovementDisabled())
{
return;
}
// Get current position of the L2Character
final int curX = effector.getX();
final int curY = effector.getY();
final int curZ = effector.getZ();
// Calculate distance (dx,dy) between current position and destination
final double dx = effected.getX() - curX;
final double dy = effected.getY() - curY;
final double dz = effected.getZ() - curZ;
final double distance = Math.sqrt((dx * dx) + (dy * dy));
if (distance > 2000)
{
_log.info("EffectEnemyCharge was going to use invalid coordinates for characters, getEffector: " + curX + "," + curY + " and getEffected: " + effected.getX() + "," + effected.getY());
return;
}
int offset = Math.max((int) distance - skill.getFlyRadius(), 30);
// approximation for moving closer when z coordinates are different
// TODO: handle Z axis movement better
offset -= Math.abs(dz);
if (offset < 5)
{
offset = 5;
}
// If no distance
if ((distance < 1) || ((distance - offset) <= 0))
{
return;
}
// Calculate movement angles needed
final double sin = dy / distance;
final double cos = dx / distance;
// Calculate the new destination with offset included
final int x = curX + (int) ((distance - offset) * cos);
final int y = curY + (int) ((distance - offset) * sin);
final int z = effected.getZ();
final Location destination = GeoData.getInstance().moveCheck(effector.getX(), effector.getY(), effector.getZ(), x, y, z, effector.getInstanceWorld());
effector.broadcastPacket(new FlyToLocation(effector, destination, skill.getFlyType(), _speed, _delay, _animationSpeed));
// maybe is need force set X,Y,Z
effected.setXYZ(destination);
effected.broadcastPacket(new ValidateLocation(effector));
effected.revalidateZone(true);
}
}

View File

@@ -43,6 +43,7 @@ public final class EnergyAttack extends AbstractEffect
private final int _criticalChance;
private final boolean _ignoreShieldDefence;
private final boolean _overHit;
private final double _pDefMod;
public EnergyAttack(StatsSet params)
{
@@ -51,6 +52,7 @@ public final class EnergyAttack extends AbstractEffect
_ignoreShieldDefence = params.getBoolean("ignoreShieldDefence", false);
_overHit = params.getBoolean("overHit", false);
_chargeConsume = params.getInt("chargeConsume", 0);
_pDefMod = params.getDouble("pDefMod", 1.0);
}
@Override
@@ -103,7 +105,7 @@ public final class EnergyAttack extends AbstractEffect
((L2Attackable) effected).overhitEnabled(true);
}
int defence = effected.getPDef();
double defence = effected.getPDef() * _pDefMod;
if (!_ignoreShieldDefence)
{
@@ -137,7 +139,7 @@ public final class EnergyAttack extends AbstractEffect
// Skill specific mods.
final double energyChargesBoost = 1 + (charge * 0.1); // 10% bonus damage for each charge used.
final double critMod = critical ? Formulas.calcCritDamage(attacker, effected, skill) : 1;
final double ssmod = (skill.useSoulShot() && attacker.isChargedShot(ShotType.SOULSHOTS)) ? attacker.getStat().getValue(Stats.SHOTS_BONUS, 2) : 1; // 2.04 for dual weapon?
final double ssmod = (skill.useSoulShot() && attacker.isChargedShot(ShotType.SOULSHOTS)) ? (2 * attacker.getStat().getValue(Stats.SHOTS_BONUS)) : 1; // 2.04 for dual weapon?
// ...................________Initial Damage_________...__Charges Additional Damage__...____________________________________
// ATTACK CALCULATION ((77 * ((pAtk * lvlMod) + power) * (1 + (0.1 * chargesConsumed)) / pdef) * skillPower) + skillPowerAdd

View File

@@ -30,10 +30,13 @@ import com.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
/**
* Throw Up effect implementation.
*/
public final class ThrowUp extends AbstractEffect
public final class FlyAway extends AbstractEffect
{
public ThrowUp(StatsSet params)
private final int _radius;
public FlyAway(StatsSet params)
{
_radius = params.getInt("radius");
}
@Override
@@ -45,52 +48,18 @@ public final class ThrowUp extends AbstractEffect
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
final int curX = effected.getX();
final int curY = effected.getY();
final int curZ = effected.getZ();
// Calculate distance between effector and effected current position
final double dx = effector.getX() - curX;
final double dy = effector.getY() - curY;
final double dz = effector.getZ() - curZ;
final int dx = effector.getX() - effected.getX();
final int dy = effector.getY() - effected.getY();
final double distance = Math.sqrt((dx * dx) + (dy * dy));
if (distance > 2000)
{
_log.info("EffectThrow was going to use invalid coordinates for characters, getEffected: " + curX + "," + curY + " and getEffector: " + effector.getX() + "," + effector.getY());
return;
}
int offset = Math.min((int) distance + skill.getFlyRadius(), 1400);
final double nRadius = effector.getCollisionRadius() + effected.getCollisionRadius() + _radius;
double cos;
double sin;
// approximation for moving futher when z coordinates are different
// TODO: handle Z axis movement better
offset += Math.abs(dz);
if (offset < 5)
{
offset = 5;
}
// If no distance
if (distance < 1)
{
return;
}
// Calculate movement angles needed
sin = dy / distance;
cos = dx / distance;
// Calculate the new destination with offset included
final int x = effector.getX() - (int) (offset * cos);
final int y = effector.getY() - (int) (offset * sin);
final int z = effected.getZ();
final int x = (int) (effector.getX() - (nRadius * (dx / distance)));
final int y = (int) (effector.getY() - (nRadius * (dy / distance)));
final int z = effector.getZ();
final Location destination = GeoData.getInstance().moveCheck(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld());
effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP));
// TODO: Review.
effected.setXYZ(destination);
effected.broadcastPacket(new ValidateLocation(effected));
effected.revalidateZone(true);

View File

@@ -1,86 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Nos
*/
public class FlyMove extends AbstractEffect
{
private final FlyType _flyType;
private final int _angle;
private final boolean _absoluteAngle; // Use map angle instead of character angle.
private final int _range;
private final boolean _selfPos; // Use the position and heading of yourself to move in the given range
private final int _speed;
private final int _delay;
private final int _animationSpeed;
public FlyMove(StatsSet params)
{
_flyType = params.getEnum("flyType", FlyType.class, FlyType.DUMMY);
_angle = params.getInt("angle", 0);
_absoluteAngle = params.getBoolean("absoluteAngle", false);
_range = params.getInt("range", 20);
_selfPos = params.getBoolean("selfPos", false);
_speed = params.getInt("speed", 0);
_delay = params.getInt("delay", 0);
_animationSpeed = params.getInt("animationSpeed", 0);
}
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
final L2Character target = _selfPos ? effector : effected;
// Avoid calculating heading towards yourself because it always yields 0. Same results can be achieved with absoluteAngle of 0.
final int heading = (_selfPos || (effector == effected)) ? effector.getHeading() : Util.calculateHeadingFrom(effector, effected);
double angle = _absoluteAngle ? _angle : Util.convertHeadingToDegree(heading);
angle = (angle + _angle) % 360;
if (angle < 0)
{
angle += 360;
}
final double radiansAngle = Math.toRadians(angle);
final int posX = (int) (target.getX() + (_range * Math.cos(radiansAngle)));
final int posY = (int) (target.getY() + (_range * Math.sin(radiansAngle)));
final int posZ = target.getZ();
final Location destination = GeoData.getInstance().moveCheck(effector.getX(), effector.getY(), effector.getZ(), posX, posY, posZ, effector.getInstanceWorld());
effector.broadcastPacket(new FlyToLocation(effector, destination, _flyType, _speed, _delay, _animationSpeed));
effector.setXYZ(destination);
effected.revalidateZone(true);
}
@Override
public boolean isInstant()
{
return true;
}
}

View File

@@ -1,31 +1,31 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* @author Sdw
*/
public class JewelSlot extends AbstractStatAddEffect
{
public JewelSlot(StatsSet params)
{
super(params, Stats.BROOCH_JEWELS);
}
}
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* @author Sdw
*/
public class JewelSlot extends AbstractStatAddEffect
{
public JewelSlot(StatsSet params)
{
super(params, Stats.BROOCH_JEWELS);
}
}

View File

@@ -44,6 +44,7 @@ public final class PhysicalAttackWeaponBonus extends AbstractEffect
private final double _criticalChance;
private final boolean _ignoreShieldDefence;
private final boolean _overHit;
private final double _pDefMod;
private final Map<WeaponType, Double> _weaponBonus = new HashMap<>();
@@ -53,6 +54,7 @@ public final class PhysicalAttackWeaponBonus extends AbstractEffect
_criticalChance = params.getDouble("criticalChance", 0);
_ignoreShieldDefence = params.getBoolean("ignoreShieldDefence", false);
_overHit = params.getBoolean("overHit", false);
_pDefMod = params.getDouble("pDefMod", 1.0);
for (WeaponType weapon : WeaponType.values())
{
@@ -106,7 +108,7 @@ public final class PhysicalAttackWeaponBonus extends AbstractEffect
}
final double attack = effector.getPAtk();
double defence = effected.getPDef();
double defence = effected.getPDef() * _pDefMod;
if (!_ignoreShieldDefence)
{

View File

@@ -137,7 +137,7 @@ public final class PhysicalSoulAttack extends AbstractEffect
final double wpnMod = effector.getAttackType().isRanged() ? 70 : (70 * 1.10113);
final double rangedBonus = effector.getAttackType().isRanged() ? (attack + _power) : 0;
final double critMod = critical ? Formulas.calcCritDamage(effector, effected, skill) : 1;
final double ssmod = (skill.useSoulShot() && effector.isChargedShot(ShotType.SOULSHOTS)) ? effector.getStat().getValue(Stats.SHOTS_BONUS, 2) : 1; // 2.04 for dual weapon?
final double ssmod = (skill.useSoulShot() && effector.isChargedShot(ShotType.SOULSHOTS)) ? (2 * effector.getStat().getValue(Stats.SHOTS_BONUS)) : 1; // 2.04 for dual weapon?
final double soulsMod = 1 + (souls * 0.04); // Souls Formula (each soul increase +4%)
// ...................____________Melee Damage_____________......................................___________________Ranged Damage____________________

View File

@@ -0,0 +1,63 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.effecthandlers;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDamageReceived;
import com.l2jmobius.gameserver.model.events.listeners.FunctionEventListener;
import com.l2jmobius.gameserver.model.events.returns.DamageReturn;
import com.l2jmobius.gameserver.model.skills.BuffInfo;
/**
* @author Sdw
*/
public class ReduceDamage extends AbstractEffect
{
private final double _amount;
public ReduceDamage(StatsSet params)
{
_amount = params.getDouble("amount");
}
private DamageReturn onDamageReceivedEvent(OnCreatureDamageReceived event)
{
// DOT effects are not taken into account.
if (event.isDamageOverTime())
{
return null;
}
final double newDamage = event.getDamage() * (_amount / 100);
return new DamageReturn(false, true, false, newDamage);
}
@Override
public void onExit(BuffInfo info)
{
info.getEffected().removeListenerIf(EventType.ON_CREATURE_DAMAGE_RECEIVED, listener -> listener.getOwner() == this);
}
@Override
public void onStart(BuffInfo info)
{
info.getEffected().addListener(new FunctionEventListener(info.getEffected(), EventType.ON_CREATURE_DAMAGE_RECEIVED, (OnCreatureDamageReceived event) -> onDamageReceivedEvent(event), this));
}
}

View File

@@ -87,7 +87,7 @@ public final class TriggerSkillByAttack extends AbstractEffect
public void onAttackEvent(OnCreatureDamageDealt event)
{
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0)) || (!_allowNormalAttack && !_allowSkillAttack))
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0)) || (!_allowNormalAttack && !_allowSkillAttack))
{
return;
}

View File

@@ -57,7 +57,7 @@ public final class TriggerSkillByAvoid extends AbstractEffect
public void onAvoidEvent(OnCreatureAttackAvoid event)
{
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0)))
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0)))
{
return;
}

View File

@@ -61,7 +61,7 @@ public final class TriggerSkillByDamage extends AbstractEffect
public void onDamageReceivedEvent(OnCreatureDamageReceived event)
{
if (event.isDamageOverTime() || (_chance == 0) || (_skill.getSkillLvl() == 0))
if (event.isDamageOverTime() || (_chance == 0) || (_skill.getSkillLevel() == 0))
{
return;
}

View File

@@ -16,17 +16,23 @@
*/
package handlers.effecthandlers;
import java.util.logging.Level;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.TargetHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDeath;
import com.l2jmobius.gameserver.model.events.listeners.FunctionEventListener;
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDamageReceived;
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.skills.BuffInfo;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.SkillCaster;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
/**
* Trigger Skill By Death Blow effect implementation.
@@ -34,43 +40,76 @@ import com.l2jmobius.gameserver.model.skills.SkillCaster;
*/
public final class TriggerSkillByDeathBlow extends AbstractEffect
{
private final int _minAttackerLevel;
private final int _maxAttackerLevel;
private final int _chance;
private final SkillHolder _skill;
private final TargetType _targetType;
private final InstanceType _attackerType;
public TriggerSkillByDeathBlow(StatsSet params)
{
_minAttackerLevel = params.getInt("minAttackerLevel", 1);
_maxAttackerLevel = params.getInt("maxAttackerLevel", 127);
_chance = params.getInt("chance", 100);
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel"));
_targetType = params.getEnum("targetType", TargetType.class, TargetType.SELF);
_attackerType = params.getEnum("attackerType", InstanceType.class, InstanceType.L2Character);
}
public TerminateReturn onCreatureDeath(OnCreatureDeath event)
public void onDamageReceivedEvent(OnCreatureDamageReceived event)
{
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0)))
if (event.getDamage() < event.getTarget().getCurrentHp())
{
return new TerminateReturn(false, false, false);
return;
}
if (Rnd.get(100) > _chance)
if ((_chance == 0) || (_skill.getSkillLevel() == 0))
{
return new TerminateReturn(false, false, false);
return;
}
if (event.getAttacker() == event.getTarget())
{
return;
}
if ((event.getAttacker().getLevel() < _minAttackerLevel) || (event.getAttacker().getLevel() > _maxAttackerLevel))
{
return;
}
if (((_chance < 100) && (Rnd.get(100) > _chance)) || !event.getAttacker().getInstanceType().isType(_attackerType))
{
return;
}
final Skill triggerSkill = _skill.getSkill();
L2Object target = null;
try
{
target = TargetHandler.getInstance().getHandler(_targetType).getTarget(event.getTarget(), event.getAttacker(), triggerSkill, false, false, false);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in ITargetTypeHandler.getTarget(): " + e.getMessage(), e);
}
SkillCaster.triggerCast(event.getTarget(), event.getTarget(), triggerSkill);
return new TerminateReturn(true, true, true);
if ((target != null) && target.isCharacter())
{
SkillCaster.triggerCast(event.getTarget(), (L2Character) target, triggerSkill);
}
}
@Override
public void onExit(BuffInfo info)
{
info.getEffected().removeListenerIf(EventType.ON_CREATURE_DEATH, listener -> listener.getOwner() == this);
info.getEffected().removeListenerIf(EventType.ON_CREATURE_DAMAGE_RECEIVED, listener -> listener.getOwner() == this);
}
@Override
public void onStart(BuffInfo info)
{
info.getEffected().addListener(new FunctionEventListener(info.getEffected(), EventType.ON_CREATURE_DEATH, (OnCreatureDeath event) -> onCreatureDeath(event), this));
info.getEffected().addListener(new ConsumerEventListener(info.getEffected(), EventType.ON_CREATURE_DAMAGE_RECEIVED, (OnCreatureDamageReceived event) -> onDamageReceivedEvent(event), this));
}
}

View File

@@ -45,7 +45,7 @@ public final class TriggerSkillByKill extends AbstractEffect
public void onCreatureKilled(OnCreatureKilled event, L2Character target)
{
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0)))
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0)))
{
return;
}

View File

@@ -114,7 +114,7 @@ public final class TriggerSkillByMagicType extends AbstractEffect
@Override
public void onStart(BuffInfo info)
{
if ((_chance == 0) || (_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0) || (_magicTypes.length == 0))
if ((_chance == 0) || (_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0) || (_magicTypes.length == 0))
{
return;
}

View File

@@ -48,9 +48,9 @@ public final class TriggerSkillBySkill extends AbstractEffect
public TriggerSkillBySkill(StatsSet params)
{
_castSkillId = params.getInt("castSkillId", 0);
_castSkillId = params.getInt("castSkillId");
_chance = params.getInt("chance", 100);
_skill = new SkillHolder(params.getInt("skillId", 0), params.getInt("skillLevel", 0));
_skill = new SkillHolder(params.getInt("skillId"), params.getInt("skillLevel"));
_skillLevelScaleTo = params.getInt("skillLevelScaleTo", 0);
_targetType = params.getEnum("targetType", TargetType.class, TargetType.TARGET);
}
@@ -67,9 +67,9 @@ public final class TriggerSkillBySkill extends AbstractEffect
info.getEffected().removeListenerIf(EventType.ON_CREATURE_SKILL_FINISH_CAST, listener -> listener.getOwner() == this);
}
public void onSkillUseEvent(OnCreatureSkillFinishCast event)
private void onSkillUseEvent(OnCreatureSkillFinishCast event)
{
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0) || (_castSkillId == 0)))
if ((_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0) || (_castSkillId == 0)))
{
return;
}

View File

@@ -77,9 +77,9 @@ public final class TriggerSkillBySkillAttack extends AbstractEffect
info.getEffected().removeListenerIf(EventType.ON_CREATURE_DAMAGE_DEALT, listener -> listener.getOwner() == this);
}
public void onAttackEvent(OnCreatureDamageDealt event)
private void onAttackEvent(OnCreatureDamageDealt event)
{
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLvl() == 0)) || (_attackSkill.getSkillId() == 0))
if (event.isDamageOverTime() || (_chance == 0) || ((_skill.getSkillId() == 0) || (_skill.getSkillLevel() == 0)) || (_attackSkill.getSkillId() == 0))
{
return;
}

View File

@@ -121,7 +121,7 @@ public class BeastSoulShot implements IItemHandler
if (!pet.isChargedShot(ShotType.SOULSHOTS))
{
pet.setChargedShot(ShotType.SOULSHOTS, true);
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
}
}
@@ -130,7 +130,7 @@ public class BeastSoulShot implements IItemHandler
if (!s.isChargedShot(ShotType.SOULSHOTS))
{
s.setChargedShot(ShotType.SOULSHOTS, true);
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
}
});
return true;

View File

@@ -123,7 +123,7 @@ public class BeastSpiritShot implements IItemHandler
if (!pet.isChargedShot(shotType))
{
pet.setChargedShot(shotType, true);
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
}
}
@@ -132,7 +132,7 @@ public class BeastSpiritShot implements IItemHandler
if (!s.isChargedShot(shotType))
{
s.setChargedShot(shotType, true);
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
}
});
return true;

View File

@@ -101,7 +101,7 @@ public class BlessedSpiritShot implements IItemHandler
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
return true;
}
}

View File

@@ -88,7 +88,7 @@ public class FishShots implements IItemHandler
return false;
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
activeChar.setTarget(oldTarget);
return true;
}

View File

@@ -49,7 +49,7 @@ public class PetFood implements IItemHandler
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
if (skills != null)
{
skills.forEach(holder -> useFood(playable, holder.getSkillId(), holder.getSkillLvl(), item));
skills.forEach(holder -> useFood(playable, holder.getSkillId(), holder.getSkillLevel(), item));
}
return true;
}

View File

@@ -113,7 +113,7 @@ public class SoulShots implements IItemHandler
{
activeChar.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
return true;
}
}

View File

@@ -101,7 +101,7 @@ public class SpiritShot implements IItemHandler
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLevel(), 0, 0), 600));
return true;
}
}

View File

@@ -23,7 +23,6 @@ import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
/**
* Any friendly selected target. Works on dead targets or doors as well. Unable to force use.
@@ -74,7 +73,7 @@ public class EnemyNot implements ITargetTypeHandler
}
}
if ((skill.getFlyType() == FlyType.CHARGE) && !GeoData.getInstance().canMove(activeChar, target))
if ((skill.isFlyType()) && !GeoData.getInstance().canMove(activeChar, target))
{
if (sendMessage)
{

View File

@@ -20,6 +20,7 @@ import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.ITargetTypeHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -60,14 +61,14 @@ public class NpcBody implements ITargetTypeHandler
return null;
}
final L2Character target = (L2Character) selectedTarget;
final L2Npc npc = (L2Npc) selectedTarget;
if (target.isDead())
if (npc.isDead())
{
// Check for cast range if character cannot move. TODO: char will start follow until within castrange, but if his moving is blocked by geodata, this msg will be sent.
if (dontMove)
{
if (activeChar.calculateDistance(target, false, false) > skill.getCastRange())
if (activeChar.calculateDistance(npc, false, false) > skill.getCastRange())
{
if (sendMessage)
{
@@ -79,7 +80,7 @@ public class NpcBody implements ITargetTypeHandler
}
// Geodata check when character is within range.
if (!GeoData.getInstance().canSeeTarget(activeChar, target))
if (!GeoData.getInstance().canSeeTarget(activeChar, npc))
{
if (sendMessage)
{
@@ -89,7 +90,7 @@ public class NpcBody implements ITargetTypeHandler
return null;
}
return selectedTarget;
return npc;
}
// If target is not dead or not player/pet it will not even bother to walk within range, unlike Enemy target type.

View File

@@ -23,7 +23,6 @@ import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
/**
* Any friendly selected target or enemy if force use. Works on dead targets or doors as well.
@@ -76,7 +75,7 @@ public class Target implements ITargetTypeHandler
}
}
if ((skill.getFlyType() == FlyType.CHARGE) && !GeoData.getInstance().canMove(activeChar, target))
if ((skill.isFlyType()) && !GeoData.getInstance().canMove(activeChar, target))
{
if (sendMessage)
{

View File

@@ -77,9 +77,9 @@ public class Fan implements IAffectScopeHandler
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
if (filter.test(activeChar))
{
action.accept(target);
action.accept(activeChar);
}
// Check and add targets.

View File

@@ -29,6 +29,7 @@ import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
import com.l2jmobius.gameserver.model.skills.targets.AffectScope;
import com.l2jmobius.gameserver.model.skills.targets.TargetType;
@@ -53,11 +54,8 @@ public class PointBlank implements IAffectScopeHandler
{
return false;
}
if (c.isDead())
{
return false;
}
if ((affectObject != null) && !affectObject.checkAffectedObject(activeChar, c))
// XXX : Find a proper way to fix, if it's not proper.
if ((affectObject != null) && (!c.isDead() || (skill.getAffectObject() == AffectObject.OBJECT_DEAD_NPC_BODY)) && !affectObject.checkAffectedObject(activeChar, c))
{
return false;
}

View File

@@ -90,9 +90,9 @@ public class Square implements IAffectScopeHandler
};
// Add object of origin since its skipped in the forEachVisibleObjectInRange method.
if (target.isCharacter() && filter.test((L2Character) target))
if (filter.test(activeChar))
{
action.accept(target);
action.accept(activeChar);
}
// Check and add targets.