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,144 @@
using System;
using System.Collections.Generic;
namespace Server.Spells.Bushido
{
public class Confidence : SamuraiSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Confidence", null,
-1,
9002
);
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
private static Dictionary<Mobile, Timer> m_RegenTable = new Dictionary<Mobile, Timer>();
public Confidence(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
}
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.25);
public override double RequiredSkill => 25.0;
public override int RequiredMana => 10;
public override void OnBeginCast()
{
base.OnBeginCast();
Caster.FixedEffect(0x37C4, 10, 7, 4, 3);
}
public override void OnCast()
{
if (CheckSequence())
{
Caster.SendLocalizedMessage(1063115); // You exude confidence.
Caster.FixedParticles(0x375A, 1, 17, 0x7DA, 0x960, 0x3, EffectLayer.Waist);
Caster.PlaySound(0x51A);
OnCastSuccessful(Caster);
BeginConfidence(Caster);
BeginRegenerating(Caster);
}
FinishSequence();
}
public static bool IsConfident(Mobile m)
{
return m_Table.ContainsKey(m);
}
public static void BeginConfidence(Mobile m)
{
m_Table.TryGetValue(m, out Timer timer);
timer?.Stop();
m_Table[m] = timer = new InternalTimer(m);
timer.Start();
}
public static void EndConfidence(Mobile m)
{
if (m_Table.TryGetValue(m, out Timer timer))
{
timer.Stop();
m_Table.Remove(m);
}
OnEffectEnd(m, typeof(Confidence));
}
public static bool IsRegenerating(Mobile m)
{
return m_RegenTable.ContainsKey(m);
}
public static void BeginRegenerating(Mobile m)
{
m_RegenTable.TryGetValue(m, out Timer timer);
timer?.Stop();
m_RegenTable[m] = timer = new RegenTimer(m);
timer.Start();
}
public static void StopRegenerating(Mobile m)
{
if (m_RegenTable.TryGetValue(m, out Timer timer))
{
timer.Stop();
m_RegenTable.Remove(m);
}
}
private class InternalTimer : Timer
{
private Mobile m_Mobile;
public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(15.0))
{
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
EndConfidence(m_Mobile);
m_Mobile.SendLocalizedMessage(1063116); // Your confidence wanes.
}
}
private class RegenTimer : Timer
{
private int m_Hits;
private Mobile m_Mobile;
private int m_Ticks;
public RegenTimer(Mobile m) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
{
m_Mobile = m;
m_Hits = 15 + m.Skills.Bushido.Fixed * m.Skills.Bushido.Fixed / 57600;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
++m_Ticks;
if (m_Ticks >= 5)
{
m_Mobile.Hits += m_Hits - m_Hits * 4 / 5;
StopRegenerating(m_Mobile);
}
m_Mobile.Hits += m_Hits / 5;
}
}
}
}

View file

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using Server.Items;
namespace Server.Spells.Bushido
{
public class CounterAttack : SamuraiSpell
{
private static SpellInfo m_Info = new SpellInfo(
"CounterAttack", null,
-1,
9002
);
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
public CounterAttack(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
{
}
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.25);
public override double RequiredSkill => 40.0;
public override int RequiredMana => 5;
public override bool CheckCast()
{
if (!base.CheckCast())
return false;
if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)
return true;
if (Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon)
return true;
if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon)
return true;
Caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability!
return false;
}
public override void OnBeginCast()
{
base.OnBeginCast();
Caster.FixedEffect(0x37C4, 10, 7, 4, 3);
}
public override void OnCast()
{
if (CheckSequence())
{
Caster.SendLocalizedMessage(1063118); // You prepare to respond immediately to the next blocked blow.
OnCastSuccessful(Caster);
StartCountering(Caster);
}
FinishSequence();
}
public static bool IsCountering(Mobile m)
{
return m_Table.ContainsKey(m);
}
public static void StartCountering(Mobile m)
{
m_Table.TryGetValue(m, out Timer timer);
timer?.Stop();
m_Table[m] = timer = new InternalTimer(m);
timer.Start();
}
public static void StopCountering(Mobile m)
{
if (m_Table.TryGetValue(m, out Timer timer))
{
timer.Stop();
m_Table.Remove(m);
}
OnEffectEnd(m, typeof(CounterAttack));
}
private class InternalTimer : Timer
{
private Mobile m_Mobile;
public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(30.0))
{
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
StopCountering(m_Mobile);
m_Mobile.SendLocalizedMessage(1063119); // You return to your normal stance.
}
}
}
}

View file

@ -0,0 +1,215 @@
using System;
using System.Collections.Generic;
using Server.Items;
namespace Server.Spells.Bushido
{
public class Evasion : SamuraiSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Evasion", null,
-1,
9002
);
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
public Evasion(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)
{
}
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.25);
public override double RequiredSkill => 60.0;
public override int RequiredMana => 10;
public override bool CheckCast()
{
return VerifyCast(Caster, true) && base.CheckCast();
}
public static bool VerifyCast(Mobile Caster, bool messages)
{
if (Caster == null) // Sanity
return false;
if (!(Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap))
weap = Caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
if (weap != null)
{
if (Core.ML && Caster.Skills[weap.Skill].Base < 50)
{
if (messages)
Caster.SendLocalizedMessage(
1076206); // Your skill with your equipped weapon must be 50 or higher to use Evasion.
return false;
}
}
else if (!(Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield))
{
if (messages)
Caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability!
return false;
}
if (!Caster.CanBeginAction<Evasion>())
{
if (messages) Caster.SendLocalizedMessage(501789); // You must wait before trying again.
return false;
}
return true;
}
public static bool CheckSpellEvasion(Mobile defender)
{
if (!(defender.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap))
weap = defender.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
if (Core.ML)
{
if (defender.Spell != null && defender.Spell.IsCasting) return false;
if (weap != null)
{
if (defender.Skills[weap.Skill].Base < 50) return false;
}
else if (!(defender.FindItemOnLayer(Layer.TwoHanded) is BaseShield))
{
return false;
}
}
if (IsEvading(defender) && BaseWeapon.CheckParry(defender))
{
defender.Emote("*evades*"); // Yes. Eew. Blame OSI.
defender.FixedEffect(0x37B9, 10, 16);
return true;
}
return false;
}
public override void OnBeginCast()
{
base.OnBeginCast();
Caster.FixedEffect(0x37C4, 10, 7, 4, 3);
}
public override void OnCast()
{
if (CheckSequence())
{
Caster.SendLocalizedMessage(1063120); // You feel that you might be able to deflect any attack!
Caster.FixedParticles(0x376A, 1, 20, 0x7F5, 0x960, 3, EffectLayer.Waist);
Caster.PlaySound(0x51B);
OnCastSuccessful(Caster);
BeginEvasion(Caster);
Caster.BeginAction<Evasion>();
Timer.DelayCall(TimeSpan.FromSeconds(20.0), delegate { Caster.EndAction<Evasion>(); });
}
FinishSequence();
}
public static bool IsEvading(Mobile m)
{
return m_Table.ContainsKey(m);
}
public static TimeSpan GetEvadeDuration(Mobile m)
{
/* Evasion duration now scales with Bushido skill
*
* If the player has higher than GM Bushido, and GM Tactics and Anatomy, they get a 1 second bonus
* Evasion duration range:
* o 3-6 seconds w/o tactics/anatomy
* o 6-7 seconds w/ GM+ Bushido and GM tactics/anatomy
*/
if (!Core.ML)
return TimeSpan.FromSeconds(8.0);
double seconds = 3;
if (m.Skills.Bushido.Value > 60)
seconds += (m.Skills.Bushido.Value - 60) / 20;
if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0
) //Bushido being HIGHER than 100 for bonus is intended
seconds++;
return TimeSpan.FromSeconds((int)seconds);
}
public static double GetParryScalar(Mobile m)
{
/* Evasion modifier to parry now scales with Bushido skill
*
* If the player has higher than GM Bushido, and at least GM Tactics and Anatomy, they get a bonus to their evasion modifier (10% bonus to the evasion modifier to parry NOT 10% to the final parry chance)
*
* Bonus modifier to parry range: (these are the ranges for the evasion modifier)
* o 16-40% bonus w/o tactics/anatomy
* o 42-50% bonus w/ GM+ bushido and GM tactics/anatomy
*/
if (!Core.ML)
return 1.5;
double bonus = 0;
if (m.Skills.Bushido.Value >= 60)
bonus += (m.Skills.Bushido.Value - 60) * .004 + 0.16;
if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100
) //Bushido being HIGHER than 100 for bonus is intended
bonus += 0.10;
return 1.0 + bonus;
}
public static void BeginEvasion(Mobile m)
{
m_Table.TryGetValue(m, out Timer timer);
timer?.Stop();
m_Table[m] = timer = new InternalTimer(m, GetEvadeDuration(m));
timer.Start();
}
public static void EndEvasion(Mobile m)
{
if (m_Table.TryGetValue(m, out Timer timer))
{
timer.Stop();
m_Table.Remove(m);
}
OnEffectEnd(m, typeof(Evasion));
}
private class InternalTimer : Timer
{
private Mobile m_Mobile;
public InternalTimer(Mobile m, TimeSpan delay)
: base(delay)
{
m_Mobile = m;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
EndEvasion(m_Mobile);
m_Mobile.SendLocalizedMessage(1063121); // You no longer feel that you could deflect any attack.
}
}
}
}

View file

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
namespace Server.Spells.Bushido
{
public class HonorableExecution : SamuraiMove
{
private static Dictionary<Mobile, HonorableExecutionInfo> m_Table = new Dictionary<Mobile, HonorableExecutionInfo>();
public override int BaseMana => 0;
public override double RequiredSkill => 25.0;
public override TextDefinition AbilityMessage =>
new TextDefinition(1063122); // You better kill your enemy with your next hit or you'll be rather sorry...
public override double GetDamageScalar(Mobile attacker, Mobile defender)
{
double bushido = attacker.Skills.Bushido.Value;
// TODO: 20 -> Perfection
return 1.0 + bushido * 20 / 10000;
}
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
if (!Validate(attacker) || !CheckMana(attacker, true))
return;
ClearCurrentMove(attacker);
if (m_Table.TryGetValue(attacker, out HonorableExecutionInfo info))
{
info.Clear();
info.m_Timer?.Stop();
}
if (!defender.Alive)
{
attacker.FixedParticles(0x373A, 1, 17, 0x7E2, EffectLayer.Waist);
double bushido = attacker.Skills.Bushido.Value;
attacker.Hits += 20 + (int)(bushido * bushido / 480.0);
int swingBonus = Math.Max(1, (int)(bushido * bushido / 720.0));
info = new HonorableExecutionInfo(attacker, swingBonus);
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(20.0), RemovePenalty, info.m_Mobile);
m_Table[attacker] = info;
}
else
{
List<object> mods = new List<object>
{
new ResistanceMod(ResistanceType.Physical, -40),
new ResistanceMod(ResistanceType.Fire, -40),
new ResistanceMod(ResistanceType.Cold, -40),
new ResistanceMod(ResistanceType.Poison, -40),
new ResistanceMod(ResistanceType.Energy, -40)
};
double resSpells = attacker.Skills.MagicResist.Value;
if (resSpells > 0.0)
mods.Add(new DefaultSkillMod(SkillName.MagicResist, true, -resSpells));
info = new HonorableExecutionInfo(attacker, mods);
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(7.0), RemovePenalty, info.m_Mobile);
m_Table[attacker] = info;
}
CheckGain(attacker);
}
public static int GetSwingBonus(Mobile target)
{
return m_Table.TryGetValue(target, out HonorableExecutionInfo info) ? info.m_SwingBonus : 0;
}
public static bool IsUnderPenalty(Mobile target)
{
return m_Table.TryGetValue(target, out HonorableExecutionInfo info) && info.m_Penalty;
}
public static void RemovePenalty(Mobile target)
{
if (!m_Table.TryGetValue(target, out HonorableExecutionInfo info) || !info.m_Penalty)
return;
info.Clear();
info.m_Timer?.Stop();
m_Table.Remove(target);
}
private class HonorableExecutionInfo
{
public Mobile m_Mobile;
public List<object> m_Mods;
public bool m_Penalty;
public int m_SwingBonus;
public Timer m_Timer;
public HonorableExecutionInfo(Mobile from, List<object> mods) : this(from, 0, mods, mods != null)
{
}
public HonorableExecutionInfo(Mobile from, int swingBonus, List<object> mods = null, bool penalty = false)
{
m_Mobile = from;
m_SwingBonus = swingBonus;
m_Mods = mods;
m_Penalty = penalty;
Apply();
}
public void Apply()
{
if (m_Mods == null)
return;
for (int i = 0; i < m_Mods.Count; ++i)
{
object mod = m_Mods[i];
if (mod is ResistanceMod resistanceMod)
m_Mobile.AddResistanceMod(resistanceMod);
else if (mod is SkillMod skillMod)
m_Mobile.AddSkillMod(skillMod);
}
}
public void Clear()
{
if (m_Mods == null)
return;
for (int i = 0; i < m_Mods.Count; ++i)
{
object mod = m_Mods[i];
if (mod is ResistanceMod resistanceMod)
m_Mobile.RemoveResistanceMod(resistanceMod);
else if (mod is SkillMod skillMod)
m_Mobile.RemoveSkillMod(skillMod);
}
}
}
}
}

View file

@ -0,0 +1,69 @@
using Server.Mobiles;
namespace Server.Spells.Bushido
{
public class LightningStrike : SamuraiMove
{
public override int BaseMana => 5;
public override double RequiredSkill => 50.0;
public override TextDefinition AbilityMessage => new TextDefinition(1063167); // You prepare to strike quickly.
public override bool DelayedContext => true;
public override bool ValidatesDuringHit => false;
public override int GetAccuracyBonus(Mobile attacker)
{
return 50;
}
public override bool Validate(Mobile from)
{
bool isValid = base.Validate(from);
if (isValid)
{
PlayerMobile ThePlayer = from as PlayerMobile;
ThePlayer.ExecutesLightningStrike = BaseMana;
}
return isValid;
}
public override bool IgnoreArmor(Mobile attacker)
{
double bushido = attacker.Skills.Bushido.Value;
double criticalChance = bushido * bushido / 72000.0;
return criticalChance >= Utility.RandomDouble();
}
public override bool OnBeforeSwing(Mobile attacker, Mobile defender)
{
/* no mana drain before actual hit */
bool enoughMana = CheckMana(attacker, false);
return Validate(attacker);
}
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
ClearCurrentMove(attacker);
if (CheckMana(attacker, true))
{
attacker.SendLocalizedMessage(1063168); // You attack with lightning precision!
defender.SendLocalizedMessage(1063169); // Your opponent's quick strike causes extra damage!
defender.FixedParticles(0x3818, 1, 11, 0x13A8, 0, 0, EffectLayer.Waist);
defender.PlaySound(0x51D);
CheckGain(attacker);
SetContext(attacker);
}
}
public override void OnClearMove(Mobile attacker)
{
PlayerMobile
ThePlayer =
attacker as PlayerMobile; // this can be deletet if the PlayerMobile parts are moved to Server.Mobile
ThePlayer.ExecutesLightningStrike = 0;
}
}
}

View file

@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Linq;
using Server.Items;
namespace Server.Spells.Bushido
{
public class MomentumStrike : SamuraiMove
{
public override int BaseMana => 10;
public override double RequiredSkill => 70.0;
public override TextDefinition AbilityMessage =>
new TextDefinition(1070757); // You prepare to strike two enemies with one blow.
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
if (!Validate(attacker) || !CheckMana(attacker, false))
return;
ClearCurrentMove(attacker);
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
List<Mobile> targets = attacker.GetMobilesInRange(weapon.MaxRange)
.Where(m => m != defender).Where(m => m.Combatant == attacker).ToList();
if (targets.Count <= 0)
{
attacker.SendLocalizedMessage(1063123); // There are no valid targets to attack!
return;
}
if (!CheckMana(attacker, true))
return;
Mobile target = targets[Utility.Random(targets.Count)];
double damageBonus = attacker.Skills.Bushido.Value / 100.0;
if (!defender.Alive)
damageBonus *= 1.5;
attacker.SendLocalizedMessage(1063171); // You transfer the momentum of your weapon into another enemy!
target.SendLocalizedMessage(1063172); // You were hit by the momentum of a Samurai's weapon!
target.FixedParticles(0x37B9, 1, 4, 0x251D, 0, 0, EffectLayer.Waist);
attacker.PlaySound(0x510);
weapon.OnSwing(attacker, target, damageBonus);
CheckGain(attacker);
}
public override void CheckGain(Mobile m)
{
m.CheckSkill(MoveSkill, RequiredSkill, 120.0);
}
}
}

View file

@ -0,0 +1,12 @@
namespace Server.Spells
{
public class SamuraiMove : SpecialMove
{
public override SkillName MoveSkill => SkillName.Bushido;
public override void CheckGain(Mobile m)
{
m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); //Per five on friday 02/16/07
}
}
}

View file

@ -0,0 +1,126 @@
using System;
using Server.Mobiles;
using Server.Network;
namespace Server.Spells.Bushido
{
public abstract class SamuraiSpell : Spell
{
public SamuraiSpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
{
}
public abstract double RequiredSkill{ get; }
public abstract int RequiredMana{ get; }
public override SkillName CastSkill => SkillName.Bushido;
public override SkillName DamageSkill => SkillName.Bushido;
public override bool ClearHandsOnCast => false;
public override bool BlocksMovement => false;
public override bool ShowHandMovement => false;
//public override int CastDelayBase => 1;
public override double CastDelayFastScalar => 0;
public override int CastRecoveryBase => 7;
public static bool CheckExpansion(Mobile from)
{
return (from as PlayerMobile)?.NetState?.SupportsExpansion(Expansion.SE) == true;
}
public override bool CheckCast()
{
int mana = ScaleMana(RequiredMana);
if (!base.CheckCast())
return false;
if (!CheckExpansion(Caster))
{
Caster.SendLocalizedMessage(1063456); // You must upgrade to Samurai Empire in order to use that ability.
return false;
}
if (Caster.Skills[CastSkill].Value < RequiredSkill)
{
string args = $"{RequiredSkill.ToString("F1")}\t{CastSkill.ToString()}\t ";
Caster.SendLocalizedMessage(1063013,
args); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
return false;
}
if (Caster.Mana < mana)
{
Caster.SendLocalizedMessage(1060174,
mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
return false;
}
return true;
}
public override bool CheckFizzle()
{
int mana = ScaleMana(RequiredMana);
if (Caster.Skills[CastSkill].Value < RequiredSkill)
{
Caster.SendLocalizedMessage(1070768,
RequiredSkill.ToString("F1")); // You need ~1_SKILL_REQUIREMENT~ Bushido skill to perform that attack!
return false;
}
if (Caster.Mana < mana)
{
Caster.SendLocalizedMessage(1060174,
mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
return false;
}
if (!base.CheckFizzle())
return false;
Caster.Mana -= mana;
return true;
}
public override void GetCastSkills(out double min, out double max)
{
min = RequiredSkill - 12.5; //per 5 on friday, 2/16/07
max = RequiredSkill + 37.5;
}
public override int GetMana()
{
return 0;
}
public virtual void OnCastSuccessful(Mobile caster)
{
if (Evasion.IsEvading(caster))
Evasion.EndEvasion(caster);
if (Confidence.IsConfident(caster))
Confidence.EndConfidence(caster);
if (CounterAttack.IsCountering(caster))
CounterAttack.StopCountering(caster);
int spellID = SpellRegistry.GetRegistryNumber(this);
if (spellID > 0)
caster.Send(new ToggleSpecialAbility(spellID + 1, true));
}
public static void OnEffectEnd(Mobile caster, Type type)
{
int spellID = SpellRegistry.GetRegistryNumber(type);
if (spellID > 0)
caster.Send(new ToggleSpecialAbility(spellID + 1, false));
}
}
}