Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,214 @@
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections.Generic;
using Server.Multis;
using System.Linq;
namespace Server.Items
{
[Flipable(0x9A95, 0x9AA7)]
public abstract class BaseSpecialScrollBook : Container, ISecurable
{
public const int MaxScrolls = 300;
private int _Capacity;
[CommandProperty(AccessLevel.GameMaster)]
public int Capacity
{
get { return _Capacity <= 0 ? MaxScrolls : _Capacity; }
set
{
_Capacity = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; }
public override bool DisplaysContent { get { return false; } }
public override double DefaultWeight { get { return 1.0; } }
public abstract Type ScrollType { get; }
public abstract int BadDropMessage { get; }
public abstract int DropMessage { get; }
public abstract int RemoveMessage { get; }
public abstract int GumpTitle { get; }
public BaseSpecialScrollBook(int id)
: base(id)
{
LootType = LootType.Blessed;
}
public override int GetTotal(TotalType type)
{
return 0;
}
public override void OnDoubleClick(Mobile m)
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (m is PlayerMobile && m.InRange(GetWorldLocation(), 2) /*&& (house == null || house.HasSecureAccess(m, this))*/)
{
BaseGump.SendGump(new SpecialScrollBookGump((PlayerMobile)m, this));
}
else if (m.AccessLevel > AccessLevel.Player)
{
base.OnDoubleClick(m);
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1151797, String.Format("{0}\t{1}", Items.Count, Capacity)); // Scrolls in book: ~1_val~/~2_val~
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
SetSecureLevelEntry.AddTo(from, this, list);
}
public override bool OnDragDrop(Mobile m, Item dropped)
{
if (m.InRange(GetWorldLocation(), 2))
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (dropped.GetType() != ScrollType)
{
m.SendLocalizedMessage(BadDropMessage);
}
else if (house == null || !IsLockedDown)
{
m.SendLocalizedMessage(1151765); // You must lock this book down in a house to add scrolls to it.
}
else if (!house.CheckAccessibility(this, m))
{
m.SendLocalizedMessage(1155693); // This item is impermissible and can not be added to the book.
}
else if (Items.Count < Capacity) // TODO: Message for overfilled?
{
DropItem(dropped);
m.SendLocalizedMessage(DropMessage);
dropped.Movable = false;
m.CloseGump(typeof(SpecialScrollBookGump));
return true;
}
}
return false;
}
public virtual void Construct(Mobile m, SkillName sk, double value)
{
var scroll = Items.OfType<SpecialScroll>().FirstOrDefault(s => s.Skill == sk && s.Value == value);
if (scroll != null)
{
if (m.Backpack == null || !m.Backpack.TryDropItem(m, scroll, false))
{
m.SendLocalizedMessage(502868); // Your backpack is too full.
}
else
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.LockDowns.ContainsKey(scroll))
{
house.LockDowns.Remove(scroll);
}
if (!scroll.Movable)
{
scroll.Movable = true;
}
if (scroll.IsLockedDown)
{
scroll.IsLockedDown = false;
}
m.SendLocalizedMessage(RemoveMessage);
}
}
}
public BaseSpecialScrollBook(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(3); // version
writer.Write((int)Level);
writer.Write(_Capacity);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if (version > 2)
{
Level = (SecureLevel)reader.ReadInt();
_Capacity = reader.ReadInt();
}
Timer.DelayCall(
() =>
{
foreach (var item in Items.Where(i => i.Movable))
item.Movable = false;
});
}
public virtual Dictionary<SkillCat, List<SkillName>> SkillInfo { get { return null; } }
public virtual Dictionary<int, double> ValueInfo { get { return null; } }
public static int GetCategoryLocalization(SkillCat category)
{
switch (category)
{
default:
//case SkillCat.None:
return 0;
case SkillCat.Miscellaneous:
return 1078596;
case SkillCat.Combat:
return 1078592;
case SkillCat.TradeSkills:
return 1078591;
case SkillCat.Magic:
return 1078593;
case SkillCat.Wilderness:
return 1078595;
case SkillCat.Thievery:
return 1078594;
case SkillCat.Bard:
return 1078590;
}
}
}
}

View File

@@ -0,0 +1,71 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Items
{
[Flipable(0x9A95, 0x9AA7)]
public class PowerScrollBook : BaseSpecialScrollBook
{
public override Type ScrollType { get { return typeof(PowerScroll); } }
public override int LabelNumber { get { return 1155684; } } // Power Scroll Book
public override int BadDropMessage { get { return 1155691; } } // This book only holds Power Scrolls.
public override int DropMessage { get { return 1155692; } } // You add the scroll to your Power Scroll book.
public override int RemoveMessage { get { return 1155690; } } // You remove a Power Scroll and put it in your pack.
public override int GumpTitle { get { return 1155689; } } // Power Scrolls
[Constructable]
public PowerScrollBook()
: base(0x9A95)
{
Hue = 1153;
}
public PowerScrollBook(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public override Dictionary<SkillCat, List<SkillName>> SkillInfo { get { return _SkillInfo; } }
public override Dictionary<int, double> ValueInfo { get { return _ValueInfo; } }
public static Dictionary<SkillCat, List<SkillName>> _SkillInfo;
public static Dictionary<int, double> _ValueInfo;
public static void Initialize()
{
_SkillInfo = new Dictionary<SkillCat, List<SkillName>>();
_SkillInfo[SkillCat.Miscellaneous] = new List<SkillName>();
_SkillInfo[SkillCat.Combat] = new List<SkillName>() { SkillName.Anatomy, SkillName.Archery, SkillName.Fencing, SkillName.Focus, SkillName.Healing, SkillName.Macing, SkillName.Parry, SkillName.Swords, SkillName.Tactics, SkillName.Throwing, SkillName.Wrestling };
_SkillInfo[SkillCat.TradeSkills] = new List<SkillName>() { SkillName.Blacksmith, SkillName.Tailoring };
_SkillInfo[SkillCat.Magic] = new List<SkillName>() { SkillName.Bushido, SkillName.Chivalry, SkillName.EvalInt, SkillName.Imbuing, SkillName.Magery, SkillName.Meditation, SkillName.Mysticism, SkillName.Necromancy, SkillName.Ninjitsu, SkillName.MagicResist, SkillName.Spellweaving, SkillName.SpiritSpeak };
_SkillInfo[SkillCat.Wilderness] = new List<SkillName>() { SkillName.AnimalLore, SkillName.AnimalTaming, SkillName.Fishing, SkillName.Veterinary };
_SkillInfo[SkillCat.Thievery] = new List<SkillName>() { SkillName.Stealing, SkillName.Stealth };
_SkillInfo[SkillCat.Bard] = new List<SkillName>() { SkillName.Discordance, SkillName.Musicianship, SkillName.Peacemaking, SkillName.Provocation };
_ValueInfo = new Dictionary<int, double>();
_ValueInfo[1155685] = 105;
_ValueInfo[1155686] = 110;
_ValueInfo[1155687] = 115;
_ValueInfo[1155688] = 120;
}
}
}

View File

@@ -0,0 +1,505 @@
using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Multis;
using Server.Prompts;
using Server.Mobiles;
using Server.ContextMenus;
using System.Linq;
using Server.Network;
namespace Server.Items
{
public enum RecipeSkillName
{
Alchemy = 0,
Blacksmith = 1,
Carpentry = 2,
Cartography = 3,
Cooking = 4,
Fletching = 5,
Inscription = 6,
Masonry = 7,
Tailoring = 8,
Tinkering = 9,
}
public class RecipeScrollDefinition
{
public int ID { get; set; }
public int RecipeID { get; set; }
public Expansion Expansion { get; set; }
public RecipeSkillName Skill { get; set; }
public int Amount { get; set; }
public int Price { get; set; }
public RecipeScrollDefinition(int id, int rid, Expansion exp, RecipeSkillName skill)
: this(id, rid, exp, skill, 0, 0)
{
}
public RecipeScrollDefinition(int id, int rid, Expansion exp, RecipeSkillName skill, int amount, int price)
{
ID = id;
RecipeID = rid;
Expansion = exp;
Skill = skill;
Amount = amount;
Price = price;
}
}
public class RecipeBook : Item, ISecurable
{
public override int LabelNumber { get { return 1125598; } } // recipe book
[CommandProperty(AccessLevel.GameMaster)]
public string BookName { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool Using { get; set; }
public List<RecipeScrollDefinition> Recipes;
public RecipeScrollFilter Filter { get; set; }
public static RecipeScrollDefinition[] Definitions = new RecipeScrollDefinition[]
{
new RecipeScrollDefinition(1, 501, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(2, 502, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(3, 503, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(4, 504, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(5, 505, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(6, 599, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(7, 250, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(8, 251, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(9, 252, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(10, 253, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(11, 254, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(12, 350, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(13, 351, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(14, 354, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(15, 150, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(16, 352, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(17, 353, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(18, 151, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(19, 152, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(20, 551, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(21, 550, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(22, 552, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(23, 452, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(24, 450, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(25, 451, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(26, 453, Expansion.ML, RecipeSkillName.Inscription),
new RecipeScrollDefinition(27, 116, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(28, 106, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(29, 108, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(30, 109, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(31, 100, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(32, 102, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(33, 111, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(34, 118, Expansion.ML, RecipeSkillName.Masonry),
new RecipeScrollDefinition(35, 200, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(36, 201, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(37, 202, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(38, 203, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(39, 204, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(40, 205, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(41, 206, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(42, 207, Expansion.ML, RecipeSkillName.Fletching),
new RecipeScrollDefinition(43, 300, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(44, 301, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(45, 302, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(46, 303, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(47, 304, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(48, 305, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(49, 306, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(50, 307, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(51, 308, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(52, 309, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(53, 310, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(54, 311, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(55, 312, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(56, 313, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(57, 314, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(58, 315, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(59, 332, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(60, 333, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(61, 334, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(62, 335, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(63, 316, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(64, 317, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(65, 318, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(66, 319, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(67, 320, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(68, 321, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(69, 322, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(70, 323, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(71, 324, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(72, 325, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(73, 326, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(74, 327, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(75, 328, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(76, 329, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(77, 330, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(78, 331, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(79, 112, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(80, 113, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(81, 114, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(82, 115, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(83, 400, Expansion.ML, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(84, 402, Expansion.ML, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(85, 401, Expansion.ML, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(86, 117, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(87, 107, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(88, 120, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(89, 110, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(90, 101, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(91, 103, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(92, 105, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(93, 119, Expansion.ML, RecipeSkillName.Masonry),
new RecipeScrollDefinition(94, 104, Expansion.ML, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(95, 336, Expansion.ML, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(96, 500, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(97, 604, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(98, 603, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(99, 702, Expansion.ML, RecipeSkillName.Masonry),
new RecipeScrollDefinition(100, 701, Expansion.ML, RecipeSkillName.Masonry),
new RecipeScrollDefinition(101, 560, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(102, 561, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(103, 562, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(104, 563, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(105, 564, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(106, 565, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(107, 566, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(108, 570, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(109, 575, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(110, 573, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(111, 574, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(112, 576, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(113, 577, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(114, 572, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(115, 571, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(116, 581, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(117, 584, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(118, 583, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(119, 582, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(120, 580, Expansion.TOL, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(121, 600, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(122, 601, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(123, 602, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(124, 800, Expansion.ML, RecipeSkillName.Inscription),
new RecipeScrollDefinition(125, 900, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(126, 901, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(127, 902, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(128, 903, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(129, 904, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(130, 905, Expansion.TOL, RecipeSkillName.Alchemy),
new RecipeScrollDefinition(131, 1000, Expansion.TOL, RecipeSkillName.Cartography),
new RecipeScrollDefinition(132, 455, Expansion.TOL, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(133, 461, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(134, 462, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(135, 460, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(136, 459, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(137, 170, Expansion.TOL, RecipeSkillName.Carpentry),
new RecipeScrollDefinition(138, 457, Expansion.TOL, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(139, 458, Expansion.TOL, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(140, 355, Expansion.SA, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(141, 356, Expansion.SA, RecipeSkillName.Blacksmith),
new RecipeScrollDefinition(142, 585, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(143, 456, Expansion.SA, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(144, 464, Expansion.SA, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(145, 465, Expansion.ML, RecipeSkillName.Tinkering),
new RecipeScrollDefinition(146, 605, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(147, 606, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(148, 607, Expansion.ML, RecipeSkillName.Cooking),
new RecipeScrollDefinition(149, 586, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(150, 587, Expansion.ML, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(151, 588, Expansion.SA, RecipeSkillName.Tailoring),
new RecipeScrollDefinition(152, 463, Expansion.SA, RecipeSkillName.Tinkering)
};
[Constructable]
public RecipeBook()
: base(0xA266)
{
Weight = 1.0;
LootType = LootType.Blessed;
LoadDefinitions();
Filter = new RecipeScrollFilter();
Level = SecureLevel.CoOwners;
}
public void LoadDefinitions()
{
Recipes = new List<RecipeScrollDefinition>();
Definitions.ToList().ForEach(x =>
{
Recipes.Add(x);
});
}
public void ReLoadDefinitions()
{
Definitions.Where(n => !Recipes.Any(o => o.RecipeID == n.RecipeID)).ToList().ForEach(x =>
{
Recipes.Add(x);
});
}
public bool CheckAccessible(Mobile from, Item item)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
return true; // Staff can access anything
BaseHouse house = BaseHouse.FindHouseAt(item);
if (house == null)
return false;
switch (Level)
{
case SecureLevel.Owner: return house.IsOwner(from);
case SecureLevel.CoOwners: return house.IsCoOwner(from);
case SecureLevel.Friends: return house.IsFriend(from);
case SecureLevel.Anyone: return true;
case SecureLevel.Guild: return house.IsGuildMember(from);
}
return false;
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045);
}
else
{
if (from.HasGump(typeof(RecipeBookGump)))
return;
if (!Using)
{
Using = true;
from.SendGump(new RecipeBookGump((PlayerMobile)from, this));
}
else
{
from.SendLocalizedMessage(1062456); // The book is currently in use.
}
}
}
public override void OnDoubleClickSecureTrade(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.SendLocalizedMessage(500446); // That is too far away.
}
else
{
from.SendGump(new RecipeBookGump(from, this));
SecureTradeContainer cont = GetSecureTradeCont();
if (cont != null)
{
SecureTrade trade = cont.Trade;
if (trade != null && trade.From.Mobile == from)
trade.To.Mobile.SendGump(new RecipeBookGump(trade.To.Mobile, this));
else if (trade != null && trade.To.Mobile == from)
trade.From.Mobile.SendGump(new RecipeBookGump(trade.From.Mobile, this));
}
}
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (!IsChildOf(from.Backpack) && !IsLockedDown)
{
from.SendLocalizedMessage(1158823); // You must have the book in your backpack to add recipes to it.
return false;
}
else if (dropped is RecipeScroll)
{
RecipeScroll recipe = dropped as RecipeScroll;
if (Recipes.Any(x => x.RecipeID == recipe.RecipeID))
{
Recipes.ForEach(x =>
{
if (x.RecipeID == recipe.RecipeID)
x.Amount = x.Amount + 1;
});
InvalidateProperties();
from.SendLocalizedMessage(1158826); // Recipe added to the book.
if (from is PlayerMobile)
from.SendGump(new RecipeBookGump((PlayerMobile)from, this));
dropped.Delete();
return true;
}
else
{
from.SendLocalizedMessage(1158825); // That is not a recipe.
return false;
}
}
else
{
from.SendLocalizedMessage(1158825); // That is not a recipe.
return false;
}
}
public RecipeBook(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1);
writer.Write((int)Level);
writer.Write(BookName);
Filter.Serialize(writer);
writer.Write(Recipes.Count);
Recipes.ForEach(s =>
{
writer.Write(s.ID);
writer.Write(s.RecipeID);
writer.Write((int)s.Expansion);
writer.Write((int)s.Skill);
writer.Write(s.Amount);
writer.Write(s.Price);
});
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
case 0:
Level = (SecureLevel)reader.ReadInt();
BookName = reader.ReadString();
Filter = new RecipeScrollFilter(reader);
int count = reader.ReadInt();
Recipes = new List<RecipeScrollDefinition>();
for (int i = count; i > 0; i--)
{
int id = reader.ReadInt();
int rid = reader.ReadInt();
Expansion ex = (Expansion)reader.ReadInt();
RecipeSkillName skill = (RecipeSkillName)reader.ReadInt();
int amount = reader.ReadInt();
int price = reader.ReadInt();
Recipes.Add(new RecipeScrollDefinition(id, rid, ex, skill, amount, price));
}
ReLoadDefinitions();
break;
}
if(version == 0)
LootType = LootType.Blessed;
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1158849, String.Format("{0}", Recipes.Sum(x => x.Amount))); // Recipes in book: ~1_val~
if (BookName != null && BookName.Length > 0)
list.Add(1062481, BookName);
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (from.CheckAlive() && IsChildOf(from.Backpack))
{
list.Add(new NameBookEntry(from, this));
}
SetSecureLevelEntry.AddTo(from, this, list);
}
private class NameBookEntry : ContextMenuEntry
{
private Mobile m_From;
private RecipeBook m_Book;
public NameBookEntry(Mobile from, RecipeBook book)
: base(6216)
{
m_From = from;
m_Book = book;
}
public override void OnClick()
{
if (m_From.CheckAlive() && m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new NameBookPrompt(m_Book);
m_From.SendLocalizedMessage(1062479); // Type in the new name of the book:
}
}
}
private class NameBookPrompt : Prompt
{
public override int MessageCliloc { get { return 1062479; } }
private RecipeBook m_Book;
public NameBookPrompt(RecipeBook book)
{
m_Book = book;
}
public override void OnResponse(Mobile from, string text)
{
if (text.Length > 40)
text = text.Substring(0, 40);
if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
{
m_Book.BookName = Utility.FixHtml(text.Trim());
from.SendLocalizedMessage(1158827); // The recipe book's name has been changed.
}
}
public override void OnCancel(Mobile from)
{
}
}
}
}

View File

@@ -0,0 +1,487 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Engines.Craft;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.Prompts;
namespace Server.Items
{
public class RecipeBookGump : Gump
{
private RecipeBook m_Book;
private List<RecipeScrollDefinition> m_List;
private int m_Page;
private const int LabelColor = 0xFFFFFF;
public bool CheckFilter(RecipeScrollDefinition recipe)
{
RecipeScrollFilter f = m_Book.Filter;
if (f.IsDefault)
return true;
if (f.Skill == 1 && recipe.Skill != RecipeSkillName.Blacksmith )
{
return false;
}
else if (f.Skill == 2 && recipe.Skill != RecipeSkillName.Tailoring)
{
return false;
}
else if (f.Skill == 3 && recipe.Skill != RecipeSkillName.Fletching)
{
return false;
}
else if (f.Skill == 4 && recipe.Skill != RecipeSkillName.Carpentry && recipe.Skill != RecipeSkillName.Masonry)
{
return false;
}
else if (f.Skill == 5 && recipe.Skill != RecipeSkillName.Inscription)
{
return false;
}
else if (f.Skill == 6 && recipe.Skill != RecipeSkillName.Cooking)
{
return false;
}
else if (f.Skill == 7 && recipe.Skill != RecipeSkillName.Alchemy)
{
return false;
}
else if (f.Skill == 8 && recipe.Skill != RecipeSkillName.Tinkering)
{
return false;
}
else if (f.Skill == 9 && recipe.Skill != RecipeSkillName.Cartography)
{
return false;
}
if (f.Expansion == 1 && recipe.Expansion != Expansion.ML)
{
return false;
}
else if (f.Expansion == 2 && recipe.Expansion != Expansion.SA)
{
return false;
}
else if (f.Expansion == 3 && recipe.Expansion != Expansion.TOL)
{
return false;
}
if (f.Amount == 1 && recipe.Amount == 0)
{
return false;
}
return true;
}
public int GetIndexForPage(int page)
{
int index = 0;
while (page-- > 0)
index += GetCountForIndex(index);
return index;
}
public int GetCountForIndex(int index)
{
int slots = 0;
int count = 0;
List<RecipeScrollDefinition> list = m_List;
for (int i = index; i >= 0 && i < list.Count; ++i)
{
var recipe = list[i];
if (CheckFilter(recipe))
{
int add;
add = 1;
if ((slots + add) > 10)
break;
slots += add;
}
++count;
}
return count;
}
public RecipeBookGump(Mobile from, RecipeBook book)
: this(from, book, 0, null)
{
}
private class SetPricePrompt : Prompt
{
private RecipeBook m_Book;
private RecipeScrollDefinition m_Recipe;
private int m_Page;
private List<RecipeScrollDefinition> m_List;
public SetPricePrompt(RecipeBook book, RecipeScrollDefinition recipe, int page, List<RecipeScrollDefinition> list)
{
m_Book = book;
m_Recipe = recipe;
m_Page = page;
m_List = list;
}
public override void OnResponse(Mobile from, string text)
{
int price = Utility.ToInt32(text);
if (price < 0 || price > 250000000)
{
from.SendLocalizedMessage(1062390);
m_Book.Using = false;
}
else
{
m_Book.Recipes.Find(x => x.RecipeID == m_Recipe.RecipeID).Price = price;
from.SendLocalizedMessage(1158822); // Recipe price set.
from.SendGump(new RecipeBookGump((PlayerMobile)from, m_Book, m_Page, m_List));
}
}
}
private string GetExpansion(Expansion expansion)
{
switch (expansion)
{
default:
case Expansion.ML:
return "Mondain's";
case Expansion.SA:
return "Stygian";
case Expansion.TOL:
return "ToL";
}
}
private int GetSkillName(RecipeSkillName skill)
{
switch (skill)
{
default:
case RecipeSkillName.Alchemy:
return 1002000;
case RecipeSkillName.Blacksmith:
return 1150187;
case RecipeSkillName.Carpentry:
return 1002054;
case RecipeSkillName.Cartography:
return 1002057;
case RecipeSkillName.Cooking:
return 1002063;
case RecipeSkillName.Fletching:
return 1044068;
case RecipeSkillName.Inscription:
return 1002090;
case RecipeSkillName.Masonry:
return 1072392;
case RecipeSkillName.Tailoring:
return 1150188;
case RecipeSkillName.Tinkering:
return 1002162;
}
}
public RecipeBookGump(Mobile from, RecipeBook book, int page, List<RecipeScrollDefinition> list)
: base(12, 24)
{
from.CloseGump(typeof(RecipeBookGump));
from.CloseGump(typeof(RecipeScrollFilterGump));
m_Book = book;
m_Page = page;
if (list == null)
{
list = new List<RecipeScrollDefinition>();
m_Book.Recipes.ForEach(x =>
{
if (CheckFilter(x))
{
list.Add(x);
}
});
}
m_List = list;
int index = GetIndexForPage(page);
int count = GetCountForIndex(index);
int tableIndex = 0;
PlayerVendor pv = book.RootParent as PlayerVendor;
bool canLocked = book.IsLockedDown;
bool canDrop = book.IsChildOf(from.Backpack);
bool canBuy = (pv != null);
bool canPrice = (canDrop || canBuy || canLocked);
if (canBuy)
{
VendorItem vi = pv.GetVendorItem(book);
canBuy = (vi != null && !vi.IsForSale);
}
int width = 600;
if (!canPrice)
width = 516;
X = (624 - width) / 2;
AddPage(0);
AddBackground(10, 10, width, 439, 5054);
AddImageTiled(18, 20, width - 17, 420, 2624);
if (canPrice)
{
AddImageTiled(573, 64, 24, 352, 200);
AddImageTiled(493, 64, 78, 352, 1416);
}
if (canDrop)
AddImageTiled(24, 64, 32, 352, 1416);
AddImageTiled(58, 64, 36, 352, 200);
AddImageTiled(96, 64, 133, 352, 1416);
AddImageTiled(231, 64, 80, 352, 200);
AddImageTiled(313, 64, 100, 352, 1416);
AddImageTiled(415, 64, 76, 352, 200);
list = list.OrderBy(x => x.ID).ToList();
for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i)
{
var recipe = list[i];
if (!CheckFilter(recipe))
continue;
AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624);
++tableIndex;
}
AddAlphaRegion(18, 20, width - 17, 420);
AddImage(0, 0, 10460);
AddImage(width - 15, 5, 10460);
AddImage(0, 429, 10460);
AddImage(width - 15, 429, 10460);
AddHtmlLocalized(266, 32, 200, 32, 1158810, LabelColor, false, false); // Recipe Book
AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item
AddHtmlLocalized(246, 64, 200, 32, 1158814, LabelColor, false, false); // Expansion
AddHtmlLocalized(336, 64, 200, 32, 1158816, LabelColor, false, false); // Crafting
AddHtmlLocalized(429, 64, 100, 32, 1062217, LabelColor, false, false); // Amount
AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter
AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0);
RecipeScrollFilter f = book.Filter;
if (f.IsDefault)
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter
else if (((PlayerMobile)from).UseOwnFilter)
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false); // Using Your Filter
else
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); // Using Book Filter
AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); // EXIT
if (canDrop)
AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); // Drop
if (canPrice)
{
AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); // Price
if (canBuy)
AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); // Buy
else
AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false); // Set
}
tableIndex = 0;
if (page > 0)
{
AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false); // Previous page
}
if (GetIndexForPage(page + 1) < list.Count)
{
AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); // Next page
}
for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i)
{
var recipe = list[i];
if (!CheckFilter(recipe) || !Recipe.Recipes.ContainsKey(recipe.RecipeID))
continue;
int y = 96 + (tableIndex++ * 32);
if (recipe.Amount > 0 && (canDrop || canLocked))
AddButton(35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0);
AddLabel(61, y, 0x480, String.Format("{0}", recipe.ID));
AddHtmlLocalized(103, y, 130, 32, Recipe.Recipes[recipe.RecipeID].TextDefinition.Number, "#103221", 0xFFFFFF, false, false); // ~1_val~
AddLabel(235, y, 0x480, GetExpansion(recipe.Expansion));
AddHtmlLocalized(316, y, 100, 20, GetSkillName(recipe.Skill), "#104409", 0xFFFFFF, false, false); // ~1_val~
AddLabel(421, y, 0x480, recipe.Amount.ToString());
if (canDrop || (canBuy && recipe.Price > 0))
{
AddButton(579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0);
AddLabel(495, y, 1152, recipe.Price.ToString("N0"));
}
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
int index = info.ButtonID;
switch (index)
{
case 0: { m_Book.Using = false; break; }
case 1:
{
from.SendGump(new RecipeScrollFilterGump(from, m_Book));
break;
}
case 2:
{
if (m_Page > 0)
from.SendGump(new RecipeBookGump(from, m_Book, m_Page - 1, m_List));
return;
}
case 3:
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
from.SendGump(new RecipeBookGump(from, m_Book, m_Page + 1, m_List));
break;
}
default:
{
bool canDrop = m_Book.IsChildOf(from.Backpack);
bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);
index -= 4;
int type = index % 2;
index /= 2;
if (index < 0 || index >= m_List.Count)
break;
var recipe = m_List[index];
if (type == 0)
{
if (!m_Book.CheckAccessible(from, m_Book))
{
m_Book.SendLocalizedMessageTo(from, 1061637); // You are not allowed to access this.
m_Book.Using = false;
break;
}
if (m_Book.IsChildOf(from.Backpack) || m_Book.IsLockedDown)
{
if (recipe.Amount == 0)
{
from.SendLocalizedMessage(1158821); // The recipe selected is not available.
m_Book.Using = false;
break;
}
Item item = new RecipeScroll(recipe.RecipeID);
if (from.AddToBackpack(item))
{
m_Book.Recipes.ForEach(x =>
{
if (x.RecipeID == recipe.RecipeID)
x.Amount = x.Amount - 1;
});
m_Book.InvalidateProperties();
from.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack.
from.SendGump(new RecipeBookGump(from, m_Book, m_Page, null));
}
else
{
m_Book.Using = false;
item.Delete();
from.SendLocalizedMessage(1158819); // There is not enough room in your backpack for the recipe.
}
}
else
{
m_Book.Using = false;
}
}
else
{
if (m_Book.IsChildOf(from.Backpack))
{
from.Prompt = new SetPricePrompt(m_Book, recipe, m_Page, m_List);
from.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor)
{
if (recipe.Amount > 0)
{
from.SendGump(new RecipeScrollBuyGump(from, m_Book, recipe, recipe.Price));
}
else
{
m_Book.Using = false;
}
}
}
break;
}
}
}
}
}

View File

@@ -0,0 +1,120 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Items
{
public class RecipeScrollBuyGump : Gump
{
private Mobile m_From;
private RecipeBook m_Book;
private RecipeScrollDefinition m_Recipe;
private int m_Price;
public RecipeScrollBuyGump(Mobile from, RecipeBook book, RecipeScrollDefinition recipe, int price)
: base(100, 200)
{
m_From = from;
m_Book = book;
m_Recipe = recipe;
m_Price = price;
AddPage(0);
AddBackground(100, 10, 300, 150, 5054);
AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase:
AddHtmlLocalized(125, 45, 250, 24, 1074560, false, false); // recipe scroll
AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of:
AddLabel(125, 95, 0, price.ToString());
AddButton(250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL
AddButton(120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 2)
{
PlayerVendor pv = m_Book.RootParent as PlayerVendor;
if (pv != null)
{
int price = 0;
VendorItem vi = pv.GetVendorItem(m_Book);
if (vi != null && !vi.IsForSale)
{
price = m_Recipe.Price;
}
if (price != m_Price)
{
pv.SayTo(m_From, 1150158); // The price of the selected item has been changed from the value you confirmed. You must select and confirm the purchase again at the new price in order to buy it.
m_Book.Using = false;
}
else if (m_Recipe.Amount == 0 || price == 0)
{
pv.SayTo(m_From, 1158821); // The recipe selected is not available.
m_Book.Using = false;
}
else
{
Item item = new RecipeScroll(m_Recipe.RecipeID);
pv.Say(m_From.Name);
Container pack = m_From.Backpack;
if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price))
{
m_Book.Recipes.ForEach(x =>
{
if (x.RecipeID == m_Recipe.RecipeID)
x.Amount = x.Amount - 1;
});
m_Book.InvalidateProperties();
pv.HoldGold += price;
if (m_From.AddToBackpack(item))
m_From.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack.
else
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this.
m_From.SendGump(new RecipeBookGump(m_From, m_Book));
}
else
{
pv.SayTo(m_From, 503205); // You cannot afford this item.
item.Delete();
m_Book.Using = false;
}
}
}
else
{
m_Book.Using = false;
if (pv == null)
m_From.SendLocalizedMessage(1158821); // The recipe selected is not available.
else
pv.SayTo(m_From, 1158821); // The recipe selected is not available.
}
}
else
{
m_Book.Using = false;
m_From.SendLocalizedMessage(503207); // Cancelled purchase.
}
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
namespace Server.Items
{
public class RecipeScrollFilter
{
public bool IsDefault
{
get { return (Skill == 0 && Expansion == 0 && Amount == 0); }
}
public void Clear()
{
Skill = 0;
Expansion = 0;
Amount = 0;
}
public int Skill { get; set; }
public int Expansion { get; set; }
public int Amount { get; set; }
public RecipeScrollFilter()
{
}
public RecipeScrollFilter(GenericReader reader)
{
int version = reader.ReadInt();
switch (version)
{
case 1:
Skill = reader.ReadInt();
Expansion = reader.ReadInt();
Amount = reader.ReadInt();
break;
}
}
public void Serialize(GenericWriter writer)
{
if (IsDefault)
{
writer.Write((int)0);
}
else
{
writer.Write(1);
writer.Write((int)Skill);
writer.Write((int)Expansion);
writer.Write((int)Amount);
}
}
}
}

View File

@@ -0,0 +1,196 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Items
{
public class RecipeScrollFilterGump : Gump
{
private Mobile m_From;
private RecipeBook m_Book;
private const int LabelColor = 0x7FFF;
private const int TitleLabelColor = 0xFFFFFF;
private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int xHeights, int filterValue, int filterIndex)
{
for (int i = 0; i < filters.GetLength(0); ++i)
{
int number = filters[i, 0];
if (number == 0)
continue;
bool isSelected = (filters[i, 1] == filterValue);
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 80, xHeights, number, isSelected ? 16927 : LabelColor, false, false);
AddButton(x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0);
}
}
private static readonly int[,] m_SkillFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1150187, 1 }, // Blacksmith
{ 1150188, 2 }, // Tailor
{ 1044068, 3 }, // Fletching
{ 1002054, 4 }, // Carpentry
{ 1002090, 5 }, // Inscription
{ 1002063, 6 }, // Cooking
{ 1002000, 7 }, // Alchemy
{ 1002162, 8 }, // Tinkering
{ 1002057, 9 }, // Cartography
};
private static readonly int[,] m_ExpansionFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1158817, 1 }, // Mondain's Legacy
{ 1095190, 2 }, // Stygian Abyss
{ 1158818, 3 }, // Time of Legends
};
private static readonly int[,] m_AmountFilters = new int[,]
{
{ 1062229, 0 }, // All
{ 1158815, 1 }, // Owned
{ 1074235, 2 }, // Unknown
};
private static readonly int[][,] m_Filters = new int[][,]
{
m_SkillFilters,
m_ExpansionFilters,
m_AmountFilters
};
private static readonly int[] m_XOffsets_Skill = new int[] { 0, 125, 250, 375 };
private static readonly int[] m_XOffsets_Expansion = new int[] { 0, 125, 250, 375 };
private static readonly int[] m_XOffsets_Amount = new int[] { 0, 125, 250 };
public RecipeScrollFilterGump(Mobile from, RecipeBook book)
: base(12, 24)
{
from.CloseGump(typeof(RecipeBookGump));
from.CloseGump(typeof(RecipeScrollFilterGump));
m_From = from;
m_Book = book;
RecipeScrollFilter f = book.Filter;
AddPage(0);
AddBackground(10, 10, 600, 375, 0x13BE);
AddImageTiled(18, 20, 583, 356, 0xA40);
AddAlphaRegion(18, 20, 583, 356);
AddImage(0, 0, 0x28DC);
AddImage(590, 0, 0x28DC);
AddImage(0, 365, 0x28DC);
AddImage(590, 365, 0x28DC);
AddHtmlLocalized(26, 64, 120, 32, 1158816, TitleLabelColor, false, false); // Crafting
AddHtmlLocalized(270, 32, 200, 32, 1062223, TitleLabelColor, false, false); // Filter Preference
AddHtmlLocalized(26, 64, 120, 32, 1158816, TitleLabelColor, false, false); // Crafting
AddFilterList(25, 96, m_XOffsets_Skill, 32, m_SkillFilters, 32, f.Skill, 0);
AddHtmlLocalized(26, 192, 120, 42, 1158814, TitleLabelColor, false, false); // Expansion
AddFilterList(25, 224, m_XOffsets_Expansion, 32, m_ExpansionFilters, 42, f.Expansion, 1);
AddHtmlLocalized(26, 256, 120, 32, 1062217, TitleLabelColor, false, false); // Amount
AddFilterList(25, 288, m_XOffsets_Amount, 32, m_AmountFilters, 32, f.Amount, 2);
AddHtmlLocalized(75, 352, 120, 32, 1062477, (((PlayerMobile)from).UseOwnFilter ? LabelColor : 16927), false, false); // Set Book Filter
AddButton(40, 352, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(235, 352, 120, 32, 1062478, (((PlayerMobile)from).UseOwnFilter ? 16927 : LabelColor), false, false); // Set Your Filter
AddButton(200, 352, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(405, 352, 120, 32, 1062231, TitleLabelColor, false, false); // Clear Filter
AddButton(370, 352, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(540, 352, 50, 32, 1011046, TitleLabelColor, false, false); // APPLY
AddButton(505, 352, 4017, 4018, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
RecipeScrollFilter f = m_Book.Filter;
int index = info.ButtonID;
switch (index)
{
case 0: // APPLY
{
m_From.SendGump(new RecipeBookGump(m_From, m_Book));
break;
}
case 1: // Set Book Filter
{
((PlayerMobile)m_From).UseOwnFilter = false;
m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book));
break;
}
case 2: // Set Your Filter
{
((PlayerMobile)m_From).UseOwnFilter = true;
m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book));
break;
}
case 3: // Clear
{
f.Clear();
m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
int[][,] filter = m_Filters;
if (type >= 0 && type < filter.Length)
{
int[,] filters = filter[type];
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
break;
switch (type)
{
case 0:
f.Skill = filters[index, 1];
break;
case 1:
f.Expansion = filters[index, 1];
break;
case 2:
f.Amount = filters[index, 1];
break;
}
m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book));
}
}
break;
}
}
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Items
{
[Flipable(0x9981, 0x9982)]
public class ScrollOfAlacrityBook : BaseSpecialScrollBook
{
public override Type ScrollType { get { return typeof(ScrollOfAlacrity); } }
public override int LabelNumber { get { return 1154321; } } // Scrolls of Alacrity Book
public override int BadDropMessage { get { return 1154323; } } // This book only holds Scrolls of Alacrity.
public override int DropMessage { get { return 1154326; } } // You add the scroll to your Scrolls of Alacrity book.
public override int RemoveMessage { get { return 1154322; } } // You remove a Scroll of Alacrity and put it in your pack.
public override int GumpTitle { get { return 1154324; } } // Alacrity Scrolls
[Constructable]
public ScrollOfAlacrityBook()
: base(0x9981)
{
Hue = 1195;
}
public ScrollOfAlacrityBook(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public override Dictionary<SkillCat, List<SkillName>> SkillInfo { get { return _SkillInfo; } }
public override Dictionary<int, double> ValueInfo { get { return _ValueInfo; } }
public static Dictionary<SkillCat, List<SkillName>> _SkillInfo;
public static Dictionary<int, double> _ValueInfo;
public static void Initialize()
{
_SkillInfo = new Dictionary<SkillCat, List<SkillName>>();
_SkillInfo[SkillCat.Miscellaneous] = new List<SkillName>() { SkillName.ArmsLore, SkillName.Begging, SkillName.Camping, SkillName.Cartography, SkillName.Forensics, SkillName.ItemID, SkillName.TasteID};
_SkillInfo[SkillCat.Combat] = new List<SkillName>() { SkillName.Anatomy, SkillName.Archery, SkillName.Fencing, SkillName.Focus, SkillName.Healing, SkillName.Macing, SkillName.Parry, SkillName.Swords, SkillName.Tactics, SkillName.Throwing, SkillName.Wrestling };
_SkillInfo[SkillCat.TradeSkills] = new List<SkillName>() { SkillName.Alchemy, SkillName.Blacksmith, SkillName.Fletching, SkillName.Carpentry, SkillName.Cooking, SkillName.Inscribe, SkillName.Lumberjacking, SkillName.Mining, SkillName.Tailoring, SkillName.Tinkering };
_SkillInfo[SkillCat.Magic] = new List<SkillName>() { SkillName.Bushido, SkillName.Chivalry, SkillName.EvalInt, SkillName.Imbuing, SkillName.Magery, SkillName.Meditation, SkillName.Mysticism, SkillName.Necromancy, SkillName.Ninjitsu, SkillName.MagicResist, SkillName.Spellweaving, SkillName.SpiritSpeak };
_SkillInfo[SkillCat.Wilderness] = new List<SkillName>() { SkillName.AnimalLore, SkillName.AnimalTaming, SkillName.Fishing, SkillName.Herding, SkillName.Tracking, SkillName.Veterinary };
_SkillInfo[SkillCat.Thievery] = new List<SkillName>() { SkillName.DetectHidden, SkillName.Hiding, SkillName.Lockpicking, SkillName.Poisoning, SkillName.RemoveTrap, SkillName.Snooping, SkillName.Stealing, SkillName.Stealth };
_SkillInfo[SkillCat.Bard] = new List<SkillName>() { SkillName.Discordance, SkillName.Musicianship, SkillName.Peacemaking, SkillName.Provocation };
_ValueInfo = new Dictionary<int, double>();
_ValueInfo[1154324] = 0.0;
}
}
}

View File

@@ -0,0 +1,79 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Items
{
[Flipable(0x577E, 0x577F)]
public class ScrollOfTranscendenceBook : BaseSpecialScrollBook
{
public override Type ScrollType { get { return typeof(ScrollOfTranscendence); } }
public override int LabelNumber { get { return 1151679; } } // Scrolls of Transcendence Book
public override int BadDropMessage { get { return 1151677; } } // This book only holds Scrolls of Transcendence.
public override int DropMessage { get { return 1151674; } } // You add the scroll to your Scrolls of Transcendence book.
public override int RemoveMessage { get { return 1151658; } } // You remove a Scroll of Transcendence and put it in your pack.
public override int GumpTitle { get { return 1151675; } } // Scrolls of Transcendence
[Constructable]
public ScrollOfTranscendenceBook()
: base(0x577E)
{
Hue = 0x490;
}
public ScrollOfTranscendenceBook(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public override Dictionary<SkillCat, List<SkillName>> SkillInfo { get { return _SkillInfo; } }
public override Dictionary<int, double> ValueInfo { get { return _ValueInfo; } }
public static Dictionary<SkillCat, List<SkillName>> _SkillInfo;
public static Dictionary<int, double> _ValueInfo;
public static void Initialize()
{
_SkillInfo = new Dictionary<SkillCat, List<SkillName>>();
_SkillInfo[SkillCat.Miscellaneous] = new List<SkillName>() { SkillName.ArmsLore, SkillName.Begging, SkillName.Camping, SkillName.Cartography, SkillName.Forensics, SkillName.ItemID, SkillName.TasteID};
_SkillInfo[SkillCat.Combat] = new List<SkillName>() { SkillName.Anatomy, SkillName.Archery, SkillName.Fencing, SkillName.Focus, SkillName.Healing, SkillName.Macing, SkillName.Parry, SkillName.Swords, SkillName.Tactics, SkillName.Throwing, SkillName.Wrestling };
_SkillInfo[SkillCat.TradeSkills] = new List<SkillName>() { SkillName.Alchemy, SkillName.Blacksmith, SkillName.Fletching, SkillName.Carpentry, SkillName.Cooking, SkillName.Inscribe, SkillName.Lumberjacking, SkillName.Mining, SkillName.Tailoring, SkillName.Tinkering };
_SkillInfo[SkillCat.Magic] = new List<SkillName>() { SkillName.Bushido, SkillName.Chivalry, SkillName.EvalInt, SkillName.Imbuing, SkillName.Magery, SkillName.Meditation, SkillName.Mysticism, SkillName.Necromancy, SkillName.Ninjitsu, SkillName.MagicResist, SkillName.Spellweaving, SkillName.SpiritSpeak };
_SkillInfo[SkillCat.Wilderness] = new List<SkillName>() { SkillName.AnimalLore, SkillName.AnimalTaming, SkillName.Fishing, SkillName.Herding, SkillName.Tracking, SkillName.Veterinary };
_SkillInfo[SkillCat.Thievery] = new List<SkillName>() { SkillName.DetectHidden, SkillName.Hiding, SkillName.Lockpicking, SkillName.Poisoning, SkillName.RemoveTrap, SkillName.Snooping, SkillName.Stealing, SkillName.Stealth };
_SkillInfo[SkillCat.Bard] = new List<SkillName>() { SkillName.Discordance, SkillName.Musicianship, SkillName.Peacemaking, SkillName.Provocation };
_ValueInfo = new Dictionary<int, double>();
_ValueInfo[1151659] = 0.1;
_ValueInfo[1151660] = 0.2;
_ValueInfo[1151661] = 0.3;
_ValueInfo[1151662] = 0.4;
_ValueInfo[1151663] = 0.5;
_ValueInfo[1151664] = 0.6;
_ValueInfo[1151665] = 0.7;
_ValueInfo[1151666] = 0.8;
_ValueInfo[1151667] = 0.9;
_ValueInfo[1151668] = 1.0;
_ValueInfo[1151669] = 3.0;
_ValueInfo[1151670] = 5.0;
}
}
}

View File

@@ -0,0 +1,232 @@
using System;
using Server;
using Server.Gumps;
using Server.Mobiles;
using Server.Items;
using System.Collections.Generic;
using System.Linq;
namespace Server.Gumps
{
public class SpecialScrollBookGump : BaseGump
{
public BaseSpecialScrollBook Book { get; private set; }
public SkillCat Category { get; set; }
public SkillName Skill { get; set; }
public SpecialScrollBookGump(PlayerMobile pm, BaseSpecialScrollBook book)
: base(pm, 150, 200)
{
Book = book;
pm.CloseGump(typeof(SpecialScrollBookGump));
}
public override void AddGumpLayout()
{
AddImage(0, 0, 2200);
for (int i = 0; i < 2; ++i)
{
int xOffset = 25 + (i * 165);
AddImage(xOffset, 45, 57);
xOffset += 20;
for (int j = 0; j < 6; ++j, xOffset += 15)
AddImage(xOffset, 45, 58);
AddImage(xOffset - 5, 45, 59);
}
if (Category != SkillCat.None)
{
if (Skill != SkillName.Alchemy)
{
BuildSkillPage();
AddButton(20, 5, 2205, 2205, 1, GumpButtonType.Reply, 0);
}
else
{
BuildSkillsPage();
AddButton(20, 5, 2205, 2205, 2, GumpButtonType.Reply, 0);
}
}
else
{
BuildCategoriesPage();
}
}
public virtual void BuildCategoriesPage()
{
AddHtmlLocalized(0, 15, 175, 20, CenterLoc, String.Format("#{0}", Book.GumpTitle), 0, false, false);
if (Book == null || Book.Deleted || Book.SkillInfo == null)
return;
int index = 0;
foreach (var kvp in Book.SkillInfo)
{
AddHtmlLocalized(45, 55 + (index * 15), 100, 20, BaseSpecialScrollBook.GetCategoryLocalization(kvp.Key), false, false);
if (HasScroll(kvp.Value))
{
AddButton(30, 59 + (index * 15), 2103, 2104, 10 + (int)kvp.Key, GumpButtonType.Reply, 0);
}
index++;
}
}
public virtual void BuildSkillsPage()
{
AddHtmlLocalized(0, 15, 175, 20, CenterLoc, String.Format("#{0}", BaseSpecialScrollBook.GetCategoryLocalization(Category)), 0, false, false); // Power Scrolls
if (Category == SkillCat.None || Book == null || Book.Deleted || Book.SkillInfo == null)
return;
List<SkillName> list = Book.SkillInfo[Category];
int x = 45;
int y = 55;
int buttonX = 30;
int split = list.Count >= 9 ? list.Count / 2 : -1;
for (int i = 0; i < list.Count; i++)
{
SkillName skill = list[i];
if (split > -1 && i == split)
{
x = 205;
y = 55;
buttonX = 190;
}
AddHtmlLocalized(x, y, 110, 20, SkillInfo.Table[(int)skill].Localization, false, false);
if (HasScroll(skill))
{
AddButton(buttonX, y + 4, 2103, 2104, 100 + i, GumpButtonType.Reply, 0);
}
y += 15;
}
}
public virtual void BuildSkillPage()
{
AddHtmlLocalized(0, 15, 175, 20, CenterLoc, String.Format("#{0}", SkillInfo.Table[(int)Skill].Localization), 0, false, false);
if (Skill == SkillName.Alchemy || Book == null || Book.Deleted || Book.ValueInfo == null)
return;
int x = 40;
int buttonX = 30;
int y = 55;
int index = 0;
int split = Book.ValueInfo.Count >= 9 ? Book.ValueInfo.Count / 2 : -1;
foreach(var kvp in Book.ValueInfo)
{
if (split > -1 && index == split)
{
x = 205;
buttonX = 195;
y = 55;
}
int total = GetTotalScrolls(Skill, kvp.Value);
AddHtmlLocalized(x, y, 100, 20, kvp.Key, false, false);
AddLabel(x + 100, y, 0, total.ToString());
if (total > 0)
{
AddButton(buttonX, y + 4, 2437, 2438, 1000 + (int)(kvp.Value * 10), GumpButtonType.Reply, 0);
}
y += 15;
index++;
}
}
public override void OnResponse(RelayInfo info)
{
if (info.ButtonID == 1)
{
Skill = SkillName.Alchemy;
Refresh();
}
else if (info.ButtonID == 2)
{
Category = SkillCat.None;
Skill = SkillName.Alchemy;
Refresh();
}
else
{
int id = info.ButtonID;
if (id < 100)
{
id -= 10;
if (id >= 0 && id <= 7)
{
Category = (SkillCat)id;
Refresh();
}
}
else if (id < 1000)
{
id -= 100;
if (Category > SkillCat.None)
{
List<SkillName> list = Book.SkillInfo[Category];
if (id >= 0 && id < list.Count)
{
Skill = list[id];
Refresh();
}
}
}
else
{
double value = id - 1000;
value /= 10;
Book.Construct(User, Skill, value);
}
}
}
public bool HasScroll(List<SkillName> skills)
{
return Book.Items.FirstOrDefault(i => i is SpecialScroll && skills.Contains(((SpecialScroll)i).Skill)) != null;
}
public bool HasScroll(SkillName skill)
{
return Book.Items.FirstOrDefault(i => i is SpecialScroll && skill == ((SpecialScroll)i).Skill) != null;
}
public int GetTotalScrolls(SkillName skill, double value)
{
int count = 0;
foreach (var scroll in Book.Items.OfType<SpecialScroll>().Where(s => s.Skill == skill && value == s.Value))
count++;
return count;
}
}
}