From ccf50bece21d0c7151c01f48c8d4f1e104ee3ed7 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Thu, 14 Sep 2017 21:55:22 +0000 Subject: [PATCH] Merged some L2QuestGuard methods to FriendlyNpc. --- .../gameserver/ai/FriendlyNpcAI.java | 6 -- .../actor/instance/FriendlyNpcInstance.java | 66 +++++++++++++++++-- .../gameserver/ai/FriendlyNpcAI.java | 6 -- .../actor/instance/FriendlyNpcInstance.java | 66 +++++++++++++++++-- .../gameserver/ai/FriendlyNpcAI.java | 6 -- .../actor/instance/FriendlyNpcInstance.java | 66 +++++++++++++++++-- .../gameserver/ai/FriendlyNpcAI.java | 6 -- .../actor/instance/FriendlyNpcInstance.java | 66 +++++++++++++++++-- 8 files changed, 236 insertions(+), 52 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java index 60fa4b1c8a..a22a385bee 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java @@ -38,12 +38,6 @@ public class FriendlyNpcAI extends L2AttackableAI super(attackable); } - @Override - protected void thinkActive() - { - - } - @Override protected void onEvtAttacked(L2Character attacker) { diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java index bce431514c..c67abe7ebd 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java @@ -16,24 +16,28 @@ */ package com.l2jmobius.gameserver.model.actor.instance; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.FriendlyNpcAI; import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.model.actor.L2Attackable; +import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.events.EventDispatcher; import com.l2jmobius.gameserver.model.events.EventType; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableAttack; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableKill; import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk; +import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; -import com.l2jmobius.gameserver.network.serverpackets.SocialAction; /** - * @author Sdw + * @author GKR, Sdw */ public class FriendlyNpcInstance extends L2Attackable { + private boolean _isAutoAttackable = true; + public FriendlyNpcInstance(L2NpcTemplate template) { super(template); @@ -46,6 +50,58 @@ public class FriendlyNpcInstance extends L2Attackable return false; } + @Override + public boolean isAutoAttackable(L2Character attacker) + { + return _isAutoAttackable && !attacker.isPlayable(); + } + + @Override + public void setAutoAttackable(boolean state) + { + _isAutoAttackable = state; + } + + @Override + public void addDamage(L2Character attacker, int damage, Skill skill) + { + if (!attacker.isPlayer()) + { + super.addDamage(attacker, damage, skill); + } + + if (attacker.isAttackable()) + { + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(null, this, damage, skill, false), this); + } + } + + @Override + public void addDamageHate(L2Character attacker, int damage, int aggro) + { + if (!attacker.isPlayable()) + { + super.addDamageHate(attacker, damage, aggro); + } + } + + @Override + public boolean doDie(L2Character killer) + { + // Kill the L2NpcInstance (the corpse disappeared after 7 seconds) + if (!super.doDie(killer)) + { + return false; + } + + if (killer.isAttackable()) + { + // Delayed notification + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(null, this, false), this); + } + return true; + } + @Override public void onAction(L2PcInstance player, boolean interact) { @@ -70,10 +126,6 @@ public class FriendlyNpcInstance extends L2Attackable } else { - // Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance - // to display a social action of the L2GuardInstance on their client - broadcastPacket(new SocialAction(getObjectId(), Rnd.nextInt(8))); - player.setLastFolkNPC(this); // Open a chat window on client with the text of the L2GuardInstance diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java index 60fa4b1c8a..a22a385bee 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java @@ -38,12 +38,6 @@ public class FriendlyNpcAI extends L2AttackableAI super(attackable); } - @Override - protected void thinkActive() - { - - } - @Override protected void onEvtAttacked(L2Character attacker) { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java index bce431514c..c67abe7ebd 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java @@ -16,24 +16,28 @@ */ package com.l2jmobius.gameserver.model.actor.instance; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.FriendlyNpcAI; import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.model.actor.L2Attackable; +import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.events.EventDispatcher; import com.l2jmobius.gameserver.model.events.EventType; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableAttack; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableKill; import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk; +import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; -import com.l2jmobius.gameserver.network.serverpackets.SocialAction; /** - * @author Sdw + * @author GKR, Sdw */ public class FriendlyNpcInstance extends L2Attackable { + private boolean _isAutoAttackable = true; + public FriendlyNpcInstance(L2NpcTemplate template) { super(template); @@ -46,6 +50,58 @@ public class FriendlyNpcInstance extends L2Attackable return false; } + @Override + public boolean isAutoAttackable(L2Character attacker) + { + return _isAutoAttackable && !attacker.isPlayable(); + } + + @Override + public void setAutoAttackable(boolean state) + { + _isAutoAttackable = state; + } + + @Override + public void addDamage(L2Character attacker, int damage, Skill skill) + { + if (!attacker.isPlayer()) + { + super.addDamage(attacker, damage, skill); + } + + if (attacker.isAttackable()) + { + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(null, this, damage, skill, false), this); + } + } + + @Override + public void addDamageHate(L2Character attacker, int damage, int aggro) + { + if (!attacker.isPlayable()) + { + super.addDamageHate(attacker, damage, aggro); + } + } + + @Override + public boolean doDie(L2Character killer) + { + // Kill the L2NpcInstance (the corpse disappeared after 7 seconds) + if (!super.doDie(killer)) + { + return false; + } + + if (killer.isAttackable()) + { + // Delayed notification + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(null, this, false), this); + } + return true; + } + @Override public void onAction(L2PcInstance player, boolean interact) { @@ -70,10 +126,6 @@ public class FriendlyNpcInstance extends L2Attackable } else { - // Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance - // to display a social action of the L2GuardInstance on their client - broadcastPacket(new SocialAction(getObjectId(), Rnd.nextInt(8))); - player.setLastFolkNPC(this); // Open a chat window on client with the text of the L2GuardInstance diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java index 60fa4b1c8a..a22a385bee 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java @@ -38,12 +38,6 @@ public class FriendlyNpcAI extends L2AttackableAI super(attackable); } - @Override - protected void thinkActive() - { - - } - @Override protected void onEvtAttacked(L2Character attacker) { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java index bce431514c..c67abe7ebd 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java @@ -16,24 +16,28 @@ */ package com.l2jmobius.gameserver.model.actor.instance; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.FriendlyNpcAI; import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.model.actor.L2Attackable; +import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.events.EventDispatcher; import com.l2jmobius.gameserver.model.events.EventType; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableAttack; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableKill; import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk; +import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; -import com.l2jmobius.gameserver.network.serverpackets.SocialAction; /** - * @author Sdw + * @author GKR, Sdw */ public class FriendlyNpcInstance extends L2Attackable { + private boolean _isAutoAttackable = true; + public FriendlyNpcInstance(L2NpcTemplate template) { super(template); @@ -46,6 +50,58 @@ public class FriendlyNpcInstance extends L2Attackable return false; } + @Override + public boolean isAutoAttackable(L2Character attacker) + { + return _isAutoAttackable && !attacker.isPlayable(); + } + + @Override + public void setAutoAttackable(boolean state) + { + _isAutoAttackable = state; + } + + @Override + public void addDamage(L2Character attacker, int damage, Skill skill) + { + if (!attacker.isPlayer()) + { + super.addDamage(attacker, damage, skill); + } + + if (attacker.isAttackable()) + { + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(null, this, damage, skill, false), this); + } + } + + @Override + public void addDamageHate(L2Character attacker, int damage, int aggro) + { + if (!attacker.isPlayable()) + { + super.addDamageHate(attacker, damage, aggro); + } + } + + @Override + public boolean doDie(L2Character killer) + { + // Kill the L2NpcInstance (the corpse disappeared after 7 seconds) + if (!super.doDie(killer)) + { + return false; + } + + if (killer.isAttackable()) + { + // Delayed notification + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(null, this, false), this); + } + return true; + } + @Override public void onAction(L2PcInstance player, boolean interact) { @@ -70,10 +126,6 @@ public class FriendlyNpcInstance extends L2Attackable } else { - // Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance - // to display a social action of the L2GuardInstance on their client - broadcastPacket(new SocialAction(getObjectId(), Rnd.nextInt(8))); - player.setLastFolkNPC(this); // Open a chat window on client with the text of the L2GuardInstance diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java index 60fa4b1c8a..a22a385bee 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/ai/FriendlyNpcAI.java @@ -38,12 +38,6 @@ public class FriendlyNpcAI extends L2AttackableAI super(attackable); } - @Override - protected void thinkActive() - { - - } - @Override protected void onEvtAttacked(L2Character attacker) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java index bce431514c..c67abe7ebd 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/FriendlyNpcInstance.java @@ -16,24 +16,28 @@ */ package com.l2jmobius.gameserver.model.actor.instance; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.FriendlyNpcAI; import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.model.actor.L2Attackable; +import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.events.EventDispatcher; import com.l2jmobius.gameserver.model.events.EventType; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableAttack; +import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableKill; import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk; +import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; -import com.l2jmobius.gameserver.network.serverpackets.SocialAction; /** - * @author Sdw + * @author GKR, Sdw */ public class FriendlyNpcInstance extends L2Attackable { + private boolean _isAutoAttackable = true; + public FriendlyNpcInstance(L2NpcTemplate template) { super(template); @@ -46,6 +50,58 @@ public class FriendlyNpcInstance extends L2Attackable return false; } + @Override + public boolean isAutoAttackable(L2Character attacker) + { + return _isAutoAttackable && !attacker.isPlayable(); + } + + @Override + public void setAutoAttackable(boolean state) + { + _isAutoAttackable = state; + } + + @Override + public void addDamage(L2Character attacker, int damage, Skill skill) + { + if (!attacker.isPlayer()) + { + super.addDamage(attacker, damage, skill); + } + + if (attacker.isAttackable()) + { + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(null, this, damage, skill, false), this); + } + } + + @Override + public void addDamageHate(L2Character attacker, int damage, int aggro) + { + if (!attacker.isPlayable()) + { + super.addDamageHate(attacker, damage, aggro); + } + } + + @Override + public boolean doDie(L2Character killer) + { + // Kill the L2NpcInstance (the corpse disappeared after 7 seconds) + if (!super.doDie(killer)) + { + return false; + } + + if (killer.isAttackable()) + { + // Delayed notification + EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(null, this, false), this); + } + return true; + } + @Override public void onAction(L2PcInstance player, boolean interact) { @@ -70,10 +126,6 @@ public class FriendlyNpcInstance extends L2Attackable } else { - // Send a Server->Client packet SocialAction to the all L2PcInstance on the _knownPlayer of the L2NpcInstance - // to display a social action of the L2GuardInstance on their client - broadcastPacket(new SocialAction(getObjectId(), Rnd.nextInt(8))); - player.setLastFolkNPC(this); // Open a chat window on client with the text of the L2GuardInstance