Видел кто не будь, где не будь, рабочий вариант этого квеста, до куда должен идти нпц за чаром? до какова конкретного места? В прочем как не крутил, не хочет не за что следовать за персонажем не на шаг, не то что до указанного места (сам квест берётся корректно)
Вот до этого кода дошёл ))
ID 32764 невидимый NPC должен у обеих выходах быть?
Вот до этого кода дошёл ))
package quests;
import java.util.concurrent.ScheduledFuture;
import core.gameserver.ThreadPoolManager;
import core.gameserver.ai.CtrlIntention;
import core.gameserver.model.GameObjectsStorage;
import core.gameserver.model.Player;
import core.gameserver.model.instances.NpcInstance;
import core.gameserver.model.quest.Quest;
import core.gameserver.model.quest.QuestState;
import core.gameserver.scripts.ScriptFile;
public class _457_LostAndFound extends Quest implements ScriptFile
{
private ScheduledFuture<?> _followTask;
public _457_LostAndFound()
{
super(true);
addStartNpc(32759);
}
@Override
public void onLoad(){}
@Override
public void onReload(){}
@Override
public void onShutdown(){}
@Override
public String onEvent(String event, QuestState st, NpcInstance npc)
{
Player player = st.getPlayer();
if (event.equalsIgnoreCase("lost_villager_q0457_06.htm"))
{
st.setCond(1);
st.setState(2);
st.playSound("ItemSound.quest_accept");
npc.setFollowTarget(st.getPlayer());
if (_followTask != null)
{
_followTask.cancel(false);
_followTask = null;
}
_followTask = ThreadPoolManager.getInstance().scheduleAtFixedRate(new Follow(npc, player, st), 0L, 1000L);
}
return event;
}
@Override
public String onTalk(NpcInstance npc, QuestState st)
{
Player player = st.getPlayer();
int npcId = npc.getNpcId();
int state = st.getState();
int cond = st.getCond();
if (npcId == 32759)
{
if (state == 1)
{
if ((npc.getFollowTarget() != null) && (npc.getFollowTarget() != player))
{
return "lost_villager_q0457_01a.htm";
}
if (st.getPlayer().getLevel() >= 82)
{
if (st.isNowAvailable())
{
return "lost_villager_q0457_01.htm";
}
return "lost_villager_q0457_02.htm";
}
return "lost_villager_q0457_03.htm";
}
if (state == 2)
{
if ((npc.getFollowTarget() != null) && (npc.getFollowTarget() != player))
{
return "lost_villager_q0457_01a.htm";
}
if (cond == 1)
{
return "lost_villager_q0457_08.htm";
}
if (cond == 2)
{
npc.deleteMe();
st.giveItems(15716, 1);
st.unset("cond");
st.playSound("ItemSound.quest_finish");
st.exitCurrentQuest(this);
return "lost_villager_q0457_09.htm";
}
}
}
return "noquest";
}
void checkInRadius(int id, QuestState st, NpcInstance npc)
{
NpcInstance quest0457 = GameObjectsStorage.getByNpcId(id);
if (npc.getRealDistance3D(quest0457) <= 150.0D)
{
st.setCond(2);
if (_followTask != null)
{
_followTask.cancel(false);
}
_followTask = null;
npc.stopMove();
}
}
private class Follow implements Runnable
{
private final NpcInstance _npc;
private final Player player;
private final QuestState st;
Follow(NpcInstance npc, Player pl, QuestState _st)
{
_npc = npc;
player = pl;
st = _st;
}
@Override
public void run()
{
_npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player, Integer.valueOf(150));
checkInRadius(32764, st, _npc);
}
}
}
import java.util.concurrent.ScheduledFuture;
import core.gameserver.ThreadPoolManager;
import core.gameserver.ai.CtrlIntention;
import core.gameserver.model.GameObjectsStorage;
import core.gameserver.model.Player;
import core.gameserver.model.instances.NpcInstance;
import core.gameserver.model.quest.Quest;
import core.gameserver.model.quest.QuestState;
import core.gameserver.scripts.ScriptFile;
public class _457_LostAndFound extends Quest implements ScriptFile
{
private ScheduledFuture<?> _followTask;
public _457_LostAndFound()
{
super(true);
addStartNpc(32759);
}
@Override
public void onLoad(){}
@Override
public void onReload(){}
@Override
public void onShutdown(){}
@Override
public String onEvent(String event, QuestState st, NpcInstance npc)
{
Player player = st.getPlayer();
if (event.equalsIgnoreCase("lost_villager_q0457_06.htm"))
{
st.setCond(1);
st.setState(2);
st.playSound("ItemSound.quest_accept");
npc.setFollowTarget(st.getPlayer());
if (_followTask != null)
{
_followTask.cancel(false);
_followTask = null;
}
_followTask = ThreadPoolManager.getInstance().scheduleAtFixedRate(new Follow(npc, player, st), 0L, 1000L);
}
return event;
}
@Override
public String onTalk(NpcInstance npc, QuestState st)
{
Player player = st.getPlayer();
int npcId = npc.getNpcId();
int state = st.getState();
int cond = st.getCond();
if (npcId == 32759)
{
if (state == 1)
{
if ((npc.getFollowTarget() != null) && (npc.getFollowTarget() != player))
{
return "lost_villager_q0457_01a.htm";
}
if (st.getPlayer().getLevel() >= 82)
{
if (st.isNowAvailable())
{
return "lost_villager_q0457_01.htm";
}
return "lost_villager_q0457_02.htm";
}
return "lost_villager_q0457_03.htm";
}
if (state == 2)
{
if ((npc.getFollowTarget() != null) && (npc.getFollowTarget() != player))
{
return "lost_villager_q0457_01a.htm";
}
if (cond == 1)
{
return "lost_villager_q0457_08.htm";
}
if (cond == 2)
{
npc.deleteMe();
st.giveItems(15716, 1);
st.unset("cond");
st.playSound("ItemSound.quest_finish");
st.exitCurrentQuest(this);
return "lost_villager_q0457_09.htm";
}
}
}
return "noquest";
}
void checkInRadius(int id, QuestState st, NpcInstance npc)
{
NpcInstance quest0457 = GameObjectsStorage.getByNpcId(id);
if (npc.getRealDistance3D(quest0457) <= 150.0D)
{
st.setCond(2);
if (_followTask != null)
{
_followTask.cancel(false);
}
_followTask = null;
npc.stopMove();
}
}
private class Follow implements Runnable
{
private final NpcInstance _npc;
private final Player player;
private final QuestState st;
Follow(NpcInstance npc, Player pl, QuestState _st)
{
_npc = npc;
player = pl;
st = _st;
}
@Override
public void run()
{
_npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player, Integer.valueOf(150));
checkInRadius(32764, st, _npc);
}
}
}
Последнее редактирование: