public void Add(Quest quest)
{
// Check quest item
if (quest.QuestItem == null)
throw new InvalidOperationException("Quest item can't be null.");
if (!_creature.Inventory.Has(quest.QuestItem))
throw new InvalidOperationException("The quest item needs to be in the creature's inventory first.");
this.AddSilent(quest);
// Quest info
Send.NewQuest(_creature, quest);
// Start PTJ clock
if (quest.Data.Type == QuestType.Deliver)
Send.QuestStartPtj(_creature, quest.UniqueId);
// Initial objective check, for things like collect and reach rank,
// that may be done already.
quest.Data.CheckCurrentObjective(_creature);
// Give item to deliver for first deliver objective
var deliverObjective = quest.Data.Objectives[quest.CurrentObjectiveOrLast.Ident] as QuestObjectiveDeliver;
if (deliverObjective != null)
{
var item = new Item(deliverObjective.ItemId);
item.Amount = Math.Min(1, deliverObjective.Amount);
_creature.Inventory.Add(item, true);
}
// Receive event
// XXX: Could be used for the deliver objectives above as well?
// It would make more sense to always give delvier items
// automatically though, not only on start.
quest.Data.OnReceive(_creature);
}