06-29-2012, 12:18 PM
после выполнения данного действия:
получаю квест и должно портануть в музей но не че не происходит при попытке поговорить с NPC этот же квест можно опять взять и так без конечно хотя в базе прописано что квест уже взят портанулся я через корды Гмом книги нигде нету ну и соответственно нету мобов которые дожны напасть вот скрипт :PHP код:
<?php
Pantheon:Thank you!When you get to the museum, you should see a number of desks - one of them has The War of Giants and Godson it. Find it, and bring it to me.<br>Would you like to go to the museum?[Quest _10327_BookOfGiants enter_instance|"Yes."]
PHP код:
<?php
package quests;
import java.util.List;
import l2p.commons.util.Rnd;
import l2p.gameserver.ai.CtrlIntention;
import l2p.gameserver.model.instances.NpcInstance;
import l2p.gameserver.model.quest.Quest;
import l2p.gameserver.model.quest.QuestState;
import l2p.gameserver.scripts.ScriptFile;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.Skill;
import l2p.gameserver.model.entity.Reflection;
import l2p.gameserver.utils.Location;
import l2p.gameserver.utils.ReflectionUtils;
/**
* Quest "Intruder Who Wants the Book of Giants"
*
* @author Yorie
*/
public class _10327_BookOfGiants extends Quest implements ScriptFile
{
private static final int PANTHEON = 32972;
private static final int DESK = 33126;
private static final int THIEF = 23121;
private static final int TOYRON = 33004;
private static final int APPRENTICE_EARRING = 112;
// Desk that have the book of giants
private int bookDeskObjectId = 0;
private boolean bookTaken = false;
private int thievesKilled = 0;
private NpcInstance toyron = null;
private static final int BOOK_OF_GIANTS = 17575;
private static final int INSTANCE_ID = 182;
public _10327_BookOfGiants()
{
super(false);
addStartNpc(PANTHEON);
addFirstTalkId(DESK);
addQuestItem(BOOK_OF_GIANTS);
addAttackId(THIEF);
addSkillUseId(THIEF);
addKillId(THIEF);
addFirstTalkId(TOYRON);
}
@Override
public String onEvent(String event, QuestState st, NpcInstance npc)
{
String htmltext = event;
if(event.equalsIgnoreCase("enter_instance"))
{
htmltext = "";
st.setState(STARTED);
st.setCond(1);
st.playSound(SOUND_ACCEPT);
bookTaken = false;
enterInstance(st.getPlayer());
st.startQuestTimer("follow_player", 5000);
toyron = st.getPlayer().getActiveReflection().getAllByNpcId(TOYRON, true).get(0);
if (toyron != null)
toyron.setRunning();
}
else if (st.getCond() == 3 && event.equalsIgnoreCase("quest_done"))
{
htmltext = "pantheon_q10327_5.htm";
st.getPlayer().addExpAndSp(7800, 3500);
st.giveItems(ADENA_ID, 16000);
st.giveItems(APPRENTICE_EARRING, 2);
st.exitCurrentQuest(false);
st.playSound(SOUND_FINISH);
}
else if (event.equalsIgnoreCase("follow_player"))
{
htmltext = "";
if (st.getCond() == 2)
{
if (toyron != null)
{
toyron.setRunning();
toyron.moveToLocation(st.getPlayer().getLoc(), Rnd.get(0, 50), true);
}
st.startQuestTimer("follow_player", 5000);
}
}
return htmltext;
}
@Override
public String onTalk(NpcInstance npc, QuestState st)
{
String htmltext = "noquest";
int npcId = npc.getNpcId();
int cond = st.getCond();
QuestState reqQuest = st.getPlayer().getQuestState("_10326_RespectYourElders");
switch(npcId)
{
case PANTHEON:
htmltext = "pantheon_q10327_1.htm";
if (cond == 3)
htmltext = "pantheon_q10327_4.htm";
break;
}
return htmltext;
}
@Override
public String onFirstTalk(NpcInstance npc, Player player)
{
String htmltext = "noquest";
int npcId = npc.getNpcId();
switch (npcId)
{
case DESK:
if (npc.getObjectId() == bookDeskObjectId && !bookTaken)
{
bookTaken = true;
htmltext = "desk_q10327_book.htm";
QuestState qs = player.getQuestState(_10327_BookOfGiants.class);
player.getActiveReflection().addSpawnWithoutRespawn(THIEF, new Location(-114835, 244966, -7976, 16072), 0);
player.getActiveReflection().addSpawnWithoutRespawn(THIEF, new Location(-114564, 244954, -7976, 16072), 0);
qs.takeAllItems(BOOK_OF_GIANTS); // Don't let to have more than one item
qs.giveItems(BOOK_OF_GIANTS, 1);
qs.setCond(2);
}
else
htmltext = "desk_q10327_nobook.htm";
break;
case TOYRON:
if (player.getQuestState(_10327_BookOfGiants.class) != null &&
player.getQuestState(_10327_BookOfGiants.class).getCond() == 3)
htmltext = "toyron_q10327_1.htm";
break;
}
return htmltext;
}
/**
* Toyron will attack only target, that is THIEF and only if target was attacked with magic by player
*
* @param npc Attacked NPC
* @param qs Current quest state
* @return HTML message
*/
@Override
public String onSkillUse(NpcInstance npc, Skill skill, QuestState qs)
{
if (npc.getNpcId() == THIEF)
{
if (toyron != null)
{
toyron.setRunning();
toyron.getAggroList().addDamageHate(npc, 0, 10000);
toyron.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK);
++thievesKilled;
if (thievesKilled >= 2)
qs.setCond(3);
}
}
return "";
}
private void enterInstance(Player player)
{
Reflection reflection = player.getActiveReflection();
if(reflection != null)
{
if(player.canReenterInstance(INSTANCE_ID))
player.teleToLocation(reflection.getTeleportLoc(), reflection);
}
else if(player.canEnterInstance(INSTANCE_ID))
ReflectionUtils.enterReflection(player, INSTANCE_ID);
List<NpcInstance> desks = player.getActiveReflection().getAllByNpcId(DESK, true);
double seed = Math.random();
int counter = 0;
// Selecting one of desks to contain book of giants
for (NpcInstance desk : desks)
{
if ((seed <= 0.25 && counter == 0) ||
(seed > 0.25 && seed <= 0.5 && counter == 1) ||
(seed > 0.5 && seed <= 0.75 && counter == 2) ||
(seed > 0.75 && counter == 3))
bookDeskObjectId = desk.getObjectId();
++counter;
}
// In some unusual cases we might have not 4 spawned desks, preventing from errors
if (bookDeskObjectId == 0 && desks.size() > 0)
bookDeskObjectId = desks.get(0).getObjectId();
}
@Override
public void onLoad() {}
@Override
public void onReload() {}
@Override
public void onShutdown() {}
}