Addition of simplified quest onCreatureSee NPC id registration and method override.
This commit is contained in:
@@ -818,6 +818,36 @@ 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
|
||||
*/
|
||||
public void notifyCreatureSee(Npc npc, Creature creature)
|
||||
{
|
||||
PlayerInstance player = null;
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
player = creature.getActingPlayer();
|
||||
}
|
||||
String res = null;
|
||||
try
|
||||
{
|
||||
res = onCreatureSee(npc, creature);
|
||||
}
|
||||
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
|
||||
@@ -1282,6 +1312,17 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever an NPC "sees" a creature.
|
||||
* @param npc the NPC who sees the creature
|
||||
* @param creature the creature seen by the NPC
|
||||
* @return
|
||||
*/
|
||||
public String onCreatureSee(Npc npc, Creature creature)
|
||||
{
|
||||
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.
|
||||
@@ -2059,6 +2100,22 @@ 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 addCreatureSeeId(int... npcIds)
|
||||
{
|
||||
setCreatureSeeId(event -> notifyCreatureSee((Npc) event.getCreature(), event.getSeen()), npcIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param npcIds the IDs of the NPCs to register
|
||||
*/
|
||||
public void addCreatureSeeId(Collection<Integer> npcIds)
|
||||
{
|
||||
setCreatureSeeId(event -> notifyCreatureSee((Npc) event.getCreature(), event.getSeen()), npcIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register onEnterZone trigger for zone
|
||||
* @param zoneId the ID of the zone to register
|
||||
|
Reference in New Issue
Block a user