mirror of
https://github.com/ServUO/ServUO
synced 2026-08-11 20:23:04 -04:00
* OCT17 Minor gump cleanup and XML cleanup. * Improvements - Skill Gain is no longer redundantly checked against the same values inside of XMLSpawner. - AI_Animal (which was not used and just defaulted to AI_Melee) along with AI_Beserk, AI_Predator, and AI_Thief have been safely removed. - ItemFlags.cs has been moved from XMLSpawner to MISC. - Removed some misc double calls. * Needed for recent AI fix. * Item Fix
104 lines
2.9 KiB
C#
104 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Server.Engines.Quests
|
|
{
|
|
public class FishQuestObjective : BaseObjective
|
|
{
|
|
public Dictionary<Type, int[]> Line { get; set; }
|
|
|
|
public bool IsCompleted
|
|
{
|
|
get
|
|
{
|
|
foreach (KeyValuePair<Type, int[]> kvp in Line)
|
|
{
|
|
if (kvp.Value[0] < kvp.Value[1])
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public FishQuestObjective()
|
|
{
|
|
}
|
|
|
|
public FishQuestObjective(Dictionary<Type, int> line)
|
|
: base(500, 0)
|
|
{
|
|
Line = new Dictionary<Type, int[]>();
|
|
|
|
foreach (KeyValuePair<Type, int> kvp in line)
|
|
{
|
|
Line[kvp.Key] = new int[] { 0, kvp.Value };
|
|
}
|
|
}
|
|
|
|
public override bool Update(object obj)
|
|
{
|
|
if (obj is Item)
|
|
{
|
|
Item item = (Item)obj;
|
|
|
|
foreach (KeyValuePair<Type, int[]> kvp in Line)
|
|
{
|
|
if (item.GetType() == kvp.Key)
|
|
{
|
|
kvp.Value[0] += item.Amount;
|
|
|
|
if (IsCompleted && Quest.Owner != null)
|
|
{
|
|
CurProgress = 500;
|
|
Quest.Owner.SendLocalizedMessage(1072273, null, 0x23); // You've completed a quest! Don't forget to collect your reward.
|
|
Quest.Owner.SendSound(Quest.CompleteSound);
|
|
}
|
|
else
|
|
Quest.Owner.SendSound(Quest.UpdateSound);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool CheckLift(Item item)
|
|
{
|
|
return item != null && Line.ContainsKey(item.GetType());
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
writer.Write(0);
|
|
|
|
writer.Write(Line.Count);
|
|
foreach (KeyValuePair<Type, int[]> kvp in Line)
|
|
{
|
|
writer.Write(FishQuestHelper.GetIndexForType(kvp.Key));
|
|
writer.Write(kvp.Value[0]);
|
|
writer.Write(kvp.Value[1]);
|
|
}
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
int version = reader.ReadInt();
|
|
|
|
int count = reader.ReadInt();
|
|
Line = new Dictionary<Type, int[]>();
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
Type type = FishQuestHelper.GetTypeFromIndex(reader.ReadInt());
|
|
int[] line = { reader.ReadInt(), reader.ReadInt() };
|
|
|
|
if (type != null)
|
|
Line[type] = line;
|
|
}
|
|
}
|
|
}
|
|
}
|