Moved EventType to a separate class.

This commit is contained in:
MobiusDevelopment 2020-01-24 17:05:10 +00:00
parent 4f5e72d88d
commit 90352a0447
25 changed files with 166 additions and 127 deletions

View File

@ -16,6 +16,7 @@
*/
package ai.bosses;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
/*
@ -30,7 +31,7 @@ public class Barakiel extends Quest
{
super(-1, "ai/bosses");
addEventId(BARAKIEL, Quest.QuestEventType.ON_ATTACK);
addEventId(BARAKIEL, EventType.ON_ATTACK);
}
// FIXME: Mobius - AI does nothing?

View File

@ -32,6 +32,7 @@ import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.Announcements;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -93,8 +94,8 @@ public class Core extends Quest
for (int mob : mobs)
{
addEventId(mob, Quest.QuestEventType.ON_KILL);
addEventId(mob, Quest.QuestEventType.ON_ATTACK);
addEventId(mob, EventType.ON_KILL);
addEventId(mob, EventType.ON_ATTACK);
}
_firstAttacked = false;

View File

@ -16,6 +16,7 @@
*/
package ai.bosses;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
/*
@ -30,7 +31,7 @@ public class Golkonda extends Quest
{
super(-1, "ai/bosses");
addEventId(GOLKONDA, Quest.QuestEventType.ON_ATTACK);
addEventId(GOLKONDA, EventType.ON_ATTACK);
}
// FIXME: Mobius - AI does nothing?

View File

@ -24,6 +24,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.spawn.Spawn;
@ -108,9 +109,9 @@ public class Gordon extends Quest
{
super(-1, "ai/bosses");
addEventId(GORDON, Quest.QuestEventType.ON_KILL);
addEventId(GORDON, Quest.QuestEventType.ON_ATTACK);
addEventId(GORDON, Quest.QuestEventType.ON_SPAWN);
addEventId(GORDON, EventType.ON_KILL);
addEventId(GORDON, EventType.ON_ATTACK);
addEventId(GORDON, EventType.ON_SPAWN);
// wait 2 minutes after Start AI
startQuestTimer("check_ai", 120000, null, null, true);

View File

@ -16,6 +16,7 @@
*/
package ai.bosses;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
/*
@ -30,7 +31,7 @@ public class Hallate extends Quest
{
super(-1, "ai/bosses");
addEventId(HALLATE, Quest.QuestEventType.ON_ATTACK);
addEventId(HALLATE, EventType.ON_ATTACK);
}
// FIXME: Mobius - AI does nothing?

View File

@ -31,6 +31,7 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.spawn.Spawn;
import org.l2jmobius.gameserver.model.zone.type.BossZone;
@ -65,9 +66,9 @@ public class IceFairySirra extends Quest
for (int mob : mobs)
{
// TODO:
addEventId(mob, Quest.QuestEventType.QUEST_START);
addEventId(mob, Quest.QuestEventType.QUEST_TALK);
addEventId(mob, Quest.QuestEventType.NPC_FIRST_TALK);
addEventId(mob, EventType.QUEST_START);
addEventId(mob, EventType.QUEST_TALK);
addEventId(mob, EventType.NPC_FIRST_TALK);
}
init();

View File

@ -16,6 +16,7 @@
*/
package ai.bosses;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
/*
@ -30,7 +31,7 @@ public class Kernon extends Quest
{
super(-1, "ai/bosses");
addEventId(KERNON, Quest.QuestEventType.ON_ATTACK);
addEventId(KERNON, EventType.ON_ATTACK);
}
// FIXME: Mobius - AI does nothing?

View File

@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.Announcements;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -57,8 +58,8 @@ public class Orfen extends Quest
final StatsSet info = GrandBossManager.getInstance().getStatsSet(ORFEN);
final Integer status = GrandBossManager.getInstance().getBossStatus(ORFEN);
addEventId(ORFEN, Quest.QuestEventType.ON_KILL);
addEventId(ORFEN, Quest.QuestEventType.ON_ATTACK);
addEventId(ORFEN, EventType.ON_KILL);
addEventId(ORFEN, EventType.ON_ATTACK);
switch (status)
{

View File

@ -31,6 +31,7 @@ import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.Announcements;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.zone.type.BossZone;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -84,8 +85,8 @@ public class QueenAnt extends Quest
};
for (int mob : mobs)
{
addEventId(mob, Quest.QuestEventType.ON_KILL);
addEventId(mob, Quest.QuestEventType.ON_ATTACK);
addEventId(mob, EventType.ON_KILL);
addEventId(mob, EventType.ON_ATTACK);
}
_zone = GrandBossManager.getInstance().getZone(-21610, 181594, -5734);

View File

@ -47,6 +47,7 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.RaidBossInstance;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.spawn.Spawn;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
@ -132,10 +133,10 @@ public class VanHalter extends Quest
32066
};
addEventId(29062, Quest.QuestEventType.ON_ATTACK);
addEventId(29062, EventType.ON_ATTACK);
for (int mob : mobs)
{
addEventId(mob, Quest.QuestEventType.ON_KILL);
addEventId(mob, EventType.ON_KILL);
}
// GrandBossManager.getInstance().addBoss(29062);

View File

@ -34,6 +34,7 @@ import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.zone.type.BossZone;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -157,8 +158,8 @@ public class Zaken extends Quest
}
}, 2000L, 600000L);
addEventId(ZAKEN, Quest.QuestEventType.ON_KILL);
addEventId(ZAKEN, Quest.QuestEventType.ON_ATTACK);
addEventId(ZAKEN, EventType.ON_KILL);
addEventId(ZAKEN, EventType.ON_ATTACK);
_Zone = GrandBossManager.getInstance().getZone(55312, 219168, -3223);

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.util.Util;
@ -62,8 +63,8 @@ public class Monastery extends Quest
public Monastery()
{
super(-1, "ai");
registerMobs(MOBS_1, QuestEventType.ON_AGGRO_RANGE_ENTER, QuestEventType.ON_SPAWN, QuestEventType.ON_SPELL_FINISHED);
registerMobs(MOBS_2, QuestEventType.ON_SPELL_FINISHED);
registerMobs(MOBS_1, EventType.ON_AGGRO_RANGE_ENTER, EventType.ON_SPAWN, EventType.ON_SPELL_FINISHED);
registerMobs(MOBS_2, EventType.ON_SPELL_FINISHED);
}
@Override

View File

@ -29,6 +29,7 @@ import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -136,8 +137,8 @@ public class SummonMinions extends Quest
for (int mob : mobs)
{
addEventId(mob, Quest.QuestEventType.ON_KILL);
addEventId(mob, Quest.QuestEventType.ON_ATTACK);
addEventId(mob, EventType.ON_KILL);
addEventId(mob, EventType.ON_ATTACK);
}
}

View File

@ -25,6 +25,7 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -112,7 +113,7 @@ public class Transform extends Quest
for (int mob : mobsKill)
{
addEventId(mob, Quest.QuestEventType.ON_KILL);
addEventId(mob, EventType.ON_KILL);
}
final int[] mobsAttack =
@ -132,7 +133,7 @@ public class Transform extends Quest
for (int mob : mobsAttack)
{
addEventId(mob, Quest.QuestEventType.ON_ATTACK);
addEventId(mob, EventType.ON_ATTACK);
}
}

View File

@ -52,6 +52,7 @@ import org.l2jmobius.gameserver.model.actor.instance.RaidBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvaderInstance;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
/**
@ -452,7 +453,7 @@ public class AttackableAI extends CreatureAI
{
final PlayerInstance targetPlayer = obj instanceof PlayerInstance ? (PlayerInstance) obj : ((Summon) obj).getOwner();
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_AGGRO_RANGE_ENTER))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_AGGRO_RANGE_ENTER))
{
quest.notifyAggroRangeEnter(npc, targetPlayer, obj instanceof Summon);
}
@ -676,8 +677,8 @@ public class AttackableAI extends CreatureAI
* mobs else if ("c_dungeon_nephi".equals(faction_id) && "c_dungeon_clan".equals(npcfaction)) sevenSignFaction = true; if (!faction_id.equals(npc.getFactionId()) && !sevenSignFaction) continue; // Check if the WorldObject is inside the Faction Range of // the actor if
* (_actor.isInsideRadius(npc, npc.getFactionRange() + npc.getTemplate().collisionRadius, true, false) && npc.getAI() != null) { if (Math.abs(originalAttackTarget.getZ() - npc.getZ()) < 600 && _actor.getAttackByList().contains(originalAttackTarget) && (npc.getAI()._intention ==
* CtrlIntention.AI_INTENTION_IDLE || npc.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE) && GeoEngine.getInstance().canSeeTarget(_actor, npc)) { if ((originalAttackTarget instanceof PlayerInstance) || (originalAttackTarget instanceof Summon)) { if
* (npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_FACTION_CALL) != null) { PlayerInstance player = (originalAttackTarget instanceof PlayerInstance) ? (PlayerInstance) originalAttackTarget : ((Summon) originalAttackTarget).getOwner(); for (Quest quest :
* npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_FACTION_CALL)) quest.notifyFactionCall(npc, (NpcInstance) _actor, player, (originalAttackTarget instanceof Summon)); } } else if (npc instanceof Attackable && getAttackTarget() != null && npc.getAI()._intention !=
* (npc.getTemplate().getEventQuests(EventType.ON_FACTION_CALL) != null) { PlayerInstance player = (originalAttackTarget instanceof PlayerInstance) ? (PlayerInstance) originalAttackTarget : ((Summon) originalAttackTarget).getOwner(); for (Quest quest :
* npc.getTemplate().getEventQuests(EventType.ON_FACTION_CALL)) quest.notifyFactionCall(npc, (NpcInstance) _actor, player, (originalAttackTarget instanceof Summon)); } } else if (npc instanceof Attackable && getAttackTarget() != null && npc.getAI()._intention !=
* CtrlIntention.AI_INTENTION_ATTACK) { ((Attackable) npc).addDamageHate(getAttackTarget(), 0, ((Attackable) _actor).getHating(getAttackTarget())); npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, getAttackTarget()); } } } } } } catch (NullPointerException e) { LOGGER.warning(
* "AttackableAI: thinkAttack() faction call failed: " + e.getMessage()); } }
*/
@ -725,7 +726,7 @@ public class AttackableAI extends CreatureAI
if ((originalAttackTarget instanceof PlayerInstance) || (originalAttackTarget instanceof Summon))
{
final PlayerInstance player = originalAttackTarget instanceof PlayerInstance ? (PlayerInstance) originalAttackTarget : ((Summon) originalAttackTarget).getOwner();
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_FACTION_CALL))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_FACTION_CALL))
{
quest.notifyFactionCall(npc, (NpcInstance) _actor, player, (originalAttackTarget instanceof Summon));
}

View File

@ -56,6 +56,7 @@ import org.l2jmobius.gameserver.model.base.SoulCrystal;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.EtcItemType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.Stats;
import org.l2jmobius.gameserver.network.SystemMessageId;
@ -552,7 +553,7 @@ public class Attackable extends NpcInstance
final PlayerInstance player = killer instanceof PlayerInstance ? (PlayerInstance) killer : ((Summon) killer).getOwner();
// only 1 randomly choosen quest of all quests registered to this character can be applied
for (Quest quest : getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL))
for (Quest quest : getTemplate().getEventQuests(EventType.ON_KILL))
{
quest.notifyKill(this, player, killer instanceof Summon);
}
@ -1027,7 +1028,7 @@ public class Attackable extends NpcInstance
{
final PlayerInstance player = attacker instanceof PlayerInstance ? (PlayerInstance) attacker : ((Summon) attacker).getOwner();
for (Quest quest : getTemplate().getEventQuests(Quest.QuestEventType.ON_ATTACK))
for (Quest quest : getTemplate().getEventQuests(EventType.ON_ATTACK))
{
quest.notifyAttack(this, player, damage, attacker instanceof Summon);
}

View File

@ -96,6 +96,7 @@ import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.skills.Calculator;
@ -8111,7 +8112,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
{
final PlayerInstance player = target instanceof PlayerInstance ? (PlayerInstance) target : ((Summon) target).getOwner();
for (Quest quest : ((NpcTemplate) _template).getEventQuests(Quest.QuestEventType.ON_SPELL_FINISHED))
for (Quest quest : ((NpcTemplate) _template).getEventQuests(EventType.ON_SPELL_FINISHED))
{
quest.notifySpellFinished(((NpcInstance) this), player, skill);
}
@ -8625,7 +8626,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
{
final NpcInstance npc = (NpcInstance) target;
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_USE))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_SKILL_USE))
{
quest.notifySkillUse(npc, caster, skill);
}

View File

@ -70,6 +70,7 @@ import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.model.multisell.Multisell;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.State;
@ -765,7 +766,7 @@ public class NpcInstance extends Creature
}
else
{
final List<Quest> questList = getTemplate().getEventQuests(Quest.QuestEventType.NPC_FIRST_TALK);
final List<Quest> questList = getTemplate().getEventQuests(EventType.NPC_FIRST_TALK);
if (questList.size() == 1)
{
questList.get(0).notifyFirstTalk(this, player);
@ -1096,7 +1097,7 @@ public class NpcInstance extends Creature
}
else
{
final List<Quest> questList = getTemplate().getEventQuests(Quest.QuestEventType.NPC_FIRST_TALK);
final List<Quest> questList = getTemplate().getEventQuests(EventType.NPC_FIRST_TALK);
if (questList.size() == 1)
{
questList.get(0).notifyFirstTalk(this, player);
@ -1832,7 +1833,7 @@ public class NpcInstance extends Creature
}
}
// Check for start point
for (Quest temp : getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START))
for (Quest temp : getTemplate().getEventQuests(EventType.QUEST_START))
{
if (temp == q)
{
@ -1878,7 +1879,7 @@ public class NpcInstance extends Creature
final List<Quest> options = new ArrayList<>();
final List<QuestState> awaits = player.getQuestsForTalk(getTemplate().npcId);
final List<Quest> starts = getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START);
final List<Quest> starts = getTemplate().getEventQuests(EventType.QUEST_START);
// Quests are limited between 1 and 999 because those are the quests that are supported by the client.
// By limiting them there, we are allowed to create custom quests at higher IDs without interfering

View File

@ -156,6 +156,7 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.ArmorType;
import org.l2jmobius.gameserver.model.items.type.EtcItemType;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.State;
@ -1624,7 +1625,7 @@ public class PlayerInstance extends Playable
List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ATTACK))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_ATTACK))
{
// Check if the Identifier of the Attackable attck is needed for the current quest
if (getQuestState(quest.getName()) != null)
@ -1649,7 +1650,7 @@ public class PlayerInstance extends Playable
List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_KILL))
{
// Check if the Identifier of the Attackable killed is needed for the current quest
if (getQuestState(quest.getName()) != null)
@ -1674,7 +1675,7 @@ public class PlayerInstance extends Playable
List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests
for (Quest quest : NpcTable.getInstance().getTemplate(npcId).getEventQuests(Quest.QuestEventType.QUEST_TALK))
for (Quest quest : NpcTable.getInstance().getTemplate(npcId).getEventQuests(EventType.QUEST_TALK))
{
// Copy the current PlayerInstance QuestState in the QuestState table
if ((quest != null) && (getQuestState(quest.getName()) != null))

View File

@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.instancemanager.FourSepulchersManager;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -239,11 +240,11 @@ public class SepulcherNpcInstance extends NpcInstance
}
default:
{
if (!getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START).isEmpty())
if (!getTemplate().getEventQuests(EventType.QUEST_START).isEmpty())
{
player.setLastQuestNpcObject(getObjectId());
}
final List<Quest> questList = getTemplate().getEventQuests(Quest.QuestEventType.QUEST_TALK);
final List<Quest> questList = getTemplate().getEventQuests(EventType.QUEST_TALK);
if (questList.size() == 1)
{
questList.get(0).notifyFirstTalk(this, player);

View File

@ -31,7 +31,7 @@ import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.base.ClassId;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.Quest.QuestEventType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.skills.Stats;
/**
@ -126,7 +126,7 @@ public class NpcTemplate extends CreatureTemplate
private final Map<Integer, Skill> _skills = new HashMap<>();
private final Map<Stats, Double> _vulnerabilities = new EnumMap<>(Stats.class);
// contains a list of quests for each event type (questStart, questAttack, questKill, etc)
private final Map<QuestEventType, List<Quest>> _questEvents = new EnumMap<>(QuestEventType.class);
private final Map<EventType, List<Quest>> _questEvents = new EnumMap<>(EventType.class);
/**
* Constructor of Creature.<BR>
@ -298,7 +298,7 @@ public class NpcTemplate extends CreatureTemplate
return _skills;
}
public void addQuestEvent(Quest.QuestEventType eventType, Quest q)
public void addQuestEvent(EventType eventType, Quest q)
{
if (_questEvents.get(eventType) == null)
{
@ -342,7 +342,7 @@ public class NpcTemplate extends CreatureTemplate
}
}
public List<Quest> getEventQuests(Quest.QuestEventType eventType)
public List<Quest> getEventQuests(EventType eventType)
{
if (_questEvents.get(eventType) == null)
{

View File

@ -32,6 +32,7 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.WeaponType;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.Env;
import org.l2jmobius.gameserver.model.skills.conditions.ConditionGameChance;
@ -426,7 +427,7 @@ public class Weapon extends Item
if ((caster instanceof PlayerInstance) && (target instanceof NpcInstance))
{
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_USE))
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(EventType.ON_SKILL_USE))
{
quest.notifySkillUse((NpcInstance) target, (PlayerInstance) caster, skill);
}

View File

@ -0,0 +1,66 @@
/*
* 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.quest;
/**
* @author Mobius
*/
public enum EventType
{
/** Control the first dialog shown by NPCs when they are clicked (some quests must override the default npc action) */
NPC_FIRST_TALK(false),
/** onTalk action from start npcs */
QUEST_START(true),
/** onTalk action from npcs participating in a quest */
QUEST_TALK(true),
/** Call a faction for support */
ON_FACTION_CALL(true),
/** on spell finished action when npc finish casting skill */
ON_SPELL_FINISHED(true),
/** a person came within the Npc/Mob's range */
ON_AGGRO_RANGE_ENTER(true),
/** onSpawn action triggered when an NPC is spawned or respawned */
ON_SPAWN(true),
/** NPC or Mob saw a person casting a skill (regardless what the target is) */
ON_SKILL_USE(true),
/** onKill action triggered when a mob gets killed */
ON_KILL(true),
/** onAttack action triggered when a mob gets attacked by someone */
ON_ATTACK(true);
// Control whether this event type is allowed for the same npc template in multiple quests or if the npc must be registered in at most one quest for the specified event.
private boolean _allowMultipleRegistration;
EventType(boolean allowMultipleRegistration)
{
_allowMultipleRegistration = allowMultipleRegistration;
}
public boolean isMultipleRegistrationAllowed()
{
return _allowMultipleRegistration;
}
}

View File

@ -189,54 +189,6 @@ public class Quest extends ManagedScript
{
}
public enum QuestEventType
{
/**
* control the first dialog shown by NPCs when they are clicked (some quests must override the default npc action)
*/
NPC_FIRST_TALK(false),
/** onTalk action from start npcs */
QUEST_START(true),
/** onTalk action from npcs participating in a quest */
QUEST_TALK(true),
/** Call a faction for support */
ON_FACTION_CALL(true),
/** on spell finished action when npc finish casting skill */
ON_SPELL_FINISHED(true),
/** a person came within the Npc/Mob's range */
ON_AGGRO_RANGE_ENTER(true),
/** OnSpawn действие при спауне моба */
ON_SPAWN(true),
/** OnSkillUse действие при использовании скилла (MOB_TARGETED_BY_SKILL) */
ON_SKILL_USE(true),
/** OnKill действие при убийстве (MOBKILLED) */
ON_KILL(true),
/** OnAttack действие при атаке (MOBGOTATTACKED) */
ON_ATTACK(true);
// Control whether this event type is allowed for the same npc template in multiple quests or if the npc must be registered in at most one quest for the specified event.
private boolean _allowMultipleRegistration;
QuestEventType(boolean allowMultipleRegistration)
{
_allowMultipleRegistration = allowMultipleRegistration;
}
public boolean isMultipleRegistrationAllowed()
{
return _allowMultipleRegistration;
}
}
/**
* Return ID of the quest
* @return int
@ -876,14 +828,14 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addStartNpc(int npcId)
{
return addEventId(npcId, QuestEventType.QUEST_START);
return addEventId(npcId, EventType.QUEST_START);
}
public void addStartNpc(int... npcIds)
{
for (int npcId : npcIds)
{
addEventId(npcId, QuestEventType.QUEST_START);
addEventId(npcId, EventType.QUEST_START);
}
}
@ -894,14 +846,14 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addFirstTalkId(int npcId)
{
return addEventId(npcId, QuestEventType.NPC_FIRST_TALK);
return addEventId(npcId, EventType.NPC_FIRST_TALK);
}
public void addFirstTalkId(int... npcIds)
{
for (int npcId : npcIds)
{
addEventId(npcId, QuestEventType.NPC_FIRST_TALK);
addEventId(npcId, EventType.NPC_FIRST_TALK);
}
}
@ -913,14 +865,14 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addAttackId(int attackId)
{
return addEventId(attackId, QuestEventType.ON_ATTACK);
return addEventId(attackId, EventType.ON_ATTACK);
}
public void addAttackId(int... attackIds)
{
for (int attackId : attackIds)
{
addEventId(attackId, QuestEventType.ON_ATTACK);
addEventId(attackId, EventType.ON_ATTACK);
}
}
@ -932,7 +884,7 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addKillId(int killId)
{
return addEventId(killId, QuestEventType.ON_KILL);
return addEventId(killId, EventType.ON_KILL);
}
/**
@ -943,7 +895,7 @@ public class Quest extends ManagedScript
{
for (int killId : killIds)
{
addEventId(killId, QuestEventType.ON_KILL);
addEventId(killId, EventType.ON_KILL);
}
}
@ -955,7 +907,7 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addTalkId(int talkId)
{
return addEventId(talkId, QuestEventType.QUEST_TALK);
return addEventId(talkId, EventType.QUEST_TALK);
}
/**
@ -966,13 +918,13 @@ public class Quest extends ManagedScript
{
for (int talkId : talkIds)
{
addEventId(talkId, QuestEventType.QUEST_TALK);
addEventId(talkId, EventType.QUEST_TALK);
}
}
public NpcTemplate addFactionCallId(int npcId)
{
return addEventId(npcId, QuestEventType.ON_FACTION_CALL);
return addEventId(npcId, EventType.ON_FACTION_CALL);
}
/**
@ -983,20 +935,20 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addSkillUseId(int npcId)
{
return addEventId(npcId, QuestEventType.ON_SKILL_USE);
return addEventId(npcId, EventType.ON_SKILL_USE);
}
public void addSkillUseId(int... npcIds)
{
for (int npcId : npcIds)
{
addEventId(npcId, QuestEventType.ON_SKILL_USE);
addEventId(npcId, EventType.ON_SKILL_USE);
}
}
public NpcTemplate addSpellFinishedId(int npcId)
{
return addEventId(npcId, QuestEventType.ON_SPELL_FINISHED);
return addEventId(npcId, EventType.ON_SPELL_FINISHED);
}
/**
@ -1007,27 +959,27 @@ public class Quest extends ManagedScript
*/
public NpcTemplate addAggroRangeEnterId(int npcId)
{
return addEventId(npcId, QuestEventType.ON_AGGRO_RANGE_ENTER);
return addEventId(npcId, EventType.ON_AGGRO_RANGE_ENTER);
}
public void addAggroRangeEnterId(int... npcIds)
{
for (int npcId : npcIds)
{
addEventId(npcId, QuestEventType.ON_AGGRO_RANGE_ENTER);
addEventId(npcId, EventType.ON_AGGRO_RANGE_ENTER);
}
}
public NpcTemplate addSpawnId(int npcId)
{
return addEventId(npcId, QuestEventType.ON_SPAWN);
return addEventId(npcId, EventType.ON_SPAWN);
}
public void addSpawnId(int... npcIds)
{
for (int npcId : npcIds)
{
addEventId(npcId, QuestEventType.ON_SPAWN);
addEventId(npcId, EventType.ON_SPAWN);
}
}
@ -1054,12 +1006,11 @@ public class Quest extends ManagedScript
* @param eventType : type of event being registered
* @return NpcTemplate : Npc Template corresponding to the npcId, or null if the id is invalid
*/
public NpcTemplate addEventId(int npcId, QuestEventType eventType)
public NpcTemplate addEventId(int npcId, EventType eventType)
{
try
{
final NpcTemplate t = NpcTable.getInstance().getTemplate(npcId);
if (t != null)
{
t.addQuestEvent(eventType, this);
@ -1870,21 +1821,21 @@ public class Quest extends ManagedScript
/**
* This is used to register all monsters contained in mobs for a particular script<BR>
* <FONT COLOR=#FF0000><B> <U>Caution</U> : This method register ID for all QuestEventTypes<BR>
* <FONT COLOR=#FF0000><B> <U>Caution</U> : This method register ID for all EventTypes<BR>
* Do not use for group_template AIs</B></FONT><BR>
* @param mobs
* @see #registerMobs(int[], QuestEventType...)
* @see #registerMobs(int[], EventType...)
*/
public void registerMobs(int[] mobs)
{
for (int id : mobs)
{
addEventId(id, QuestEventType.ON_ATTACK);
addEventId(id, QuestEventType.ON_KILL);
addEventId(id, QuestEventType.ON_SPAWN);
addEventId(id, QuestEventType.ON_SPELL_FINISHED);
addEventId(id, QuestEventType.ON_FACTION_CALL);
addEventId(id, QuestEventType.ON_AGGRO_RANGE_ENTER);
addEventId(id, EventType.ON_ATTACK);
addEventId(id, EventType.ON_KILL);
addEventId(id, EventType.ON_SPAWN);
addEventId(id, EventType.ON_SPELL_FINISHED);
addEventId(id, EventType.ON_FACTION_CALL);
addEventId(id, EventType.ON_AGGRO_RANGE_ENTER);
}
}
@ -1893,11 +1844,11 @@ public class Quest extends ManagedScript
* @param mobs
* @param types
*/
public void registerMobs(int[] mobs, QuestEventType... types)
public void registerMobs(int[] mobs, EventType... types)
{
for (int id : mobs)
{
for (QuestEventType type : types)
for (EventType type : types)
{
addEventId(id, type);
}

View File

@ -28,6 +28,7 @@ import org.l2jmobius.gameserver.idfactory.IdFactory;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.quest.EventType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -543,7 +544,7 @@ public class Spawn
_lastSpawn = npc;
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_SPAWN))
for (Quest quest : npc.getTemplate().getEventQuests(EventType.ON_SPAWN))
{
quest.notifySpawn(npc);
}