Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 • committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,244 @@
using System.Collections.Generic;
namespace Server.Items
{
public class PowerScroll : SpecialScroll
{
private static SkillName[] m_Skills =
{
SkillName.Blacksmith,
SkillName.Tailoring,
SkillName.Swords,
SkillName.Fencing,
SkillName.Macing,
SkillName.Archery,
SkillName.Wrestling,
SkillName.Parry,
SkillName.Tactics,
SkillName.Anatomy,
SkillName.Healing,
SkillName.Magery,
SkillName.Meditation,
SkillName.EvalInt,
SkillName.MagicResist,
SkillName.AnimalTaming,
SkillName.AnimalLore,
SkillName.Veterinary,
SkillName.Musicianship,
SkillName.Provocation,
SkillName.Discordance,
SkillName.Peacemaking
};
private static SkillName[] m_AOSSkills =
{
SkillName.Chivalry,
SkillName.Focus,
SkillName.Necromancy,
SkillName.Stealing,
SkillName.Stealth,
SkillName.SpiritSpeak
};
private static SkillName[] m_SESkills =
{
SkillName.Ninjitsu,
SkillName.Bushido
};
private static SkillName[] m_MLSkills =
{
SkillName.Spellweaving
};
/*
private static SkillName[] m_SASkills = new SkillName[]
{
SkillName.Throwing,
SkillName.Mysticism,
SkillName.Imbuing
};
private static SkillName[] m_HSSkills = new SkillName[]
{
SkillName.Fishing
};
*/
private static List<SkillName> _Skills = new List<SkillName>();
[Constructible]
public PowerScroll(SkillName skill = SkillName.Alchemy, double value = 0.0) : base(skill, value)
{
Hue = 0x481;
if (Value == 105.0 || skill == SkillName.Blacksmith || skill == SkillName.Tailoring)
LootType = LootType.Regular;
}
public PowerScroll(Serial serial) : base(serial)
{
}
public override int Message =>
1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window. */
public override int Title
{
get
{
double level = (Value - 105.0) / 5.0;
if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0)
return 1049635 + (int)level; /* Wonderous Scroll (105 Skill): OR
* Exalted Scroll (110 Skill): OR
* Mythical Scroll (115 Skill): OR
* Legendary Scroll (120 Skill): */
return 0;
}
}
public override string DefaultTitle => $"<basefont color=#FFFFFF>Power Scroll ({Value} Skill):</basefont>";
public static List<SkillName> Skills
{
get
{
if (_Skills.Count == 0)
{
_Skills.AddRange(m_Skills);
if (Core.AOS)
{
_Skills.AddRange(m_AOSSkills);
if (Core.SE)
{
_Skills.AddRange(m_SESkills);
if (Core.ML) _Skills.AddRange(m_MLSkills);
}
}
}
return _Skills;
}
}
public static PowerScroll CreateRandom(int min, int max)
{
min /= 5;
max /= 5;
return new PowerScroll(Skills[Utility.Random(Skills.Count)], 100 + Utility.RandomMinMax(min, max) * 5);
}
public static PowerScroll CreateRandomNoCraft(int min, int max)
{
min /= 5;
max /= 5;
SkillName skillName;
do
{
skillName = Skills[Utility.Random(Skills.Count)];
} while (skillName == SkillName.Blacksmith || skillName == SkillName.Tailoring);
return new PowerScroll(skillName, 100 + Utility.RandomMinMax(min, max) * 5);
}
public override void AddNameProperty(ObjectPropertyList list)
{
double level = (Value - 105.0) / 5.0;
if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0)
list.Add(1049639 + (int)level, GetNameLocalized()); /* a wonderous scroll of ~1_type~ (105 Skill) OR
* an exalted scroll of ~1_type~ (110 Skill) OR
* a mythical scroll of ~1_type~ (115 Skill) OR
* a legendary scroll of ~1_type~ (120 Skill) */
else
list.Add("a power scroll of {0} ({1} Skill)", GetName(), Value);
}
public override void OnSingleClick(Mobile from)
{
double level = (Value - 105.0) / 5.0;
if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0)
LabelTo(from, 1049639 + (int)level, GetNameLocalized());
else
LabelTo(from, "a power scroll of {0} ({1} Skill)", GetName(), Value);
}
public override bool CanUse(Mobile from)
{
if (!base.CanUse(from))
return false;
Skill skill = from.Skills[Skill];
if (skill == null)
return false;
if (skill.Cap >= Value)
{
from.SendLocalizedMessage(1049511, GetNameLocalized()); // Your ~1_type~ is too high for this power scroll.
return false;
}
return true;
}
public override void Use(Mobile from)
{
if (!CanUse(from))
return;
from.SendLocalizedMessage(1049513,
GetNameLocalized()); // You feel a surge of magic as the scroll enhances your ~1_type~!
from.Skills[Skill].Cap = Value;
Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0, 0, 0, 0,
0, 5060, 0);
Effects.PlaySound(from.Location, from.Map, 0x243);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 4, from.Y - 6, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 4, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendTargetParticles(from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);
Delete();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion
if (Value == 105.0 || Skill == SkillName.Blacksmith || Skill == SkillName.Tailoring)
{
LootType = LootType.Regular;
}
else
{
LootType = LootType.Cursed;
Insured = false;
}
}
}
}

View file

@ -0,0 +1,126 @@
using System;
using Server.Engines.MLQuests;
using Server.Engines.MLQuests.Objectives;
using Server.Mobiles;
namespace Server.Items
{
public class ScrollofAlacrity : SpecialScroll
{
[Constructible]
public ScrollofAlacrity(SkillName skill = SkillName.Alchemy) : base(skill, 0.0)
{
ItemID = 0x14EF;
Hue = 0x4AB;
}
public ScrollofAlacrity(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1078604; // Scroll of Alacrity
public override int Message =>
1078602; /*Using a Scroll of Transcendence for a given skill will permanently increase your current
*level in that skill by the amount of points displayed on the scroll.
*As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/
public override string DefaultTitle => "<basefont color=#FFFFFF>Scroll of Alacrity:</basefont>";
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1071345, "{0} 15 Minutes", GetName()); // Skill: ~1_val~
}
public override bool CanUse(Mobile from)
{
if (!(base.CanUse(from) && from is PlayerMobile pm))
return false;
#region Mondain's Legacy
MLQuestContext context = MLQuestSystem.GetContext(pm);
if (context != null)
{
foreach (MLQuestInstance instance in context.QuestInstances)
{
foreach (BaseObjectiveInstance objective in instance.Objectives)
{
if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
objectiveInstance.Handles(Skill))
{
from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
return false;
}
}
}
}
#endregion
if (pm.AcceleratedStart > DateTime.UtcNow)
{
from.SendLocalizedMessage(1077951); // You are already under the effect of an accelerated skillgain scroll.
return false;
}
return true;
}
public override void Use(Mobile from)
{
if (!(CanUse(from) && from is PlayerMobile pm))
return;
double tskill = from.Skills[Skill].Base;
double tcap = from.Skills[Skill].Cap;
if (tskill >= tcap || from.Skills[Skill].Lock != SkillLock.Up)
{
from.SendLocalizedMessage(
1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
*If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/
return;
}
from.SendLocalizedMessage(
1077956); // You are infused with intense energy. You are under the effects of an accelerated skillgain scroll.
Effects.PlaySound(from.Location, from.Map, 0x1E9);
Effects.SendTargetParticles(from, 0x373A, 35, 45, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);
pm.AcceleratedStart = DateTime.UtcNow + TimeSpan.FromMinutes(15);
Timer.DelayCall(TimeSpan.FromMinutes(15), Expire_Callback, from);
pm.AcceleratedSkill = Skill;
Delete();
}
// TODO: Handle this upon deserialization. Create Dictionary and serialize Mobile/Timers?
private static void Expire_Callback(Mobile m)
{
m.PlaySound(0x1F8);
m.SendLocalizedMessage(
1077957); // The intense energy dissipates. You are no longer under the effects of an accelerated skillgain scroll.
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion
LootType = LootType.Cursed;
Insured = false;
}
}
}

View file

@ -0,0 +1,157 @@
using System;
using Server.Engines.MLQuests;
using Server.Engines.MLQuests.Objectives;
using Server.Mobiles;
namespace Server.Items
{
public class ScrollofTranscendence : SpecialScroll
{
[Constructible]
public ScrollofTranscendence(SkillName skill = SkillName.Alchemy, double value = 0.0) : base(skill, value)
{
ItemID = 0x14EF;
Hue = 0x490;
}
public ScrollofTranscendence(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1094934; // Scroll of Transcendence
public override int Message =>
1094933; /*Using a Scroll of Transcendence for a given skill will permanently increase your current
*level in that skill by the amount of points displayed on the scroll.
*As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/
public override string DefaultTitle =>
$"<basefont color=#FFFFFF>Scroll of Transcendence ({Value} Skill):</basefont>";
public static ScrollofTranscendence CreateRandom(int min, int max)
{
SkillName skill = (SkillName)Utility.Random(SkillInfo.Table.Length);
return new ScrollofTranscendence(skill, Utility.RandomMinMax(min, max) * 0.1);
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Value == 1)
list.Add(1076759, "{0}\t{1}.0 Skill Points", GetName(), Value);
else
list.Add(1076759, "{0}\t{1} Skill Points", GetName(), Value);
}
public override bool CanUse(Mobile from)
{
if (!(base.CanUse(from) && from is PlayerMobile pm))
return false;
#region Mondain's Legacy
MLQuestContext context = MLQuestSystem.GetContext(pm);
if (context != null)
{
foreach (MLQuestInstance instance in context.QuestInstances)
{
foreach (BaseObjectiveInstance objective in instance.Objectives)
{
if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
objectiveInstance.Handles(Skill))
{
from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
return false;
}
}
}
}
#endregion
if (pm.AcceleratedStart > DateTime.UtcNow)
{
from.SendLocalizedMessage(1077951); // You are already under the effect of an accelerated skillgain scroll.
return false;
}
return true;
}
public override void Use(Mobile from)
{
if (!CanUse(from))
return;
double tskill = from.Skills[Skill].Base; // value of skill without item bonuses etc
double tcap = from.Skills[Skill].Cap; // maximum value permitted
bool canGain = false;
double newValue = Value;
if (tskill + newValue > tcap)
newValue = tcap - tskill;
if (tskill < tcap && from.Skills[Skill].Lock == SkillLock.Up)
{
if (from.SkillsTotal + newValue * 10 > from.SkillsCap)
{
int ns = from.Skills.Length; // number of items in from.Skills[]
for (int i = 0; i < ns; i++)
// skill must point down and its value must be enough
if (from.Skills[i].Lock == SkillLock.Down && from.Skills[i].Base >= newValue)
{
from.Skills[i].Base -= newValue;
canGain = true;
break;
}
}
else
{
canGain = true;
}
}
if (!canGain)
{
from.SendLocalizedMessage(
1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
*If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/
return;
}
from.SendLocalizedMessage(1049513,
GetNameLocalized()); // You feel a surge of magic as the scroll enhances your ~1_type~!
from.Skills[Skill].Base += newValue;
Effects.PlaySound(from.Location, from.Map, 0x1F7);
Effects.SendTargetParticles(from, 0x373A, 35, 45, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);
Effects.SendTargetParticles(from, 0x376A, 35, 45, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);
Delete();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion
LootType = LootType.Cursed;
Insured = false;
if (Hue == 0x7E)
Hue = 0x490;
}
}
}

View file

@ -0,0 +1,171 @@
using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public abstract class SpecialScroll : Item
{
public SpecialScroll(SkillName skill, double value) : base(0x14F0)
{
LootType = LootType.Cursed;
Weight = 1.0;
Skill = skill;
Value = value;
}
public SpecialScroll(Serial serial) : base(serial)
{
}
#region Old Item Serialization Vars
/* DO NOT USE! Only used in serialization of special scrolls that originally derived from Item */
protected bool InheritsItem{ get; private set; }
#endregion
public abstract int Message{ get; }
public virtual int Title => 0;
public abstract string DefaultTitle{ get; }
[CommandProperty(AccessLevel.GameMaster)]
public SkillName Skill{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public double Value{ get; set; }
public virtual string GetNameLocalized()
{
return string.Concat("#", AosSkillBonuses.GetLabel(Skill).ToString());
}
public virtual string GetName()
{
int index = (int)Skill;
SkillInfo[] table = SkillInfo.Table;
if (index >= 0 && index < table.Length)
return table[index].Name.ToLower();
return "???";
}
public virtual bool CanUse(Mobile from)
{
if (Deleted)
return false;
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
return false;
}
return true;
}
public virtual void Use(Mobile from)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!CanUse(from))
return;
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(from, this));
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write((int)Skill);
writer.Write(Value);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
{
Skill = (SkillName)reader.ReadInt();
Value = reader.ReadDouble();
break;
}
case 0:
{
InheritsItem = true;
if (!(this is StatCapScroll))
Skill = (SkillName)reader.ReadInt();
else
Skill = SkillName.Alchemy;
if (this is ScrollofAlacrity)
Value = 0.0;
else if (this is StatCapScroll)
Value = reader.ReadInt();
else
Value = reader.ReadDouble();
break;
}
}
}
public class InternalGump : Gump
{
private Mobile m_Mobile;
private SpecialScroll m_Scroll;
public InternalGump(Mobile mobile, SpecialScroll scroll) : base(25, 50)
{
m_Mobile = mobile;
m_Scroll = scroll;
AddPage(0);
AddBackground(25, 10, 420, 200, 5054);
AddImageTiled(33, 20, 401, 181, 2624);
AddAlphaRegion(33, 20, 401, 181);
AddHtmlLocalized(40, 48, 387, 100, m_Scroll.Message, true, true);
AddHtmlLocalized(125, 148, 200, 20, 1049478, 0xFFFFFF); // Do you wish to use this scroll?
AddButton(100, 172, 4005, 4007, 1);
AddHtmlLocalized(135, 172, 120, 20, 1046362, 0xFFFFFF); // Yes
AddButton(275, 172, 4005, 4007, 0);
AddHtmlLocalized(310, 172, 120, 20, 1046363, 0xFFFFFF); // No
if (m_Scroll.Title != 0)
AddHtmlLocalized(40, 20, 260, 20, m_Scroll.Title, 0xFFFFFF);
else
AddHtml(40, 20, 260, 20, m_Scroll.DefaultTitle);
if (m_Scroll is StatCapScroll)
AddHtmlLocalized(310, 20, 120, 20, 1038019, 0xFFFFFF); // Power
else
AddHtmlLocalized(310, 20, 120, 20, AosSkillBonuses.GetLabel(m_Scroll.Skill), 0xFFFFFF);
}
public override void OnResponse(NetState state, RelayInfo info)
{
if (info.ButtonID == 1)
m_Scroll.Use(m_Mobile);
}
}
}
}

View file

@ -0,0 +1,131 @@
using Server.Mobiles;
namespace Server.Items
{
public class StatCapScroll : SpecialScroll
{
[Constructible]
public StatCapScroll(int value = 105) : base(SkillName.Alchemy, value)
{
Hue = 0x481;
}
public StatCapScroll(Serial serial) : base(serial)
{
}
public override int Message =>
1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window. */
public override int Title
{
get
{
int level = ((int)Value - 230) / 5;
if (level >= 0 && level <= 4 && Value % 5 == 0)
return 1049458 + level; /* Wonderous Scroll (+5 Maximum Stats): OR
* Exalted Scroll (+10 Maximum Stats): OR
* Mythical Scroll (+15 Maximum Stats): OR
* Legendary Scroll (+20 Maximum Stats): OR
* Ultimate Scroll (+25 Maximum Stats): */
return 0;
}
}
public override string DefaultTitle =>
$"<basefont color=#FFFFFF>Power Scroll ({((int)Value - 225 >= 0 ? "+" : "")}{(int)Value - 225} Maximum Stats):</basefont>";
public override void AddNameProperty(ObjectPropertyList list)
{
int level = ((int)Value - 230) / 5;
if (level >= 0 && level <= 4 && (int)Value % 5 == 0)
list.Add(1049463 + level, "#1049476"); /* a wonderous scroll of ~1_type~ (+5 Maximum Stats) OR
* an exalted scroll of ~1_type~ (+10 Maximum Stats) OR
* a mythical scroll of ~1_type~ (+15 Maximum Stats) OR
* a legendary scroll of ~1_type~ (+20 Maximum Stats) OR
* an ultimate scroll of ~1_type~ (+25 Maximum Stats) */
else
list.Add("a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225);
}
public override void OnSingleClick(Mobile from)
{
int level = ((int)Value - 230) / 5;
if (level >= 0 && level <= 4 && (int)Value % 5 == 0)
LabelTo(from, 1049463 + level, "#1049476");
else
LabelTo(from, "a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225);
}
public override bool CanUse(Mobile from)
{
if (!base.CanUse(from))
return false;
int newValue = (int)Value;
if (from is PlayerMobile mobile && mobile.HasStatReward)
newValue += 5;
if (from.StatCap >= newValue)
{
from.SendLocalizedMessage(1049510); // Your stats are too high for this power scroll.
return false;
}
return true;
}
public override void Use(Mobile from)
{
if (!CanUse(from))
return;
from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!
if (from is PlayerMobile mobile && mobile.HasStatReward)
mobile.StatCap = (int)Value + 5;
else
from.StatCap = (int)Value;
Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0, 0, 0, 0,
0, 5060, 0);
Effects.PlaySound(from.Location, from.Map, 0x243);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 4, from.Y - 6, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(from.X - 6, from.Y - 4, from.Z + 15), from.Map),
from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendTargetParticles(from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);
Delete();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion
LootType = LootType.Cursed;
Insured = false;
}
}
}