Dropped OnNpcCreatureSee in favor of OnCreatureSee event.

This commit is contained in:
MobiusDevelopment
2021-06-23 02:05:25 +00:00
parent f6bc846256
commit fee7b294bb
581 changed files with 2730 additions and 6055 deletions

View File

@@ -34,6 +34,7 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
@@ -110,8 +111,8 @@ public class Baium extends AbstractNpcAI
addStartNpc(ANG_VORTEX, TELE_CUBE, BAIUM_STONE);
addAttackId(BAIUM, ARCHANGEL);
addKillId(BAIUM);
addSeeCreatureId(BAIUM);
addSpellFinishedId(BAIUM);
setCreatureSeeId(this::onCreatureSee, BAIUM);
final StatSet info = GrandBossManager.getInstance().getStatSet(BAIUM);
@@ -560,12 +561,12 @@ public class Baium extends AbstractNpcAI
return super.onKill(npc, killer, isSummon);
}
@Override
public String onSeeCreature(Npc npc, Creature creature, boolean isSummon)
public void onCreatureSee(OnCreatureSee event)
{
final Creature creature = event.getSeen();
if (!zone.isInsideZone(creature) || (creature.isNpc() && (creature.getId() == BAIUM_STONE)))
{
return super.onSeeCreature(npc, creature, isSummon);
return;
}
if (creature.isPlayer() && !creature.isDead() && (_standbyPlayer == null))
@@ -573,6 +574,7 @@ public class Baium extends AbstractNpcAI
_standbyPlayer = (PlayerInstance) creature;
}
final Npc npc = (Npc) event.getSeer();
if (creature.isInCategory(CategoryType.CLERIC_GROUP))
{
if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
@@ -597,7 +599,6 @@ public class Baium extends AbstractNpcAI
refreshAiParams(creature, npc, 10000, 1000);
}
manageSkills(npc);
return super.onSeeCreature(npc, creature, isSummon);
}
@Override

View File

@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.MerchantInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.ClanPrivilege;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.residences.ClanHall;
import org.l2jmobius.gameserver.model.residences.ResidenceFunction;
@@ -94,7 +95,7 @@ public class ClanHallManager extends AbstractNpcAI
addStartNpc(CLANHALL_MANAGERS);
addTalkId(CLANHALL_MANAGERS);
addFirstTalkId(CLANHALL_MANAGERS);
addSeeCreatureId(CLANHALL_MANAGERS);
setCreatureSeeId(this::onCreatureSee, CLANHALL_MANAGERS);
}
@Override
@@ -476,18 +477,18 @@ public class ClanHallManager extends AbstractNpcAI
return htmltext;
}
@Override
public String onSeeCreature(Npc npc, Creature creature, boolean isSummon)
public void onCreatureSee(OnCreatureSee event)
{
final Creature creature = event.getSeen();
if (creature.isPlayer())
{
final Npc npc = (Npc) event.getSeer();
final ClanHall clanHall = npc.getClanHall();
if (clanHall != null)
{
creature.getActingPlayer().sendPacket(new AgitDecoInfo(clanHall));
}
}
return super.onSeeCreature(npc, creature, isSummon);
}
private void updateVisualEffects(ClanHall clanHall, Npc npc)

View File

@@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.State;
@@ -53,7 +54,7 @@ public class Q00275_DarkWingedSpies extends Quest
addStartNpc(NERUGA_CHIEF_TANTUS);
addTalkId(NERUGA_CHIEF_TANTUS);
addKillId(DARKWING_BAT, VARANGKAS_TRACKER);
addSeeCreatureId(VARANGKAS_TRACKER);
setCreatureSeeId(this::onCreatureSee, VARANGKAS_TRACKER);
registerQuestItems(DARKWING_BAT_FANG, VARANGKAS_PARASITE);
}
@@ -109,16 +110,16 @@ public class Q00275_DarkWingedSpies extends Quest
return super.onKill(npc, killer, isSummon);
}
@Override
public String onSeeCreature(Npc npc, Creature creature, boolean isSummon)
public void onCreatureSee(OnCreatureSee event)
{
final Creature creature = event.getSeen();
if (creature.isPlayer())
{
final Npc npc = (Npc) event.getSeer();
npc.setRunning();
((Attackable) npc).addDamageHate(creature, 0, 1);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, creature);
}
return super.onSeeCreature(npc, creature, isSummon);
}
@Override

View File

@@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@@ -357,16 +355,6 @@ public class World
}
}
}
if (wo.isNpc() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) wo, (Creature) object, object.isSummon()), (Npc) wo);
}
if (object.isNpc() && wo.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) object, (Creature) wo, wo.isSummon()), (Npc) object);
}
});
}
@@ -580,16 +568,6 @@ public class World
}
}
}
if (wo.isNpc() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) wo, (Creature) object, object.isSummon()), (Npc) wo);
}
if (object.isNpc() && wo.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) object, (Creature) wo, wo.isSummon()), (Npc) object);
}
}
}
}

View File

@@ -85,7 +85,6 @@ import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableFacti
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableHate;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableKill;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCanBeSeen;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcDespawn;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcEventReceived;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcFirstTalk;
@@ -926,28 +925,6 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// ---------------------------------------------------------------------------------------------------------------------------
/**
* Provides instant callback operation when {@link Npc} sees another creature.
* @param callback
* @param npcIds
* @return
*/
protected final List<AbstractEventListener> setNpcCreatureSeeId(Consumer<OnNpcCreatureSee> callback, int... npcIds)
{
return registerConsumer(callback, EventType.ON_NPC_CREATURE_SEE, ListenerRegisterType.NPC, npcIds);
}
/**
* Provides instant callback operation when {@link Npc} sees another creature.
* @param callback
* @param npcIds
* @return
*/
protected final List<AbstractEventListener> setNpcCreatureSeeId(Consumer<OnNpcCreatureSee> callback, Collection<Integer> npcIds)
{
return registerConsumer(callback, EventType.ON_NPC_CREATURE_SEE, ListenerRegisterType.NPC, npcIds);
}
/**
* Provides instant callback operation when {@link Creature} sees another creature.
* @param callback

View File

@@ -43,7 +43,6 @@ import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableFacti
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableHate;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableKill;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCanBeSeen;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcDespawn;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcEventReceived;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcFirstTalk;
@@ -187,7 +186,6 @@ public enum EventType
// NPC events
ON_NPC_CAN_BE_SEEN(OnNpcCanBeSeen.class, void.class, TerminateReturn.class),
ON_NPC_CREATURE_SEE(OnNpcCreatureSee.class, void.class),
ON_NPC_EVENT_RECEIVED(OnNpcEventReceived.class, void.class),
ON_NPC_FIRST_TALK(OnNpcFirstTalk.class, void.class),
ON_NPC_HATE(OnAttackableHate.class, void.class, TerminateReturn.class),

View File

@@ -1,61 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.events.impl.creature.npc;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
/**
* An instantly executed event when Creature is killed by Creature.
* @author UnAfraid
*/
public class OnNpcCreatureSee implements IBaseEvent
{
private final Npc _npc;
private final Creature _creature;
private final boolean _isSummon;
public OnNpcCreatureSee(Npc npc, Creature creature, boolean isSummon)
{
_npc = npc;
_creature = creature;
_isSummon = isSummon;
}
public Npc getNpc()
{
return _npc;
}
public Creature getCreature()
{
return _creature;
}
public boolean isSummon()
{
return _isSummon;
}
@Override
public EventType getType()
{
return EventType.ON_NPC_CREATURE_SEE;
}
}

View File

@@ -816,37 +816,6 @@ public class Quest extends AbstractScript implements IIdentifiable
showResult(player, res);
}
/**
* @param npc the NPC that sees the creature
* @param creature the creature seen by the NPC
* @param isSummon
*/
public void notifySeeCreature(Npc npc, Creature creature, boolean isSummon)
{
PlayerInstance player = null;
if (isSummon || creature.isPlayer())
{
player = creature.getActingPlayer();
}
String res = null;
try
{
res = onSeeCreature(npc, creature, isSummon);
}
catch (Exception e)
{
if (player != null)
{
showError(player, e);
}
return;
}
if (player != null)
{
showResult(player, res);
}
}
/**
* @param eventName - name of event
* @param sender - NPC, who sent event
@@ -1295,18 +1264,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return null;
}
/**
* This function is called whenever a NPC "sees" a creature.
* @param npc the NPC who sees the creature
* @param creature the creature seen by the NPC
* @param isSummon this parameter if it's {@code false} it denotes that the character seen by the NPC was indeed the player, else it specifies that the character was the player's summon
* @return
*/
public String onSeeCreature(Npc npc, Creature creature, boolean isSummon)
{
return null;
}
/**
* This function is called whenever a player enters the game.
* @param player this parameter contains a reference to the exact instance of the player who is entering to the world.
@@ -2074,22 +2031,6 @@ public class Quest extends AbstractScript implements IIdentifiable
setAttackableAggroRangeEnterId(event -> notifyAggroRangeEnter(event.getNpc(), event.getActiveChar(), event.isSummon()), npcIds);
}
/**
* @param npcIds the IDs of the NPCs to register
*/
public void addSeeCreatureId(int... npcIds)
{
setNpcCreatureSeeId(event -> notifySeeCreature(event.getNpc(), event.getCreature(), event.isSummon()), npcIds);
}
/**
* @param npcIds the IDs of the NPCs to register
*/
public void addSeeCreatureId(Collection<Integer> npcIds)
{
setNpcCreatureSeeId(event -> notifySeeCreature(event.getNpc(), event.getCreature(), event.isSummon()), npcIds);
}
/**
* Register onEnterZone trigger for zone
* @param zoneId the ID of the zone to register