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,14 @@
using System;
namespace Server.Spells
{
public enum DisturbType
{
Unspecified,
EquipRequest,
UseRequest,
Hurt,
Kill,
NewCast
}
}

View File

@@ -0,0 +1,101 @@
using System;
using Server.Items;
namespace Server.Spells
{
public abstract class MagerySpell : Spell
{
private static readonly int[] m_ManaTable = new int[] { 4, 6, 9, 11, 14, 20, 40, 50 };
private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0;
public MagerySpell(Mobile caster, Item scroll, SpellInfo info)
: base(caster, scroll, info)
{
}
public abstract SpellCircle Circle { get; }
public override TimeSpan CastDelayBase
{
get
{
return TimeSpan.FromMilliseconds(((4 + (int)Circle) * CastDelaySecondsPerTick) * 1000);
}
}
public override bool ConsumeReagents()
{
if (base.ConsumeReagents())
return true;
if (ArcaneGem.ConsumeCharges(Caster, (Core.SE ? 1 : 1 + (int)Circle)))
return true;
return false;
}
public override void GetCastSkills(out double min, out double max)
{
int circle = (int)Circle;
if (Scroll != null)
circle -= 2;
double avg = ChanceLength * circle;
min = avg - ChanceOffset;
max = avg + ChanceOffset;
}
public override int GetMana()
{
if (Scroll is BaseWand)
return 0;
return m_ManaTable[(int)Circle];
}
public virtual bool CheckResisted(Mobile target)
{
double n = GetResistPercent(target);
n /= 100.0;
if (n <= 0.0)
return false;
if (n >= 1.0)
return true;
int maxSkill = (1 + (int)Circle) * 10;
maxSkill += (1 + ((int)Circle / 6)) * 25;
if (target.Skills[SkillName.MagicResist].Value < maxSkill)
target.CheckSkill(SkillName.MagicResist, 0.0, target.Skills[SkillName.MagicResist].Cap);
return (n >= Utility.RandomDouble());
}
public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle)
{
double value = GetResistSkill(target);
double firstPercent = value / 5.0;
double secondPercent = value - (((Caster.Skills[CastSkill].Value - 20.0) / 5.0) + (1 + (int)circle) * 5.0);
return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0; // Seems should be about half of what stratics says.
}
public virtual double GetResistPercent(Mobile target)
{
return GetResistPercentForCircle(target, Circle);
}
public override TimeSpan GetCastDelay()
{
if (!Core.ML && Scroll is BaseWand)
return TimeSpan.Zero;
if (!Core.AOS)
return TimeSpan.FromSeconds(0.5 + (0.25 * (int)Circle));
return base.GetCastDelay();
}
}
}

View File

@@ -0,0 +1,420 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Network;
using Server.Spells.Bushido;
using Server.Spells.Ninjitsu;
using Server.Spells.SkillMasteries;
namespace Server.Spells
{
public abstract class SpecialMove
{
public virtual int BaseMana
{
get
{
return 0;
}
}
public virtual SkillName MoveSkill
{
get
{
return SkillName.Bushido;
}
}
public virtual double RequiredSkill
{
get
{
return 0.0;
}
}
public virtual TextDefinition AbilityMessage
{
get
{
return 0;
}
}
public virtual bool BlockedByAnimalForm
{
get
{
return true;
}
}
public virtual bool DelayedContext
{
get
{
return false;
}
}
public virtual int GetAccuracyBonus(Mobile attacker)
{
return 0;
}
public virtual double GetDamageScalar(Mobile attacker, Mobile defender)
{
return 1.0;
}
// Called before swinging, to make sure the accuracy scalar is to be computed.
public virtual bool OnBeforeSwing(Mobile attacker, Mobile defender)
{
return true;
}
// Called when a hit connects, but before damage is calculated.
public virtual bool OnBeforeDamage(Mobile attacker, Mobile defender)
{
return true;
}
// Called as soon as the ability is used.
public virtual void OnUse(Mobile from)
{
}
// Called when a hit connects, at the end of the weapon.OnHit() method.
public virtual void OnHit(Mobile attacker, Mobile defender, int damage)
{
}
// Called when a hit misses.
public virtual void OnMiss(Mobile attacker, Mobile defender)
{
}
// Called when the move is cleared.
public virtual void OnClearMove(Mobile from)
{
}
public virtual void SendAbilityMessage(Mobile m)
{
TextDefinition.SendMessageTo(m, AbilityMessage);
}
public virtual bool IgnoreArmor(Mobile attacker)
{
return false;
}
public virtual double GetPropertyBonus(Mobile attacker)
{
return 1.0;
}
public virtual bool CheckSkills(Mobile m)
{
if (m.Skills[this.MoveSkill].Value < this.RequiredSkill)
{
string args = String.Format("{0}\t{1}\t ", this.RequiredSkill.ToString("F1"), this.MoveSkill.ToString());
m.SendLocalizedMessage(1063013, args); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
return false;
}
return true;
}
public virtual int ScaleMana(Mobile m, int mana)
{
double scalar = 1.0;
if (ManaPhasingOrb.IsInManaPhase(m))
{
ManaPhasingOrb.RemoveFromTable(m);
return 0;
}
if (!Server.Spells.Necromancy.MindRotSpell.GetMindRotScalar(m, ref scalar))
{
scalar = 1.0;
}
if (Server.Spells.Mysticism.PurgeMagicSpell.IsUnderCurseEffects(m))
{
scalar += .5;
}
// Lower Mana Cost = 40%
int lmc = Math.Min(AosAttributes.GetValue(m, AosAttribute.LowerManaCost), 40);
lmc += BaseArmor.GetInherentLowerManaCost(m);
scalar -= (double)lmc / 100;
int total = (int)(mana * scalar);
if (m.Skills[this.MoveSkill].Value < 50.0 && GetContext(m) != null)
total *= 2;
return total;
}
public virtual bool CheckMana(Mobile from, bool consume)
{
int mana = this.ScaleMana(from, this.BaseMana);
if (from.Mana < mana)
{
from.SendLocalizedMessage(1060181, mana.ToString()); // You need ~1_MANA_REQUIREMENT~ mana to perform that attack
return false;
}
if (consume)
{
if (!this.DelayedContext)
this.SetContext(from);
from.Mana -= mana;
}
return true;
}
public virtual void SetContext(Mobile from)
{
if (GetContext(from) == null)
{
if (this.DelayedContext || from.Skills[this.MoveSkill].Value < 50.0)
{
Timer timer = new SpecialMoveTimer(from);
timer.Start();
AddContext(from, new SpecialMoveContext(timer, this.GetType()));
}
}
}
public virtual bool Validate(Mobile from)
{
if (!from.Player)
return true;
if (Bushido.HonorableExecution.IsUnderPenalty(from))
{
from.SendLocalizedMessage(1063024); // You cannot perform this special move right now.
return false;
}
if (Ninjitsu.AnimalForm.UnderTransformation(from))
{
from.SendLocalizedMessage(1063024); // You cannot perform this special move right now.
return false;
}
return this.CheckSkills(from) && this.CheckMana(from, false);
}
public virtual void CheckGain(Mobile m)
{
m.CheckSkill(this.MoveSkill, this.RequiredSkill, this.RequiredSkill + 37.5);
}
private static readonly Dictionary<Mobile, SpecialMove> m_Table = new Dictionary<Mobile, SpecialMove>();
public static Dictionary<Mobile, SpecialMove> Table
{
get
{
return m_Table;
}
}
public static void ClearAllMoves(Mobile m)
{
foreach (KeyValuePair<Int32, SpecialMove> kvp in SpellRegistry.SpecialMoves)
{
int moveID = kvp.Key;
if (moveID != -1)
m.Send(new ToggleSpecialAbility(moveID + 1, false));
}
}
public virtual bool ValidatesDuringHit
{
get
{
return true;
}
}
public static SpecialMove GetCurrentMove(Mobile m)
{
if (m == null)
return null;
if (!Core.SE)
{
ClearCurrentMove(m);
return null;
}
SpecialMove move = null;
m_Table.TryGetValue(m, out move);
if (move != null && move.ValidatesDuringHit && !move.Validate(m))
{
ClearCurrentMove(m);
return null;
}
return move;
}
public static bool SetCurrentMove(Mobile m, SpecialMove move)
{
if (!Core.SE)
{
ClearCurrentMove(m);
return false;
}
if (move != null && !move.Validate(m))
{
ClearCurrentMove(m);
return false;
}
bool sameMove = (move == GetCurrentMove(m));
ClearCurrentMove(m);
if (sameMove)
return true;
if (move != null)
{
WeaponAbility.ClearCurrentAbility(m);
m_Table[m] = move;
move.OnUse(m);
int moveID = SpellRegistry.GetRegistryNumber(move);
if (moveID > 0)
m.Send(new ToggleSpecialAbility(moveID + 1, true));
move.SendAbilityMessage(m);
SkillMasterySpell.CancelSpecialMove(m);
}
return true;
}
public static void ClearCurrentMove(Mobile m)
{
SpecialMove move = null;
m_Table.TryGetValue(m, out move);
if (move != null)
{
move.OnClearMove(m);
int moveID = SpellRegistry.GetRegistryNumber(move);
if (moveID > 0)
m.Send(new ToggleSpecialAbility(moveID + 1, false));
}
m_Table.Remove(m);
}
public SpecialMove()
{
}
private static readonly Dictionary<Mobile, SpecialMoveContext> m_PlayersTable = new Dictionary<Mobile, SpecialMoveContext>();
private static void AddContext(Mobile m, SpecialMoveContext context)
{
m_PlayersTable[m] = context;
}
private static void RemoveContext(Mobile m)
{
SpecialMoveContext context = GetContext(m);
if (context != null)
{
m_PlayersTable.Remove(m);
context.Timer.Stop();
}
}
private static SpecialMoveContext GetContext(Mobile m)
{
return (m_PlayersTable.ContainsKey(m) ? m_PlayersTable[m] : null);
}
public static bool GetContext(Mobile m, Type type)
{
SpecialMoveContext context = null;
m_PlayersTable.TryGetValue(m, out context);
if (context == null)
return false;
return (context.Type == type);
}
private class SpecialMoveTimer : Timer
{
private readonly Mobile m_Mobile;
public SpecialMoveTimer(Mobile from)
: base(TimeSpan.FromSeconds(3.0))
{
this.m_Mobile = from;
this.Priority = TimerPriority.TwentyFiveMS;
}
protected override void OnTick()
{
RemoveContext(this.m_Mobile);
}
}
public class SpecialMoveContext
{
private readonly Timer m_Timer;
private readonly Type m_Type;
public Timer Timer
{
get
{
return this.m_Timer;
}
}
public Type Type
{
get
{
return this.m_Type;
}
}
public SpecialMoveContext(Timer timer, Type type)
{
this.m_Timer = timer;
this.m_Type = type;
}
}
}
}

1401
Scripts/Spells/Base/Spell.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
using System;
namespace Server.Spells
{
public enum SpellCircle
{
First,
Second,
Third,
Fourth,
Fifth,
Sixth,
Seventh,
Eighth
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
using System;
namespace Server.Spells
{
public class SpellInfo
{
private string m_Name;
private string m_Mantra;
private Type[] m_Reagents;
private int[] m_Amounts;
private int m_Action;
private bool m_AllowTown;
private int m_LeftHandEffect, m_RightHandEffect;
public SpellInfo(string name, string mantra, params Type[] regs)
: this(name, mantra, 16, 0, 0, true, regs)
{
}
public SpellInfo(string name, string mantra, bool allowTown, params Type[] regs)
: this(name, mantra, 16, 0, 0, allowTown, regs)
{
}
public SpellInfo(string name, string mantra, int action, params Type[] regs)
: this(name, mantra, action, 0, 0, true, regs)
{
}
public SpellInfo(string name, string mantra, int action, bool allowTown, params Type[] regs)
: this(name, mantra, action, 0, 0, allowTown, regs)
{
}
public SpellInfo(string name, string mantra, int action, int handEffect, params Type[] regs)
: this(name, mantra, action, handEffect, handEffect, true, regs)
{
}
public SpellInfo(string name, string mantra, int action, int handEffect, bool allowTown, params Type[] regs)
: this(name, mantra, action, handEffect, handEffect, allowTown, regs)
{
}
public SpellInfo(string name, string mantra, int action, int leftHandEffect, int rightHandEffect, bool allowTown, params Type[] regs)
{
this.m_Name = name;
this.m_Mantra = mantra;
this.m_Action = action;
this.m_Reagents = regs;
this.m_AllowTown = allowTown;
this.m_LeftHandEffect = leftHandEffect;
this.m_RightHandEffect = rightHandEffect;
this.m_Amounts = new int[regs.Length];
for (int i = 0; i < regs.Length; ++i)
this.m_Amounts[i] = 1;
}
public int Action
{
get
{
return this.m_Action;
}
set
{
this.m_Action = value;
}
}
public bool AllowTown
{
get
{
return this.m_AllowTown;
}
set
{
this.m_AllowTown = value;
}
}
public int[] Amounts
{
get
{
return this.m_Amounts;
}
set
{
this.m_Amounts = value;
}
}
public string Mantra
{
get
{
return this.m_Mantra;
}
set
{
this.m_Mantra = value;
}
}
public string Name
{
get
{
return this.m_Name;
}
set
{
this.m_Name = value;
}
}
public Type[] Reagents
{
get
{
return this.m_Reagents;
}
set
{
this.m_Reagents = value;
}
}
public int LeftHandEffect
{
get
{
return this.m_LeftHandEffect;
}
set
{
this.m_LeftHandEffect = value;
}
}
public int RightHandEffect
{
get
{
return this.m_RightHandEffect;
}
set
{
this.m_RightHandEffect = value;
}
}
}
}

View File

@@ -0,0 +1,183 @@
using System;
using System.Collections.Generic;
namespace Server.Spells
{
public class SpellRegistry
{
private static readonly Type[] m_Types = new Type[745];
private static int m_Count;
public static Type[] Types
{
get
{
m_Count = -1;
return m_Types;
}
}
//What IS this used for anyways.
public static int Count
{
get
{
if (m_Count == -1)
{
m_Count = 0;
for (int i = 0; i < m_Types.Length; ++i)
if (m_Types[i] != null)
++m_Count;
}
return m_Count;
}
}
private static readonly Dictionary<Type, Int32> m_IDsFromTypes = new Dictionary<Type, Int32>(m_Types.Length);
private static readonly Dictionary<Int32, SpecialMove> m_SpecialMoves = new Dictionary<Int32, SpecialMove>();
public static Dictionary<Int32, SpecialMove> SpecialMoves
{
get
{
return m_SpecialMoves;
}
}
public static int GetRegistryNumber(ISpell s)
{
return GetRegistryNumber(s.GetType());
}
public static int GetRegistryNumber(SpecialMove s)
{
return GetRegistryNumber(s.GetType());
}
public static int GetRegistryNumber(Type type)
{
if (m_IDsFromTypes.ContainsKey(type))
return m_IDsFromTypes[type];
return -1;
}
public static void Register(int spellID, Type type)
{
if (spellID < 0 || spellID >= m_Types.Length)
return;
if (m_Types[spellID] == null)
++m_Count;
m_Types[spellID] = type;
if (!m_IDsFromTypes.ContainsKey(type))
m_IDsFromTypes.Add(type, spellID);
if (type.IsSubclassOf(typeof(SpecialMove)))
{
SpecialMove spm = null;
try
{
spm = Activator.CreateInstance(type) as SpecialMove;
}
catch
{
}
if (spm != null)
m_SpecialMoves.Add(spellID, spm);
}
}
public static SpecialMove GetSpecialMove(int spellID)
{
if (spellID < 0 || spellID >= m_Types.Length)
return null;
Type t = m_Types[spellID];
if (t == null || !t.IsSubclassOf(typeof(SpecialMove)) || !m_SpecialMoves.ContainsKey(spellID))
return null;
return m_SpecialMoves[spellID];
}
private static readonly object[] m_Params = new object[2];
public static Spell NewSpell(int spellID, Mobile caster, Item scroll)
{
if (spellID < 0 || spellID >= m_Types.Length)
return null;
Type t = m_Types[spellID];
if (t != null && !t.IsSubclassOf(typeof(SpecialMove)))
{
m_Params[0] = caster;
m_Params[1] = scroll;
try
{
return (Spell)Activator.CreateInstance(t, m_Params);
}
catch
{
}
}
return null;
}
private static readonly string[] m_CircleNames = new string[]
{
"First",
"Second",
"Third",
"Fourth",
"Fifth",
"Sixth",
"Seventh",
"Eighth",
"Necromancy",
"Chivalry",
"Bushido",
"Ninjitsu",
"Spellweaving",
#region Stygian Abyss
"Mystic",
#endregion
#region TOL
"SkillMasteries"
#endregion
};
public static Spell NewSpell(string name, Mobile caster, Item scroll)
{
for (int i = 0; i < m_CircleNames.Length; ++i)
{
Type t = ScriptCompiler.FindTypeByFullName(String.Format("Server.Spells.{0}.{1}", m_CircleNames[i], name));
if (t != null && !t.IsSubclassOf(typeof(SpecialMove)))
{
m_Params[0] = caster;
m_Params[1] = scroll;
try
{
return (Spell)Activator.CreateInstance(t, m_Params);
}
catch
{
}
}
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
namespace Server.Spells
{
public enum SpellState
{
None = 0,
Casting = 1, // We are in the process of casting (that is, waiting GetCastTime() and doing animations). Spell casting may be interupted in this state.
Sequencing = 2 // Casting completed, but the full spell sequence isn't. Usually waiting for a target response. Some actions are restricted in this state (using skills for example).
}
}