* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand. * WIP - Rewriting packets. * Cleanup and updates README * Converts more packets * Fixes header * Converts Effects packets. * Forgot the send command * Adds the start of containers packets. * Adds message packets with caching * Extends the send methods * Starts to add Acquire methods * Converted the packets * Cleanup * Cleanup * Adds more packets * Adds more packets * Fixes clearing arrays from pool. Adds Mobile Incoming * Converts more packets. * Moves more packets * Moves more packets * Test compression * Merges * Migrating to an idiomatic syntax that also supports compression, and proxying. * Optimize the stack alloc. Changes attributes * Converted container packets * Visual Studio doesn't auto save files. I am still getting used to subpar IDEs. * Adds static packet caching. Will profile later. Converts more packets * Fixes packets and changes how compression is configured * WIP - Adds basics for Gumps. Not finished though. * Fix file * Fixes formatting * Changed SpanWriter to be more idiomatic. * Fixes Span vs RawSpan and missing stackallocs * Converts over some more gumps * WIP - Deletes 32bit support. * Drops RDRand32 support. * Fixes gump compilation * Converting gump components * Removes old huffman compression function * Revert signature for backwards compatibility * WIP - Converting more gump components * Creates ArraySet for the strings. Updates AppendTo to reference that. * Converts the maining gump components * Cleans up gump components * Cleans up directives * Cleans up ArraySet and moves it. Adds null-coalescing-assignment * Cleanup, Target Packets, and C# 8 changes. * Removed OPL Packet * World packets * Fixing packet uses * Cleans up code. Fixes packet uses in various places. * More cleanup for packets * Code cleanup * Converts more packet uses and cleans up more code * More code cleanup * Finishes fixing the packets in Item * Updates secure trade packets * Updates core and gets it to compile. * Moved packets to scripts. Fixed account handler use of packets * Code cleanup * Updates chat packets * Code cleanuo * Adds party packets, but need to implement them. * Party packets WIP * Finishes party packets * Rearrange movement namespaces and classes * Finishes plant packets * Code Formatting * Fixes moving effects * Code cleanup, eliminates equipinfo * Adds more packets. Fixes bugs with various packets. * Finishes mahjon packets * Fixes mahjong packet * Code cleanup * Finishes mahjong packets * Adds Map packets * Add multifacet maps and charts * Cleans up some packets with UTF8 * Optimizes packets * Cleans up more packets. Moves the MessageHelper * Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets. * Updates protocol extensions packet receiver * Fixes a few bugs. Fixes a few more packets. * Code cleanup and fixing more packets * Fixes packet effects * Cleaned up more code * Buff Icon cleanup * Removed unused constructors * Code Cleanup. Adds BoatHS Packets * Moves house files. Updates house foundation packets. * Deployment cleanup * Fixes: * Code cleanup * More code cleanup * More code cleanup * Cleaned up BaseHouse * Enforces styling * Converts foreach to linq where possible. * Dont need that * Goals/Readme updates * Removes 32bit support at the highest level. Turns on HRT by default. * Code cleanup. Fixes extended features packet. * Fixes various bugs * Code cleanup * Code cleanup * Code cleanup. Fixes gump X/Y assignment. * Code cleanup using |= operator * More code cleanup * Cleanup * Fixes spacing issues. Thanks Visual Studio. You suck. * Compiler error * Fixes NPE from RunUO 2.7 * Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README * Fixes more packets. Stupid trailing nulls. * Fixes various bugs. * Fixes for gumps * Fixes more gump stuff. Going to split it out later since it is getting insane * Recoded the gump writing * WIP * *Added output path of scripts project to dev branch *Activated debugging in code
215 lines
6.3 KiB
C#
215 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Spells.Necromancy
|
|
{
|
|
public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile
|
|
{
|
|
private static SpellInfo m_Info = new SpellInfo(
|
|
"Strangle", "In Bal Nox",
|
|
209,
|
|
9031,
|
|
Reagent.DaemonBlood,
|
|
Reagent.NoxCrystal
|
|
);
|
|
|
|
private static readonly Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
|
|
|
|
public StrangleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
|
{
|
|
}
|
|
|
|
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.0);
|
|
|
|
public override double RequiredSkill => 65.0;
|
|
public override int RequiredMana => 29;
|
|
|
|
public override void OnCast()
|
|
{
|
|
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
|
|
}
|
|
|
|
public void Target(Mobile m)
|
|
{
|
|
if (m == null)
|
|
return;
|
|
|
|
if (CheckHSequence(m))
|
|
{
|
|
SpellHelper.Turn(Caster, m);
|
|
|
|
//SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent after AoS
|
|
|
|
/* Temporarily chokes off the air suply of the target with poisonous fumes.
|
|
* The target is inflicted with poison damage over time.
|
|
* The amount of damage dealt each "hit" is based off of the caster's Spirit Speak skill and the Target's current Stamina.
|
|
* The less Stamina the target has, the more damage is done by Strangle.
|
|
* Duration of the effect is Spirit Speak skill level / 10 rounds, with a minimum number of 4 rounds.
|
|
* The first round of damage is dealt after 5 seconds, and every next round after that comes 1 second sooner than the one before, until there is only 1 second between rounds.
|
|
* The base damage of the effect lies between (Spirit Speak skill level / 10) - 2 and (Spirit Speak skill level / 10) + 1.
|
|
* Base damage is multiplied by the following formula: (3 - (target's current Stamina / target's maximum Stamina) * 2).
|
|
* Example:
|
|
* For a target at full Stamina the damage multiplier is 1,
|
|
* for a target at 50% Stamina the damage multiplier is 2 and
|
|
* for a target at 20% Stamina the damage multiplier is 2.6
|
|
*/
|
|
|
|
m.Spell?.OnCasterHurt();
|
|
|
|
m.PlaySound(0x22F);
|
|
m.FixedParticles(0x36CB, 1, 9, 9911, 67, 5, EffectLayer.Head);
|
|
m.FixedParticles(0x374A, 1, 17, 9502, 1108, 4, (EffectLayer)255);
|
|
|
|
if (!m_Table.TryGetValue(m, out InternalTimer timer))
|
|
{
|
|
m_Table[m] = timer = new InternalTimer(m, Caster);
|
|
timer.Start();
|
|
}
|
|
|
|
HarmfulSpell(m);
|
|
}
|
|
|
|
//Calculations for the buff bar
|
|
double spiritlevel = Caster.Skills.SpiritSpeak.Value / 10;
|
|
if (spiritlevel < 4)
|
|
spiritlevel = 4;
|
|
int d_MinDamage = 4;
|
|
int d_MaxDamage = ((int)spiritlevel + 1) * 3;
|
|
string args = $"{d_MinDamage}\t{d_MaxDamage}";
|
|
|
|
int i_Count = (int)spiritlevel;
|
|
int i_MaxCount = i_Count;
|
|
int i_HitDelay = 5;
|
|
int i_Length = i_HitDelay;
|
|
|
|
while (i_Count > 1)
|
|
{
|
|
--i_Count;
|
|
if (i_HitDelay > 1)
|
|
{
|
|
if (i_MaxCount < 5)
|
|
{
|
|
--i_HitDelay;
|
|
}
|
|
else
|
|
{
|
|
int delay = (int)Math.Ceiling((1.0 + 5 * i_Count) / i_MaxCount);
|
|
|
|
i_HitDelay = delay <= 5 ? delay : 5;
|
|
}
|
|
}
|
|
|
|
i_Length += i_HitDelay;
|
|
}
|
|
|
|
TimeSpan t_Duration = TimeSpan.FromSeconds(i_Length);
|
|
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Strangle, 1075794, args, t_Duration, m));
|
|
|
|
FinishSequence();
|
|
}
|
|
|
|
public static bool RemoveCurse(Mobile m)
|
|
{
|
|
if (!m_Table.TryGetValue(m, out InternalTimer timer))
|
|
return false;
|
|
|
|
timer.Stop();
|
|
m.SendLocalizedMessage(1061687); // You can breath normally again.
|
|
|
|
m_Table.Remove(m);
|
|
return true;
|
|
}
|
|
|
|
private class InternalTimer : Timer
|
|
{
|
|
private int m_Count, m_MaxCount;
|
|
private int m_HitDelay;
|
|
private double m_MinBaseDamage, m_MaxBaseDamage;
|
|
|
|
private DateTime m_NextHit;
|
|
private Mobile m_Target, m_From;
|
|
|
|
public InternalTimer(Mobile target, Mobile from) : base(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.1))
|
|
{
|
|
Priority = TimerPriority.FiftyMS;
|
|
|
|
m_Target = target;
|
|
m_From = from;
|
|
|
|
double spiritLevel = from.Skills.SpiritSpeak.Value / 10;
|
|
|
|
m_MinBaseDamage = spiritLevel - 2;
|
|
m_MaxBaseDamage = spiritLevel + 1;
|
|
|
|
m_HitDelay = 5;
|
|
m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay);
|
|
|
|
m_Count = (int)spiritLevel;
|
|
|
|
if (m_Count < 4)
|
|
m_Count = 4;
|
|
|
|
m_MaxCount = m_Count;
|
|
}
|
|
|
|
protected override void OnTick()
|
|
{
|
|
if (!m_Target.Alive)
|
|
{
|
|
m_Table.Remove(m_Target);
|
|
Stop();
|
|
}
|
|
|
|
if (!m_Target.Alive || DateTime.UtcNow < m_NextHit)
|
|
return;
|
|
|
|
--m_Count;
|
|
|
|
if (m_HitDelay > 1)
|
|
{
|
|
if (m_MaxCount < 5)
|
|
{
|
|
--m_HitDelay;
|
|
}
|
|
else
|
|
{
|
|
int delay = (int)Math.Ceiling((1.0 + 5 * m_Count) / m_MaxCount);
|
|
|
|
if (delay <= 5)
|
|
m_HitDelay = delay;
|
|
else
|
|
m_HitDelay = 5;
|
|
}
|
|
}
|
|
|
|
if (m_Count == 0)
|
|
{
|
|
m_Target.SendLocalizedMessage(1061687); // You can breath normally again.
|
|
m_Table.Remove(m_Target);
|
|
Stop();
|
|
}
|
|
else
|
|
{
|
|
m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay);
|
|
|
|
double damage = m_MinBaseDamage + Utility.RandomDouble() * (m_MaxBaseDamage - m_MinBaseDamage);
|
|
|
|
damage *= 3 - (double)m_Target.Stam / m_Target.StamMax * 2;
|
|
|
|
if (damage < 1)
|
|
damage = 1;
|
|
|
|
if (!m_Target.Player)
|
|
damage *= 1.75;
|
|
|
|
AOS.Damage(m_Target, m_From, (int)damage, 0, 0, 0, 100, 0);
|
|
|
|
if (0.60 <= Utility.RandomDouble()
|
|
) // OSI: randomly revealed between first and third damage tick, guessing 60% chance
|
|
m_Target.RevealingAction();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|