Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
423
Scripts/Services/Craft/Core/AlterItem.cs
Normal file
423
Scripts/Services/Craft/Core/AlterItem.cs
Normal file
@@ -0,0 +1,423 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
using Server.Engines.VeteranRewards;
|
||||
using Server.SkillHandlers;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class AlterableAttribute : Attribute
|
||||
{
|
||||
public Type CraftSystem { get; private set; }
|
||||
public Type AlteredType { get; private set; }
|
||||
public bool Inherit { get; private set; }
|
||||
|
||||
public AlterableAttribute(Type craftSystem, Type alteredType, bool inherit = false)
|
||||
{
|
||||
CraftSystem = craftSystem;
|
||||
AlteredType = alteredType;
|
||||
Inherit = inherit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this enables any craftable item where their parent class can be altered, can be altered too.
|
||||
/// This is mainly for the ML craftable artifacts.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CheckInherit(Type original)
|
||||
{
|
||||
if (Inherit)
|
||||
return true;
|
||||
|
||||
var system = CraftContext.Systems.FirstOrDefault(sys => sys.GetType() == CraftSystem);
|
||||
|
||||
if (system != null)
|
||||
{
|
||||
return system.CraftItems.SearchFor(original) != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class AlterItem
|
||||
{
|
||||
public static void BeginTarget(Mobile from, CraftSystem system, ITool tool)
|
||||
{
|
||||
from.Target = new AlterItemTarget(system, tool);
|
||||
from.SendLocalizedMessage(1094730); //Target the item to altar
|
||||
}
|
||||
|
||||
public static void BeginTarget(Mobile from, CraftSystem system, Item contract)
|
||||
{
|
||||
from.Target = new AlterItemTarget(system, contract);
|
||||
from.SendLocalizedMessage(1094730); //Target the item to altar
|
||||
}
|
||||
}
|
||||
|
||||
public class AlterItemTarget : Target
|
||||
{
|
||||
private readonly CraftSystem m_System;
|
||||
private readonly ITool m_Tool;
|
||||
private Item m_Contract;
|
||||
|
||||
public AlterItemTarget(CraftSystem system, Item contract)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
m_System = system;
|
||||
m_Contract = contract;
|
||||
}
|
||||
|
||||
public AlterItemTarget(CraftSystem system, ITool tool)
|
||||
: base(1, false, TargetFlags.None)
|
||||
{
|
||||
this.m_System = system;
|
||||
this.m_Tool = tool;
|
||||
}
|
||||
|
||||
private static AlterableAttribute GetAlterableAttribute(object o, bool inherit)
|
||||
{
|
||||
Type t = o.GetType();
|
||||
|
||||
object[] attrs = t.GetCustomAttributes(typeof(AlterableAttribute), inherit);
|
||||
|
||||
if (attrs != null && attrs.Length > 0)
|
||||
{
|
||||
AlterableAttribute attr = attrs[0] as AlterableAttribute;
|
||||
|
||||
if (attr != null && (!inherit || attr.CheckInherit(t)))
|
||||
return attr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
int number = -1;
|
||||
|
||||
Item origItem = o as Item;
|
||||
SkillName skill = m_System.MainSkill;
|
||||
double value = from.Skills[skill].Value;
|
||||
|
||||
var alterInfo = GetAlterableAttribute(o, false);
|
||||
|
||||
if (alterInfo == null)
|
||||
{
|
||||
alterInfo = GetAlterableAttribute(o, true);
|
||||
}
|
||||
|
||||
if (origItem == null || !origItem.IsChildOf(from.Backpack))
|
||||
{
|
||||
number = 1094729; // The item must be in your backpack for you to alter it.
|
||||
}
|
||||
else if (origItem is BlankScroll)
|
||||
{
|
||||
if (m_Contract == null)
|
||||
{
|
||||
if (value >= 100.0)
|
||||
{
|
||||
Item contract = null;
|
||||
|
||||
if (skill == SkillName.Blacksmith)
|
||||
contract = new AlterContract(RepairSkillType.Smithing, from);
|
||||
else if (skill == SkillName.Carpentry)
|
||||
contract = new AlterContract(RepairSkillType.Carpentry, from);
|
||||
else if (skill == SkillName.Tailoring)
|
||||
contract = new AlterContract(RepairSkillType.Tailoring, from);
|
||||
else if (skill == SkillName.Tinkering)
|
||||
contract = new AlterContract(RepairSkillType.Tinkering, from);
|
||||
|
||||
if (contract != null)
|
||||
{
|
||||
from.AddToBackpack(contract);
|
||||
|
||||
number = 1044154; // You create the item.
|
||||
|
||||
// Consume a blank scroll
|
||||
origItem.Consume();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1111869; // You must be at least grandmaster level to create an alter service contract.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1094728; // You may not alter that item.
|
||||
}
|
||||
}
|
||||
else if (alterInfo == null)
|
||||
{
|
||||
number = 1094728; // You may not alter that item.
|
||||
}
|
||||
else if (!IsAlterable(origItem))
|
||||
{
|
||||
number = 1094728; // You may not alter that item.
|
||||
}
|
||||
else if (alterInfo.CraftSystem != m_System.GetType())
|
||||
{
|
||||
if (m_Tool != null)
|
||||
{
|
||||
// You may not alter that item.
|
||||
number = 1094728;
|
||||
}
|
||||
else
|
||||
{
|
||||
// You cannot alter that item with this type of alter contract.
|
||||
number = 1094793;
|
||||
}
|
||||
}
|
||||
else if (!Server.SkillHandlers.Imbuing.CheckSoulForge(from, 2, false, false))
|
||||
{
|
||||
number = 1111867; // You must be near a soulforge to alter an item.
|
||||
}
|
||||
else if (m_Contract == null && value < 100.0)
|
||||
{
|
||||
number = 1111870; // You must be at least grandmaster level to alter an item.
|
||||
}
|
||||
else if (origItem is BaseWeapon && ((BaseWeapon)origItem).EnchantedWeilder != null)
|
||||
{
|
||||
number = 1111849; // You cannot alter an item that is currently enchanted.
|
||||
}
|
||||
else if (origItem.HasSocket<SlayerSocket>())
|
||||
{
|
||||
var socket = origItem.GetSocket<SlayerSocket>();
|
||||
|
||||
if (socket.Slayer == SlayerName.Silver)
|
||||
{
|
||||
number = 1155681; // You cannot alter an item that has been treated with Tincture of Silver.
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1111849; // You cannot alter an item that is currently enchanted.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Item newitem = Activator.CreateInstance(alterInfo.AlteredType) as Item;
|
||||
|
||||
if (newitem == null)
|
||||
return;
|
||||
|
||||
if (origItem is BaseWeapon && newitem is BaseWeapon)
|
||||
{
|
||||
BaseWeapon oldweapon = (BaseWeapon)origItem;
|
||||
BaseWeapon newweapon = (BaseWeapon)newitem;
|
||||
|
||||
newweapon.Slayer = oldweapon.Slayer;
|
||||
newweapon.Slayer2 = oldweapon.Slayer2;
|
||||
newweapon.Slayer3 = oldweapon.Slayer3;
|
||||
newweapon.Resource = oldweapon.Resource;
|
||||
|
||||
if (oldweapon.PlayerConstructed)
|
||||
{
|
||||
newweapon.PlayerConstructed = true;
|
||||
newweapon.Crafter = oldweapon.Crafter;
|
||||
newweapon.Quality = oldweapon.Quality;
|
||||
}
|
||||
|
||||
newweapon.Altered = true;
|
||||
}
|
||||
else if (origItem is BaseArmor && newitem is BaseArmor)
|
||||
{
|
||||
BaseArmor oldarmor = (BaseArmor)origItem;
|
||||
BaseArmor newarmor = (BaseArmor)newitem;
|
||||
|
||||
if (oldarmor.PlayerConstructed)
|
||||
{
|
||||
newarmor.PlayerConstructed = true;
|
||||
newarmor.Crafter = oldarmor.Crafter;
|
||||
newarmor.Quality = oldarmor.Quality;
|
||||
}
|
||||
|
||||
newarmor.Resource = oldarmor.Resource;
|
||||
|
||||
newarmor.PhysicalBonus = oldarmor.PhysicalBonus;
|
||||
newarmor.FireBonus = oldarmor.FireBonus;
|
||||
newarmor.ColdBonus = oldarmor.ColdBonus;
|
||||
newarmor.PoisonBonus = oldarmor.PoisonBonus;
|
||||
newarmor.EnergyBonus = oldarmor.EnergyBonus;
|
||||
|
||||
newarmor.Altered = true;
|
||||
}
|
||||
else if (origItem is BaseClothing && newitem is BaseClothing)
|
||||
{
|
||||
BaseClothing oldcloth = (BaseClothing)origItem;
|
||||
BaseClothing newcloth = (BaseClothing)newitem;
|
||||
|
||||
if (oldcloth.PlayerConstructed)
|
||||
{
|
||||
newcloth.PlayerConstructed = true;
|
||||
newcloth.Crafter = oldcloth.Crafter;
|
||||
newcloth.Quality = oldcloth.Quality;
|
||||
}
|
||||
|
||||
newcloth.Altered = true;
|
||||
}
|
||||
else if (origItem is BaseClothing && newitem is BaseArmor)
|
||||
{
|
||||
BaseClothing oldcloth = (BaseClothing)origItem;
|
||||
BaseArmor newarmor = (BaseArmor)newitem;
|
||||
|
||||
if (oldcloth.PlayerConstructed)
|
||||
{
|
||||
int qual = (int)oldcloth.Quality;
|
||||
|
||||
newarmor.PlayerConstructed = true;
|
||||
newarmor.Crafter = oldcloth.Crafter;
|
||||
newarmor.Quality = (ItemQuality)qual;
|
||||
}
|
||||
|
||||
newarmor.Altered = true;
|
||||
}
|
||||
else if (origItem is BaseQuiver && newitem is BaseArmor)
|
||||
{
|
||||
/*BaseQuiver oldquiver = (BaseQuiver)origItem;
|
||||
BaseArmor newarmor = (BaseArmor)newitem;*/
|
||||
|
||||
((BaseArmor)newitem).Altered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (origItem.Name != null)
|
||||
{
|
||||
newitem.Name = origItem.Name;
|
||||
}
|
||||
else if (Server.Engines.VendorSearching.VendorSearch.StringList != null)
|
||||
{
|
||||
if (origItem.LabelNumber > 0 && RetainsName(origItem))
|
||||
newitem.Name = Server.Engines.VendorSearching.VendorSearch.StringList.GetString(origItem.LabelNumber);
|
||||
}
|
||||
|
||||
AlterResists(newitem, origItem);
|
||||
|
||||
newitem.Hue = origItem.Hue;
|
||||
newitem.LootType = origItem.LootType;
|
||||
newitem.Insured = origItem.Insured;
|
||||
|
||||
origItem.OnAfterDuped(newitem);
|
||||
newitem.Parent = null;
|
||||
|
||||
if (origItem is IDurability && newitem is IDurability)
|
||||
{
|
||||
((IDurability)newitem).MaxHitPoints = ((IDurability)origItem).MaxHitPoints;
|
||||
((IDurability)newitem).HitPoints = ((IDurability)origItem).HitPoints;
|
||||
}
|
||||
|
||||
if (from.Backpack == null)
|
||||
newitem.MoveToWorld(from.Location, from.Map);
|
||||
else
|
||||
from.Backpack.DropItem(newitem);
|
||||
|
||||
newitem.InvalidateProperties();
|
||||
|
||||
if (m_Contract != null)
|
||||
m_Contract.Delete();
|
||||
|
||||
origItem.Delete();
|
||||
|
||||
EventSink.InvokeAlterItem(new AlterItemEventArgs(from, m_Tool is Item ? (Item)m_Tool : m_Contract, origItem, newitem));
|
||||
|
||||
number = 1094727; // You have altered the item.
|
||||
}
|
||||
|
||||
if (m_Tool != null)
|
||||
from.SendGump(new CraftGump(from, m_System, m_Tool, number));
|
||||
else
|
||||
from.SendLocalizedMessage(number);
|
||||
}
|
||||
|
||||
private void AlterResists(Item newItem, Item oldItem)
|
||||
{
|
||||
if (newItem is BaseArmor || newItem is BaseClothing)
|
||||
{
|
||||
var newResists = Imbuing.GetBaseResists(newItem);
|
||||
var oldResists = Imbuing.GetBaseResists(oldItem);
|
||||
|
||||
for (int i = 0; i < newResists.Length; i++)
|
||||
{
|
||||
if (oldResists[i] > newResists[i])
|
||||
{
|
||||
Imbuing.SetProperty(newItem, 51 + i, oldResists[i] - newResists[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool RetainsName(Item item)
|
||||
{
|
||||
if (item is Glasses || item is ElvenGlasses || item.IsArtifact)
|
||||
return true;
|
||||
|
||||
if (item is IArtifact && ((IArtifact)item).ArtifactRarity > 0)
|
||||
return true;
|
||||
|
||||
return (item.LabelNumber >= 1073505 && item.LabelNumber <= 1073552) || (item.LabelNumber >= 1073111 && item.LabelNumber <= 1075040);
|
||||
}
|
||||
|
||||
private static bool IsAlterable(Item item)
|
||||
{
|
||||
if (item is BaseWeapon)
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)item;
|
||||
|
||||
if (weapon.SetID != SetItem.None || !weapon.CanAlter || weapon.NegativeAttributes.Antique != 0)
|
||||
return false;
|
||||
|
||||
if ((weapon.RequiredRace != null && weapon.RequiredRace == Race.Gargoyle && !weapon.IsArtifact))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item is BaseArmor)
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)item;
|
||||
|
||||
if (armor.SetID != SetItem.None || !armor.CanAlter || armor.NegativeAttributes.Antique != 0)
|
||||
return false;
|
||||
|
||||
if ((armor.RequiredRace != null && armor.RequiredRace == Race.Gargoyle && !armor.IsArtifact))
|
||||
return false;
|
||||
|
||||
if (armor is RingmailGlovesOfMining && armor.Resource > CraftResource.Iron)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item is BaseClothing)
|
||||
{
|
||||
BaseClothing cloth = (BaseClothing)item;
|
||||
|
||||
if (cloth.SetID != SetItem.None || !cloth.CanAlter || cloth.NegativeAttributes.Antique != 0)
|
||||
return false;
|
||||
|
||||
if ((cloth.RequiredRace != null && cloth.RequiredRace == Race.Gargoyle && !cloth.IsArtifact))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item is BaseQuiver)
|
||||
{
|
||||
BaseQuiver quiver = (BaseQuiver) item;
|
||||
|
||||
if (quiver.SetID != SetItem.None || !quiver.CanAlter)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item is IVvVItem && ((IVvVItem)item).IsVvVItem)
|
||||
return false;
|
||||
|
||||
if (item is IRewardItem)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
156
Scripts/Services/Craft/Core/AutoCraft.cs
Normal file
156
Scripts/Services/Craft/Core/AutoCraft.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Prompts;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class MakeNumberCraftPrompt : Prompt
|
||||
{
|
||||
private Mobile m_From;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private CraftItem m_CraftItem;
|
||||
private ITool m_Tool;
|
||||
|
||||
public MakeNumberCraftPrompt(Mobile from, CraftSystem system, CraftItem item, ITool tool)
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = system;
|
||||
m_CraftItem = item;
|
||||
m_Tool = tool;
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_From.SendLocalizedMessage(501806); //Request cancelled.
|
||||
from.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null));
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
int amount = Utility.ToInt32(text);
|
||||
|
||||
if (amount < 1 || amount > 100)
|
||||
{
|
||||
from.SendLocalizedMessage(1112587); // Invalid Entry.
|
||||
ResendGump();
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoCraftTimer.EndTimer(from);
|
||||
new AutoCraftTimer(m_From, m_CraftSystem, m_CraftItem, m_Tool, amount, TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0), TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0));
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(from);
|
||||
|
||||
if (context != null)
|
||||
context.MakeTotal = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResendGump()
|
||||
{
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null));
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoCraftTimer : Timer
|
||||
{
|
||||
private static Dictionary<Mobile, AutoCraftTimer> m_AutoCraftTable = new Dictionary<Mobile, AutoCraftTimer>();
|
||||
public static Dictionary<Mobile, AutoCraftTimer> AutoCraftTable { get { return m_AutoCraftTable; } }
|
||||
|
||||
private Mobile m_From;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private CraftItem m_CraftItem;
|
||||
private ITool m_Tool;
|
||||
private int m_Amount;
|
||||
private int m_Attempts;
|
||||
private int m_Ticks;
|
||||
private Type m_TypeRes;
|
||||
|
||||
public int Amount { get { return m_Amount; } }
|
||||
public int Attempts { get { return m_Attempts; } }
|
||||
|
||||
public AutoCraftTimer(Mobile from, CraftSystem system, CraftItem item, ITool tool, int amount, TimeSpan delay, TimeSpan interval)
|
||||
: base(delay, interval)
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = system;
|
||||
m_CraftItem = item;
|
||||
m_Tool = tool;
|
||||
m_Amount = amount;
|
||||
m_Ticks = 0;
|
||||
m_Attempts = 0;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
int resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
|
||||
|
||||
if (resIndex > -1)
|
||||
m_TypeRes = res.GetAt(resIndex).ItemType;
|
||||
}
|
||||
|
||||
m_AutoCraftTable[from] = this;
|
||||
|
||||
this.Start();
|
||||
}
|
||||
|
||||
public AutoCraftTimer(Mobile from, CraftSystem system, CraftItem item, ITool tool, int amount)
|
||||
: this(from, system, item, tool, amount, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3))
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Ticks++;
|
||||
|
||||
if (m_From.NetState == null)
|
||||
{
|
||||
EndTimer(m_From);
|
||||
return;
|
||||
}
|
||||
|
||||
CraftItem();
|
||||
|
||||
if (m_Ticks >= m_Amount)
|
||||
EndTimer(m_From);
|
||||
}
|
||||
|
||||
private void CraftItem()
|
||||
{
|
||||
if (m_From.HasGump(typeof(CraftGump)))
|
||||
m_From.CloseGump(typeof(CraftGump));
|
||||
|
||||
if (m_From.HasGump(typeof(CraftGumpItem)))
|
||||
m_From.CloseGump(typeof(CraftGumpItem));
|
||||
|
||||
m_Attempts++;
|
||||
|
||||
if (m_CraftItem.TryCraft != null)
|
||||
{
|
||||
m_CraftItem.TryCraft(m_From, m_CraftItem, m_Tool);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, m_TypeRes, m_Tool, m_CraftItem);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EndTimer(Mobile from)
|
||||
{
|
||||
if (m_AutoCraftTable.ContainsKey(from))
|
||||
{
|
||||
m_AutoCraftTable[from].Stop();
|
||||
m_AutoCraftTable.Remove(from);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasTimer(Mobile from)
|
||||
{
|
||||
return from != null && m_AutoCraftTable.ContainsKey(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
329
Scripts/Services/Craft/Core/CraftContext.cs
Normal file
329
Scripts/Services/Craft/Core/CraftContext.cs
Normal file
@@ -0,0 +1,329 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.Plants;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum CraftMarkOption
|
||||
{
|
||||
MarkItem,
|
||||
DoNotMark,
|
||||
PromptForMark
|
||||
}
|
||||
|
||||
#region SA
|
||||
public enum CraftQuestOption
|
||||
{
|
||||
QuestItem,
|
||||
NonQuestItem
|
||||
}
|
||||
#endregion
|
||||
|
||||
public class CraftContext
|
||||
{
|
||||
public Mobile Owner { get; private set; }
|
||||
public CraftSystem System { get; private set; }
|
||||
|
||||
private readonly List<CraftItem> m_Items;
|
||||
private int m_LastResourceIndex;
|
||||
private int m_LastResourceIndex2;
|
||||
private int m_LastGroupIndex;
|
||||
private bool m_DoNotColor;
|
||||
private CraftMarkOption m_MarkOption;
|
||||
private CraftQuestOption m_QuestOption;
|
||||
private int m_MakeTotal;
|
||||
private PlantHue m_RequiredPlantHue;
|
||||
|
||||
#region Hue State Vars
|
||||
/*private bool m_CheckedHues;
|
||||
private List<int> m_Hues;
|
||||
private Item m_CompareHueTo;
|
||||
|
||||
public bool CheckedHues
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CheckedHues;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_CheckedHues = value;
|
||||
}
|
||||
}
|
||||
public List<int> Hues
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Hues;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Hues = value;
|
||||
}
|
||||
}
|
||||
public Item CompareHueTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CompareHueTo;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_CompareHueTo = value;
|
||||
}
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
public List<CraftItem> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Items;
|
||||
}
|
||||
}
|
||||
public int LastResourceIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastResourceIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LastResourceIndex = value;
|
||||
}
|
||||
}
|
||||
public int LastResourceIndex2
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastResourceIndex2;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LastResourceIndex2 = value;
|
||||
}
|
||||
}
|
||||
public int LastGroupIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastGroupIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LastGroupIndex = value;
|
||||
}
|
||||
}
|
||||
public bool DoNotColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DoNotColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_DoNotColor = value;
|
||||
}
|
||||
}
|
||||
public CraftMarkOption MarkOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MarkOption;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MarkOption = value;
|
||||
}
|
||||
}
|
||||
#region SA
|
||||
public CraftQuestOption QuestOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_QuestOption;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_QuestOption = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int MakeTotal
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MakeTotal;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MakeTotal = value;
|
||||
}
|
||||
}
|
||||
|
||||
public PlantHue RequiredPlantHue
|
||||
{
|
||||
get { return m_RequiredPlantHue; }
|
||||
set { m_RequiredPlantHue = value; }
|
||||
}
|
||||
|
||||
public PlantPigmentHue RequiredPigmentHue { get; set; }
|
||||
#endregion
|
||||
|
||||
public CraftContext(Mobile owner, CraftSystem system)
|
||||
{
|
||||
Owner = owner;
|
||||
System = system;
|
||||
|
||||
m_Items = new List<CraftItem>();
|
||||
m_LastResourceIndex = -1;
|
||||
m_LastResourceIndex2 = -1;
|
||||
m_LastGroupIndex = -1;
|
||||
|
||||
m_QuestOption = CraftQuestOption.NonQuestItem;
|
||||
m_RequiredPlantHue = PlantHue.None;
|
||||
RequiredPigmentHue = PlantPigmentHue.None;
|
||||
|
||||
Contexts.Add(this);
|
||||
}
|
||||
|
||||
public CraftItem LastMade
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Items.Count > 0)
|
||||
return m_Items[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMade(CraftItem item)
|
||||
{
|
||||
m_Items.Remove(item);
|
||||
|
||||
if (m_Items.Count == 10)
|
||||
m_Items.RemoveAt(9);
|
||||
|
||||
m_Items.Insert(0, item);
|
||||
}
|
||||
|
||||
public virtual void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write((int)0);
|
||||
|
||||
writer.Write(Owner);
|
||||
writer.Write(GetSystemIndex(System));
|
||||
writer.Write(m_LastResourceIndex);
|
||||
writer.Write(m_LastResourceIndex2);
|
||||
writer.Write(m_LastGroupIndex);
|
||||
writer.Write(m_DoNotColor);
|
||||
writer.Write((int)m_MarkOption);
|
||||
writer.Write((int)m_QuestOption);
|
||||
|
||||
writer.Write(m_MakeTotal);
|
||||
}
|
||||
|
||||
public CraftContext(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Items = new List<CraftItem>();
|
||||
|
||||
Owner = reader.ReadMobile();
|
||||
int sysIndex = reader.ReadInt();
|
||||
m_LastResourceIndex = reader.ReadInt();
|
||||
m_LastResourceIndex2 = reader.ReadInt();
|
||||
m_LastGroupIndex = reader.ReadInt();
|
||||
m_DoNotColor = reader.ReadBool();
|
||||
m_MarkOption = (CraftMarkOption)reader.ReadInt();
|
||||
m_QuestOption = (CraftQuestOption)reader.ReadInt();
|
||||
|
||||
m_MakeTotal = reader.ReadInt();
|
||||
|
||||
System = GetCraftSystem(sysIndex);
|
||||
|
||||
if (System != null && Owner != null)
|
||||
{
|
||||
System.AddContext(Owner, this);
|
||||
Contexts.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSystemIndex(CraftSystem system)
|
||||
{
|
||||
for (int i = 0; i < _Systems.Length; i++)
|
||||
{
|
||||
if (_Systems[i] == system)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public CraftSystem GetCraftSystem(int i)
|
||||
{
|
||||
if (i >= 0 && i < _Systems.Length)
|
||||
return _Systems[i];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#region Serialize/Deserialize Persistence
|
||||
private static string FilePath = Path.Combine("Saves", "CraftContext", "Contexts.bin");
|
||||
|
||||
private static List<CraftContext> Contexts = new List<CraftContext>();
|
||||
|
||||
public static CraftSystem[] Systems { get { return _Systems; } }
|
||||
private static CraftSystem[] _Systems = new CraftSystem[11];
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
_Systems[0] = DefAlchemy.CraftSystem;
|
||||
_Systems[1] = DefBlacksmithy.CraftSystem;
|
||||
_Systems[2] = DefBowFletching.CraftSystem;
|
||||
_Systems[3] = DefCarpentry.CraftSystem;
|
||||
_Systems[4] = DefCartography.CraftSystem;
|
||||
_Systems[5] = DefCooking.CraftSystem;
|
||||
_Systems[6] = DefGlassblowing.CraftSystem;
|
||||
_Systems[7] = DefInscription.CraftSystem;
|
||||
_Systems[8] = DefMasonry.CraftSystem;
|
||||
_Systems[9] = DefTailoring.CraftSystem;
|
||||
_Systems[10] = DefTinkering.CraftSystem;
|
||||
|
||||
EventSink.WorldSave += OnSave;
|
||||
EventSink.WorldLoad += OnLoad;
|
||||
}
|
||||
|
||||
public static void OnSave(WorldSaveEventArgs e)
|
||||
{
|
||||
Persistence.Serialize(
|
||||
FilePath,
|
||||
writer =>
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(Contexts.Count);
|
||||
Contexts.ForEach(c => c.Serialize(writer));
|
||||
});
|
||||
}
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
Persistence.Deserialize(
|
||||
FilePath,
|
||||
reader =>
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
new CraftContext(reader);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
43
Scripts/Services/Craft/Core/CraftGroup.cs
Normal file
43
Scripts/Services/Craft/Core/CraftGroup.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGroup
|
||||
{
|
||||
private readonly CraftItemCol m_arCraftItem;
|
||||
private readonly string m_NameString;
|
||||
private readonly int m_NameNumber;
|
||||
public CraftGroup(TextDefinition groupName)
|
||||
{
|
||||
this.m_NameNumber = groupName;
|
||||
this.m_NameString = groupName;
|
||||
this.m_arCraftItem = new CraftItemCol();
|
||||
}
|
||||
|
||||
public CraftItemCol CraftItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_arCraftItem;
|
||||
}
|
||||
}
|
||||
public string NameString
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameString;
|
||||
}
|
||||
}
|
||||
public int NameNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameNumber;
|
||||
}
|
||||
}
|
||||
public void AddCraftItem(CraftItem craftItem)
|
||||
{
|
||||
this.m_arCraftItem.Add(craftItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Scripts/Services/Craft/Core/CraftGroupCol.cs
Normal file
48
Scripts/Services/Craft/Core/CraftGroupCol.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGroupCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftGroupCol()
|
||||
{
|
||||
}
|
||||
|
||||
public int Add(CraftGroup craftGroup)
|
||||
{
|
||||
return this.List.Add(craftGroup);
|
||||
}
|
||||
|
||||
public void Remove(int index)
|
||||
{
|
||||
if (index > this.Count - 1 || index < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.List.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftGroup GetAt(int index)
|
||||
{
|
||||
return index >= 0 && index < List.Count ? (CraftGroup)List[index] : null;
|
||||
}
|
||||
|
||||
public int SearchFor(TextDefinition groupName)
|
||||
{
|
||||
for (int i = 0; i < this.List.Count; i++)
|
||||
{
|
||||
CraftGroup craftGroup = (CraftGroup)this.List[i];
|
||||
|
||||
int nameNumber = craftGroup.NameNumber;
|
||||
string nameString = craftGroup.NameString;
|
||||
|
||||
if ((nameNumber != 0 && nameNumber == groupName.Number) || (nameString != null && nameString == groupName.String))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
783
Scripts/Services/Craft/Core/CraftGump.cs
Normal file
783
Scripts/Services/Craft/Core/CraftGump.cs
Normal file
@@ -0,0 +1,783 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGump : Gump
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly ITool m_Tool;
|
||||
|
||||
private readonly CraftPage m_Page;
|
||||
|
||||
private const int LabelHue = 0x480;
|
||||
private const int LabelColor = 0x7FFF;
|
||||
private const int FontColor = 0xFFFFFF;
|
||||
|
||||
public bool Locked { get { return AutoCraftTimer.HasTimer(m_From); } }
|
||||
|
||||
private enum CraftPage
|
||||
{
|
||||
None,
|
||||
PickResource,
|
||||
PickResource2
|
||||
}
|
||||
|
||||
/*public CraftGump( Mobile from, CraftSystem craftSystem, ITool tool ): this( from, craftSystem, -1, -1, tool, null )
|
||||
{
|
||||
}*/
|
||||
|
||||
public CraftGump(Mobile from, CraftSystem craftSystem, ITool tool, object notice)
|
||||
: this(from, craftSystem, tool, notice, CraftPage.None)
|
||||
{
|
||||
}
|
||||
|
||||
private CraftGump(Mobile from, CraftSystem craftSystem, ITool tool, object notice, CraftPage page)
|
||||
: base(40, 40)
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
m_Page = page;
|
||||
|
||||
CraftContext context = craftSystem.GetContext(from);
|
||||
|
||||
from.CloseGump(typeof(CraftGump));
|
||||
from.CloseGump(typeof(CraftGumpItem));
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 530, 497, 5054);
|
||||
AddImageTiled(10, 10, 510, 22, 2624);
|
||||
AddImageTiled(10, 292, 150, 45, 2624);
|
||||
AddImageTiled(165, 292, 355, 45, 2624);
|
||||
AddImageTiled(10, 342, 510, 145, 2624);
|
||||
AddImageTiled(10, 37, 200, 250, 2624);
|
||||
AddImageTiled(215, 37, 305, 250, 2624);
|
||||
AddAlphaRegion(10, 10, 510, 477);
|
||||
|
||||
if (craftSystem.GumpTitleNumber > 0)
|
||||
AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
|
||||
else
|
||||
AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
|
||||
|
||||
AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER>
|
||||
AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
|
||||
AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>
|
||||
|
||||
AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT
|
||||
|
||||
AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE
|
||||
|
||||
// Repair option
|
||||
if (m_CraftSystem.Repair)
|
||||
{
|
||||
AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// Mark option
|
||||
if (m_CraftSystem.MarkOption)
|
||||
{
|
||||
AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// Enhance option
|
||||
if (m_CraftSystem.CanEnhance)
|
||||
{
|
||||
AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
#region SA
|
||||
// Alter option
|
||||
if (Core.SA && m_CraftSystem.CanAlter)
|
||||
{
|
||||
AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// Quest item
|
||||
if (Core.SA)
|
||||
{
|
||||
AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
|
||||
}
|
||||
// ****************************************
|
||||
#endregion
|
||||
|
||||
AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST
|
||||
|
||||
#region Stygian Abyss
|
||||
int total = 1;
|
||||
int made = 0;
|
||||
|
||||
if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
|
||||
{
|
||||
AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
total = timer.Amount;
|
||||
made = timer.Attempts;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context != null)
|
||||
total = context.MakeTotal;
|
||||
}
|
||||
}
|
||||
|
||||
string args = String.Format("{0}\t{1}", made.ToString(), total.ToString());
|
||||
|
||||
AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED
|
||||
#endregion
|
||||
|
||||
// Resmelt option
|
||||
if (m_CraftSystem.Resmelt)
|
||||
{
|
||||
AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
if (notice is int && (int)notice > 0)
|
||||
AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
|
||||
else if (notice is string)
|
||||
AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
|
||||
|
||||
// If the system has more than one resource
|
||||
if (craftSystem.CraftSubRes.Init)
|
||||
{
|
||||
string nameString = craftSystem.CraftSubRes.NameString;
|
||||
int nameNumber = craftSystem.CraftSubRes.NameNumber;
|
||||
|
||||
int resIndex = (context == null ? -1 : context.LastResourceIndex);
|
||||
|
||||
Type resourceType = craftSystem.CraftSubRes.ResType;
|
||||
|
||||
if (resIndex > -1)
|
||||
{
|
||||
CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);
|
||||
|
||||
nameString = subResource.NameString;
|
||||
nameNumber = subResource.NameNumber;
|
||||
resourceType = subResource.ItemType;
|
||||
}
|
||||
|
||||
Type resourceType2 = GetAltType(resourceType);
|
||||
int resourceCount = 0;
|
||||
|
||||
if (from.Backpack != null)
|
||||
{
|
||||
Item[] items = from.Backpack.FindItemsByType(resourceType, true);
|
||||
|
||||
for (int i = 0; i < items.Length; ++i)
|
||||
resourceCount += items[i].Amount;
|
||||
|
||||
if (resourceType2 != null)
|
||||
{
|
||||
Item[] items2 = m_From.Backpack.FindItemsByType(resourceType2, true);
|
||||
|
||||
for (int i = 0; i < items2.Length; ++i)
|
||||
resourceCount += items2[i].Amount;
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);
|
||||
|
||||
if (nameNumber > 0)
|
||||
{
|
||||
if (context.DoNotColor)
|
||||
AddLabel(50, 365, LabelHue, "*");
|
||||
|
||||
AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
|
||||
}
|
||||
else
|
||||
AddLabel(50, 362, LabelHue, (context.DoNotColor ? "*" : "") + String.Format("{0} ({1} Available)", nameString, resourceCount));
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
// For dragon scales
|
||||
if (craftSystem.CraftSubRes2.Init)
|
||||
{
|
||||
string nameString = craftSystem.CraftSubRes2.NameString;
|
||||
int nameNumber = craftSystem.CraftSubRes2.NameNumber;
|
||||
|
||||
int resIndex = (context == null ? -1 : context.LastResourceIndex2);
|
||||
|
||||
Type resourceType = craftSystem.CraftSubRes2.ResType;
|
||||
|
||||
if (resIndex > -1)
|
||||
{
|
||||
CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);
|
||||
|
||||
nameString = subResource.NameString;
|
||||
nameNumber = subResource.NameNumber;
|
||||
resourceType = subResource.ItemType;
|
||||
}
|
||||
|
||||
int resourceCount = 0;
|
||||
|
||||
if (from.Backpack != null)
|
||||
{
|
||||
Item[] items = from.Backpack.FindItemsByType(resourceType, true);
|
||||
|
||||
for (int i = 0; i < items.Length; ++i)
|
||||
resourceCount += items[i].Amount;
|
||||
}
|
||||
|
||||
AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);
|
||||
|
||||
if (nameNumber > 0)
|
||||
AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
|
||||
else
|
||||
AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
|
||||
}
|
||||
// ****************************************
|
||||
|
||||
CreateGroupList();
|
||||
|
||||
if (page == CraftPage.PickResource)
|
||||
CreateResList(false, from);
|
||||
else if (page == CraftPage.PickResource2)
|
||||
CreateResList(true, from);
|
||||
else if (context != null && context.LastGroupIndex > -1)
|
||||
CreateItemList(context.LastGroupIndex);
|
||||
}
|
||||
|
||||
private Type GetAltType(Type original)
|
||||
{
|
||||
for (int i = 0; i < m_TypesTable.Length; i++)
|
||||
{
|
||||
if (original == m_TypesTable[i][0] && m_TypesTable[i].Length > 1)
|
||||
return m_TypesTable[i][1];
|
||||
|
||||
if (m_TypesTable[i].Length > 1 && original == m_TypesTable[i][1])
|
||||
return m_TypesTable[i][0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Type[][] m_TypesTable = new Type[][]
|
||||
{
|
||||
new Type[]{ typeof( Log ), typeof( Board ) },
|
||||
new Type[]{ typeof( HeartwoodLog ), typeof( HeartwoodBoard ) },
|
||||
new Type[]{ typeof( BloodwoodLog ), typeof( BloodwoodBoard ) },
|
||||
new Type[]{ typeof( FrostwoodLog ), typeof( FrostwoodBoard ) },
|
||||
new Type[]{ typeof( OakLog ), typeof( OakBoard ) },
|
||||
new Type[]{ typeof( AshLog ), typeof( AshBoard ) },
|
||||
new Type[]{ typeof( YewLog ), typeof( YewBoard ) },
|
||||
new Type[]{ typeof( Leather ), typeof( Hides ) },
|
||||
new Type[]{ typeof( SpinedLeather ), typeof( SpinedHides ) },
|
||||
new Type[]{ typeof( HornedLeather ), typeof( HornedHides ) },
|
||||
new Type[]{ typeof( BarbedLeather ), typeof( BarbedHides ) },
|
||||
};
|
||||
|
||||
public void CreateResList(bool opt, Mobile from)
|
||||
{
|
||||
CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
|
||||
for (int i = 0; i < res.Count; ++i)
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftSubRes subResource = res.GetAt(i);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (i > 0)
|
||||
AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
|
||||
|
||||
AddPage((i / 10) + 1);
|
||||
|
||||
if (i > 0)
|
||||
AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(255, 260, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
|
||||
}
|
||||
|
||||
int resourceCount = 0;
|
||||
|
||||
if (from.Backpack != null)
|
||||
{
|
||||
Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);
|
||||
|
||||
for (int j = 0; j < items.Length; ++j)
|
||||
resourceCount += items[j].Amount;
|
||||
|
||||
Type alt = GetAltType(subResource.ItemType);
|
||||
|
||||
if (alt != null)
|
||||
{
|
||||
Item[] items2 = m_From.Backpack.FindItemsByType(alt, true);
|
||||
|
||||
for (int j = 0; j < items2.Length; ++j)
|
||||
resourceCount += items2[j].Amount;
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);
|
||||
|
||||
if (subResource.NameNumber > 0)
|
||||
AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
|
||||
else
|
||||
AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateMakeLastList()
|
||||
{
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
List<CraftItem> items = context.Items;
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftItem craftItem = items[i];
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
|
||||
AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE
|
||||
}
|
||||
|
||||
AddPage((i / 10) + 1);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
|
||||
AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(3, i), GumpButtonType.Reply, 0);
|
||||
|
||||
if (craftItem.NameNumber > 0)
|
||||
AddHtmlLocalized(255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false);
|
||||
else
|
||||
AddLabel(255, 60 + (index * 20), LabelHue, craftItem.NameString);
|
||||
|
||||
AddButton(480, 60 + (index * 20), 4011, 4012, GetButtonID(4, i), GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: This is not as OSI; it is an intentional difference
|
||||
AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor, false, false); // You haven't made anything yet.
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateItemList(int selectedGroup)
|
||||
{
|
||||
if (selectedGroup == 501) // 501 : Last 10
|
||||
{
|
||||
CreateMakeLastList();
|
||||
return;
|
||||
}
|
||||
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
CraftGroup craftGroup = craftGroupCol.GetAt(selectedGroup);
|
||||
|
||||
if (craftGroup == null)
|
||||
return;
|
||||
|
||||
CraftItemCol craftItemCol = craftGroup.CraftItems;
|
||||
|
||||
for (int i = 0; i < craftItemCol.Count; ++i)
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftItem craftItem = craftItemCol.GetAt(i);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
|
||||
AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE
|
||||
}
|
||||
|
||||
AddPage((i / 10) + 1);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
|
||||
AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(1, i), GumpButtonType.Reply, 0);
|
||||
|
||||
if (craftItem.NameNumber > 0)
|
||||
AddHtmlLocalized(255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false);
|
||||
else
|
||||
AddLabel(255, 60 + (index * 20), LabelHue, craftItem.NameString);
|
||||
|
||||
AddButton(480, 60 + (index * 20), 4011, 4012, GetButtonID(2, i), GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int CreateGroupList()
|
||||
{
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
|
||||
AddButton(15, 60, 4005, 4007, GetButtonID(6, 3), GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor, false, false); // LAST TEN
|
||||
|
||||
for (int i = 0; i < craftGroupCol.Count; i++)
|
||||
{
|
||||
CraftGroup craftGroup = craftGroupCol.GetAt(i);
|
||||
|
||||
AddButton(15, 80 + (i * 20), 4005, 4007, GetButtonID(0, i), GumpButtonType.Reply, 0);
|
||||
|
||||
if (craftGroup.NameNumber > 0)
|
||||
AddHtmlLocalized(50, 83 + (i * 20), 150, 18, craftGroup.NameNumber, LabelColor, false, false);
|
||||
else
|
||||
AddLabel(50, 80 + (i * 20), LabelHue, craftGroup.NameString);
|
||||
}
|
||||
|
||||
return craftGroupCol.Count;
|
||||
}
|
||||
|
||||
public static int GetButtonID(int type, int index)
|
||||
{
|
||||
return 1 + type + (index * 7);
|
||||
}
|
||||
|
||||
public void CraftItem(CraftItem item)
|
||||
{
|
||||
if (item.TryCraft != null)
|
||||
{
|
||||
item.TryCraft(m_From, item, m_Tool);
|
||||
return;
|
||||
}
|
||||
|
||||
int num = m_CraftSystem.CanCraft(m_From, m_Tool, item.ItemType);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
|
||||
}
|
||||
else
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
CraftSubResCol res = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
int resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
|
||||
|
||||
if (resIndex >= 0 && resIndex < res.Count)
|
||||
type = res.GetAt(resIndex).ItemType;
|
||||
}
|
||||
|
||||
m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID <= 0)
|
||||
return; // Canceled
|
||||
|
||||
int buttonID = info.ButtonID - 1;
|
||||
int type = buttonID % 7;
|
||||
int index = buttonID / 7;
|
||||
|
||||
CraftSystem system = m_CraftSystem;
|
||||
CraftGroupCol groups = system.CraftGroups;
|
||||
CraftContext context = system.GetContext(m_From);
|
||||
|
||||
#region Stygian Abyss
|
||||
if (Locked)
|
||||
{
|
||||
if (type == 6 && index == 11)
|
||||
{
|
||||
// Cancel Make
|
||||
AutoCraftTimer.EndTimer(m_From);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: // Show group
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
if (index >= 0 && index < groups.Count)
|
||||
{
|
||||
context.LastGroupIndex = index;
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Create item
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
int groupIndex = context.LastGroupIndex;
|
||||
|
||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||
{
|
||||
CraftGroup group = groups.GetAt(groupIndex);
|
||||
|
||||
if (index >= 0 && index < group.CraftItems.Count)
|
||||
CraftItem(group.CraftItems.GetAt(index));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Item details
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
int groupIndex = context.LastGroupIndex;
|
||||
|
||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||
{
|
||||
CraftGroup group = groups.GetAt(groupIndex);
|
||||
|
||||
if (index >= 0 && index < group.CraftItems.Count)
|
||||
m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Create item (last 10)
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
List<CraftItem> lastTen = context.Items;
|
||||
|
||||
if (index >= 0 && index < lastTen.Count)
|
||||
CraftItem(lastTen[index]);
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Item details (last 10)
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
List<CraftItem> lastTen = context.Items;
|
||||
|
||||
if (index >= 0 && index < lastTen.Count)
|
||||
m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Resource selected
|
||||
{
|
||||
if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
|
||||
{
|
||||
int groupIndex = (context == null ? -1 : context.LastGroupIndex);
|
||||
|
||||
CraftSubRes res = system.CraftSubRes.GetAt(index);
|
||||
|
||||
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
|
||||
{
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context != null)
|
||||
context.LastResourceIndex = index;
|
||||
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
|
||||
}
|
||||
}
|
||||
else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
|
||||
{
|
||||
int groupIndex = (context == null ? -1 : context.LastGroupIndex);
|
||||
|
||||
CraftSubRes res = system.CraftSubRes2.GetAt(index);
|
||||
|
||||
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
|
||||
{
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context != null)
|
||||
context.LastResourceIndex2 = index;
|
||||
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 6: // Misc. buttons
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // Resource selection
|
||||
{
|
||||
if (system.CraftSubRes.Init)
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Smelt item
|
||||
{
|
||||
if (system.Resmelt)
|
||||
Resmelt.Do(m_From, system, m_Tool);
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Make last
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
CraftItem item = context.LastMade;
|
||||
|
||||
if (item != null)
|
||||
CraftItem(item);
|
||||
else
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page)); // You haven't made anything yet.
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Last 10
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
context.LastGroupIndex = 501;
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Toggle use resource hue
|
||||
{
|
||||
if (context == null)
|
||||
break;
|
||||
|
||||
context.DoNotColor = !context.DoNotColor;
|
||||
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // Repair item
|
||||
{
|
||||
if (system.Repair)
|
||||
Repair.Do(m_From, system, m_Tool);
|
||||
|
||||
break;
|
||||
}
|
||||
case 6: // Toggle mark option
|
||||
{
|
||||
if (context == null || !system.MarkOption)
|
||||
break;
|
||||
|
||||
switch ( context.MarkOption )
|
||||
{
|
||||
case CraftMarkOption.MarkItem:
|
||||
context.MarkOption = CraftMarkOption.DoNotMark;
|
||||
break;
|
||||
case CraftMarkOption.DoNotMark:
|
||||
context.MarkOption = CraftMarkOption.PromptForMark;
|
||||
break;
|
||||
case CraftMarkOption.PromptForMark:
|
||||
context.MarkOption = CraftMarkOption.MarkItem;
|
||||
break;
|
||||
}
|
||||
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
|
||||
|
||||
break;
|
||||
}
|
||||
case 7: // Resource selection 2
|
||||
{
|
||||
if (system.CraftSubRes2.Init)
|
||||
m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
|
||||
|
||||
break;
|
||||
}
|
||||
case 8: // Enhance item
|
||||
{
|
||||
if (system.CanEnhance)
|
||||
Enhance.BeginTarget(m_From, system, m_Tool);
|
||||
|
||||
break;
|
||||
}
|
||||
case 9: // Alter Item (Gargoyle)
|
||||
{
|
||||
if (system.CanAlter)
|
||||
{
|
||||
if (Server.SkillHandlers.Imbuing.CheckSoulForge(m_From, 1, false))
|
||||
{
|
||||
AlterItem.BeginTarget(m_From, system, m_Tool);
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(1111867); // You must be near a soulforge to alter an item.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: // Quest Item/Non Quest Item toggle
|
||||
{
|
||||
//if (context == null || !system.QuestOption)
|
||||
//break;
|
||||
switch ( context.QuestOption )
|
||||
{
|
||||
case CraftQuestOption.QuestItem:
|
||||
context.QuestOption = CraftQuestOption.NonQuestItem;
|
||||
break;
|
||||
case CraftQuestOption.NonQuestItem:
|
||||
context.QuestOption = CraftQuestOption.QuestItem;
|
||||
break;
|
||||
}
|
||||
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
|
||||
|
||||
break;
|
||||
}
|
||||
case 11: // Cancel Make
|
||||
{
|
||||
AutoCraftTimer.EndTimer(m_From);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
342
Scripts/Services/Craft/Core/CraftGumpItem.cs
Normal file
342
Scripts/Services/Craft/Core/CraftGumpItem.cs
Normal file
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftGumpItem : Gump
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly CraftItem m_CraftItem;
|
||||
private readonly ITool m_Tool;
|
||||
|
||||
private const int LabelHue = 0x480; // 0x384
|
||||
private const int RedLabelHue = 0x20;
|
||||
|
||||
private const int LabelColor = 0x7FFF;
|
||||
private const int RedLabelColor = 0x6400;
|
||||
|
||||
private const int GreyLabelColor = 0x3DEF;
|
||||
|
||||
private int m_OtherCount;
|
||||
|
||||
public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, ITool tool)
|
||||
: base(40, 40)
|
||||
{
|
||||
m_From = from;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_CraftItem = craftItem;
|
||||
m_Tool = tool;
|
||||
|
||||
from.CloseGump(typeof(CraftGump));
|
||||
from.CloseGump(typeof(CraftGumpItem));
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 530, 417, 5054);
|
||||
AddImageTiled(10, 10, 510, 22, 2624);
|
||||
AddImageTiled(10, 37, 150, 148, 2624);
|
||||
AddImageTiled(165, 37, 355, 90, 2624);
|
||||
AddImageTiled(10, 190, 155, 22, 2624);
|
||||
AddImageTiled(10, 240, 150, 57, 2624);
|
||||
AddImageTiled(165, 132, 355, 80, 2624);
|
||||
AddImageTiled(10, 325, 150, 57, 2624);
|
||||
AddImageTiled(165, 217, 355, 80, 2624);
|
||||
AddImageTiled(165, 302, 355, 80, 2624);
|
||||
AddImageTiled(10, 387, 510, 22, 2624);
|
||||
AddAlphaRegion(10, 10, 510, 399);
|
||||
|
||||
AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false); // ITEM
|
||||
AddHtmlLocalized(10, 217, 150, 22, 1044055, LabelColor, false, false); // <CENTER>MATERIALS</CENTER>
|
||||
AddHtmlLocalized(10, 302, 150, 22, 1044056, LabelColor, false, false); // <CENTER>OTHER</CENTER>
|
||||
|
||||
if (craftSystem.GumpTitleNumber > 0)
|
||||
AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
|
||||
else
|
||||
AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
|
||||
|
||||
bool needsRecipe = (craftItem.Recipe != null && from is PlayerMobile && !((PlayerMobile)from).HasRecipe(craftItem.Recipe));
|
||||
|
||||
if (needsRecipe)
|
||||
{
|
||||
AddButton(405, 387, 4005, 4007, 0, GumpButtonType.Page, 0);
|
||||
AddHtmlLocalized(440, 390, 150, 18, 1044151, GreyLabelColor, false, false); // MAKE NOW
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(405, 387, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(445, 390, 150, 18, 1044151, LabelColor, false, false); // MAKE NOW
|
||||
}
|
||||
|
||||
#region Stygian Abyss
|
||||
AddButton(265, 387, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(300, 390, 150, 18, 1112623, LabelColor, false, false); //MAKE NUMBER
|
||||
|
||||
AddButton(135, 387, 4005, 4007, 3, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(170, 390, 150, 18, 1112624, LabelColor, false, false); //MAKE MAX
|
||||
#endregion
|
||||
|
||||
AddButton(15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false); // BACK
|
||||
|
||||
if (craftItem.NameNumber > 0)
|
||||
AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false);
|
||||
else
|
||||
AddLabel(330, 40, LabelHue, craftItem.NameString);
|
||||
|
||||
if (craftItem.UseAllRes)
|
||||
AddHtmlLocalized(170, 302 + (m_OtherCount++ * 20), 310, 18, 1048176, LabelColor, false, false); // Makes as many as possible at once
|
||||
|
||||
DrawItem();
|
||||
DrawSkill();
|
||||
DrawResource();
|
||||
|
||||
/*
|
||||
if( craftItem.RequiresSE )
|
||||
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1063363, LabelColor, false, false ); //* Requires the "Samurai Empire" expansion
|
||||
* */
|
||||
|
||||
if (craftItem.RequiredExpansion != Expansion.None)
|
||||
{
|
||||
bool supportsEx = (from.NetState != null && from.NetState.SupportsExpansion(craftItem.RequiredExpansion));
|
||||
TextDefinition.AddHtmlText(this, 170, 302 + (m_OtherCount++ * 20), 310, 18, RequiredExpansionMessage(craftItem.RequiredExpansion), false, false, supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue);
|
||||
}
|
||||
|
||||
if (craftItem.RequiredThemePack != ThemePack.None)
|
||||
{
|
||||
TextDefinition.AddHtmlText(this, 170, 302 + (m_OtherCount++ * 20), 310, 18, RequiredThemePackMessage(craftItem.RequiredThemePack), false, false, LabelColor, LabelHue);
|
||||
}
|
||||
|
||||
if (needsRecipe)
|
||||
AddHtmlLocalized(170, 302 + (m_OtherCount++ * 20), 310, 18, 1073620, RedLabelColor, false, false); // You have not learned this recipe.
|
||||
}
|
||||
|
||||
private TextDefinition RequiredExpansionMessage(Expansion expansion)
|
||||
{
|
||||
switch( expansion )
|
||||
{
|
||||
case Expansion.SE:
|
||||
return 1063363; // * Requires the "Samurai Empire" expansion
|
||||
case Expansion.ML:
|
||||
return 1072651; // * Requires the "Mondain's Legacy" expansion
|
||||
case Expansion.SA:
|
||||
return 1094732; // * Requires the "Stygian Abyss" expansion
|
||||
case Expansion.HS:
|
||||
return 1116296; // * Requires the "High Seas" booster
|
||||
case Expansion.TOL:
|
||||
return 1155876; // * Requires the "Time of Legends" expansion.
|
||||
default:
|
||||
return String.Format("* Requires the \"{0}\" expansion", ExpansionInfo.GetInfo(expansion).Name);
|
||||
}
|
||||
}
|
||||
|
||||
private TextDefinition RequiredThemePackMessage(ThemePack pack)
|
||||
{
|
||||
switch (pack)
|
||||
{
|
||||
case ThemePack.Kings:
|
||||
return 1154195; // *Requires the "King's Collection" theme pack
|
||||
case ThemePack.Rustic:
|
||||
return 1150651; // * Requires the "Rustic" theme pack
|
||||
case ThemePack.Gothic:
|
||||
return 1150650; // * Requires the "Gothic" theme pack
|
||||
default:
|
||||
return String.Format("Requires the \"{0}\" theme pack.", null);
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_ShowExceptionalChance;
|
||||
|
||||
public void DrawItem()
|
||||
{
|
||||
Type type = m_CraftItem.ItemType;
|
||||
int id = m_CraftItem.DisplayID;
|
||||
if (id == 0) id = CraftItem.ItemIDOf(type);
|
||||
Rectangle2D b = ItemBounds.Table[id];
|
||||
AddItem(90 - b.Width / 2 - b.X, 110 - b.Height / 2 - b.Y, id, m_CraftItem.ItemHue);
|
||||
|
||||
if (m_CraftItem.IsMarkable(type))
|
||||
{
|
||||
AddHtmlLocalized(170, 302 + (m_OtherCount++ * 20), 310, 18, 1044059, LabelColor, false, false); // This item may hold its maker's mark
|
||||
m_ShowExceptionalChance = true;
|
||||
}
|
||||
else if (typeof(IQuality).IsAssignableFrom(m_CraftItem.ItemType))
|
||||
{
|
||||
m_ShowExceptionalChance = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawSkill()
|
||||
{
|
||||
for (int i = 0; i < m_CraftItem.Skills.Count; i++)
|
||||
{
|
||||
CraftSkill skill = m_CraftItem.Skills.GetAt(i);
|
||||
double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;
|
||||
|
||||
if (minSkill < 0)
|
||||
minSkill = 0;
|
||||
|
||||
AddHtmlLocalized(170, 132 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false);
|
||||
AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
|
||||
}
|
||||
|
||||
CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
int resIndex = -1;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
if (context != null)
|
||||
resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
|
||||
|
||||
bool allRequiredSkills = true;
|
||||
double chance = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
|
||||
double excepChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);
|
||||
|
||||
if (chance < 0.0)
|
||||
chance = 0.0;
|
||||
else if (chance > 1.0)
|
||||
chance = 1.0;
|
||||
|
||||
AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance:
|
||||
AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100));
|
||||
|
||||
if (m_ShowExceptionalChance)
|
||||
{
|
||||
if (excepChance < 0.0)
|
||||
excepChance = 0.0;
|
||||
else if (excepChance > 1.0)
|
||||
excepChance = 1.0;
|
||||
|
||||
AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance:
|
||||
AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Type typeofBlankScroll = typeof(BlankScroll);
|
||||
private static readonly Type typeofSpellScroll = typeof(SpellScroll);
|
||||
|
||||
public void DrawResource()
|
||||
{
|
||||
bool retainedColor = false;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
int resIndex = -1;
|
||||
|
||||
if (context != null)
|
||||
resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
|
||||
|
||||
bool cropScroll = (m_CraftItem.Resources.Count > 1) &&
|
||||
m_CraftItem.Resources.GetAt(m_CraftItem.Resources.Count - 1).ItemType == typeofBlankScroll &&
|
||||
typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);
|
||||
|
||||
for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
|
||||
{
|
||||
Type type;
|
||||
string nameString;
|
||||
int nameNumber;
|
||||
|
||||
CraftRes craftResource = m_CraftItem.Resources.GetAt(i);
|
||||
|
||||
type = craftResource.ItemType;
|
||||
nameString = craftResource.NameString;
|
||||
nameNumber = craftResource.NameNumber;
|
||||
|
||||
// Resource Mutation
|
||||
if (type == res.ResType && resIndex > -1)
|
||||
{
|
||||
CraftSubRes subResource = res.GetAt(resIndex);
|
||||
|
||||
type = subResource.ItemType;
|
||||
|
||||
nameString = subResource.NameString;
|
||||
nameNumber = subResource.GenericNameNumber;
|
||||
|
||||
if (nameNumber <= 0)
|
||||
nameNumber = subResource.NameNumber;
|
||||
}
|
||||
// ******************
|
||||
|
||||
if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
|
||||
{
|
||||
retainedColor = true;
|
||||
AddHtmlLocalized(170, 302 + (m_OtherCount++ * 20), 310, 18, 1044152, LabelColor, false, false); // * The item retains the color of this material
|
||||
AddLabel(500, 219 + (i * 20), LabelHue, "*");
|
||||
}
|
||||
|
||||
if (nameNumber > 0)
|
||||
AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
|
||||
else
|
||||
AddLabel(170, 219 + (i * 20), LabelHue, nameString);
|
||||
|
||||
AddLabel(430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString());
|
||||
}
|
||||
|
||||
if (m_CraftItem.NameNumber == 1041267) // runebook
|
||||
{
|
||||
AddHtmlLocalized(170, 219 + (m_CraftItem.Resources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
|
||||
AddLabel(430, 219 + (m_CraftItem.Resources.Count * 20), LabelHue, "1");
|
||||
}
|
||||
|
||||
if (cropScroll)
|
||||
AddHtmlLocalized(170, 302 + (m_OtherCount++ * 20), 360, 18, 1044379, LabelColor, false, false); // Inscribing scrolls also requires a blank scroll and mana.
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0: // Back Button
|
||||
{
|
||||
CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
|
||||
m_From.SendGump(craftGump);
|
||||
break;
|
||||
}
|
||||
case 1: // Make Button
|
||||
{
|
||||
if (m_CraftItem.TryCraft != null)
|
||||
{
|
||||
m_CraftItem.TryCraft(m_From, m_CraftItem, m_Tool);
|
||||
return;
|
||||
}
|
||||
|
||||
int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
|
||||
}
|
||||
else
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
CraftContext context = m_CraftSystem.GetContext(m_From);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
|
||||
int resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
|
||||
|
||||
if (resIndex > -1)
|
||||
type = res.GetAt(resIndex).ItemType;
|
||||
}
|
||||
|
||||
m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: //Make Number
|
||||
m_From.Prompt = new MakeNumberCraftPrompt(m_From, m_CraftSystem, m_CraftItem, m_Tool);
|
||||
m_From.SendLocalizedMessage(1112576); //Please type the amount you wish to create(1 - 100): <Escape to cancel>
|
||||
break;
|
||||
case 3: //Make Max
|
||||
AutoCraftTimer.EndTimer(m_From);
|
||||
new AutoCraftTimer(m_From, m_CraftSystem, m_CraftItem, m_Tool, 9999, TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0), TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2291
Scripts/Services/Craft/Core/CraftItem.cs
Normal file
2291
Scripts/Services/Craft/Core/CraftItem.cs
Normal file
File diff suppressed because it is too large
Load Diff
58
Scripts/Services/Craft/Core/CraftItemCol.cs
Normal file
58
Scripts/Services/Craft/Core/CraftItemCol.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftItemCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftItemCol()
|
||||
{
|
||||
}
|
||||
|
||||
public int Add(CraftItem craftItem)
|
||||
{
|
||||
return this.List.Add(craftItem);
|
||||
}
|
||||
|
||||
public void Remove(int index)
|
||||
{
|
||||
if (index > this.Count - 1 || index < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.List.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftItem GetAt(int index)
|
||||
{
|
||||
return (CraftItem)this.List[index];
|
||||
}
|
||||
|
||||
public CraftItem SearchForSubclass(Type type)
|
||||
{
|
||||
for (int i = 0; i < this.List.Count; i++)
|
||||
{
|
||||
CraftItem craftItem = (CraftItem)this.List[i];
|
||||
|
||||
if (craftItem.ItemType == type || type.IsSubclassOf(craftItem.ItemType))
|
||||
return craftItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CraftItem SearchFor(Type type)
|
||||
{
|
||||
for (int i = 0; i < this.List.Count; i++)
|
||||
{
|
||||
CraftItem craftItem = (CraftItem)this.List[i];
|
||||
if (craftItem.ItemType == type)
|
||||
{
|
||||
return craftItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Scripts/Services/Craft/Core/CraftItemIDAttribute.cs
Normal file
22
Scripts/Services/Craft/Core/CraftItemIDAttribute.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class CraftItemIDAttribute : Attribute
|
||||
{
|
||||
private readonly int m_ItemID;
|
||||
public CraftItemIDAttribute(int itemID)
|
||||
{
|
||||
this.m_ItemID = itemID;
|
||||
}
|
||||
|
||||
public int ItemID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ItemID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Scripts/Services/Craft/Core/CraftRes.cs
Normal file
81
Scripts/Services/Craft/Core/CraftRes.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftRes
|
||||
{
|
||||
private readonly Type m_Type;
|
||||
private readonly int m_Amount;
|
||||
private readonly string m_MessageString;
|
||||
private readonly int m_MessageNumber;
|
||||
private readonly string m_NameString;
|
||||
private readonly int m_NameNumber;
|
||||
public CraftRes(Type type, int amount)
|
||||
{
|
||||
this.m_Type = type;
|
||||
this.m_Amount = amount;
|
||||
}
|
||||
|
||||
public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message)
|
||||
: this(type, amount)
|
||||
{
|
||||
this.m_NameNumber = name;
|
||||
this.m_MessageNumber = message;
|
||||
|
||||
this.m_NameString = name;
|
||||
this.m_MessageString = message;
|
||||
}
|
||||
|
||||
public Type ItemType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
}
|
||||
public string MessageString
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_MessageString;
|
||||
}
|
||||
}
|
||||
public int MessageNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_MessageNumber;
|
||||
}
|
||||
}
|
||||
public string NameString
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameString;
|
||||
}
|
||||
}
|
||||
public int NameNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameNumber;
|
||||
}
|
||||
}
|
||||
public int Amount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Amount;
|
||||
}
|
||||
}
|
||||
public void SendMessage(Mobile from)
|
||||
{
|
||||
if (this.m_MessageNumber > 0)
|
||||
from.SendLocalizedMessage(this.m_MessageNumber);
|
||||
else if (!String.IsNullOrEmpty(this.m_MessageString))
|
||||
from.SendMessage(this.m_MessageString);
|
||||
else
|
||||
from.SendLocalizedMessage(502925); // You don't have the resources required to make that item.
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Scripts/Services/Craft/Core/CraftResCol.cs
Normal file
32
Scripts/Services/Craft/Core/CraftResCol.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftResCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftResCol()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(CraftRes craftRes)
|
||||
{
|
||||
this.List.Add(craftRes);
|
||||
}
|
||||
|
||||
public void Remove(int index)
|
||||
{
|
||||
if (index > this.Count - 1 || index < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.List.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftRes GetAt(int index)
|
||||
{
|
||||
return (CraftRes)this.List[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Scripts/Services/Craft/Core/CraftSkill.cs
Normal file
39
Scripts/Services/Craft/Core/CraftSkill.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSkill
|
||||
{
|
||||
private readonly SkillName m_SkillToMake;
|
||||
private readonly double m_MinSkill;
|
||||
private readonly double m_MaxSkill;
|
||||
public CraftSkill(SkillName skillToMake, double minSkill, double maxSkill)
|
||||
{
|
||||
this.m_SkillToMake = skillToMake;
|
||||
this.m_MinSkill = minSkill;
|
||||
this.m_MaxSkill = maxSkill;
|
||||
}
|
||||
|
||||
public SkillName SkillToMake
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SkillToMake;
|
||||
}
|
||||
}
|
||||
public double MinSkill
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_MinSkill;
|
||||
}
|
||||
}
|
||||
public double MaxSkill
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_MaxSkill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Scripts/Services/Craft/Core/CraftSkillCol.cs
Normal file
32
Scripts/Services/Craft/Core/CraftSkillCol.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSkillCol : System.Collections.CollectionBase
|
||||
{
|
||||
public CraftSkillCol()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(CraftSkill craftSkill)
|
||||
{
|
||||
this.List.Add(craftSkill);
|
||||
}
|
||||
|
||||
public void Remove(int index)
|
||||
{
|
||||
if (index > this.Count - 1 || index < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.List.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftSkill GetAt(int index)
|
||||
{
|
||||
return (CraftSkill)this.List[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Scripts/Services/Craft/Core/CraftSubRes.cs
Normal file
71
Scripts/Services/Craft/Core/CraftSubRes.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSubRes
|
||||
{
|
||||
private readonly Type m_Type;
|
||||
private readonly double m_ReqSkill;
|
||||
private readonly string m_NameString;
|
||||
private readonly int m_NameNumber;
|
||||
private readonly int m_GenericNameNumber;
|
||||
private readonly object m_Message;
|
||||
public CraftSubRes(Type type, TextDefinition name, double reqSkill, object message)
|
||||
: this(type, name, reqSkill, 0, message)
|
||||
{
|
||||
}
|
||||
|
||||
public CraftSubRes(Type type, TextDefinition name, double reqSkill, int genericNameNumber, object message)
|
||||
{
|
||||
this.m_Type = type;
|
||||
this.m_NameNumber = name;
|
||||
this.m_NameString = name;
|
||||
this.m_ReqSkill = reqSkill;
|
||||
this.m_GenericNameNumber = genericNameNumber;
|
||||
this.m_Message = message;
|
||||
}
|
||||
|
||||
public Type ItemType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
}
|
||||
public string NameString
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameString;
|
||||
}
|
||||
}
|
||||
public int NameNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameNumber;
|
||||
}
|
||||
}
|
||||
public int GenericNameNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_GenericNameNumber;
|
||||
}
|
||||
}
|
||||
public object Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Message;
|
||||
}
|
||||
}
|
||||
public double RequiredSkill
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ReqSkill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
94
Scripts/Services/Craft/Core/CraftSubResCol.cs
Normal file
94
Scripts/Services/Craft/Core/CraftSubResCol.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSubResCol : System.Collections.CollectionBase
|
||||
{
|
||||
private Type m_Type;
|
||||
private string m_NameString;
|
||||
private int m_NameNumber;
|
||||
private bool m_Init;
|
||||
public CraftSubResCol()
|
||||
{
|
||||
this.m_Init = false;
|
||||
}
|
||||
|
||||
public bool Init
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Init;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Init = value;
|
||||
}
|
||||
}
|
||||
public Type ResType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Type = value;
|
||||
}
|
||||
}
|
||||
public string NameString
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameString;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_NameString = value;
|
||||
}
|
||||
}
|
||||
public int NameNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_NameNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_NameNumber = value;
|
||||
}
|
||||
}
|
||||
public void Add(CraftSubRes craftSubRes)
|
||||
{
|
||||
this.List.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void Remove(int index)
|
||||
{
|
||||
if (index > this.Count - 1 || index < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.List.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftSubRes GetAt(int index)
|
||||
{
|
||||
return (CraftSubRes)this.List[index];
|
||||
}
|
||||
|
||||
public CraftSubRes SearchFor(Type type)
|
||||
{
|
||||
for (int i = 0; i < this.List.Count; i++)
|
||||
{
|
||||
CraftSubRes craftSubRes = (CraftSubRes)this.List[i];
|
||||
if (craftSubRes.ItemType == type)
|
||||
{
|
||||
return craftSubRes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
632
Scripts/Services/Craft/Core/CraftSystem.cs
Normal file
632
Scripts/Services/Craft/Core/CraftSystem.cs
Normal file
@@ -0,0 +1,632 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum CraftECA
|
||||
{
|
||||
ChanceMinusSixty,
|
||||
FiftyPercentChanceMinusTenPercent,
|
||||
ChanceMinusSixtyToFourtyFive
|
||||
}
|
||||
|
||||
public abstract class CraftSystem
|
||||
{
|
||||
public static List<CraftSystem> Systems { get; set; }
|
||||
|
||||
private readonly int m_MinCraftEffect;
|
||||
private readonly int m_MaxCraftEffect;
|
||||
private readonly double m_Delay;
|
||||
private bool m_Resmelt;
|
||||
private bool m_Repair;
|
||||
private bool m_MarkOption;
|
||||
private bool m_CanEnhance;
|
||||
|
||||
private bool m_QuestOption;
|
||||
private bool m_CanAlter;
|
||||
|
||||
private readonly CraftItemCol m_CraftItems;
|
||||
private readonly CraftGroupCol m_CraftGroups;
|
||||
private readonly CraftSubResCol m_CraftSubRes;
|
||||
private readonly CraftSubResCol m_CraftSubRes2;
|
||||
|
||||
public int MinCraftEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MinCraftEffect;
|
||||
}
|
||||
}
|
||||
public int MaxCraftEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MaxCraftEffect;
|
||||
}
|
||||
}
|
||||
public double Delay
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Delay;
|
||||
}
|
||||
}
|
||||
|
||||
public CraftItemCol CraftItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CraftItems;
|
||||
}
|
||||
}
|
||||
public CraftGroupCol CraftGroups
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CraftGroups;
|
||||
}
|
||||
}
|
||||
public CraftSubResCol CraftSubRes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CraftSubRes;
|
||||
}
|
||||
}
|
||||
public CraftSubResCol CraftSubRes2
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CraftSubRes2;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract SkillName MainSkill { get; }
|
||||
|
||||
public virtual int GumpTitleNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public virtual string GumpTitleString
|
||||
{
|
||||
get
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public virtual CraftECA ECA
|
||||
{
|
||||
get
|
||||
{
|
||||
return CraftECA.ChanceMinusSixty;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
|
||||
|
||||
public abstract double GetChanceAtMin(CraftItem item);
|
||||
|
||||
public virtual bool RetainsColorFrom(CraftItem item, Type type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddContext(Mobile m, CraftContext c)
|
||||
{
|
||||
if (c == null || m == null || c.System != this)
|
||||
return;
|
||||
|
||||
m_ContextTable[m] = c;
|
||||
}
|
||||
|
||||
public CraftContext GetContext(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
return null;
|
||||
|
||||
if (m.Deleted)
|
||||
{
|
||||
m_ContextTable.Remove(m);
|
||||
return null;
|
||||
}
|
||||
|
||||
CraftContext c = null;
|
||||
m_ContextTable.TryGetValue(m, out c);
|
||||
|
||||
if (c == null)
|
||||
m_ContextTable[m] = c = new CraftContext(m, this);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public void OnMade(Mobile m, CraftItem item)
|
||||
{
|
||||
CraftContext c = GetContext(m);
|
||||
|
||||
if (c != null)
|
||||
c.OnMade(item);
|
||||
}
|
||||
|
||||
public void OnRepair(Mobile m, ITool tool, Item deed, Item addon, IEntity e)
|
||||
{
|
||||
Item source;
|
||||
|
||||
if (tool is Item)
|
||||
{
|
||||
source = (Item)tool;
|
||||
}
|
||||
else
|
||||
{
|
||||
source = deed ?? addon;
|
||||
}
|
||||
|
||||
EventSink.InvokeRepairItem(new RepairItemEventArgs(m, source, e));
|
||||
}
|
||||
|
||||
public bool Resmelt
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Resmelt;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Resmelt = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Repair
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Repair;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Repair = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MarkOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MarkOption;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MarkOption = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanEnhance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CanEnhance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_CanEnhance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool QuestOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_QuestOption;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_QuestOption = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanAlter
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CanAlter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_CanAlter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
|
||||
{
|
||||
m_MinCraftEffect = minCraftEffect;
|
||||
m_MaxCraftEffect = maxCraftEffect;
|
||||
m_Delay = delay;
|
||||
|
||||
m_CraftItems = new CraftItemCol();
|
||||
m_CraftGroups = new CraftGroupCol();
|
||||
m_CraftSubRes = new CraftSubResCol();
|
||||
m_CraftSubRes2 = new CraftSubResCol();
|
||||
|
||||
InitCraftList();
|
||||
AddSystem(this);
|
||||
}
|
||||
|
||||
private void AddSystem(CraftSystem system)
|
||||
{
|
||||
if (Systems == null)
|
||||
Systems = new List<CraftSystem>();
|
||||
|
||||
Systems.Add(system);
|
||||
}
|
||||
|
||||
private Type[] _GlobalNoConsume =
|
||||
{
|
||||
typeof(CapturedEssence), typeof(EyeOfTheTravesty), typeof(DiseasedBark), typeof(LardOfParoxysmus), typeof(GrizzledBones), typeof(DreadHornMane),
|
||||
|
||||
typeof(Blight), typeof(Corruption), typeof(Muculent), typeof(Scourge), typeof(Putrefaction), typeof(Taint),
|
||||
|
||||
// Tailoring
|
||||
typeof(MidnightBracers), typeof(CrimsonCincture), typeof(GargishCrimsonCincture), typeof(LeurociansMempoOfFortune),
|
||||
|
||||
// Blacksmithy
|
||||
typeof(LeggingsOfBane), typeof(GauntletsOfNobility),
|
||||
|
||||
// Carpentry
|
||||
typeof(StaffOfTheMagi), typeof(BlackrockMoonstone),
|
||||
|
||||
// Tinkering
|
||||
typeof(Server.Factions.Silver), typeof(RingOfTheElements), typeof(HatOfTheMagi), typeof(AutomatonActuator),
|
||||
|
||||
// Inscription
|
||||
typeof(AntiqueDocumentsKit)
|
||||
};
|
||||
|
||||
public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem)
|
||||
{
|
||||
return !_GlobalNoConsume.Any(t => t == resourceType);
|
||||
}
|
||||
|
||||
public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem, ref MasterCraftsmanTalisman talisman)
|
||||
{
|
||||
if (!ConsumeOnFailure(from, resourceType, craftItem))
|
||||
return false;
|
||||
|
||||
Item item = from.FindItemOnLayer(Layer.Talisman);
|
||||
|
||||
if (item is MasterCraftsmanTalisman)
|
||||
{
|
||||
MasterCraftsmanTalisman mct = (MasterCraftsmanTalisman)item;
|
||||
|
||||
if (mct.Charges > 0)
|
||||
{
|
||||
talisman = mct;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CreateItem(Mobile from, Type type, Type typeRes, ITool tool, CraftItem realCraftItem)
|
||||
{
|
||||
// Verify if the type is in the list of the craftable item
|
||||
CraftItem craftItem = m_CraftItems.SearchFor(type);
|
||||
if (craftItem != null)
|
||||
{
|
||||
// The item is in the list, try to create it
|
||||
// Test code: items like sextant parts can be crafted either directly from ingots, or from different parts
|
||||
realCraftItem.Craft(from, this, typeRes, tool);
|
||||
//craftItem.Craft( from, this, typeRes, tool );
|
||||
}
|
||||
}
|
||||
|
||||
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount)
|
||||
{
|
||||
return AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "");
|
||||
}
|
||||
|
||||
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message)
|
||||
{
|
||||
return AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, message);
|
||||
}
|
||||
|
||||
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount)
|
||||
{
|
||||
return AddCraft(typeItem, group, name, skillToMake, minSkill, maxSkill, typeRes, nameRes, amount, "");
|
||||
}
|
||||
|
||||
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, SkillName skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message)
|
||||
{
|
||||
CraftItem craftItem = new CraftItem(typeItem, group, name);
|
||||
craftItem.AddRes(typeRes, nameRes, amount, message);
|
||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||
|
||||
DoGroup(group, craftItem);
|
||||
return m_CraftItems.Add(craftItem);
|
||||
}
|
||||
|
||||
private void DoGroup(TextDefinition groupName, CraftItem craftItem)
|
||||
{
|
||||
int index = m_CraftGroups.SearchFor(groupName);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
CraftGroup craftGroup = new CraftGroup(groupName);
|
||||
craftGroup.AddCraftItem(craftItem);
|
||||
m_CraftGroups.Add(craftGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CraftGroups.GetAt(index).AddCraftItem(craftItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetItemHue(int index, int hue)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ItemHue = hue;
|
||||
}
|
||||
|
||||
public void SetManaReq(int index, int mana)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.Mana = mana;
|
||||
}
|
||||
|
||||
public void SetStamReq(int index, int stam)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.Stam = stam;
|
||||
}
|
||||
|
||||
public void SetHitsReq(int index, int hits)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.Hits = hits;
|
||||
}
|
||||
|
||||
public void SetUseAllRes(int index, bool useAll)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.UseAllRes = useAll;
|
||||
}
|
||||
|
||||
public void SetForceTypeRes(int index, bool value)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ForceTypeRes = value;
|
||||
}
|
||||
|
||||
public void SetNeedHeat(int index, bool needHeat)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.NeedHeat = needHeat;
|
||||
}
|
||||
|
||||
public void SetNeedOven(int index, bool needOven)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.NeedOven = needOven;
|
||||
}
|
||||
|
||||
public void SetNeedMaker(int index, bool needMaker)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.NeedMaker = needMaker;
|
||||
}
|
||||
|
||||
public void SetNeedWater(int index, bool needWater)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.NeedWater = needWater;
|
||||
}
|
||||
|
||||
public void SetBeverageType(int index, BeverageType requiredBeverage)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.RequiredBeverage = requiredBeverage;
|
||||
}
|
||||
|
||||
public void SetNeedMill(int index, bool needMill)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.NeedMill = needMill;
|
||||
}
|
||||
|
||||
public void SetNeededThemePack(int index, ThemePack pack)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.RequiredThemePack = pack;
|
||||
}
|
||||
|
||||
public void SetRequiresBasketWeaving(int index)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.RequiresBasketWeaving = true;
|
||||
}
|
||||
|
||||
public void SetRequireResTarget(int index)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.RequiresResTarget = true;
|
||||
}
|
||||
|
||||
public void SetRequiresMechanicalLife(int index)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.RequiresMechanicalLife = true;
|
||||
}
|
||||
|
||||
public void SetData(int index, object data)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.Data = data;
|
||||
}
|
||||
|
||||
public void SetDisplayID(int index, int id)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.DisplayID = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a callback Action to allow mutating the crafted item. Handy when you have a single Item Type but you want to create variations of it.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="action"></param>
|
||||
public void SetMutateAction(int index, Action<Mobile, Item, ITool> action)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.MutateAction = action;
|
||||
}
|
||||
|
||||
public void SetForceSuccess(int index, int success)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ForceSuccessChance = success;
|
||||
}
|
||||
|
||||
public void AddRes(int index, Type type, TextDefinition name, int amount)
|
||||
{
|
||||
AddRes(index, type, name, amount, "");
|
||||
}
|
||||
|
||||
public void AddRes(int index, Type type, TextDefinition name, int amount, TextDefinition message)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.AddRes(type, name, amount, message);
|
||||
}
|
||||
|
||||
public void AddResCallback(int index, Func<Mobile, ConsumeType, int> func)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ConsumeResCallback = func;
|
||||
}
|
||||
|
||||
public void AddSkill(int index, SkillName skillToMake, double minSkill, double maxSkill)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||
}
|
||||
|
||||
public void SetUseSubRes2(int index, bool val)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.UseSubRes2 = val;
|
||||
}
|
||||
|
||||
public void AddRecipe(int index, int id)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.AddRecipe(id, this);
|
||||
}
|
||||
|
||||
public void ForceNonExceptional(int index)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ForceNonExceptional = true;
|
||||
}
|
||||
|
||||
public void ForceExceptional(int index)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.ForceExceptional = true;
|
||||
}
|
||||
|
||||
public void SetMinSkillOffset(int index, double skillOffset)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.MinSkillOffset = skillOffset;
|
||||
}
|
||||
|
||||
public void AddCraftAction(int index, Action<Mobile, CraftItem, ITool> action)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.TryCraft = action;
|
||||
}
|
||||
|
||||
public void AddCreateItem(int index, Func<Mobile, CraftItem, ITool, Item> func)
|
||||
{
|
||||
CraftItem craftItem = m_CraftItems.GetAt(index);
|
||||
craftItem.CreateItem = func;
|
||||
}
|
||||
|
||||
public void SetSubRes(Type type, string name)
|
||||
{
|
||||
m_CraftSubRes.ResType = type;
|
||||
m_CraftSubRes.NameString = name;
|
||||
m_CraftSubRes.Init = true;
|
||||
}
|
||||
|
||||
public void SetSubRes(Type type, int name)
|
||||
{
|
||||
m_CraftSubRes.ResType = type;
|
||||
m_CraftSubRes.NameNumber = name;
|
||||
m_CraftSubRes.Init = true;
|
||||
}
|
||||
|
||||
public void AddSubRes(Type type, int name, double reqSkill, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);
|
||||
m_CraftSubRes.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void AddSubRes(Type type, int name, double reqSkill, int genericName, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, genericName, message);
|
||||
m_CraftSubRes.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void AddSubRes(Type type, string name, double reqSkill, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);
|
||||
m_CraftSubRes.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void SetSubRes2(Type type, string name)
|
||||
{
|
||||
m_CraftSubRes2.ResType = type;
|
||||
m_CraftSubRes2.NameString = name;
|
||||
m_CraftSubRes2.Init = true;
|
||||
}
|
||||
|
||||
public void SetSubRes2(Type type, int name)
|
||||
{
|
||||
m_CraftSubRes2.ResType = type;
|
||||
m_CraftSubRes2.NameNumber = name;
|
||||
m_CraftSubRes2.Init = true;
|
||||
}
|
||||
|
||||
public void AddSubRes2(Type type, int name, double reqSkill, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);
|
||||
m_CraftSubRes2.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void AddSubRes2(Type type, int name, double reqSkill, int genericName, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, genericName, message);
|
||||
m_CraftSubRes2.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public void AddSubRes2(Type type, string name, double reqSkill, object message)
|
||||
{
|
||||
CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);
|
||||
m_CraftSubRes2.Add(craftSubRes);
|
||||
}
|
||||
|
||||
public abstract void InitCraftList();
|
||||
|
||||
public abstract void PlayCraftEffect(Mobile from);
|
||||
|
||||
public abstract int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item);
|
||||
|
||||
public abstract int CanCraft(Mobile from, ITool tool, Type itemType);
|
||||
}
|
||||
}
|
||||
70
Scripts/Services/Craft/Core/CustomCraft.cs
Normal file
70
Scripts/Services/Craft/Core/CustomCraft.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public abstract class CustomCraft
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly CraftItem m_CraftItem;
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly Type m_TypeRes;
|
||||
private readonly ITool m_Tool;
|
||||
private readonly int m_Quality;
|
||||
public CustomCraft(Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, ITool tool, int quality)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_CraftItem = craftItem;
|
||||
this.m_CraftSystem = craftSystem;
|
||||
this.m_TypeRes = typeRes;
|
||||
this.m_Tool = tool;
|
||||
this.m_Quality = quality;
|
||||
}
|
||||
|
||||
public Mobile From
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_From;
|
||||
}
|
||||
}
|
||||
public CraftItem CraftItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_CraftItem;
|
||||
}
|
||||
}
|
||||
public CraftSystem CraftSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_CraftSystem;
|
||||
}
|
||||
}
|
||||
public Type TypeRes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TypeRes;
|
||||
}
|
||||
}
|
||||
public ITool Tool
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Tool;
|
||||
}
|
||||
}
|
||||
public int Quality
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Quality;
|
||||
}
|
||||
}
|
||||
public abstract void EndCraftAction();
|
||||
|
||||
public abstract Item CompleteCraft(out int message);
|
||||
}
|
||||
}
|
||||
435
Scripts/Services/Craft/Core/Enhance.cs
Normal file
435
Scripts/Services/Craft/Core/Enhance.cs
Normal file
@@ -0,0 +1,435 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum EnhanceResult
|
||||
{
|
||||
None,
|
||||
NotInBackpack,
|
||||
BadItem,
|
||||
BadResource,
|
||||
AlreadyEnhanced,
|
||||
Success,
|
||||
Failure,
|
||||
Broken,
|
||||
NoResources,
|
||||
NoSkill,
|
||||
Enchanted
|
||||
}
|
||||
|
||||
public class Enhance
|
||||
{
|
||||
private static Dictionary<Type, CraftSystem> _SpecialTable;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
_SpecialTable = new Dictionary<Type, CraftSystem>();
|
||||
|
||||
_SpecialTable[typeof(ClockworkLeggings)] = DefBlacksmithy.CraftSystem;
|
||||
_SpecialTable[typeof(GargishClockworkLeggings)] = DefBlacksmithy.CraftSystem;
|
||||
}
|
||||
|
||||
private static bool IsSpecial(Item item, CraftSystem system)
|
||||
{
|
||||
foreach (KeyValuePair<Type, CraftSystem> kvp in _SpecialTable)
|
||||
{
|
||||
if (kvp.Key == item.GetType() && kvp.Value == system)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CanEnhance(Item item)
|
||||
{
|
||||
return item is BaseArmor || item is BaseWeapon || item is FishingPole;
|
||||
}
|
||||
|
||||
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, ITool tool, Item item, CraftResource resource, Type resType, ref object resMessage)
|
||||
{
|
||||
if (item == null)
|
||||
return EnhanceResult.BadItem;
|
||||
|
||||
if (item is GargishNecklace || item is GargishEarrings)
|
||||
return EnhanceResult.BadItem;
|
||||
|
||||
if (!item.IsChildOf(from.Backpack))
|
||||
return EnhanceResult.NotInBackpack;
|
||||
|
||||
IResource ires = item as IResource;
|
||||
|
||||
if (!CanEnhance(item) || ires == null)
|
||||
return EnhanceResult.BadItem;
|
||||
|
||||
if (item is IArcaneEquip)
|
||||
{
|
||||
IArcaneEquip eq = (IArcaneEquip)item;
|
||||
if (eq.IsArcane)
|
||||
return EnhanceResult.BadItem;
|
||||
}
|
||||
|
||||
if (item is BaseWeapon && Spells.Mysticism.EnchantSpell.IsUnderSpellEffects(from, (BaseWeapon)item))
|
||||
return EnhanceResult.Enchanted;
|
||||
|
||||
if (CraftResources.IsStandard(resource))
|
||||
return EnhanceResult.BadResource;
|
||||
|
||||
int num = craftSystem.CanCraft(from, tool, item.GetType());
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
resMessage = num;
|
||||
return EnhanceResult.None;
|
||||
}
|
||||
|
||||
CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType());
|
||||
|
||||
if (IsSpecial(item, craftSystem))
|
||||
{
|
||||
craftItem = craftSystem.CraftItems.SearchForSubclass(item.GetType());
|
||||
}
|
||||
|
||||
if (craftItem == null || craftItem.Resources.Count == 0)
|
||||
{
|
||||
return EnhanceResult.BadItem;
|
||||
}
|
||||
|
||||
#region Mondain's Legacy
|
||||
if (craftItem.ForceNonExceptional)
|
||||
return EnhanceResult.BadItem;
|
||||
#endregion
|
||||
|
||||
bool allRequiredSkills = false;
|
||||
if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0)
|
||||
return EnhanceResult.NoSkill;
|
||||
|
||||
CraftResourceInfo info = CraftResources.GetInfo(resource);
|
||||
|
||||
if (info == null || info.ResourceTypes.Length == 0)
|
||||
return EnhanceResult.BadResource;
|
||||
|
||||
CraftAttributeInfo attributes = info.AttributeInfo;
|
||||
|
||||
if (attributes == null)
|
||||
return EnhanceResult.BadResource;
|
||||
|
||||
int resHue = 0, maxAmount = 0;
|
||||
|
||||
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage))
|
||||
return EnhanceResult.NoResources;
|
||||
|
||||
if (!CraftResources.IsStandard(ires.Resource))
|
||||
return EnhanceResult.AlreadyEnhanced;
|
||||
|
||||
if (craftSystem is DefBlacksmithy)
|
||||
{
|
||||
AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer;
|
||||
if (hammer != null)
|
||||
{
|
||||
hammer.UsesRemaining--;
|
||||
if (hammer.UsesRemaining < 1)
|
||||
hammer.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0;
|
||||
int dura = 0, luck = 0, lreq = 0, dinc = 0;
|
||||
int baseChance = 0;
|
||||
|
||||
bool physBonus = false;
|
||||
bool fireBonus = false;
|
||||
bool coldBonus = false;
|
||||
bool nrgyBonus = false;
|
||||
bool poisBonus = false;
|
||||
bool duraBonus = false;
|
||||
bool luckBonus = false;
|
||||
bool lreqBonus = false;
|
||||
bool dincBonus = false;
|
||||
|
||||
if (item is BaseWeapon)
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)item;
|
||||
|
||||
if(weapon.ExtendedWeaponAttributes.AssassinHoned > 0)
|
||||
return EnhanceResult.BadItem;
|
||||
|
||||
baseChance = 20;
|
||||
|
||||
dura = weapon.MaxHitPoints;
|
||||
luck = weapon.Attributes.Luck;
|
||||
lreq = weapon.WeaponAttributes.LowerStatReq;
|
||||
dinc = weapon.Attributes.WeaponDamage;
|
||||
|
||||
fireBonus = (attributes.WeaponFireDamage > 0);
|
||||
coldBonus = (attributes.WeaponColdDamage > 0);
|
||||
nrgyBonus = (attributes.WeaponEnergyDamage > 0);
|
||||
poisBonus = (attributes.WeaponPoisonDamage > 0);
|
||||
|
||||
duraBonus = (attributes.WeaponDurability > 0);
|
||||
luckBonus = (attributes.WeaponLuck > 0);
|
||||
lreqBonus = (attributes.WeaponLowerRequirements > 0);
|
||||
dincBonus = (dinc > 0);
|
||||
}
|
||||
else if (item is BaseArmor)
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)item;
|
||||
|
||||
baseChance = 20;
|
||||
|
||||
phys = armor.PhysicalResistance;
|
||||
fire = armor.FireResistance;
|
||||
cold = armor.ColdResistance;
|
||||
pois = armor.PoisonResistance;
|
||||
nrgy = armor.EnergyResistance;
|
||||
|
||||
dura = armor.MaxHitPoints;
|
||||
luck = armor.Attributes.Luck;
|
||||
lreq = armor.ArmorAttributes.LowerStatReq;
|
||||
|
||||
physBonus = (attributes.ArmorPhysicalResist > 0);
|
||||
fireBonus = (attributes.ArmorFireResist > 0);
|
||||
coldBonus = (attributes.ArmorColdResist > 0);
|
||||
nrgyBonus = (attributes.ArmorEnergyResist > 0);
|
||||
poisBonus = (attributes.ArmorPoisonResist > 0);
|
||||
|
||||
duraBonus = (attributes.ArmorDurability > 0);
|
||||
luckBonus = (attributes.ArmorLuck > 0);
|
||||
lreqBonus = (attributes.ArmorLowerRequirements > 0);
|
||||
dincBonus = false;
|
||||
}
|
||||
else if (item is FishingPole)
|
||||
{
|
||||
FishingPole pole = (FishingPole)item;
|
||||
|
||||
baseChance = 20;
|
||||
|
||||
luck = pole.Attributes.Luck;
|
||||
|
||||
luckBonus = (attributes.ArmorLuck > 0);
|
||||
lreqBonus = (attributes.ArmorLowerRequirements > 0);
|
||||
dincBonus = false;
|
||||
}
|
||||
|
||||
int skill = from.Skills[craftSystem.MainSkill].Fixed / 10;
|
||||
|
||||
if (skill >= 100)
|
||||
baseChance -= (skill - 90) / 10;
|
||||
|
||||
EnhanceResult res = EnhanceResult.Success;
|
||||
|
||||
PlayerMobile user = from as PlayerMobile;
|
||||
|
||||
if (physBonus)
|
||||
CheckResult(ref res, baseChance + phys);
|
||||
|
||||
if (fireBonus)
|
||||
CheckResult(ref res, baseChance + fire);
|
||||
|
||||
if (coldBonus)
|
||||
CheckResult(ref res, baseChance + cold);
|
||||
|
||||
if (nrgyBonus)
|
||||
CheckResult(ref res, baseChance + nrgy);
|
||||
|
||||
if (poisBonus)
|
||||
CheckResult(ref res, baseChance + pois);
|
||||
|
||||
if (duraBonus)
|
||||
CheckResult(ref res, baseChance + (dura / 40));
|
||||
|
||||
if (luckBonus)
|
||||
CheckResult(ref res, baseChance + 10 + (luck / 2));
|
||||
|
||||
if (lreqBonus)
|
||||
CheckResult(ref res, baseChance + (lreq / 4));
|
||||
|
||||
if (dincBonus)
|
||||
CheckResult(ref res, baseChance + (dinc / 4));
|
||||
|
||||
if (user.NextEnhanceSuccess)
|
||||
{
|
||||
user.NextEnhanceSuccess = false;
|
||||
user.SendLocalizedMessage(1149969); // The magical aura that surrounded you disipates and you feel that your item enhancement chances have returned to normal.
|
||||
res = EnhanceResult.Success;
|
||||
}
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case EnhanceResult.Broken:
|
||||
{
|
||||
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage))
|
||||
return EnhanceResult.NoResources;
|
||||
|
||||
item.Delete();
|
||||
break;
|
||||
}
|
||||
case EnhanceResult.Success:
|
||||
{
|
||||
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage))
|
||||
return EnhanceResult.NoResources;
|
||||
|
||||
if (craftItem.CaddelliteCraft)
|
||||
{
|
||||
Caddellite.TryInfuse(from, item, craftSystem);
|
||||
}
|
||||
|
||||
if (item is IResource)
|
||||
((IResource)item).Resource = resource;
|
||||
|
||||
if (item is BaseWeapon)
|
||||
{
|
||||
BaseWeapon w = (BaseWeapon)item;
|
||||
w.DistributeMaterialBonus(attributes);
|
||||
|
||||
int hue = w.GetElementalDamageHue();
|
||||
|
||||
if (hue > 0)
|
||||
w.Hue = hue;
|
||||
}
|
||||
else if (item is BaseArmor)
|
||||
{
|
||||
((BaseArmor)item).DistributeMaterialBonus(attributes);
|
||||
}
|
||||
else if (item is FishingPole)
|
||||
{
|
||||
((FishingPole)item).DistributeMaterialBonus(attributes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EnhanceResult.Failure:
|
||||
{
|
||||
if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage))
|
||||
return EnhanceResult.NoResources;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void CheckResult(ref EnhanceResult res, int chance)
|
||||
{
|
||||
if (res != EnhanceResult.Success)
|
||||
return; // we've already failed..
|
||||
|
||||
int random = Utility.Random(100);
|
||||
|
||||
if (10 > random)
|
||||
res = EnhanceResult.Failure;
|
||||
else if (chance > random)
|
||||
res = EnhanceResult.Broken;
|
||||
}
|
||||
|
||||
public static void BeginTarget(Mobile from, CraftSystem craftSystem, ITool tool)
|
||||
{
|
||||
CraftContext context = craftSystem.GetContext(from);
|
||||
PlayerMobile user = from as PlayerMobile;
|
||||
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
int lastRes = context.LastResourceIndex;
|
||||
CraftSubResCol subRes = craftSystem.CraftSubRes;
|
||||
|
||||
if (lastRes >= 0 && lastRes < subRes.Count)
|
||||
{
|
||||
CraftSubRes res = subRes.GetAt(lastRes);
|
||||
|
||||
if (from.Skills[craftSystem.MainSkill].Value < res.RequiredSkill)
|
||||
{
|
||||
from.SendGump(new CraftGump(from, craftSystem, tool, res.Message));
|
||||
}
|
||||
else
|
||||
{
|
||||
CraftResource resource = CraftResources.GetFromType(res.ItemType);
|
||||
|
||||
if (resource != CraftResource.None)
|
||||
{
|
||||
from.Target = new InternalTarget(craftSystem, tool, res.ItemType, resource);
|
||||
|
||||
if (user.NextEnhanceSuccess)
|
||||
{
|
||||
from.SendLocalizedMessage(1149869, "100"); // Target an item to enhance with the properties of your selected material (Success Rate: ~1_VAL~%).
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties.
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly ITool m_Tool;
|
||||
private readonly Type m_ResourceType;
|
||||
private readonly CraftResource m_Resource;
|
||||
|
||||
public InternalTarget(CraftSystem craftSystem, ITool tool, Type resourceType, CraftResource resource)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
m_ResourceType = resourceType;
|
||||
m_Resource = resource;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is Item)
|
||||
{
|
||||
object message = null;
|
||||
EnhanceResult res = Enhance.Invoke(from, m_CraftSystem, m_Tool, (Item)targeted, m_Resource, m_ResourceType, ref message);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case EnhanceResult.NotInBackpack:
|
||||
message = 1061005;
|
||||
break; // The item must be in your backpack to enhance it.
|
||||
case EnhanceResult.AlreadyEnhanced:
|
||||
message = 1061012;
|
||||
break; // This item is already enhanced with the properties of a special material.
|
||||
case EnhanceResult.BadItem:
|
||||
message = 1061011;
|
||||
break; // You cannot enhance this type of item with the properties of the selected special material.
|
||||
case EnhanceResult.BadResource:
|
||||
message = 1061010;
|
||||
break; // You must select a special material in order to enhance an item with its properties.
|
||||
case EnhanceResult.Broken:
|
||||
message = 1061080;
|
||||
break; // You attempt to enhance the item, but fail catastrophically. The item is lost.
|
||||
case EnhanceResult.Failure:
|
||||
message = 1061082;
|
||||
break; // You attempt to enhance the item, but fail. Some material is lost in the process.
|
||||
case EnhanceResult.Success:
|
||||
message = 1061008;
|
||||
break; // You enhance the item with the properties of the special material.
|
||||
case EnhanceResult.NoSkill:
|
||||
message = 1044153;
|
||||
break; // You don't have the required skills to attempt this item.
|
||||
case EnhanceResult.Enchanted:
|
||||
message = 1080131;
|
||||
break; // You cannot enhance an item that is currently enchanted.
|
||||
}
|
||||
|
||||
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Scripts/Services/Craft/Core/QueryMakersMarkGump.cs
Normal file
53
Scripts/Services/Craft/Core/QueryMakersMarkGump.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class QueryMakersMarkGump : Gump
|
||||
{
|
||||
private readonly int m_Quality;
|
||||
private readonly Mobile m_From;
|
||||
private readonly CraftItem m_CraftItem;
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly Type m_TypeRes;
|
||||
private readonly ITool m_Tool;
|
||||
public QueryMakersMarkGump(int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, ITool tool)
|
||||
: base(100, 200)
|
||||
{
|
||||
from.CloseGump(typeof(QueryMakersMarkGump));
|
||||
|
||||
this.m_Quality = quality;
|
||||
this.m_From = from;
|
||||
this.m_CraftItem = craftItem;
|
||||
this.m_CraftSystem = craftSystem;
|
||||
this.m_TypeRes = typeRes;
|
||||
this.m_Tool = tool;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 220, 170, 5054);
|
||||
this.AddBackground(10, 10, 200, 150, 3000);
|
||||
|
||||
this.AddHtmlLocalized(20, 20, 180, 80, 1018317, false, false); // Do you wish to place your maker's mark on this item?
|
||||
|
||||
this.AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false); // CONTINUE
|
||||
this.AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false); // CANCEL
|
||||
this.AddButton(20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
|
||||
{
|
||||
bool makersMark = (info.ButtonID == 1);
|
||||
|
||||
if (makersMark)
|
||||
this.m_From.SendLocalizedMessage(501808); // You mark the item.
|
||||
else
|
||||
this.m_From.SendLocalizedMessage(501809); // Cancelled mark.
|
||||
|
||||
this.m_CraftItem.CompleteCraft(this.m_Quality, makersMark, this.m_From, this.m_CraftSystem, this.m_TypeRes, this.m_Tool, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
135
Scripts/Services/Craft/Core/Recipes.cs
Normal file
135
Scripts/Services/Craft/Core/Recipes.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class Recipe
|
||||
{
|
||||
private static readonly Dictionary<int, Recipe> m_Recipes = new Dictionary<int, Recipe>();
|
||||
private static int m_LargestRecipeID;
|
||||
private readonly int m_ID;
|
||||
private CraftSystem m_System;
|
||||
private CraftItem m_CraftItem;
|
||||
private TextDefinition m_TD;
|
||||
public Recipe(int id, CraftSystem system, CraftItem item)
|
||||
{
|
||||
this.m_ID = id;
|
||||
this.m_System = system;
|
||||
this.m_CraftItem = item;
|
||||
|
||||
if (m_Recipes.ContainsKey(id))
|
||||
throw new Exception("Attempting to create recipe with preexisting ID.");
|
||||
|
||||
m_Recipes.Add(id, this);
|
||||
m_LargestRecipeID = Math.Max(id, m_LargestRecipeID);
|
||||
}
|
||||
|
||||
public static Dictionary<int, Recipe> Recipes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Recipes;
|
||||
}
|
||||
}
|
||||
public static int LargestRecipeID
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LargestRecipeID;
|
||||
}
|
||||
}
|
||||
public CraftSystem CraftSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_System;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_System = value;
|
||||
}
|
||||
}
|
||||
public CraftItem CraftItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_CraftItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_CraftItem = value;
|
||||
}
|
||||
}
|
||||
public int ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ID;
|
||||
}
|
||||
}
|
||||
public TextDefinition TextDefinition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_TD == null)
|
||||
this.m_TD = new TextDefinition(this.m_CraftItem.NameNumber, this.m_CraftItem.NameString);
|
||||
|
||||
return this.m_TD;
|
||||
}
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("LearnAllRecipes", AccessLevel.GameMaster, new CommandEventHandler(LearnAllRecipes_OnCommand));
|
||||
CommandSystem.Register("ForgetAllRecipes", AccessLevel.GameMaster, new CommandEventHandler(ForgetAllRecipes_OnCommand));
|
||||
}
|
||||
|
||||
[Usage("LearnAllRecipes")]
|
||||
[Description("Teaches a player all available recipes.")]
|
||||
private static void LearnAllRecipes_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Mobile m = e.Mobile;
|
||||
m.SendMessage("Target a player to teach them all of the recipies.");
|
||||
|
||||
m.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, new TargetCallback(
|
||||
delegate(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is PlayerMobile)
|
||||
{
|
||||
foreach (KeyValuePair<int, Recipe> kvp in m_Recipes)
|
||||
((PlayerMobile)targeted).AcquireRecipe(kvp.Key);
|
||||
|
||||
m.SendMessage("You teach them all of the recipies.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendMessage("That is not a player!");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
[Usage("ForgetAllRecipes")]
|
||||
[Description("Makes a player forget all the recipies they've learned.")]
|
||||
private static void ForgetAllRecipes_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Mobile m = e.Mobile;
|
||||
m.SendMessage("Target a player to have them forget all of the recipies they've learned.");
|
||||
|
||||
m.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, new TargetCallback(
|
||||
delegate(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is PlayerMobile)
|
||||
{
|
||||
((PlayerMobile)targeted).ResetRecipes();
|
||||
|
||||
m.SendMessage("They forget all their recipies.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendMessage("That is not a player!");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
787
Scripts/Services/Craft/Core/Repair.cs
Normal file
787
Scripts/Services/Craft/Core/Repair.cs
Normal file
@@ -0,0 +1,787 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public interface IRepairable
|
||||
{
|
||||
CraftSystem RepairSystem { get; }
|
||||
}
|
||||
|
||||
public class Repair
|
||||
{
|
||||
public Repair()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Do(Mobile from, CraftSystem craftSystem, ITool tool)
|
||||
{
|
||||
from.Target = new InternalTarget(craftSystem, tool);
|
||||
from.SendLocalizedMessage(1044276); // Target an item to repair.
|
||||
}
|
||||
|
||||
public static void Do(Mobile from, CraftSystem craftSystem, RepairDeed deed)
|
||||
{
|
||||
from.Target = new InternalTarget(craftSystem, deed);
|
||||
from.SendLocalizedMessage(1044276); // Target an item to repair.
|
||||
}
|
||||
|
||||
public static void Do(Mobile from, CraftSystem craftSystem, RepairBenchAddon addon)
|
||||
{
|
||||
from.Target = new InternalTarget(craftSystem, addon);
|
||||
from.SendLocalizedMessage(500436); // Select item to repair.
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly ITool m_Tool;
|
||||
private readonly RepairDeed m_Deed;
|
||||
private readonly RepairBenchAddon m_Addon;
|
||||
|
||||
public InternalTarget(CraftSystem craftSystem, ITool tool)
|
||||
: base(10, false, TargetFlags.None)
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
}
|
||||
|
||||
public InternalTarget(CraftSystem craftSystem, RepairDeed deed)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
public InternalTarget(CraftSystem craftSystem, RepairBenchAddon addon)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Addon = addon;
|
||||
}
|
||||
|
||||
private static void EndMobileRepair(object state)
|
||||
{
|
||||
((Mobile)state).EndAction(typeof(IRepairableMobile));
|
||||
}
|
||||
|
||||
private int GetWeakenChance(Mobile mob, SkillName skill, int curHits, int maxHits)
|
||||
{
|
||||
double value = 0;
|
||||
|
||||
if (m_Deed != null)
|
||||
{
|
||||
value = m_Deed.SkillLevel;
|
||||
}
|
||||
else if (m_Addon != null)
|
||||
{
|
||||
value = m_Addon.Tools.Find(x => x.System == m_CraftSystem).SkillValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = mob.Skills[skill].Value;
|
||||
}
|
||||
|
||||
// 40% - (1% per hp lost) - (1% per 10 craft skill)
|
||||
return (40 + (maxHits - curHits)) - (int)(value / 10);
|
||||
}
|
||||
|
||||
private bool CheckWeaken(Mobile mob, SkillName skill, int curHits, int maxHits)
|
||||
{
|
||||
return (GetWeakenChance(mob, skill, curHits, maxHits) > Utility.Random(100));
|
||||
}
|
||||
|
||||
private int GetRepairDifficulty(int curHits, int maxHits)
|
||||
{
|
||||
return (((maxHits - curHits) * 1250) / Math.Max(maxHits, 1)) - 250;
|
||||
}
|
||||
|
||||
private bool CheckRepairDifficulty(Mobile mob, SkillName skill, int curHits, int maxHits)
|
||||
{
|
||||
double difficulty = GetRepairDifficulty(curHits, maxHits) * 0.1;
|
||||
|
||||
if (m_Deed != null)
|
||||
{
|
||||
double value = m_Deed.SkillLevel;
|
||||
double minSkill = difficulty - 25.0;
|
||||
double maxSkill = difficulty + 25;
|
||||
|
||||
if (value < minSkill)
|
||||
return false; // Too difficult
|
||||
else if (value >= maxSkill)
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
return (chance >= Utility.RandomDouble());
|
||||
}
|
||||
else if (m_Addon != null)
|
||||
{
|
||||
double value = m_Addon.Tools.Find(x => x.System == m_CraftSystem).SkillValue;
|
||||
double minSkill = difficulty - 25.0;
|
||||
double maxSkill = difficulty + 25;
|
||||
|
||||
if (value < minSkill)
|
||||
return false; // Too difficult
|
||||
else if (value >= maxSkill)
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
return (chance >= Utility.RandomDouble());
|
||||
}
|
||||
else
|
||||
{
|
||||
SkillLock sl = mob.Skills[SkillName.Tinkering].Lock;
|
||||
mob.Skills[SkillName.Tinkering].SetLockNoRelay(SkillLock.Locked);
|
||||
|
||||
bool check = mob.CheckSkill(skill, difficulty - 25.0, difficulty + 25.0);
|
||||
|
||||
mob.Skills[SkillName.Tinkering].SetLockNoRelay(sl);
|
||||
|
||||
return check;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckDeed(Mobile from)
|
||||
{
|
||||
if (m_Deed != null)
|
||||
{
|
||||
return m_Deed.Check(from);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckSpecial(Item item)
|
||||
{
|
||||
return item is IRepairable && ((IRepairable)item).RepairSystem == m_CraftSystem;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
bool usingDeed = (m_Deed != null) || (m_Addon != null);
|
||||
bool toDelete = false;
|
||||
int number;
|
||||
|
||||
double value = 0;
|
||||
|
||||
if (m_Deed != null)
|
||||
{
|
||||
value = m_Deed.SkillLevel;
|
||||
}
|
||||
else if (m_Addon != null)
|
||||
{
|
||||
var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem);
|
||||
|
||||
if (tool.Charges == 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1019073);// This item is out of charges.
|
||||
m_Addon.Using = false;
|
||||
return;
|
||||
}
|
||||
|
||||
value = tool.SkillValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = from.Skills[m_CraftSystem.MainSkill].Base;
|
||||
}
|
||||
|
||||
if (m_CraftSystem is DefTinkering && targeted is IRepairableMobile)
|
||||
{
|
||||
if (TryRepairMobile(from, (IRepairableMobile)targeted, usingDeed, out toDelete))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, (IRepairableMobile)targeted);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 500426; // You can't repair that.
|
||||
}
|
||||
}
|
||||
else if (targeted is Item)
|
||||
{
|
||||
if (from.InRange(((Item)targeted).GetWorldLocation(), 2))
|
||||
{
|
||||
if (!CheckDeed(from))
|
||||
{
|
||||
if (m_Addon != null)
|
||||
m_Addon.Using = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AllowsRepair(targeted, m_CraftSystem))
|
||||
{
|
||||
from.SendLocalizedMessage(500426); // You can't repair that.
|
||||
|
||||
if (m_Addon != null)
|
||||
m_Addon.Using = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
|
||||
{
|
||||
number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
|
||||
}
|
||||
else if (!usingDeed && m_CraftSystem is DefTinkering && targeted is BrokenAutomatonHead)
|
||||
{
|
||||
if (((BrokenAutomatonHead)targeted).TryRepair(from))
|
||||
number = 1044279; // You repair the item.
|
||||
else
|
||||
number = 1044280; // You fail to repair the item.
|
||||
}
|
||||
else if (targeted is BaseWeapon)
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)targeted;
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
toWeaken = 1;
|
||||
}
|
||||
else if (skill != SkillName.Tailoring)
|
||||
{
|
||||
double skillLevel = value;
|
||||
|
||||
if (skillLevel >= 90.0)
|
||||
toWeaken = 1;
|
||||
else if (skillLevel >= 70.0)
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
}
|
||||
|
||||
if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !CheckSpecial(weapon))
|
||||
{
|
||||
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if (!Core.AOS && weapon.PoisonCharges != 0)
|
||||
{
|
||||
number = 1005012; // You cannot repair an item while a caustic substance is on it.
|
||||
}
|
||||
else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if (weapon.MaxHitPoints <= toWeaken)
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else if (weapon.NegativeAttributes.NoRepair > 0)
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
|
||||
{
|
||||
weapon.MaxHitPoints -= toWeaken;
|
||||
weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken);
|
||||
}
|
||||
|
||||
if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
weapon.HitPoints = weapon.MaxHitPoints;
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, weapon);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
}
|
||||
|
||||
toDelete = true;
|
||||
}
|
||||
}
|
||||
else if (targeted is BaseArmor)
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)targeted;
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
toWeaken = 1;
|
||||
}
|
||||
else if (skill != SkillName.Tailoring)
|
||||
{
|
||||
double skillLevel = value;
|
||||
|
||||
if (skillLevel >= 90.0)
|
||||
toWeaken = 1;
|
||||
else if (skillLevel >= 70.0)
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
}
|
||||
|
||||
if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !CheckSpecial(armor))
|
||||
{
|
||||
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if (armor.MaxHitPoints <= toWeaken)
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else if (armor.NegativeAttributes.NoRepair > 0)
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
|
||||
{
|
||||
armor.MaxHitPoints -= toWeaken;
|
||||
armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken);
|
||||
}
|
||||
|
||||
if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
armor.HitPoints = armor.MaxHitPoints;
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, armor);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
}
|
||||
|
||||
toDelete = true;
|
||||
}
|
||||
}
|
||||
else if (targeted is BaseJewel)
|
||||
{
|
||||
BaseJewel jewel = (BaseJewel)targeted;
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
toWeaken = 1;
|
||||
}
|
||||
else if (skill != SkillName.Tailoring)
|
||||
{
|
||||
double skillLevel = value;
|
||||
|
||||
if (skillLevel >= 90.0)
|
||||
toWeaken = 1;
|
||||
else if (skillLevel >= 70.0)
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
}
|
||||
|
||||
if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !CheckSpecial(jewel))
|
||||
{
|
||||
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
else if (!jewel.IsChildOf(from.Backpack))
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints)
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if (jewel.MaxHitPoints <= toWeaken)
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else if (jewel.NegativeAttributes.NoRepair > 0)
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
|
||||
{
|
||||
jewel.MaxHitPoints -= toWeaken;
|
||||
jewel.HitPoints = Math.Max(0, jewel.HitPoints - toWeaken);
|
||||
}
|
||||
|
||||
if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
jewel.HitPoints = jewel.MaxHitPoints;
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, jewel);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
}
|
||||
|
||||
toDelete = true;
|
||||
}
|
||||
}
|
||||
else if (targeted is BaseClothing)
|
||||
{
|
||||
BaseClothing clothing = (BaseClothing)targeted;
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
toWeaken = 1;
|
||||
}
|
||||
else if (skill != SkillName.Tailoring)
|
||||
{
|
||||
double skillLevel = value;
|
||||
|
||||
if (skillLevel >= 90.0)
|
||||
toWeaken = 1;
|
||||
else if (skillLevel >= 70.0)
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
}
|
||||
|
||||
if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !CheckSpecial(clothing))
|
||||
{
|
||||
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if (clothing.MaxHitPoints <= toWeaken)
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else if (clothing.NegativeAttributes.NoRepair > 0)// quick fix
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
|
||||
{
|
||||
clothing.MaxHitPoints -= toWeaken;
|
||||
clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken);
|
||||
}
|
||||
|
||||
if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
clothing.HitPoints = clothing.MaxHitPoints;
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, clothing);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
}
|
||||
|
||||
toDelete = true;
|
||||
}
|
||||
}
|
||||
else if (targeted is BaseTalisman)
|
||||
{
|
||||
BaseTalisman talisman = (BaseTalisman)targeted;
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
int toWeaken = 0;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
toWeaken = 1;
|
||||
}
|
||||
else if (skill != SkillName.Tailoring)
|
||||
{
|
||||
double skillLevel = value;
|
||||
|
||||
if (skillLevel >= 90.0)
|
||||
toWeaken = 1;
|
||||
else if (skillLevel >= 70.0)
|
||||
toWeaken = 2;
|
||||
else
|
||||
toWeaken = 3;
|
||||
}
|
||||
|
||||
if (!(m_CraftSystem is DefTinkering))
|
||||
{
|
||||
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
else if (!talisman.IsChildOf(from.Backpack) && (!Core.ML || talisman.Parent != from))
|
||||
{
|
||||
number = 1044275; // The item must be in your backpack to repair it.
|
||||
}
|
||||
else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints)
|
||||
{
|
||||
number = 1044281; // That item is in full repair
|
||||
}
|
||||
else if (talisman.MaxHitPoints <= toWeaken)
|
||||
{
|
||||
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
|
||||
}
|
||||
else if (!talisman.CanRepair)// quick fix
|
||||
{
|
||||
number = 1044277; // That item cannot be repaired.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
|
||||
{
|
||||
talisman.MaxHitPoints -= toWeaken;
|
||||
talisman.HitPoints = Math.Max(0, talisman.HitPoints - toWeaken);
|
||||
}
|
||||
|
||||
if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
|
||||
{
|
||||
number = 1044279; // You repair the item.
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
talisman.HitPoints = talisman.MaxHitPoints;
|
||||
|
||||
m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, talisman);
|
||||
}
|
||||
else
|
||||
{
|
||||
number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
|
||||
m_CraftSystem.PlayCraftEffect(from);
|
||||
}
|
||||
|
||||
toDelete = true;
|
||||
}
|
||||
}
|
||||
else if (targeted is BlankScroll)
|
||||
{
|
||||
if (!usingDeed)
|
||||
{
|
||||
SkillName skill = m_CraftSystem.MainSkill;
|
||||
|
||||
if (from.Skills[skill].Value >= 50.0)
|
||||
{
|
||||
((BlankScroll)targeted).Consume(1);
|
||||
RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
|
||||
from.AddToBackpack(deed);
|
||||
|
||||
number = 500442; // You create the item and put it in your backpack.
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1047005; // You must be at least apprentice level to create a repair service contract.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 1061136; // You cannot repair that item with this type of repair contract.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 500426; // You can't repair that.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 500446; // That is too far away.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 500426; // You can't repair that.
|
||||
}
|
||||
|
||||
if (!usingDeed)
|
||||
{
|
||||
CraftContext context = m_CraftSystem.GetContext(from);
|
||||
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Addon != null && !m_Addon.Deleted)
|
||||
{
|
||||
var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem);
|
||||
|
||||
tool.Charges--;
|
||||
|
||||
from.SendGump(new RepairBenchGump(from, m_Addon));
|
||||
|
||||
from.SendLocalizedMessage(number);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(number);
|
||||
|
||||
if (toDelete)
|
||||
m_Deed.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
|
||||
{
|
||||
if (m_Addon != null && !m_Addon.Deleted)
|
||||
{
|
||||
from.SendGump(new RepairBenchGump(from, m_Addon));
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryRepairMobile(Mobile from, IRepairableMobile m, bool usingDeed, out bool toDelete)
|
||||
{
|
||||
int damage = m.HitsMax - m.Hits;
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
toDelete = false;
|
||||
|
||||
string name = bc != null ? bc.Name : "the creature";
|
||||
|
||||
if (!from.InRange(m.Location, 2))
|
||||
{
|
||||
from.SendLocalizedMessage(1113612, name); // You must move closer to attempt to repair ~1_CREATURE~.
|
||||
}
|
||||
else if (bc != null && bc.IsDeadBondedPet)
|
||||
{
|
||||
from.SendLocalizedMessage(500426); // You can't repair that.
|
||||
}
|
||||
else if (damage <= 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1113613, name); // ~1_CREATURE~ doesn't appear to be damaged.
|
||||
}
|
||||
else
|
||||
{
|
||||
double value = 0;
|
||||
|
||||
if (m_Deed != null)
|
||||
{
|
||||
value = m_Deed.SkillLevel;
|
||||
}
|
||||
else if (m_Addon != null)
|
||||
{
|
||||
value = m_Addon.Tools.Find(x => x.System == m_CraftSystem).SkillValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = from.Skills[SkillName.Tinkering].Value;
|
||||
}
|
||||
|
||||
double skillValue = value;
|
||||
double required = m is KotlAutomaton ? 80.0 : 0.1;
|
||||
|
||||
if (skillValue < required)
|
||||
{
|
||||
if (required == 80.0)
|
||||
from.SendLocalizedMessage(1157049, name); // You must have at least 80 tinkering skill to attempt to repair ~1_CREATURE~.
|
||||
else
|
||||
from.SendLocalizedMessage(1113614, name); // You must have some tinkering skills to attempt to repair a ~1_CREATURE~.
|
||||
}
|
||||
else if (!from.CanBeginAction(typeof(IRepairableMobile)))
|
||||
{
|
||||
from.SendLocalizedMessage(1113611, name); // You must wait a moment before attempting to repair ~1_CREATURE~ again.
|
||||
}
|
||||
else if (bc != null && bc.GetMaster() != null && bc.GetMaster() != from && !bc.GetMaster().InRange(from.Location, 10))
|
||||
{
|
||||
from.SendLocalizedMessage(1157045); // The pet's owner must be nearby to attempt repair.
|
||||
}
|
||||
else if (!from.CanBeBeneficial(bc, false, false))
|
||||
{
|
||||
from.SendLocalizedMessage(1001017); // You cannot perform beneficial acts on your target.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (damage > (int)(skillValue * 0.6))
|
||||
damage = (int)(skillValue * 0.6);
|
||||
|
||||
SkillLock sl = from.Skills[SkillName.Tinkering].Lock;
|
||||
from.Skills[SkillName.Tinkering].SetLockNoRelay(SkillLock.Locked);
|
||||
|
||||
if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
|
||||
damage /= 6;
|
||||
|
||||
from.Skills[SkillName.Tinkering].SetLockNoRelay(sl);
|
||||
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if (pack != null)
|
||||
{
|
||||
int v = pack.ConsumeUpTo(m.RepairResource, (damage + 4) / 5);
|
||||
|
||||
if (v <= 0 && m is Golem)
|
||||
v = pack.ConsumeUpTo(typeof(BronzeIngot), (damage + 4) / 5);
|
||||
|
||||
if (v > 0)
|
||||
{
|
||||
m.Hits += damage;
|
||||
|
||||
if (damage > 1)
|
||||
from.SendLocalizedMessage(1113616, name); // You repair ~1_CREATURE~.
|
||||
else
|
||||
from.SendLocalizedMessage(1157030, name); // You repair ~1_CREATURE~, but it barely helps.
|
||||
|
||||
toDelete = true;
|
||||
double delay = 10 - (skillValue / 16.65);
|
||||
|
||||
from.BeginAction(typeof(IRepairableMobile));
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(delay), new TimerStateCallback(EndMobileRepair), from);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (m is Golem)
|
||||
{
|
||||
from.SendLocalizedMessage(1113615, name); // You need some iron or bronze ingots to repair the ~1_CREATURE~.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AllowsRepair(object targeted, CraftSystem system)
|
||||
{
|
||||
if (targeted is IFactionItem && ((IFactionItem)targeted).FactionItemState != null)
|
||||
return false;
|
||||
|
||||
if (targeted is BrokenAutomatonHead || targeted is IRepairableMobile)
|
||||
return true;
|
||||
|
||||
return (targeted is BlankScroll ||
|
||||
(targeted is BaseArmor && ((BaseArmor)targeted).CanRepair) ||
|
||||
(targeted is BaseWeapon && ((BaseWeapon)targeted).CanRepair) ||
|
||||
(targeted is BaseClothing && ((BaseClothing)targeted).CanRepair) ||
|
||||
(targeted is BaseJewel && ((BaseJewel)targeted).CanRepair)) ||
|
||||
(targeted is BaseTalisman && ((BaseTalisman)targeted).CanRepair);
|
||||
}
|
||||
}
|
||||
}
|
||||
189
Scripts/Services/Craft/Core/Resmelt.cs
Normal file
189
Scripts/Services/Craft/Core/Resmelt.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public enum SmeltResult
|
||||
{
|
||||
Success,
|
||||
Invalid,
|
||||
NoSkill
|
||||
}
|
||||
|
||||
public class Resmelt
|
||||
{
|
||||
public Resmelt()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Do(Mobile from, CraftSystem craftSystem, ITool tool)
|
||||
{
|
||||
int num = craftSystem.CanCraft(from, tool, null);
|
||||
|
||||
if (num > 0 && num != 1044267)
|
||||
{
|
||||
from.SendGump(new CraftGump(from, craftSystem, tool, num));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Target = new InternalTarget(craftSystem, tool);
|
||||
from.SendLocalizedMessage(1044273); // Target an item to recycle.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly ITool m_Tool;
|
||||
public InternalTarget(CraftSystem craftSystem, ITool tool)
|
||||
: base(2, false, TargetFlags.None)
|
||||
{
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
int num = m_CraftSystem.CanCraft(from, m_Tool, null);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
if (num == 1044267)
|
||||
{
|
||||
bool anvil, forge;
|
||||
|
||||
DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);
|
||||
|
||||
if (!anvil)
|
||||
num = 1044266; // You must be near an anvil
|
||||
else if (!forge)
|
||||
num = 1044265; // You must be near a forge.
|
||||
}
|
||||
|
||||
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, num));
|
||||
}
|
||||
else
|
||||
{
|
||||
SmeltResult result = SmeltResult.Invalid;
|
||||
bool isStoreBought = false;
|
||||
int message;
|
||||
|
||||
if (targeted is BaseArmor)
|
||||
{
|
||||
result = Resmelt(from, (BaseArmor)targeted, ((BaseArmor)targeted).Resource);
|
||||
isStoreBought = !((BaseArmor)targeted).PlayerConstructed;
|
||||
}
|
||||
else if (targeted is BaseWeapon)
|
||||
{
|
||||
result = Resmelt(from, (BaseWeapon)targeted, ((BaseWeapon)targeted).Resource);
|
||||
isStoreBought = !((BaseWeapon)targeted).PlayerConstructed;
|
||||
}
|
||||
else if (targeted is DragonBardingDeed)
|
||||
{
|
||||
result = Resmelt(from, (DragonBardingDeed)targeted, ((DragonBardingDeed)targeted).Resource);
|
||||
isStoreBought = false;
|
||||
}
|
||||
|
||||
switch ( result )
|
||||
{
|
||||
default:
|
||||
case SmeltResult.Invalid:
|
||||
message = 1044272;
|
||||
break; // You can't melt that down into ingots.
|
||||
case SmeltResult.NoSkill:
|
||||
message = 1044269;
|
||||
break; // You have no idea how to work this metal.
|
||||
case SmeltResult.Success:
|
||||
message = isStoreBought ? 500418 : 1044270;
|
||||
break; // You melt the item down into ingots.
|
||||
}
|
||||
|
||||
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
|
||||
}
|
||||
}
|
||||
|
||||
private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Ethics.Ethic.IsImbued(item))
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
if (CraftResources.GetType(resource) != CraftResourceType.Metal)
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftResourceInfo info = CraftResources.GetInfo(resource);
|
||||
|
||||
if (info == null || info.ResourceTypes.Length == 0)
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType());
|
||||
|
||||
if (craftItem == null || craftItem.Resources.Count == 0)
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftRes craftResource = craftItem.Resources.GetAt(0);
|
||||
|
||||
if (craftResource.Amount < 2)
|
||||
return SmeltResult.Invalid; // Not enough metal to resmelt
|
||||
|
||||
double difficulty = 0.0;
|
||||
|
||||
switch ( resource )
|
||||
{
|
||||
case CraftResource.DullCopper:
|
||||
difficulty = 65.0;
|
||||
break;
|
||||
case CraftResource.ShadowIron:
|
||||
difficulty = 70.0;
|
||||
break;
|
||||
case CraftResource.Copper:
|
||||
difficulty = 75.0;
|
||||
break;
|
||||
case CraftResource.Bronze:
|
||||
difficulty = 80.0;
|
||||
break;
|
||||
case CraftResource.Gold:
|
||||
difficulty = 85.0;
|
||||
break;
|
||||
case CraftResource.Agapite:
|
||||
difficulty = 90.0;
|
||||
break;
|
||||
case CraftResource.Verite:
|
||||
difficulty = 95.0;
|
||||
break;
|
||||
case CraftResource.Valorite:
|
||||
difficulty = 99.0;
|
||||
break;
|
||||
}
|
||||
|
||||
double skill = Math.Max(from.Skills[SkillName.Mining].Value, from.Skills[SkillName.Blacksmith].Value);
|
||||
|
||||
if (difficulty > skill)
|
||||
return SmeltResult.NoSkill;
|
||||
|
||||
Type resourceType = info.ResourceTypes[0];
|
||||
Item ingot = (Item)Activator.CreateInstance(resourceType);
|
||||
|
||||
if (item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed))
|
||||
ingot.Amount = (int)((double)craftResource.Amount * .66);
|
||||
else
|
||||
ingot.Amount = 1;
|
||||
|
||||
item.Delete();
|
||||
from.AddToBackpack(ingot);
|
||||
|
||||
from.PlaySound(0x2A);
|
||||
from.PlaySound(0x240);
|
||||
return SmeltResult.Success;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return SmeltResult.Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user