using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using Server.daat99;
namespace Server.Engines.Harvest
{
public class Lumberjacking : HarvestSystem
{
private static Lumberjacking m_System;
public override HarvestVein MutateVein(Mobile from, Item tool, HarvestDefinition def, HarvestBank bank, object toHarvest, HarvestVein vein)
{
if (tool is GargoylesAxe && def == m_Definition)
{
int veinIndex = Array.IndexOf(def.Veins, vein);
if (veinIndex >= 0 && veinIndex < (def.Veins.Length - 1))
return def.Veins[veinIndex + 1];
}
return base.MutateVein(from, tool, def, bank, toHarvest, vein);
}
private static int[] m_Offsets = new int[]
{
-1, -1,
-1, 0,
-1, 1,
0, -1,
0, 1,
1, -1,
1, 0,
1, 1
};
public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type)
{
if (tool is GargoylesAxe && def == m_Definition && 0.1 > Utility.RandomDouble())
{
HarvestResource res = vein.PrimaryResource;
Map map = from.Map;
if (map == null)
return;
BaseCreature spawned = null;
int i_Level = 0;
if (Daat99OWLTR.Ops[15].Setting)
{
if (type == typeof(FrostwoodLog)) i_Level = 311;
else if (type == typeof(BloodwoodLog)) i_Level = 310;
else if (type == typeof(HeartwoodLog)) i_Level = 309;
else if (type == typeof(BambooLog)) i_Level = 308;
else if (type == typeof(EbonyLog)) i_Level = 307;
else if (type == typeof(ZircoteLog)) i_Level = 306;
else if (type == typeof(OakLog)) i_Level = 305;
else if (type == typeof(YewLog)) i_Level = 304;
else if (type == typeof(MohoganyLog)) i_Level = 303;
else if (type == typeof(AshLog)) i_Level = 302;
else if (type == typeof(PineLog)) i_Level = 301;
else if (type == typeof(Log)) i_Level = 300;
}
else if (res == resource && res.Types.Length >= 300)
{
try
{
if (res.Types[0] == typeof(PineLog))
i_Level = 301;
else if (res.Types[0] == typeof(AshLog))
i_Level = 302;
else if (res.Types[0] == typeof(MohoganyLog))
i_Level = 303;
else if (res.Types[0] == typeof(YewLog))
i_Level = 304;
else if (res.Types[0] == typeof(OakLog))
i_Level = 305;
else if (res.Types[0] == typeof(ZircoteLog))
i_Level = 306;
else if (res.Types[0] == typeof(EbonyLog))
i_Level = 307;
else if (res.Types[0] == typeof(BambooLog))
i_Level = 308;
else if (res.Types[0] == typeof(HeartwoodLog))
i_Level = 309;
else if (res.Types[0] == typeof(BloodwoodLog))
i_Level = 310;
else if (res.Types[0] == typeof(FrostwoodLog))
i_Level = 311;
}
catch
{
}
}
if (i_Level > 299 && Daat99OWLTR.Ops[15].Setting)
GiveTokens.RewardTokens(from, (i_Level - 300 * 10));
if (i_Level > 300)
spawned = new Elementals(i_Level);
else
spawned = null;
try
{
if (spawned != null)
{
int offset = Utility.Random(8) * 2;
for (int i = 0; i < m_Offsets.Length; i += 2)
{
int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];
if (map.CanSpawnMobile(x, y, from.Z))
{
spawned.MoveToWorld(new Point3D(x, y, from.Z), map);
spawned.Combatant = from;
return;
}
else
{
int z = map.GetAverageZ(x, y);
if (map.CanSpawnMobile(x, y, z))
{
spawned.MoveToWorld(new Point3D(x, y, z), map);
spawned.Combatant = from;
return;
}
}
}
}
spawned.MoveToWorld(from.Location, from.Map);
spawned.Combatant = from;
}
catch
{
}
}
}
public static Lumberjacking System
{
get
{
if ( m_System == null )
m_System = new Lumberjacking();
return m_System;
}
}