|
@@ -35,7 +35,6 @@ import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
|
|
|
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
|
|
|
import net.sf.l2j.gameserver.network.SystemMessageId;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.ExShowQuestMark;
|
|
|
-import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.QuestList;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
|
|
@@ -53,22 +52,22 @@ import net.sf.l2j.util.Rnd;
|
|
|
public final class QuestState
|
|
|
{
|
|
|
protected static final Logger _log = Logger.getLogger(Quest.class.getName());
|
|
|
-
|
|
|
+
|
|
|
/** Quest associated to the QuestState */
|
|
|
private final String _questName;
|
|
|
-
|
|
|
+
|
|
|
/** Player who engaged the quest */
|
|
|
private final L2PcInstance _player;
|
|
|
-
|
|
|
+
|
|
|
/** State of the quest */
|
|
|
private byte _state;
|
|
|
-
|
|
|
+
|
|
|
/** List of couples (variable for quest,value of the variable for quest) */
|
|
|
private Map<String, String> _vars;
|
|
|
-
|
|
|
+
|
|
|
/** Boolean flag letting QuestStateManager know to exit quest when cleaning up */
|
|
|
private boolean _isExitQuestOnCleanUp = false;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Constructor of the QuestState : save the quest in the list of quests of the player.<BR/><BR/>
|
|
|
*
|
|
@@ -93,12 +92,12 @@ public final class QuestState
|
|
|
// set the state of the quest
|
|
|
_state = state;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public String getQuestName()
|
|
|
{
|
|
|
return _questName;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the quest
|
|
|
* @return Quest
|
|
@@ -107,7 +106,7 @@ public final class QuestState
|
|
|
{
|
|
|
return QuestManager.getInstance().getQuest(_questName);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the L2PcInstance
|
|
|
* @return L2PcInstance
|
|
@@ -116,7 +115,7 @@ public final class QuestState
|
|
|
{
|
|
|
return _player;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the state of the quest
|
|
|
* @return State
|
|
@@ -125,7 +124,7 @@ public final class QuestState
|
|
|
{
|
|
|
return _state;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return true if quest completed, false otherwise
|
|
|
* @return boolean
|
|
@@ -134,7 +133,7 @@ public final class QuestState
|
|
|
{
|
|
|
return (getState() == State.COMPLETED);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return true if quest started, false otherwise
|
|
|
* @return boolean
|
|
@@ -143,7 +142,7 @@ public final class QuestState
|
|
|
{
|
|
|
return (getState() == State.STARTED);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return state of the quest after its initialization.<BR><BR>
|
|
|
* <U><I>Actions :</I></U>
|
|
@@ -169,7 +168,7 @@ public final class QuestState
|
|
|
}
|
|
|
return state;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add parameter used in quests.
|
|
|
* @param var : String pointing out the name of the variable for quest
|
|
@@ -187,7 +186,7 @@ public final class QuestState
|
|
|
_vars.put(var, val);
|
|
|
return val;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return value of parameter "val" after adding the couple (var,val) in class variable "vars".<BR><BR>
|
|
|
* <U><I>Actions :</I></U><BR>
|
|
@@ -205,18 +204,18 @@ public final class QuestState
|
|
|
{
|
|
|
if (_vars == null)
|
|
|
_vars = new FastMap<String, String>();
|
|
|
-
|
|
|
+
|
|
|
if (val == null)
|
|
|
val = "";
|
|
|
-
|
|
|
+
|
|
|
// FastMap.put() returns previous value associated with specified key, or null if there was no mapping for key.
|
|
|
String old = _vars.put(var, val);
|
|
|
-
|
|
|
+
|
|
|
if (old != null)
|
|
|
Quest.updateQuestVarInDb(this, var, val);
|
|
|
else
|
|
|
Quest.createQuestVarInDb(this, var, val);
|
|
|
-
|
|
|
+
|
|
|
if ("cond".equals(var))
|
|
|
{
|
|
|
try
|
|
@@ -237,10 +236,10 @@ public final class QuestState
|
|
|
_log.finer(getPlayer().getName() + ", " + getQuestName() + " cond [" + val + "] is not an integer. Value stored, but no packet was sent: " + e);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return val;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Internally handles the progression of the quest so that it is ready for sending
|
|
|
* appropriate packets to the client<BR><BR>
|
|
@@ -260,11 +259,11 @@ public final class QuestState
|
|
|
private void setCond(int cond, int old)
|
|
|
{
|
|
|
int completedStateFlags = 0; // initializing...
|
|
|
-
|
|
|
+
|
|
|
// if there is no change since last setting, there is nothing to do here
|
|
|
if (cond == old)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
// cond 0 and 1 do not need completedStateFlags. Also, if cond > 1, the 1st step must
|
|
|
// always exist (i.e. it can never be skipped). So if cond is 2, we can still safely
|
|
|
// assume no steps have been skipped.
|
|
@@ -275,14 +274,14 @@ public final class QuestState
|
|
|
}
|
|
|
else
|
|
|
completedStateFlags = getInt("__compltdStateFlags");
|
|
|
-
|
|
|
+
|
|
|
// case 1: No steps have been skipped so far...
|
|
|
if (completedStateFlags == 0)
|
|
|
{
|
|
|
// check if this step also doesn't skip anything. If so, no further work is needed
|
|
|
// also, in this case, no work is needed if the state is being reset to a smaller value
|
|
|
// in those cases, skip forward to informing the client about the change...
|
|
|
-
|
|
|
+
|
|
|
// ELSE, if we just now skipped for the first time...prepare the flags!!!
|
|
|
if (cond > (old + 1))
|
|
|
{
|
|
@@ -290,11 +289,11 @@ public final class QuestState
|
|
|
// also, ensure that the least significant bit is an 1 (the first step is never skipped, no matter
|
|
|
// what the cond says)
|
|
|
completedStateFlags = 0x80000001;
|
|
|
-
|
|
|
+
|
|
|
// since no flag had been skipped until now, the least significant bits must all
|
|
|
// be set to 1, up until "old" number of bits.
|
|
|
completedStateFlags |= ((1 << old) - 1);
|
|
|
-
|
|
|
+
|
|
|
// now, just set the bit corresponding to the passed cond to 1 (current step)
|
|
|
completedStateFlags |= (1 << (cond - 1));
|
|
|
set("__compltdStateFlags", String.valueOf(completedStateFlags));
|
|
@@ -307,7 +306,7 @@ public final class QuestState
|
|
|
if (cond < old)
|
|
|
{
|
|
|
completedStateFlags &= ((1 << cond) - 1); // note, this also unsets the flag indicating that there exist skips
|
|
|
-
|
|
|
+
|
|
|
//now, check if this resulted in no steps being skipped any more
|
|
|
if (completedStateFlags == ((1 << cond) - 1))
|
|
|
unset("__compltdStateFlags");
|
|
@@ -328,16 +327,16 @@ public final class QuestState
|
|
|
set("__compltdStateFlags", String.valueOf(completedStateFlags));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// send a packet to the client to inform it of the quest progress (step change)
|
|
|
QuestList ql = new QuestList();
|
|
|
getPlayer().sendPacket(ql);
|
|
|
-
|
|
|
+
|
|
|
int questId = getQuest().getQuestIntId();
|
|
|
if (questId > 0 && questId < 19999 && cond > 0)
|
|
|
getPlayer().sendPacket(new ExShowQuestMark(questId));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Remove the variable of quest from the list of variables for the quest.<BR><BR>
|
|
|
* <U><I>Concept : </I></U>
|
|
@@ -349,14 +348,15 @@ public final class QuestState
|
|
|
{
|
|
|
if (_vars == null)
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
String old = _vars.remove(var);
|
|
|
-
|
|
|
+
|
|
|
if (old != null)
|
|
|
Quest.deleteQuestVarInDb(this, var);
|
|
|
-
|
|
|
+
|
|
|
return old;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Insert (or Update) in the database variables that need to stay persistant for this player after a reboot.
|
|
|
* This function is for storage of values that do not related to a specific quest but are
|
|
@@ -394,7 +394,7 @@ public final class QuestState
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Read from the database a previously saved variable for this quest.
|
|
|
* Due to performance considerations, this function should best be used only when the quest is first loaded.
|
|
@@ -437,7 +437,7 @@ public final class QuestState
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Permanently delete from the database one of the player's global quest variable that was previously saved.
|
|
|
* @param var : String designating the name of the variable
|
|
@@ -470,7 +470,7 @@ public final class QuestState
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the value of the variable of quest represented by "var"
|
|
|
* @param var : name of the variable of quest
|
|
@@ -480,10 +480,10 @@ public final class QuestState
|
|
|
{
|
|
|
if (_vars == null)
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
return _vars.get(var);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the value of the variable of quest represented by "var"
|
|
|
* @param var : String designating the variable for the quest
|
|
@@ -492,7 +492,7 @@ public final class QuestState
|
|
|
public int getInt(String var)
|
|
|
{
|
|
|
int varint = 0;
|
|
|
-
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
varint = Integer.parseInt(_vars.get(var));
|
|
@@ -503,7 +503,7 @@ public final class QuestState
|
|
|
// if (Config.AUTODELETE_INVALID_QUEST_DATA)
|
|
|
// exitQuest(true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return varint;
|
|
|
}
|
|
|
|
|
@@ -515,10 +515,10 @@ public final class QuestState
|
|
|
{
|
|
|
if (character == null)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
character.addNotifyQuestOfDeath(this);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the quantity of one sort of item hold by the player
|
|
|
* @param itemId : ID of the item wanted to be count
|
|
@@ -527,14 +527,14 @@ public final class QuestState
|
|
|
public long getQuestItemsCount(int itemId)
|
|
|
{
|
|
|
long count = 0;
|
|
|
-
|
|
|
+
|
|
|
for (L2ItemInstance item : getPlayer().getInventory().getItems())
|
|
|
if (item.getItemId() == itemId)
|
|
|
count += item.getCount();
|
|
|
-
|
|
|
+
|
|
|
return count;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the level of enchantment on the weapon of the player(Done specifically for weapon SA's)
|
|
|
* @param itemId : ID of the item to check enchantment
|
|
@@ -543,13 +543,13 @@ public final class QuestState
|
|
|
public int getEnchantLevel(int itemId)
|
|
|
{
|
|
|
L2ItemInstance enchanteditem = getPlayer().getInventory().getItemByItemId(itemId);
|
|
|
-
|
|
|
+
|
|
|
if (enchanteditem == null)
|
|
|
return 0;
|
|
|
-
|
|
|
+
|
|
|
return enchanteditem.getEnchantLevel();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Give adena to the player
|
|
|
* @param count
|
|
@@ -569,28 +569,26 @@ public final class QuestState
|
|
|
{
|
|
|
giveItems(itemId, count, 0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public synchronized void giveItems(int itemId, long count, int enchantlevel)
|
|
|
{
|
|
|
if (count <= 0)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
// If item for reward is adena (ID=57), modify count with rate for quest reward if rates available
|
|
|
if (itemId == 57 && !(enchantlevel > 0))
|
|
|
count = (long) (count * Config.RATE_QUESTS_REWARD);
|
|
|
- boolean have = false;
|
|
|
- if (getQuestItemsCount(itemId)>0)
|
|
|
- have = true;
|
|
|
+
|
|
|
// Add items to player's inventory
|
|
|
L2ItemInstance item = getPlayer().getInventory().addItem("Quest", itemId, count, getPlayer(), getPlayer().getTarget());
|
|
|
-
|
|
|
+
|
|
|
if (item == null)
|
|
|
return;
|
|
|
|
|
|
// set enchant level for item if that item is not adena
|
|
|
if (enchantlevel > 0 && itemId != 57)
|
|
|
item.setEnchantLevel(enchantlevel);
|
|
|
-
|
|
|
+
|
|
|
// If item for reward is gold, send message of gold reward to client
|
|
|
if (itemId == 57)
|
|
|
{
|
|
@@ -616,29 +614,19 @@ public final class QuestState
|
|
|
}
|
|
|
}
|
|
|
// send packets
|
|
|
- InventoryUpdate iu = new InventoryUpdate();
|
|
|
- if (item.isStackable() && have)
|
|
|
- iu.addModifiedItem(item);
|
|
|
- else
|
|
|
- iu.addNewItem(item);
|
|
|
- getPlayer().sendPacket(iu);
|
|
|
-
|
|
|
StatusUpdate su = new StatusUpdate(getPlayer().getObjectId());
|
|
|
su.addAttribute(StatusUpdate.CUR_LOAD, getPlayer().getCurrentLoad());
|
|
|
getPlayer().sendPacket(su);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void giveItems(int itemId, long count, byte attributeId, int attributeLevel)
|
|
|
{
|
|
|
if (count <= 0)
|
|
|
return;
|
|
|
- boolean have = false;
|
|
|
- if (getQuestItemsCount(itemId)>0)
|
|
|
- have = true;
|
|
|
-
|
|
|
+
|
|
|
// Add items to player's inventory
|
|
|
L2ItemInstance item = getPlayer().getInventory().addItem("Quest", itemId, count, getPlayer(), getPlayer().getTarget());
|
|
|
-
|
|
|
+
|
|
|
if (item == null)
|
|
|
return;
|
|
|
|
|
@@ -648,7 +636,7 @@ public final class QuestState
|
|
|
item.setElementAttr(attributeId, attributeLevel);
|
|
|
item.updateElementAttrBonus(getPlayer());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// If item for reward is gold, send message of gold reward to client
|
|
|
if (itemId == 57)
|
|
|
{
|
|
@@ -674,18 +662,11 @@ public final class QuestState
|
|
|
}
|
|
|
}
|
|
|
// send packets
|
|
|
- InventoryUpdate iu = new InventoryUpdate();
|
|
|
- if (item.isStackable() && have)
|
|
|
- iu.addModifiedItem(item);
|
|
|
- else
|
|
|
- iu.addNewItem(item);
|
|
|
- getPlayer().sendPacket(iu);
|
|
|
-
|
|
|
StatusUpdate su = new StatusUpdate(getPlayer().getObjectId());
|
|
|
su.addAttribute(StatusUpdate.CUR_LOAD, getPlayer().getCurrentLoad());
|
|
|
getPlayer().sendPacket(su);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Drop Quest item using Config.RATE_DROP_QUEST
|
|
|
* @param itemId : int Item Identifier of the item to be dropped
|
|
@@ -699,21 +680,21 @@ public final class QuestState
|
|
|
{
|
|
|
return dropQuestItems(itemId, count, count, neededCount, dropChance, sound);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean dropQuestItems(int itemId, int minCount, int maxCount, long neededCount, int dropChance, boolean sound)
|
|
|
{
|
|
|
dropChance *= Config.RATE_DROP_QUEST / ((getPlayer().getParty() != null) ? getPlayer().getParty().getMemberCount() : 1);
|
|
|
long currentCount = getQuestItemsCount(itemId);
|
|
|
-
|
|
|
+
|
|
|
if (neededCount > 0 && currentCount >= neededCount)
|
|
|
return true;
|
|
|
-
|
|
|
+
|
|
|
if (currentCount >= neededCount)
|
|
|
return true;
|
|
|
-
|
|
|
+
|
|
|
long itemCount = 0;
|
|
|
int random = Rnd.get(L2DropData.MAX_CHANCE);
|
|
|
-
|
|
|
+
|
|
|
while (random < dropChance)
|
|
|
{
|
|
|
// Get the item quantity dropped
|
|
@@ -723,50 +704,50 @@ public final class QuestState
|
|
|
itemCount += minCount;
|
|
|
else
|
|
|
itemCount++;
|
|
|
-
|
|
|
+
|
|
|
// Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
|
|
|
dropChance -= L2DropData.MAX_CHANCE;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (itemCount > 0)
|
|
|
{
|
|
|
// if over neededCount, just fill the gap
|
|
|
if (neededCount > 0 && currentCount + itemCount > neededCount)
|
|
|
itemCount = neededCount - currentCount;
|
|
|
-
|
|
|
+
|
|
|
// Inventory slot check
|
|
|
if (!getPlayer().getInventory().validateCapacityByItemId(itemId))
|
|
|
return false;
|
|
|
-
|
|
|
+
|
|
|
// Give the item to Player
|
|
|
getPlayer().addItem("Quest", itemId, itemCount, getPlayer().getTarget(), true);
|
|
|
-
|
|
|
+
|
|
|
if (sound)
|
|
|
playSound((currentCount + itemCount < neededCount) ? "Itemsound.quest_itemget" : "Itemsound.quest_middle");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return (neededCount > 0 && currentCount + itemCount >= neededCount);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//TODO: More radar functions need to be added when the radar class is complete.
|
|
|
// BEGIN STUFF THAT WILL PROBABLY BE CHANGED
|
|
|
public void addRadar(int x, int y, int z)
|
|
|
{
|
|
|
getPlayer().getRadar().addMarker(x, y, z);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void removeRadar(int x, int y, int z)
|
|
|
{
|
|
|
getPlayer().getRadar().removeMarker(x, y, z);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void clearRadar()
|
|
|
{
|
|
|
getPlayer().getRadar().removeAllMarkers();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// END STUFF THAT WILL PROBABLY BE CHANGED
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Remove items from player's inventory when talking to NPC in order to have rewards.<BR><BR>
|
|
|
* <U><I>Actions :</I></U>
|
|
@@ -779,14 +760,14 @@ public final class QuestState
|
|
|
{
|
|
|
// Get object item from player's inventory list
|
|
|
L2ItemInstance item = getPlayer().getInventory().getItemByItemId(itemId);
|
|
|
-
|
|
|
+
|
|
|
if (item == null)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
// Tests on count value in order not to have negative value
|
|
|
if (count < 0 || count > item.getCount())
|
|
|
count = item.getCount();
|
|
|
-
|
|
|
+
|
|
|
// Destroy the quantity of items wanted
|
|
|
if (itemId == 57)
|
|
|
getPlayer().reduceAdena("Quest", count, getPlayer(), true);
|
|
@@ -797,7 +778,7 @@ public final class QuestState
|
|
|
getPlayer().destroyItemByItemId("Quest", itemId, count, getPlayer(), true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Send a packet in order to play sound at client terminal
|
|
|
* @param sound
|
|
@@ -806,7 +787,7 @@ public final class QuestState
|
|
|
{
|
|
|
getPlayer().sendPacket(new PlaySound(sound));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add XP and SP as quest reward
|
|
|
* @param exp
|
|
@@ -816,7 +797,7 @@ public final class QuestState
|
|
|
{
|
|
|
getPlayer().addExpAndSp((int) getPlayer().calcStat(Stats.EXPSP_RATE, exp * Config.RATE_QUESTS_REWARD, null, null), (int) getPlayer().calcStat(Stats.EXPSP_RATE, sp * Config.RATE_QUESTS_REWARD, null, null));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return random value
|
|
|
* @param max : max value for randomisation
|
|
@@ -826,7 +807,7 @@ public final class QuestState
|
|
|
{
|
|
|
return Rnd.get(max);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return number of ticks from GameTimeController
|
|
|
* @return int
|
|
@@ -835,7 +816,7 @@ public final class QuestState
|
|
|
{
|
|
|
return getPlayer().getInventory().getPaperdollItemId(loc);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the number of ticks from the GameTimeController
|
|
|
* @return int
|
|
@@ -844,7 +825,7 @@ public final class QuestState
|
|
|
{
|
|
|
return GameTimeController.getGameTicks();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return true if quest is to exited on clean up by QuestStateManager
|
|
|
* @return boolean
|
|
@@ -853,7 +834,7 @@ public final class QuestState
|
|
|
{
|
|
|
return _isExitQuestOnCleanUp;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the QuestTimer object with the specified name
|
|
|
* @return QuestTimer<BR> Return null if name does not exist
|
|
@@ -862,7 +843,7 @@ public final class QuestState
|
|
|
{
|
|
|
_isExitQuestOnCleanUp = isExitQuestOnCleanUp;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Start a timer for quest.<BR><BR>
|
|
|
* @param name<BR> The name of the timer. Will also be the value for event of onEvent
|
|
@@ -872,22 +853,22 @@ public final class QuestState
|
|
|
{
|
|
|
getQuest().startQuestTimer(name, time, null, getPlayer(), false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void startQuestTimer(String name, long time, L2Npc npc)
|
|
|
{
|
|
|
getQuest().startQuestTimer(name, time, npc, getPlayer(), false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void startRepeatingQuestTimer(String name, long time)
|
|
|
{
|
|
|
getQuest().startQuestTimer(name, time, null, getPlayer(), true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void startRepeatingQuestTimer(String name, long time, L2Npc npc)
|
|
|
{
|
|
|
getQuest().startQuestTimer(name, time, npc, getPlayer(), true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Return the QuestTimer object with the specified name
|
|
|
* @return QuestTimer<BR> Return null if name does not exist
|
|
@@ -896,7 +877,7 @@ public final class QuestState
|
|
|
{
|
|
|
return getQuest().getQuestTimer(name, null, getPlayer());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Return object id of newly spawned npc
|
|
@@ -905,17 +886,17 @@ public final class QuestState
|
|
|
{
|
|
|
return addSpawn(npcId, getPlayer().getX(), getPlayer().getY(), getPlayer().getZ(), 0, false, 0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public L2Npc addSpawn(int npcId, int despawnDelay)
|
|
|
{
|
|
|
return addSpawn(npcId, getPlayer().getX(), getPlayer().getY(), getPlayer().getZ(), 0, false, despawnDelay);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public L2Npc addSpawn(int npcId, int x, int y, int z)
|
|
|
{
|
|
|
return addSpawn(npcId, x, y, z, 0, false, 0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Will despawn after the spawn length expires
|
|
@@ -927,12 +908,12 @@ public final class QuestState
|
|
|
{
|
|
|
return addSpawn(npcId, cha, true, 0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public L2Npc addSpawn(int npcId, L2Character cha, int despawnDelay)
|
|
|
{
|
|
|
return addSpawn(npcId, cha.getX(), cha.getY(), cha.getZ(), cha.getHeading(), true, despawnDelay);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Will despawn after the spawn length expires
|
|
@@ -942,7 +923,7 @@ public final class QuestState
|
|
|
{
|
|
|
return addSpawn(npcId, x, y, z, 0, false, despawnDelay);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Inherits coords and heading from specified L2Character instance.
|
|
@@ -953,7 +934,7 @@ public final class QuestState
|
|
|
{
|
|
|
return addSpawn(npcId, cha.getX(), cha.getY(), cha.getZ(), cha.getHeading(), randomOffset, despawnDelay);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Return object id of newly spawned npc
|
|
@@ -962,7 +943,7 @@ public final class QuestState
|
|
|
{
|
|
|
return getQuest().addSpawn(npcId, x, y, z, heading, randomOffset, despawnDelay, false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Add spawn for player instance
|
|
|
* Return object id of newly spawned npc
|
|
@@ -971,12 +952,12 @@ public final class QuestState
|
|
|
{
|
|
|
return getQuest().addSpawn(npcId, x, y, z, heading, randomOffset, despawnDelay, isSummonSpawn);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public String showHtmlFile(String fileName)
|
|
|
{
|
|
|
return getQuest().showHtmlFile(getPlayer(), fileName);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Destroy element used by quest when quest is exited
|
|
|
* @param repeatable
|
|
@@ -986,10 +967,10 @@ public final class QuestState
|
|
|
{
|
|
|
if (isCompleted())
|
|
|
return this;
|
|
|
-
|
|
|
+
|
|
|
// Say quest is completed
|
|
|
setState(State.COMPLETED);
|
|
|
-
|
|
|
+
|
|
|
// Clean registered quest items
|
|
|
int[] itemIdList = getQuest().getRegisteredItemIds();
|
|
|
if (itemIdList != null)
|
|
@@ -999,13 +980,13 @@ public final class QuestState
|
|
|
takeItems(itemIdList[i], -1);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// If quest is repeatable, delete quest from list of quest of the player and from database (quest CAN be created again => repeatable)
|
|
|
if (repeatable)
|
|
|
{
|
|
|
getPlayer().delQuestState(getQuestName());
|
|
|
Quest.deleteQuestInDb(this);
|
|
|
-
|
|
|
+
|
|
|
_vars = null;
|
|
|
}
|
|
|
else
|
|
@@ -1014,23 +995,23 @@ public final class QuestState
|
|
|
if (_vars != null)
|
|
|
for (String var : _vars.keySet())
|
|
|
unset(var);
|
|
|
-
|
|
|
+
|
|
|
Quest.updateQuestInDb(this);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void showQuestionMark(int number)
|
|
|
{
|
|
|
getPlayer().sendPacket(new TutorialShowQuestionMark(number));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void playTutorialVoice(String voice)
|
|
|
{
|
|
|
getPlayer().sendPacket(new PlaySound(2, voice, 0, 0, getPlayer().getX(), getPlayer().getY(), getPlayer().getZ()));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void showTutorialHTML(String html)
|
|
|
{
|
|
|
String text = HtmCache.getInstance().getHtm("data/scripts/quests/255_Tutorial/" + html);
|
|
@@ -1041,17 +1022,17 @@ public final class QuestState
|
|
|
}
|
|
|
getPlayer().sendPacket(new TutorialShowHtml(text));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void closeTutorialHtml()
|
|
|
{
|
|
|
getPlayer().sendPacket(new TutorialCloseHtml());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void onTutorialClientEvent(int number)
|
|
|
{
|
|
|
getPlayer().sendPacket(new TutorialEnableClientEvent(number));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void dropItem(L2MonsterInstance npc, L2PcInstance player, int itemId, int count)
|
|
|
{
|
|
|
npc.dropItem(player, itemId, count);
|