Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
616
Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs
Normal file
616
Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs
Normal file
|
|
@ -0,0 +1,616 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Spells.Fifth;
|
||||
using Server.Spells.Seventh;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class AnimalForm : NinjaSpell
|
||||
{
|
||||
public enum MorphResult
|
||||
{
|
||||
Success,
|
||||
Fail,
|
||||
NoSkill
|
||||
}
|
||||
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Animal Form", null,
|
||||
-1,
|
||||
9002
|
||||
);
|
||||
|
||||
private static Dictionary<Mobile, int> m_LastAnimalForms = new Dictionary<Mobile, int>();
|
||||
private static Dictionary<Mobile, AnimalFormContext> m_Table = new Dictionary<Mobile, AnimalFormContext>();
|
||||
|
||||
private bool m_WasMoving;
|
||||
|
||||
public AnimalForm(Mobile caster, Item scroll)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.0);
|
||||
|
||||
public override double RequiredSkill => 0.0;
|
||||
public override int RequiredMana => Core.ML ? 10 : 0;
|
||||
public override int CastRecoveryBase => Core.ML ? 10 : base.CastRecoveryBase;
|
||||
|
||||
public override bool BlockedByAnimalForm => false;
|
||||
|
||||
public static AnimalFormEntry[] Entries{ get; } =
|
||||
{
|
||||
new AnimalFormEntry(typeof(Kirin), 1029632, 9632, 0, 1070811, 100.0, 0x84, 0, 0),
|
||||
new AnimalFormEntry(typeof(Unicorn), 1018214, 9678, 0, 1070812, 100.0, 0x7A, 0, 0),
|
||||
new AnimalFormEntry(typeof(BakeKitsune), 1030083, 10083, 0, 1070810, 82.5, 0xF6, 0, 0),
|
||||
new AnimalFormEntry(typeof(GreyWolf), 1028482, 9681, 2309, 1070810, 82.5, 0x19, 0x8FD, 0x90E),
|
||||
new AnimalFormEntry(typeof(Llama), 1028438, 8438, 0, 1070809, 70.0, 0xDC, 0, 0),
|
||||
new AnimalFormEntry(typeof(ForestOstard), 1018273, 8503, 2212, 1070809, 70.0, 0xDB, 0x899, 0x8B0),
|
||||
new AnimalFormEntry(typeof(BullFrog), 1028496, 8496, 2003, 1070807, 50.0, 0x51, 0x7D1, 0x7D6, false, false),
|
||||
new AnimalFormEntry(typeof(GiantSerpent), 1018114, 9663, 2009, 1070808, 50.0, 0x15, 0x7D1, 0x7E2, false, false),
|
||||
new AnimalFormEntry(typeof(Dog), 1018280, 8476, 2309, 1070806, 40.0, 0xD9, 0x8FD, 0x90E, false, false),
|
||||
new AnimalFormEntry(typeof(Cat), 1018264, 8475, 2309, 1070806, 40.0, 0xC9, 0x8FD, 0x90E, false, false),
|
||||
new AnimalFormEntry(typeof(Rat), 1018294, 8483, 2309, 1070805, 20.0, 0xEE, 0x8FD, 0x90E, true, false),
|
||||
new AnimalFormEntry(typeof(Rabbit), 1028485, 8485, 2309, 1070805, 20.0, 0xCD, 0x8FD, 0x90E, true, false),
|
||||
new AnimalFormEntry(typeof(Squirrel), 1031671, 11671, 0, 0, 20.0, 0x116, 0, 0, false, false),
|
||||
new AnimalFormEntry(typeof(Ferret), 1031672, 11672, 0, 1075220, 40.0, 0x117, 0, 0, false, false, true),
|
||||
new AnimalFormEntry(typeof(CuSidhe), 1031670, 11670, 0, 1075221, 60.0, 0x115, 0, 0, false, false),
|
||||
new AnimalFormEntry(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false)
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Login += OnLogin;
|
||||
}
|
||||
|
||||
public static void OnLogin(LoginEventArgs e)
|
||||
{
|
||||
if (GetContext(e.Mobile)?.SpeedBoost == true)
|
||||
e.Mobile.Send(SpeedControl.MountSpeed);
|
||||
}
|
||||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
if (!Caster.CanBeginAction<PolymorphSpell>())
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TransformationSpellHelper.UnderTransformation(Caster))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063219); // You cannot mimic an animal while in that form.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DisguiseTimers.IsDisguised(Caster))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061631); // You can't do that while disguised.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckCast();
|
||||
}
|
||||
|
||||
public override bool CheckDisturb(DisturbType type, bool firstCircle, bool resistable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CasterIsMoving()
|
||||
{
|
||||
return Core.TickCount - Caster.LastMoveTime <= Caster.ComputeMovementSpeed(Caster.Direction);
|
||||
}
|
||||
|
||||
public override void OnBeginCast()
|
||||
{
|
||||
base.OnBeginCast();
|
||||
|
||||
Caster.FixedEffect(0x37C4, 10, 14, 4, 3);
|
||||
m_WasMoving = CasterIsMoving();
|
||||
}
|
||||
|
||||
public override bool CheckFizzle()
|
||||
{
|
||||
// Spell is initially always successful, and with no skill gain.
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
if (!Caster.CanBeginAction<PolymorphSpell>())
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed.
|
||||
}
|
||||
else if (TransformationSpellHelper.UnderTransformation(Caster))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063219); // You cannot mimic an animal while in that form.
|
||||
}
|
||||
else if (!Caster.CanBeginAction<IncognitoSpell>() || Caster.IsBodyMod && GetContext(Caster) == null)
|
||||
{
|
||||
DoFizzle();
|
||||
}
|
||||
else if (CheckSequence())
|
||||
{
|
||||
AnimalFormContext context = GetContext(Caster);
|
||||
|
||||
int mana = ScaleMana(RequiredMana);
|
||||
if (mana > Caster.Mana)
|
||||
{
|
||||
Caster.SendLocalizedMessage(1060174,
|
||||
mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
|
||||
}
|
||||
else if (context != null)
|
||||
{
|
||||
RemoveContext(Caster, context, true);
|
||||
Caster.Mana -= mana;
|
||||
}
|
||||
else if (Caster is PlayerMobile)
|
||||
{
|
||||
bool skipGump = m_WasMoving || CasterIsMoving();
|
||||
|
||||
if (GetLastAnimalForm(Caster) == -1 || !skipGump)
|
||||
{
|
||||
Caster.CloseGump<AnimalFormGump>();
|
||||
Caster.SendGump(new AnimalFormGump(Caster, Entries, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Morph(Caster, GetLastAnimalForm(Caster)) == MorphResult.Fail)
|
||||
{
|
||||
DoFizzle();
|
||||
}
|
||||
else
|
||||
{
|
||||
Caster.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
|
||||
Caster.Mana -= mana;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Morph(Caster, GetLastAnimalForm(Caster)) == MorphResult.Fail)
|
||||
{
|
||||
DoFizzle();
|
||||
}
|
||||
else
|
||||
{
|
||||
Caster.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
|
||||
Caster.Mana -= mana;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
}
|
||||
|
||||
public int GetLastAnimalForm(Mobile m)
|
||||
{
|
||||
return m_LastAnimalForms.TryGetValue(m, out int value) ? value : -1;
|
||||
}
|
||||
|
||||
public static MorphResult Morph(Mobile m, int entryID)
|
||||
{
|
||||
if (entryID < 0 || entryID >= Entries.Length)
|
||||
return MorphResult.Fail;
|
||||
|
||||
AnimalFormEntry entry = Entries[entryID];
|
||||
|
||||
m_LastAnimalForms[m] = entryID; //On OSI, it's the last /attempted/ one not the last succeeded one
|
||||
|
||||
if (m.Skills.Ninjitsu.Value < entry.ReqSkill)
|
||||
{
|
||||
string args = $"{entry.ReqSkill:F1}\t{SkillName.Ninjitsu}\t ";
|
||||
m.SendLocalizedMessage(1063013,
|
||||
args); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
|
||||
return MorphResult.NoSkill;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( !m.CheckSkill( SkillName.Ninjitsu, entry.ReqSkill, entry.ReqSkill + 37.5 ) )
|
||||
return MorphResult.Fail;
|
||||
*
|
||||
* On OSI,it seems you can only gain starting at '0' using Animal form.
|
||||
*/
|
||||
|
||||
double ninjitsu = m.Skills.Ninjitsu.Value;
|
||||
|
||||
if (ninjitsu < entry.ReqSkill + 37.5)
|
||||
{
|
||||
double chance = (ninjitsu - entry.ReqSkill) / 37.5;
|
||||
|
||||
if (chance < Utility.RandomDouble())
|
||||
return MorphResult.Fail;
|
||||
}
|
||||
|
||||
m.CheckSkill(SkillName.Ninjitsu, 0.0, 37.5);
|
||||
|
||||
if (!BaseFormTalisman.EntryEnabled(m, entry.Type))
|
||||
return MorphResult.Success; // Still consumes mana, just no effect
|
||||
|
||||
BaseMount.Dismount(m);
|
||||
|
||||
int bodyMod = entry.BodyMod;
|
||||
int hueMod = entry.HueMod;
|
||||
|
||||
m.BodyMod = bodyMod;
|
||||
m.HueMod = hueMod;
|
||||
|
||||
if (entry.SpeedBoost)
|
||||
m.Send(SpeedControl.MountSpeed);
|
||||
|
||||
SkillMod mod = null;
|
||||
|
||||
if (entry.StealthBonus)
|
||||
{
|
||||
mod = new DefaultSkillMod(SkillName.Stealth, true, 20.0) { ObeyCap = true };
|
||||
m.AddSkillMod(mod);
|
||||
}
|
||||
|
||||
SkillMod stealingMod = null;
|
||||
|
||||
if (entry.StealingBonus)
|
||||
{
|
||||
stealingMod = new DefaultSkillMod(SkillName.Stealing, true, 10.0) { ObeyCap = true };
|
||||
m.AddSkillMod(stealingMod);
|
||||
}
|
||||
|
||||
Timer timer = new AnimalFormTimer(m, bodyMod, hueMod);
|
||||
timer.Start();
|
||||
|
||||
AddContext(m, new AnimalFormContext(timer, mod, entry.SpeedBoost, entry.Type, stealingMod));
|
||||
m.CheckStatTimers();
|
||||
return MorphResult.Success;
|
||||
}
|
||||
|
||||
public static void AddContext(Mobile m, AnimalFormContext context)
|
||||
{
|
||||
m_Table[m] = context;
|
||||
|
||||
if (context.Type == typeof(BakeKitsune) || context.Type == typeof(GreyWolf))
|
||||
m.CheckStatTimers();
|
||||
}
|
||||
|
||||
public static void RemoveContext(Mobile m, bool resetGraphics)
|
||||
{
|
||||
AnimalFormContext context = GetContext(m);
|
||||
|
||||
if (context != null)
|
||||
RemoveContext(m, context, resetGraphics);
|
||||
}
|
||||
|
||||
public static void RemoveContext(Mobile m, AnimalFormContext context, bool resetGraphics)
|
||||
{
|
||||
m_Table.Remove(m);
|
||||
|
||||
if (context.SpeedBoost)
|
||||
m.Send(SpeedControl.Disable);
|
||||
|
||||
SkillMod mod = context.Mod;
|
||||
|
||||
if (mod != null)
|
||||
m.RemoveSkillMod(mod);
|
||||
|
||||
mod = context.StealingMod;
|
||||
|
||||
if (mod != null)
|
||||
m.RemoveSkillMod(mod);
|
||||
|
||||
if (resetGraphics)
|
||||
{
|
||||
m.HueMod = -1;
|
||||
m.BodyMod = 0;
|
||||
}
|
||||
|
||||
m.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
|
||||
|
||||
context.Timer.Stop();
|
||||
}
|
||||
|
||||
public static AnimalFormContext GetContext(Mobile m)
|
||||
{
|
||||
return m_Table.TryGetValue(m, out AnimalFormContext context) ? context : null;
|
||||
}
|
||||
|
||||
public static bool UnderTransformation(Mobile m)
|
||||
{
|
||||
return m_Table.ContainsKey(m);
|
||||
}
|
||||
|
||||
public static bool UnderTransformation(Mobile m, Type type)
|
||||
{
|
||||
return GetContext(m)?.Type == type;
|
||||
}
|
||||
|
||||
/*
|
||||
private delegate void AnimalFormCallback( Mobile from );
|
||||
private delegate bool AnimalFormRequirementCallback( Mobile from );
|
||||
*/
|
||||
|
||||
public class AnimalFormEntry
|
||||
{
|
||||
private int m_HueModMax;
|
||||
|
||||
private int m_HueModMin;
|
||||
/*
|
||||
private AnimalFormCallback m_TransformCallback;
|
||||
private AnimalFormCallback m_UntransformCallback;
|
||||
private AnimalFormRequirementCallback m_RequirementCallback;
|
||||
*/
|
||||
|
||||
public AnimalFormEntry(Type type, TextDefinition name, int itemID, int hue, int tooltip, double reqSkill,
|
||||
int bodyMod, int hueModMin, int hueModMax, bool stealthBonus = false, bool speedBoost = true, bool stealingBonus = false)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
ItemID = itemID;
|
||||
Hue = hue;
|
||||
Tooltip = tooltip;
|
||||
ReqSkill = reqSkill;
|
||||
BodyMod = bodyMod;
|
||||
m_HueModMin = hueModMin;
|
||||
m_HueModMax = hueModMax;
|
||||
StealthBonus = stealthBonus;
|
||||
SpeedBoost = speedBoost;
|
||||
StealingBonus = stealingBonus;
|
||||
}
|
||||
|
||||
public Type Type{ get; }
|
||||
|
||||
public TextDefinition Name{ get; }
|
||||
|
||||
public int ItemID{ get; }
|
||||
|
||||
public int Hue{ get; }
|
||||
|
||||
public int Tooltip{ get; }
|
||||
|
||||
public double ReqSkill{ get; }
|
||||
|
||||
public int BodyMod{ get; }
|
||||
|
||||
public int HueMod => Utility.RandomMinMax(m_HueModMin, m_HueModMax);
|
||||
public bool StealthBonus{ get; }
|
||||
|
||||
public bool SpeedBoost{ get; }
|
||||
|
||||
public bool StealingBonus{ get; }
|
||||
}
|
||||
|
||||
public class AnimalFormGump : Gump
|
||||
{
|
||||
//TODO: Convert this for ML to the BaseImageTileButtonsGump
|
||||
private Mobile m_Caster;
|
||||
private AnimalForm m_Spell;
|
||||
|
||||
public AnimalFormGump(Mobile caster, AnimalFormEntry[] entries, AnimalForm spell)
|
||||
: base(50, 50)
|
||||
{
|
||||
m_Caster = caster;
|
||||
m_Spell = spell;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 520, 404, 0x13BE);
|
||||
AddImageTiled(10, 10, 500, 20, 0xA40);
|
||||
AddImageTiled(10, 40, 500, 324, 0xA40);
|
||||
AddImageTiled(10, 374, 500, 20, 0xA40);
|
||||
AddAlphaRegion(10, 10, 500, 384);
|
||||
|
||||
AddHtmlLocalized(14, 12, 500, 20, 1063394, 0x7FFF); // <center>Polymorph Selection Menu</center>
|
||||
|
||||
AddButton(10, 374, 0xFB1, 0xFB2, 0);
|
||||
AddHtmlLocalized(45, 376, 450, 20, 1011012, 0x7FFF); // CANCEL
|
||||
|
||||
double ninjitsu = caster.Skills.Ninjitsu.Value;
|
||||
|
||||
int current = 0;
|
||||
|
||||
for (int i = 0; i < entries.Length; ++i)
|
||||
{
|
||||
bool enabled = ninjitsu >= entries[i].ReqSkill && BaseFormTalisman.EntryEnabled(caster, entries[i].Type);
|
||||
|
||||
int page = current / 10 + 1;
|
||||
int pos = current % 10;
|
||||
|
||||
if (pos == 0)
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page);
|
||||
AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next
|
||||
}
|
||||
|
||||
AddPage(page);
|
||||
|
||||
if (page > 1)
|
||||
{
|
||||
AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
|
||||
AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
int x = pos % 2 == 0 ? 14 : 264;
|
||||
int y = pos / 2 * 64 + 44;
|
||||
|
||||
Rectangle2D b = ItemBounds.Table[entries[i].ItemID];
|
||||
|
||||
AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entries[i].ItemID,
|
||||
entries[i].Hue, 40 - b.Width / 2 - b.X, 30 - b.Height / 2 - b.Y, entries[i].Tooltip);
|
||||
AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF);
|
||||
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
int entryID = info.ButtonID - 1;
|
||||
|
||||
if (entryID < 0 || entryID >= AnimalForm.Entries.Length)
|
||||
return;
|
||||
|
||||
int mana = m_Spell.ScaleMana(m_Spell.RequiredMana);
|
||||
AnimalFormEntry entry = AnimalForm.Entries[entryID];
|
||||
|
||||
if (mana > m_Caster.Mana)
|
||||
{
|
||||
m_Caster.SendLocalizedMessage(1060174,
|
||||
mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
|
||||
}
|
||||
else if (m_Caster is PlayerMobile mobile && mobile.MountBlockReason != BlockMountType.None)
|
||||
{
|
||||
mobile.SendLocalizedMessage(1063108); // You cannot use this ability right now.
|
||||
}
|
||||
else if (BaseFormTalisman.EntryEnabled(sender.Mobile, entry.Type))
|
||||
{
|
||||
#region Dueling
|
||||
|
||||
if ((m_Caster as PlayerMobile)?.DuelContext?.AllowSpellCast(m_Caster, m_Spell) == false)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
else if (Morph(m_Caster, entryID) == MorphResult.Fail)
|
||||
{
|
||||
m_Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502632); // The spell fizzles.
|
||||
m_Caster.FixedParticles(0x3735, 1, 30, 9503, EffectLayer.Waist);
|
||||
m_Caster.PlaySound(0x5C);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Caster.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
|
||||
m_Caster.Mana -= mana;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AnimalFormContext
|
||||
{
|
||||
public AnimalFormContext(Timer timer, SkillMod mod, bool speedBoost, Type type, SkillMod stealingMod)
|
||||
{
|
||||
Timer = timer;
|
||||
Mod = mod;
|
||||
SpeedBoost = speedBoost;
|
||||
Type = type;
|
||||
StealingMod = stealingMod;
|
||||
}
|
||||
|
||||
public Timer Timer{ get; }
|
||||
|
||||
public SkillMod Mod{ get; }
|
||||
|
||||
public bool SpeedBoost{ get; }
|
||||
|
||||
public Type Type{ get; }
|
||||
|
||||
public SkillMod StealingMod{ get; }
|
||||
}
|
||||
|
||||
public class AnimalFormTimer : Timer
|
||||
{
|
||||
private int m_Body;
|
||||
private int m_Counter;
|
||||
private int m_Hue;
|
||||
private Mobile m_LastTarget;
|
||||
private Mobile m_Mobile;
|
||||
|
||||
public AnimalFormTimer(Mobile from, int body, int hue)
|
||||
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Body = body;
|
||||
m_Hue = hue;
|
||||
m_Counter = 0;
|
||||
|
||||
Priority = TimerPriority.FiftyMS;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (m_Mobile.Deleted || !m_Mobile.Alive || m_Mobile.Body != m_Body || m_Mobile.Hue != m_Hue)
|
||||
{
|
||||
AnimalForm.RemoveContext(m_Mobile, true);
|
||||
Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Body == 0x115) // Cu Sidhe
|
||||
{
|
||||
if (m_Counter++ >= 8)
|
||||
{
|
||||
if (m_Mobile.Hits < m_Mobile.HitsMax && m_Mobile.Backpack != null)
|
||||
{
|
||||
Bandage b = m_Mobile.Backpack.FindItemByType<Bandage>();
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
m_Mobile.Hits += Utility.RandomMinMax(20, 50);
|
||||
b.Consume();
|
||||
}
|
||||
}
|
||||
|
||||
m_Counter = 0;
|
||||
}
|
||||
}
|
||||
else if (m_Body == 0x114) // Reptalon
|
||||
{
|
||||
if (m_Mobile.Combatant != null && m_Mobile.Combatant != m_LastTarget)
|
||||
{
|
||||
m_Counter = 1;
|
||||
m_LastTarget = m_Mobile.Combatant;
|
||||
}
|
||||
|
||||
if (m_Mobile.Warmode && m_LastTarget?.Alive == true && m_LastTarget?.Deleted != true &&
|
||||
m_Counter-- <= 0)
|
||||
{
|
||||
if (m_Mobile.CanBeHarmful(m_LastTarget) && m_LastTarget.Map == m_Mobile.Map &&
|
||||
m_LastTarget.InRange(m_Mobile.Location, BaseCreature.DefaultRangePerception) &&
|
||||
m_Mobile.InLOS(m_LastTarget))
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_LastTarget);
|
||||
m_Mobile.Freeze(TimeSpan.FromSeconds(1));
|
||||
m_Mobile.PlaySound(0x16A);
|
||||
|
||||
DelayCall(TimeSpan.FromSeconds(1.3), BreathEffect_Callback, m_LastTarget);
|
||||
}
|
||||
|
||||
m_Counter = Math.Min((int)m_Mobile.GetDistanceToSqrt(m_LastTarget), 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BreathEffect_Callback(Mobile target)
|
||||
{
|
||||
if (m_Mobile.CanBeHarmful(target))
|
||||
{
|
||||
m_Mobile.RevealingAction();
|
||||
m_Mobile.PlaySound(0x227);
|
||||
Effects.SendMovingEffect(m_Mobile, target, 0x36D4, 5, 0, false, false);
|
||||
|
||||
DelayCall(TimeSpan.FromSeconds(1), BreathDamage_Callback, target);
|
||||
}
|
||||
}
|
||||
|
||||
public void BreathDamage_Callback(Mobile target)
|
||||
{
|
||||
if (m_Mobile.CanBeHarmful(target))
|
||||
{
|
||||
m_Mobile.RevealingAction();
|
||||
m_Mobile.DoHarmful(target);
|
||||
AOS.Damage(target, m_Mobile, 20, !target.Player, 0, 100, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Projects/Scripts/Spells/Ninjitsu/Backstab.cs
Normal file
71
Projects/Scripts/Spells/Ninjitsu/Backstab.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using Server.SkillHandlers;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class Backstab : NinjaMove
|
||||
{
|
||||
public override int BaseMana => 30;
|
||||
public override double RequiredSkill => Core.ML ? 40.0 : 20.0;
|
||||
|
||||
public override TextDefinition AbilityMessage =>
|
||||
new TextDefinition(1063089); // You prepare to Backstab your opponent.
|
||||
|
||||
public override bool ValidatesDuringHit => false;
|
||||
|
||||
public override double GetDamageScalar(Mobile attacker, Mobile defender)
|
||||
{
|
||||
double ninjitsu = attacker.Skills.Ninjitsu.Value;
|
||||
|
||||
return 1.0 + ninjitsu / 360 + Tracking.GetStalkingBonus(attacker, defender) / 100;
|
||||
}
|
||||
|
||||
public override bool Validate(Mobile from)
|
||||
{
|
||||
if (!from.Hidden || from.AllowedStealthSteps <= 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1063087); // You must be in stealth mode to use this ability.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Validate(from);
|
||||
}
|
||||
|
||||
public override bool OnBeforeSwing(Mobile attacker, Mobile defender)
|
||||
{
|
||||
bool valid = Validate(attacker) && CheckMana(attacker, true);
|
||||
|
||||
if (valid)
|
||||
{
|
||||
attacker.BeginAction<Stealth>();
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), delegate { attacker.EndAction<Stealth>(); });
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
//Validates before swing
|
||||
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
attacker.SendLocalizedMessage(1063090); // You quickly stab your opponent as you come out of hiding!
|
||||
|
||||
defender.FixedParticles(0x37B9, 1, 5, 0x251D, 0x651, 0, EffectLayer.Waist);
|
||||
|
||||
attacker.RevealingAction();
|
||||
|
||||
CheckGain(attacker);
|
||||
}
|
||||
|
||||
public override void OnMiss(Mobile attacker, Mobile defender)
|
||||
{
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
attacker.SendLocalizedMessage(1063161); // You failed to properly use the element of surprise.
|
||||
|
||||
attacker.RevealingAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
152
Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs
Normal file
152
Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.SkillHandlers;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class DeathStrike : NinjaMove
|
||||
{
|
||||
private static Dictionary<Mobile, DeathStrikeInfo> m_Table = new Dictionary<Mobile, DeathStrikeInfo>();
|
||||
|
||||
public override int BaseMana => 30;
|
||||
public override double RequiredSkill => 85.0;
|
||||
|
||||
public override TextDefinition AbilityMessage =>
|
||||
new TextDefinition(1063091); // You prepare to hit your opponent with a Death Strike.
|
||||
|
||||
public override double GetDamageScalar(Mobile attacker, Mobile defender)
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
double ninjitsu = attacker.Skills.Ninjitsu.Value;
|
||||
|
||||
double chance;
|
||||
|
||||
// TODO: should be defined onHit method, what if the player hit and remove the weapon before process? ;)
|
||||
bool isRanged = attacker.Weapon is BaseRanged;
|
||||
|
||||
if (ninjitsu < 100) //This formula is an approximation from OSI data. TODO: find correct formula
|
||||
chance = 30 + (ninjitsu - 85) * 2.2;
|
||||
else
|
||||
chance = 63 + (ninjitsu - 100) * 1.1;
|
||||
|
||||
if (chance / 100 < Utility.RandomDouble())
|
||||
{
|
||||
attacker.SendLocalizedMessage(1070779); // You missed your opponent with a Death Strike.
|
||||
return;
|
||||
}
|
||||
|
||||
int damageBonus = 0;
|
||||
|
||||
if (m_Table.TryGetValue(defender, out DeathStrikeInfo info))
|
||||
{
|
||||
defender.SendLocalizedMessage(1063092); // Your opponent lands another Death Strike!
|
||||
|
||||
if (info.m_Steps > 0)
|
||||
damageBonus = attacker.Skills.Ninjitsu.Fixed / 150;
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
m_Table.Remove(defender);
|
||||
}
|
||||
else
|
||||
{
|
||||
defender.SendLocalizedMessage(1063093); // You have been hit by a Death Strike! Move with caution!
|
||||
}
|
||||
|
||||
attacker.SendLocalizedMessage(1063094); // You inflict a Death Strike upon your opponent!
|
||||
|
||||
defender.FixedParticles(0x374A, 1, 17, 0x26BC, EffectLayer.Waist);
|
||||
attacker.PlaySound(attacker.Female ? 0x50D : 0x50E);
|
||||
|
||||
info = new DeathStrikeInfo(defender, attacker, damageBonus, isRanged)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), ProcessDeathStrike, defender)
|
||||
};
|
||||
|
||||
m_Table[defender] = info;
|
||||
|
||||
CheckGain(attacker);
|
||||
}
|
||||
|
||||
public static void AddStep(Mobile m)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out DeathStrikeInfo info) && ++info.m_Steps >= 5)
|
||||
ProcessDeathStrike(m);
|
||||
}
|
||||
|
||||
private static void ProcessDeathStrike(Mobile defender)
|
||||
{
|
||||
if (!m_Table.TryGetValue(defender, out DeathStrikeInfo info))
|
||||
return;
|
||||
|
||||
int damage;
|
||||
|
||||
double ninjitsu = info.m_Attacker.Skills.Ninjitsu.Value;
|
||||
double stalkingBonus = Tracking.GetStalkingBonus(info.m_Attacker, info.m_Target);
|
||||
|
||||
if (Core.ML)
|
||||
{
|
||||
double scalar = (info.m_Attacker.Skills.Hiding.Value +
|
||||
info.m_Attacker.Skills.Stealth.Value) / 220;
|
||||
|
||||
if (scalar > 1)
|
||||
scalar = 1;
|
||||
|
||||
// New formula doesn't apply DamageBonus anymore, caps must be, directly, 60/30.
|
||||
if (info.m_Steps >= 5)
|
||||
damage = (int)Math.Floor(Math.Min(60, ninjitsu / 3 * (0.3 + 0.7 * scalar) + stalkingBonus));
|
||||
else
|
||||
damage = (int)Math.Floor(Math.Min(30, ninjitsu / 9 * (0.3 + 0.7 * scalar) + stalkingBonus));
|
||||
|
||||
if (info.m_isRanged)
|
||||
damage /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
int divisor = info.m_Steps >= 5 ? 30 : 80;
|
||||
double baseDamage = ninjitsu / divisor * 10;
|
||||
|
||||
int maxDamage = info.m_Steps >= 5 ? 62 : 22;
|
||||
damage = Math.Max(0, Math.Min(maxDamage, (int)(baseDamage + stalkingBonus))) + info.m_DamageBonus;
|
||||
}
|
||||
|
||||
if (Core.ML)
|
||||
info.m_Target.Damage(damage, info.m_Attacker); // Damage is direct.
|
||||
else
|
||||
AOS.Damage(info.m_Target, info.m_Attacker, damage, true, 100, 0, 0, 0, 0, 0, 0, false, false,
|
||||
true); // Damage is physical.
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
m_Table.Remove(info.m_Target);
|
||||
}
|
||||
|
||||
private class DeathStrikeInfo
|
||||
{
|
||||
public Mobile m_Attacker;
|
||||
public int m_DamageBonus;
|
||||
public bool m_isRanged;
|
||||
public int m_Steps;
|
||||
public Mobile m_Target;
|
||||
public Timer m_Timer;
|
||||
|
||||
public DeathStrikeInfo(Mobile target, Mobile attacker, int damageBonus, bool isRanged)
|
||||
{
|
||||
m_Target = target;
|
||||
m_Attacker = attacker;
|
||||
m_DamageBonus = damageBonus;
|
||||
m_isRanged = isRanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Projects/Scripts/Spells/Ninjitsu/FocusAttack.cs
Normal file
66
Projects/Scripts/Spells/Ninjitsu/FocusAttack.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using Server.Items;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class FocusAttack : NinjaMove
|
||||
{
|
||||
public override int BaseMana => Core.ML ? 10 : 20;
|
||||
public override double RequiredSkill => Core.ML ? 30.0 : 60;
|
||||
|
||||
public override TextDefinition AbilityMessage =>
|
||||
new TextDefinition(1063095); // You prepare to focus all of your abilities into your next strike.
|
||||
|
||||
public override bool Validate(Mobile from)
|
||||
{
|
||||
if (from.FindItemOnLayer(Layer.TwoHanded) as BaseShield != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1063096); // You cannot use this ability while holding a shield.
|
||||
return false;
|
||||
}
|
||||
|
||||
Item handOne = from.FindItemOnLayer(Layer.OneHanded) as BaseWeapon;
|
||||
|
||||
if (handOne != null && !(handOne is BaseRanged))
|
||||
return base.Validate(from);
|
||||
|
||||
Item handTwo = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
|
||||
|
||||
if (handTwo != null && !(handTwo is BaseRanged))
|
||||
return base.Validate(from);
|
||||
|
||||
from.SendLocalizedMessage(1063097); // You must be wielding a melee weapon without a shield to use this ability.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override double GetDamageScalar(Mobile attacker, Mobile defender)
|
||||
{
|
||||
double ninjitsu = attacker.Skills.Ninjitsu.Value;
|
||||
|
||||
return 1.0 + ninjitsu * ninjitsu / 43636;
|
||||
}
|
||||
|
||||
public override double GetPropertyBonus(Mobile attacker)
|
||||
{
|
||||
double ninjitsu = attacker.Skills.Ninjitsu.Value;
|
||||
|
||||
double bonus = ninjitsu * ninjitsu / 43636;
|
||||
|
||||
return 1.0 + (bonus * 3 + 0.01);
|
||||
}
|
||||
|
||||
public override bool OnBeforeDamage(Mobile attacker, Mobile defender)
|
||||
{
|
||||
return Validate(attacker) && CheckMana(attacker, true);
|
||||
}
|
||||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
attacker.SendLocalizedMessage(1063098); // You focus all of your abilities and strike with deadly force!
|
||||
attacker.PlaySound(0x510);
|
||||
|
||||
CheckGain(attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
129
Projects/Scripts/Spells/Ninjitsu/KiAttack.cs
Normal file
129
Projects/Scripts/Spells/Ninjitsu/KiAttack.cs
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class KiAttack : NinjaMove
|
||||
{
|
||||
private static Dictionary<Mobile, KiAttackInfo> m_Table = new Dictionary<Mobile, KiAttackInfo>();
|
||||
|
||||
public override int BaseMana => 25;
|
||||
public override double RequiredSkill => 80.0;
|
||||
|
||||
public override TextDefinition AbilityMessage =>
|
||||
new TextDefinition(1063099); // Your Ki Attack must be complete within 2 seconds for the damage bonus!
|
||||
|
||||
public override void OnUse(Mobile from)
|
||||
{
|
||||
if (!Validate(from))
|
||||
return;
|
||||
|
||||
KiAttackInfo info = new KiAttackInfo(from);
|
||||
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2.0), EndKiAttack, info);
|
||||
|
||||
m_Table[from] = info;
|
||||
}
|
||||
|
||||
public override bool Validate(Mobile from)
|
||||
{
|
||||
if (from.Hidden && from.AllowedStealthSteps > 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1063127); // You cannot use this ability while in stealth mode.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Core.ML && from.Weapon is BaseRanged)
|
||||
{
|
||||
from.SendLocalizedMessage(1075858); // You can only use this with melee attacks.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Validate(from);
|
||||
}
|
||||
|
||||
public override double GetDamageScalar(Mobile attacker, Mobile defender)
|
||||
{
|
||||
if (attacker.Hidden)
|
||||
return 1.0;
|
||||
|
||||
/*
|
||||
* Pub40 changed pvp damage max to 55%
|
||||
*/
|
||||
|
||||
return 1.0 + GetBonus(attacker) / (Core.ML && attacker.Player && defender.Player ? 40 : 10);
|
||||
}
|
||||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
||||
if (GetBonus(attacker) == 0.0)
|
||||
{
|
||||
attacker.SendLocalizedMessage(1063101); // You were too close to your target to cause any additional damage.
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker.FixedParticles(0x37BE, 1, 5, 0x26BD, 0x0, 0x1, EffectLayer.Waist);
|
||||
attacker.PlaySound(0x510);
|
||||
|
||||
attacker.SendLocalizedMessage(
|
||||
1063100); // Your quick flight to your target causes extra damage as you strike!
|
||||
defender.FixedParticles(0x37BE, 1, 5, 0x26BD, 0, 0x1, EffectLayer.Waist);
|
||||
|
||||
CheckGain(attacker);
|
||||
}
|
||||
|
||||
ClearCurrentMove(attacker);
|
||||
}
|
||||
|
||||
public override void OnClearMove(Mobile from)
|
||||
{
|
||||
if (!m_Table.TryGetValue(from, out KiAttackInfo info))
|
||||
return;
|
||||
|
||||
info.m_Timer.Stop();
|
||||
m_Table.Remove(info.m_Mobile);
|
||||
}
|
||||
|
||||
public static double GetBonus(Mobile from)
|
||||
{
|
||||
if (!m_Table.TryGetValue(from, out KiAttackInfo info))
|
||||
return 0;
|
||||
|
||||
int xDelta = info.m_Location.X - from.X;
|
||||
int yDelta = info.m_Location.Y - from.Y;
|
||||
|
||||
double bonus = Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
|
||||
|
||||
if (bonus > 20.0)
|
||||
bonus = 20.0;
|
||||
|
||||
return bonus;
|
||||
}
|
||||
|
||||
private static void EndKiAttack(KiAttackInfo info)
|
||||
{
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
ClearCurrentMove(info.m_Mobile);
|
||||
info.m_Mobile.SendLocalizedMessage(1063102); // You failed to complete your Ki Attack in time.
|
||||
|
||||
m_Table.Remove(info.m_Mobile);
|
||||
}
|
||||
|
||||
private class KiAttackInfo
|
||||
{
|
||||
public Point3D m_Location;
|
||||
public Mobile m_Mobile;
|
||||
public Timer m_Timer;
|
||||
|
||||
public KiAttackInfo(Mobile m)
|
||||
{
|
||||
m_Mobile = m;
|
||||
m_Location = m.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
269
Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs
Normal file
269
Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells;
|
||||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Ninjitsu;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class MirrorImage : NinjaSpell
|
||||
{
|
||||
private static Dictionary<Mobile, int> m_CloneCount = new Dictionary<Mobile, int>();
|
||||
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Mirror Image", null,
|
||||
-1,
|
||||
9002
|
||||
);
|
||||
|
||||
public MirrorImage(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5);
|
||||
|
||||
public override double RequiredSkill => Core.ML ? 20.0 : 40.0;
|
||||
public override int RequiredMana => 10;
|
||||
|
||||
public override bool BlockedByAnimalForm => false;
|
||||
|
||||
public static bool HasClone(Mobile m)
|
||||
{
|
||||
return m_CloneCount.ContainsKey(m);
|
||||
}
|
||||
|
||||
public static void AddClone(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
return;
|
||||
|
||||
m_CloneCount[m] = 1 + (m_CloneCount.TryGetValue(m, out int count) ? count : 0);
|
||||
}
|
||||
|
||||
public static void RemoveClone(Mobile m)
|
||||
{
|
||||
if (m == null || !m_CloneCount.TryGetValue(m, out int count))
|
||||
return;
|
||||
|
||||
if (count <= 1)
|
||||
m_CloneCount.Remove(m);
|
||||
else
|
||||
m_CloneCount[m]--;
|
||||
}
|
||||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
if (Caster.Mounted)
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063132); // You cannot use this ability while mounted.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Caster.Followers + 1 > Caster.FollowersMax)
|
||||
{
|
||||
Caster.SendLocalizedMessage(
|
||||
1063133); // You cannot summon a mirror image because you have too many followers.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TransformationSpellHelper.UnderTransformation(Caster, typeof(HorrificBeastSpell)))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckCast();
|
||||
}
|
||||
|
||||
public override bool CheckDisturb(DisturbType type, bool firstCircle, bool resistable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnBeginCast()
|
||||
{
|
||||
base.OnBeginCast();
|
||||
|
||||
Caster.SendLocalizedMessage(1063134); // You begin to summon a mirror image of yourself.
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
if (Caster.Mounted)
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063132); // You cannot use this ability while mounted.
|
||||
}
|
||||
else if (Caster.Followers + 1 > Caster.FollowersMax)
|
||||
{
|
||||
Caster.SendLocalizedMessage(
|
||||
1063133); // You cannot summon a mirror image because you have too many followers.
|
||||
}
|
||||
else if (TransformationSpellHelper.UnderTransformation(Caster, typeof(HorrificBeastSpell)))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
|
||||
}
|
||||
else if (CheckSequence())
|
||||
{
|
||||
Caster.FixedParticles(0x376A, 1, 14, 0x13B5, EffectLayer.Waist);
|
||||
Caster.PlaySound(0x511);
|
||||
|
||||
new Clone(Caster).MoveToWorld(Caster.Location, Caster.Map);
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class Clone : BaseCreature
|
||||
{
|
||||
private Mobile m_Caster;
|
||||
|
||||
public Clone(Mobile caster) : base(AIType.AI_Melee, FightMode.None, 10, 1, 0.2, 0.4)
|
||||
{
|
||||
m_Caster = caster;
|
||||
|
||||
Body = caster.Body;
|
||||
|
||||
Hue = caster.Hue;
|
||||
Female = caster.Female;
|
||||
|
||||
Name = caster.Name;
|
||||
NameHue = caster.NameHue;
|
||||
|
||||
Title = caster.Title;
|
||||
Kills = caster.Kills;
|
||||
|
||||
HairItemID = caster.HairItemID;
|
||||
HairHue = caster.HairHue;
|
||||
|
||||
FacialHairItemID = caster.FacialHairItemID;
|
||||
FacialHairHue = caster.FacialHairHue;
|
||||
|
||||
for (int i = 0; i < caster.Skills.Length; ++i)
|
||||
{
|
||||
Skills[i].Base = caster.Skills[i].Base;
|
||||
Skills[i].Cap = caster.Skills[i].Cap;
|
||||
}
|
||||
|
||||
for (int i = 0; i < caster.Items.Count; i++) AddItem(CloneItem(caster.Items[i]));
|
||||
|
||||
Warmode = true;
|
||||
|
||||
Summoned = true;
|
||||
SummonMaster = caster;
|
||||
|
||||
ControlOrder = OrderType.Follow;
|
||||
ControlTarget = caster;
|
||||
|
||||
TimeSpan duration = TimeSpan.FromSeconds(30 + caster.Skills.Ninjitsu.Fixed / 40);
|
||||
|
||||
new UnsummonTimer(caster, this, duration).Start();
|
||||
SummonEnd = DateTime.UtcNow + duration;
|
||||
|
||||
MirrorImage.AddClone(m_Caster);
|
||||
}
|
||||
|
||||
public Clone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
protected override BaseAI ForcedAI => new CloneAI(this);
|
||||
|
||||
public override bool DeleteCorpseOnDeath => true;
|
||||
|
||||
public override bool IsDispellable => false;
|
||||
public override bool Commandable => false;
|
||||
|
||||
public override bool IsHumanInTown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private Item CloneItem(Item item)
|
||||
{
|
||||
Item newItem = new Item(item.ItemID);
|
||||
newItem.Hue = item.Hue;
|
||||
newItem.Layer = item.Layer;
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public override void OnDamage(int amount, Mobile from, bool willKill)
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3728, 10, 15,
|
||||
5042);
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
MirrorImage.RemoveClone(m_Caster);
|
||||
base.OnAfterDelete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
|
||||
writer.Write(m_Caster);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
m_Caster = reader.ReadMobile();
|
||||
|
||||
MirrorImage.AddClone(m_Caster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class CloneAI : BaseAI
|
||||
{
|
||||
public CloneAI(Clone m) : base(m)
|
||||
{
|
||||
m.CurrentSpeed = m.ActiveSpeed;
|
||||
}
|
||||
|
||||
public override bool CanDetectHidden => false;
|
||||
|
||||
public override bool Think()
|
||||
{
|
||||
// Clones only follow their owners
|
||||
Mobile master = m_Mobile.SummonMaster;
|
||||
|
||||
if (master?.Map == m_Mobile.Map && master?.InRange(m_Mobile, m_Mobile.RangePerception) == true)
|
||||
{
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(master);
|
||||
bool bRun = iCurrDist > 5;
|
||||
|
||||
WalkMobileRange(master, 2, bRun, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
WalkRandom(2, 2, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs
Normal file
12
Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace Server.Spells
|
||||
{
|
||||
public class NinjaMove : SpecialMove
|
||||
{
|
||||
public override SkillName MoveSkill => SkillName.Ninjitsu;
|
||||
|
||||
public override void CheckGain(Mobile m)
|
||||
{
|
||||
m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); //Per five on friday 02/16/07
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs
Normal file
100
Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public abstract class NinjaSpell : Spell
|
||||
{
|
||||
public NinjaSpell(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.Ninjitsu;
|
||||
public override SkillName DamageSkill => SkillName.Ninjitsu;
|
||||
|
||||
public override bool RevealOnCast => false;
|
||||
public override bool ClearHandsOnCast => false;
|
||||
public override bool ShowHandMovement => false;
|
||||
|
||||
public override bool BlocksMovement => false;
|
||||
|
||||
//public override int CastDelayBase => 1;
|
||||
|
||||
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(1063352,
|
||||
RequiredSkill.ToString("F1")); // You need ~1_SKILL_REQUIREMENT~ Ninjitsu 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs
Normal file
114
Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using Server.Factions;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
using Server.SkillHandlers;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"Shadowjump", null,
|
||||
-1,
|
||||
9002
|
||||
);
|
||||
|
||||
public Shadowjump(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.0);
|
||||
|
||||
public override double RequiredSkill => 50.0;
|
||||
public override int RequiredMana => 15;
|
||||
|
||||
public override bool BlockedByAnimalForm => false;
|
||||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
PlayerMobile pm = Caster as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
|
||||
if (!pm.IsStealthing)
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063087); // You must be in stealth mode to use this ability.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckCast();
|
||||
}
|
||||
|
||||
public override bool CheckDisturb(DisturbType type, bool firstCircle, bool resistable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063088); // You prepare to perform a Shadowjump.
|
||||
Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 11);
|
||||
}
|
||||
|
||||
public void Target(IPoint3D p)
|
||||
{
|
||||
IPoint3D orig = p;
|
||||
Map map = Caster.Map;
|
||||
|
||||
SpellHelper.GetSurfaceTop(ref p);
|
||||
|
||||
Point3D from = Caster.Location;
|
||||
Point3D to = new Point3D(p);
|
||||
|
||||
PlayerMobile pm = Caster as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
|
||||
|
||||
if (!pm.IsStealthing)
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063087); // You must be in stealth mode to use this ability.
|
||||
}
|
||||
else if (Sigil.ExistsOn(Caster))
|
||||
{
|
||||
Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
|
||||
}
|
||||
else if (WeightOverloading.IsOverloaded(Caster))
|
||||
{
|
||||
Caster.SendLocalizedMessage(502359, "", 0x22); // Thou art too encumbered to move.
|
||||
}
|
||||
else if (!SpellHelper.CheckTravel(Caster, TravelCheckType.TeleportFrom) ||
|
||||
!SpellHelper.CheckTravel(Caster, map, to, TravelCheckType.TeleportTo))
|
||||
{
|
||||
}
|
||||
else if (map == null || !map.CanSpawnMobile(p.X, p.Y, p.Z))
|
||||
{
|
||||
Caster.SendLocalizedMessage(502831); // Cannot teleport to that spot.
|
||||
}
|
||||
else if (SpellHelper.CheckMulti(to, map, true, 5))
|
||||
{
|
||||
Caster.SendLocalizedMessage(502831); // Cannot teleport to that spot.
|
||||
}
|
||||
else if (Region.Find(to, map).IsPartOf<HouseRegion>())
|
||||
{
|
||||
Caster.SendLocalizedMessage(502829); // Cannot teleport to that spot.
|
||||
}
|
||||
else if (CheckSequence())
|
||||
{
|
||||
SpellHelper.Turn(Caster, orig);
|
||||
|
||||
Mobile m = Caster;
|
||||
|
||||
m.Location = to;
|
||||
m.ProcessDelta();
|
||||
|
||||
Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10,
|
||||
2023);
|
||||
|
||||
m.PlaySound(0x512);
|
||||
|
||||
Stealth.OnUse(m); // stealth check after the a jump
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs
Normal file
113
Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.SkillHandlers;
|
||||
|
||||
namespace Server.Spells.Ninjitsu
|
||||
{
|
||||
public class SurpriseAttack : NinjaMove
|
||||
{
|
||||
private static Dictionary<Mobile, SurpriseAttackInfo> m_Table = new Dictionary<Mobile, SurpriseAttackInfo>();
|
||||
|
||||
public override int BaseMana => 20;
|
||||
public override double RequiredSkill => Core.ML ? 60.0 : 30.0;
|
||||
|
||||
public override TextDefinition AbilityMessage => new TextDefinition(1063128); // You prepare to surprise your prey.
|
||||
|
||||
public override bool ValidatesDuringHit => false;
|
||||
|
||||
public override bool Validate(Mobile from)
|
||||
{
|
||||
if (!from.Hidden || from.AllowedStealthSteps <= 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1063087); // You must be in stealth mode to use this ability.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Validate(from);
|
||||
}
|
||||
|
||||
public override bool OnBeforeSwing(Mobile attacker, Mobile defender)
|
||||
{
|
||||
bool valid = Validate(attacker) && CheckMana(attacker, true);
|
||||
|
||||
if (valid)
|
||||
{
|
||||
attacker.BeginAction<Stealth>();
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), delegate { attacker.EndAction<Stealth>(); });
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
//Validates before swing
|
||||
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
attacker.SendLocalizedMessage(1063129); // You catch your opponent off guard with your Surprise Attack!
|
||||
defender.SendLocalizedMessage(1063130); // Your defenses are lowered as your opponent surprises you!
|
||||
|
||||
defender.FixedParticles(0x37B9, 1, 5, 0x26DA, 0, 3, EffectLayer.Head);
|
||||
|
||||
attacker.RevealingAction();
|
||||
|
||||
if (m_Table.TryGetValue(defender, out SurpriseAttackInfo info))
|
||||
{
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
m_Table.Remove(defender);
|
||||
}
|
||||
|
||||
int ninjitsu = attacker.Skills.Ninjitsu.Fixed;
|
||||
|
||||
int malus = ninjitsu / 60 + (int)Tracking.GetStalkingBonus(attacker, defender);
|
||||
|
||||
info = new SurpriseAttackInfo(defender, malus);
|
||||
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(8.0), EndSurprise, info);
|
||||
|
||||
m_Table[defender] = info;
|
||||
|
||||
CheckGain(attacker);
|
||||
}
|
||||
|
||||
public override void OnMiss(Mobile attacker, Mobile defender)
|
||||
{
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
attacker.SendLocalizedMessage(1063161); // You failed to properly use the element of surprise.
|
||||
|
||||
attacker.RevealingAction();
|
||||
}
|
||||
|
||||
public static bool GetMalus(Mobile target, ref int malus)
|
||||
{
|
||||
if (!m_Table.TryGetValue(target, out SurpriseAttackInfo info))
|
||||
return false;
|
||||
|
||||
malus = info.m_Malus;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void EndSurprise(SurpriseAttackInfo info)
|
||||
{
|
||||
info.m_Timer?.Stop();
|
||||
info.m_Target.SendLocalizedMessage(1063131); // Your defenses have returned to normal.
|
||||
|
||||
m_Table.Remove(info.m_Target);
|
||||
}
|
||||
|
||||
private class SurpriseAttackInfo
|
||||
{
|
||||
public int m_Malus;
|
||||
public Mobile m_Target;
|
||||
public Timer m_Timer;
|
||||
|
||||
public SurpriseAttackInfo(Mobile target, int effect)
|
||||
{
|
||||
m_Target = target;
|
||||
m_Malus = effect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue