Store most popular IBaseEvent to reduce object creation.
This commit is contained in:
parent
4b302b66db
commit
64223af7fd
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5040,7 +5096,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5040,7 +5096,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5040,7 +5096,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5040,7 +5096,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5049,7 +5105,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5049,7 +5105,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -66,7 +66,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3908,8 +3926,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4640,10 +4674,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5049,7 +5105,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -63,7 +63,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3907,8 +3925,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4639,10 +4673,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5048,7 +5104,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -63,7 +63,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
@ -66,6 +66,8 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
private OnNpcMoveFinished _onNpcMoveFinished = null;
|
||||
|
||||
public static class IntentionCommand
|
||||
{
|
||||
protected final CtrlIntention _crtlIntention;
|
||||
@ -691,7 +693,11 @@ public class CreatureAI extends AbstractAI
|
||||
WalkingManager.getInstance().onArrived(npc); // Walking Manager support
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveFinished(npc), npc);
|
||||
if (_onNpcMoveFinished == null)
|
||||
{
|
||||
_onNpcMoveFinished = new OnNpcMoveFinished(npc);
|
||||
}
|
||||
EventDispatcher.getInstance().notifyEventAsync(_onNpcMoveFinished, npc);
|
||||
}
|
||||
|
||||
// Launch actions corresponding to the Event Think
|
||||
|
@ -103,6 +103,8 @@ import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDamageRecei
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureKilled;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillFinishCast;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSkillUse;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleport;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureTeleported;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
@ -289,6 +291,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
/** A list containing the dropped items of this fake player. */
|
||||
private final List<ItemInstance> _fakePlayerDrops = new CopyOnWriteArrayList<>();
|
||||
|
||||
private OnCreatureAttack _onCreatureAttack = null;
|
||||
private OnCreatureAttacked _onCreatureAttacked = null;
|
||||
private OnCreatureDamageDealt _onCreatureDamageDealt = null;
|
||||
private OnCreatureDamageReceived _onCreatureDamageReceived = null;
|
||||
private OnCreatureAttackAvoid _onCreatureAttackAvoid = null;
|
||||
public OnCreatureSkillFinishCast onCreatureSkillFinishCast = null;
|
||||
public OnCreatureSkillUse onCreatureSkillUse = null;
|
||||
|
||||
/**
|
||||
* Creates a creature.
|
||||
* @param template the creature template
|
||||
@ -567,6 +577,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
{
|
||||
_summoner.removeSummonedNpc(getObjectId());
|
||||
}
|
||||
|
||||
_onCreatureAttack = null;
|
||||
_onCreatureAttacked = null;
|
||||
_onCreatureDamageDealt = null;
|
||||
_onCreatureDamageReceived = null;
|
||||
_onCreatureAttackAvoid = null;
|
||||
onCreatureSkillFinishCast = null;
|
||||
onCreatureSkillUse = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3907,8 +3925,24 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
doAttack(hit.getDamage(), target, null, false, false, hit.isCritical(), false);
|
||||
|
||||
// Notify to scripts when the attack has been done.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttack(this, target, null), this);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureAttacked(this, target, null), target);
|
||||
if (_onCreatureAttack == null)
|
||||
{
|
||||
_onCreatureAttack = new OnCreatureAttack();
|
||||
}
|
||||
_onCreatureAttack.setAttacker(this);
|
||||
_onCreatureAttack.setTarget(target);
|
||||
_onCreatureAttack.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttack, this);
|
||||
|
||||
if (_onCreatureAttacked == null)
|
||||
{
|
||||
_onCreatureAttacked = new OnCreatureAttacked();
|
||||
}
|
||||
_onCreatureAttacked.setAttacker(this);
|
||||
_onCreatureAttacked.setTarget(target);
|
||||
_onCreatureAttacked.setSkill(null);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttacked, target);
|
||||
|
||||
if (_triggerSkills != null)
|
||||
{
|
||||
for (OptionsSkillHolder holder : _triggerSkills.values())
|
||||
@ -4639,10 +4673,32 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
// Notify of this attack only if there is an attacking creature.
|
||||
if (attacker != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureDamageDealt(attacker, this, amount, skill, critical, isDOT, reflect), attacker);
|
||||
if (_onCreatureDamageDealt == null)
|
||||
{
|
||||
_onCreatureDamageDealt = new OnCreatureDamageDealt();
|
||||
}
|
||||
_onCreatureDamageDealt.setAttacker(attacker);
|
||||
_onCreatureDamageDealt.setTarget(this);
|
||||
_onCreatureDamageDealt.setDamage(amount);
|
||||
_onCreatureDamageDealt.setSkill(skill);
|
||||
_onCreatureDamageDealt.setCritical(critical);
|
||||
_onCreatureDamageDealt.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageDealt.setReflect(reflect);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureDamageDealt, attacker);
|
||||
}
|
||||
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureDamageReceived(attacker, this, amount, skill, critical, isDOT, reflect), this, DamageReturn.class);
|
||||
if (_onCreatureDamageReceived == null)
|
||||
{
|
||||
_onCreatureDamageReceived = new OnCreatureDamageReceived();
|
||||
}
|
||||
_onCreatureDamageReceived.setAttacker(attacker);
|
||||
_onCreatureDamageReceived.setTarget(this);
|
||||
_onCreatureDamageReceived.setDamage(amount);
|
||||
_onCreatureDamageReceived.setSkill(skill);
|
||||
_onCreatureDamageReceived.setCritical(critical);
|
||||
_onCreatureDamageReceived.setDamageOverTime(isDOT);
|
||||
_onCreatureDamageReceived.setReflect(reflect);
|
||||
final DamageReturn term = EventDispatcher.getInstance().notifyEvent(_onCreatureDamageReceived, this, DamageReturn.class);
|
||||
if (term != null)
|
||||
{
|
||||
if (term.terminate())
|
||||
@ -5048,7 +5104,14 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void notifyAttackAvoid(Creature target, boolean isDot)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureAttackAvoid(this, target, isDot), target);
|
||||
if (_onCreatureAttackAvoid == null)
|
||||
{
|
||||
_onCreatureAttackAvoid = new OnCreatureAttackAvoid();
|
||||
}
|
||||
_onCreatureAttackAvoid.setAttacker(this);
|
||||
_onCreatureAttackAvoid.setTarget(target);
|
||||
_onCreatureAttackAvoid.setDamageOverTime(isDot);
|
||||
EventDispatcher.getInstance().notifyEvent(_onCreatureAttackAvoid, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttack implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttack(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttack()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttack implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -26,20 +26,12 @@ import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
*/
|
||||
public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final boolean _damageOverTime;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private boolean _damageOverTime;
|
||||
|
||||
/**
|
||||
* @param attacker who attack
|
||||
* @param target who avoid
|
||||
* @param isDot is dot damage
|
||||
*/
|
||||
public OnCreatureAttackAvoid(Creature attacker, Creature target, boolean isDot)
|
||||
public OnCreatureAttackAvoid()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damageOverTime = isDot;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -47,19 +39,31 @@ public class OnCreatureAttackAvoid implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureAttacked implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final Skill _skill;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private Skill _skill;
|
||||
|
||||
public OnCreatureAttacked(Creature attacker, Creature target, Skill skill)
|
||||
public OnCreatureAttacked()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureAttacked implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageDealt implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageDealt(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageDealt()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageDealt implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,23 +27,16 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureDamageReceived implements IBaseEvent
|
||||
{
|
||||
private final Creature _attacker;
|
||||
private final Creature _target;
|
||||
private final double _damage;
|
||||
private final Skill _skill;
|
||||
private final boolean _crit;
|
||||
private final boolean _damageOverTime;
|
||||
private final boolean _reflect;
|
||||
private Creature _attacker;
|
||||
private Creature _target;
|
||||
private double _damage;
|
||||
private Skill _skill;
|
||||
private boolean _crit;
|
||||
private boolean _damageOverTime;
|
||||
private boolean _reflect;
|
||||
|
||||
public OnCreatureDamageReceived(Creature attacker, Creature target, double damage, Skill skill, boolean crit, boolean damageOverTime, boolean reflect)
|
||||
public OnCreatureDamageReceived()
|
||||
{
|
||||
_attacker = attacker;
|
||||
_target = target;
|
||||
_damage = damage;
|
||||
_skill = skill;
|
||||
_crit = crit;
|
||||
_damageOverTime = damageOverTime;
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
public Creature getAttacker()
|
||||
@ -51,36 +44,71 @@ public class OnCreatureDamageReceived implements IBaseEvent
|
||||
return _attacker;
|
||||
}
|
||||
|
||||
public synchronized void setAttacker(Creature attacker)
|
||||
{
|
||||
_attacker = attacker;
|
||||
}
|
||||
|
||||
public Creature getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(Creature target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
public synchronized void setDamage(double damage)
|
||||
{
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return _crit;
|
||||
}
|
||||
|
||||
public synchronized void setCritical(boolean crit)
|
||||
{
|
||||
_crit = crit;
|
||||
}
|
||||
|
||||
public boolean isDamageOverTime()
|
||||
{
|
||||
return _damageOverTime;
|
||||
}
|
||||
|
||||
public synchronized void setDamageOverTime(boolean damageOverTime)
|
||||
{
|
||||
_damageOverTime = damageOverTime;
|
||||
}
|
||||
|
||||
public boolean isReflect()
|
||||
{
|
||||
return _reflect;
|
||||
}
|
||||
|
||||
public synchronized void setReflect(boolean reflect)
|
||||
{
|
||||
_reflect = reflect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -28,17 +28,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private final WorldObject _target;
|
||||
private Creature _caster;
|
||||
private WorldObject _target;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillFinishCast(Creature caster, WorldObject target, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillFinishCast()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -46,21 +42,41 @@ public class OnCreatureSkillFinishCast implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public WorldObject getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public synchronized void setTarget(WorldObject target)
|
||||
{
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -27,15 +27,12 @@ import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public class OnCreatureSkillUse implements IBaseEvent
|
||||
{
|
||||
private final Creature _caster;
|
||||
private final Skill _skill;
|
||||
private final boolean _simultaneously;
|
||||
private Creature _caster;
|
||||
private Skill _skill;
|
||||
private boolean _simultaneously;
|
||||
|
||||
public OnCreatureSkillUse(Creature caster, Skill skill, boolean simultaneously)
|
||||
public OnCreatureSkillUse()
|
||||
{
|
||||
_caster = caster;
|
||||
_skill = skill;
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
public Creature getCaster()
|
||||
@ -43,16 +40,31 @@ public class OnCreatureSkillUse implements IBaseEvent
|
||||
return _caster;
|
||||
}
|
||||
|
||||
public synchronized void setCaster(Creature caster)
|
||||
{
|
||||
_caster = caster;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public synchronized void setSkill(Skill skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
public boolean isSimultaneously()
|
||||
{
|
||||
return _simultaneously;
|
||||
}
|
||||
|
||||
public synchronized void setSimultaneously(boolean simultaneously)
|
||||
{
|
||||
_simultaneously = simultaneously;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@ -523,7 +523,15 @@ public class SkillCaster implements Runnable
|
||||
}
|
||||
|
||||
// Notify skill is casted.
|
||||
EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillFinishCast(caster, target, _skill, _skill.isWithoutAction()), caster);
|
||||
if (caster.onCreatureSkillFinishCast == null)
|
||||
{
|
||||
caster.onCreatureSkillFinishCast = new OnCreatureSkillFinishCast();
|
||||
}
|
||||
caster.onCreatureSkillFinishCast.setCaster(caster);
|
||||
caster.onCreatureSkillFinishCast.setTarget(target);
|
||||
caster.onCreatureSkillFinishCast.setSkill(_skill);
|
||||
caster.onCreatureSkillFinishCast.setSimultaneously(_skill.isWithoutAction());
|
||||
EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillFinishCast, caster);
|
||||
|
||||
// Call the skill's effects and AI interraction and stuff.
|
||||
callSkill(caster, target, _targets, _skill, _item);
|
||||
@ -968,7 +976,14 @@ public class SkillCaster implements Runnable
|
||||
return false;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnCreatureSkillUse(caster, skill, skill.isWithoutAction()), caster, TerminateReturn.class);
|
||||
if (caster.onCreatureSkillUse == null)
|
||||
{
|
||||
caster.onCreatureSkillUse = new OnCreatureSkillUse();
|
||||
}
|
||||
caster.onCreatureSkillUse.setCaster(caster);
|
||||
caster.onCreatureSkillUse.setSkill(skill);
|
||||
caster.onCreatureSkillUse.setSimultaneously(skill.isWithoutAction());
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(caster.onCreatureSkillUse, caster, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
caster.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
@ -63,7 +63,11 @@ public class LargeCocoon extends AbstractNpcAI
|
||||
{
|
||||
case "attack":
|
||||
{
|
||||
onCreatureAttacked(new OnCreatureAttacked(player, npc, null));
|
||||
final OnCreatureAttacked attackEvent = new OnCreatureAttacked();
|
||||
attackEvent.setAttacker(player);
|
||||
attackEvent.setTarget(npc);
|
||||
attackEvent.setSkill(null);
|
||||
onCreatureAttacked(attackEvent);
|
||||
break;
|
||||
}
|
||||
case "attackPowerful":
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user