Lots of fixes, changes, rewrites of various things, including but not limited to:
Logging of staff crafting items, Fixes for the OSI client changes The potion stacking stuff BaseWeapon fix, so that damage increase things don't multiply themselves. admin gump fixes for Firewall Various display tweaks for weight SoS no longer spawn in Tokuno Hiryu hues happified to OSI standards staff now see alliance chat correctly Play barkeeper text increased per OSI Various other OSI skill requirement changes Various unimplemented features of the SE moves EventSink for when the client version is received from client. Client validation moved out of the core. Client version validation now has options to ignore/kick/warn/annoy. Automagically tries to detect current client. Reverted the delayeddamagecontext back to OSI standards. Can no longer use bags of sending in jail. MagerySpell implemented. Now only Magery spells have a circle, and various other properties of 'em. TransformationSpellHelper now implemented. Things moved around for this. Spells now need a Timespan for the cast delay, instead of arbitrarily based on Circle. Circle doesn't make sense for non-Magery spells! Alot of the spellweaving spells added to OSI standards.
This commit is contained in:
parent
f12e9745c6
commit
2ad37d54aa
214 changed files with 4881 additions and 1243 deletions
116
Scripts/Spells/Base/MagerySpell.cs
Normal file
116
Scripts/Spells/Base/MagerySpell.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Spells
|
||||
{
|
||||
public abstract class MagerySpell : Spell
|
||||
{
|
||||
public MagerySpell( Mobile caster, Item scroll, SpellInfo info )
|
||||
: base( caster, scroll, info )
|
||||
{
|
||||
}
|
||||
|
||||
public abstract SpellCircle Circle { get; }
|
||||
|
||||
public override bool ConsumeReagents()
|
||||
{
|
||||
if( base.ConsumeReagents() )
|
||||
return true;
|
||||
|
||||
if( ArcaneGem.ConsumeCharges( Caster, (Core.SE ? 1 : 1 + (int)Circle) ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static int[] m_ManaTable = new int[] { 4, 6, 9, 11, 14, 20, 40, 50 };
|
||||
|
||||
public override int GetMana()
|
||||
{
|
||||
if( Scroll is BaseWand )
|
||||
return 0;
|
||||
|
||||
return m_ManaTable[(int)Circle];
|
||||
}
|
||||
|
||||
public override double GetResistSkill( Mobile m )
|
||||
{
|
||||
int maxSkill = (1 + (int)Circle) * 10;
|
||||
maxSkill += (1 + ((int)Circle / 6)) * 25;
|
||||
|
||||
if( m.Skills[SkillName.MagicResist].Value < maxSkill )
|
||||
m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );
|
||||
|
||||
return m.Skills[SkillName.MagicResist].Value;
|
||||
}
|
||||
|
||||
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, 120.0 );
|
||||
|
||||
return (n >= Utility.RandomDouble());
|
||||
}
|
||||
|
||||
public virtual double GetResistPercentForCircle( Mobile target, SpellCircle circle )
|
||||
{
|
||||
double firstPercent = target.Skills[SkillName.MagicResist].Value / 5.0;
|
||||
double secondPercent = target.Skills[SkillName.MagicResist].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( Scroll is BaseWand )
|
||||
return TimeSpan.Zero;
|
||||
|
||||
if( !Core.AOS )
|
||||
return TimeSpan.FromSeconds( 0.5 + (0.25 * (int)Circle) );
|
||||
|
||||
return base.GetCastDelay();
|
||||
}
|
||||
|
||||
public override TimeSpan CastDelayBase
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromSeconds( (3 + (int)Circle) * CastDelaySecondsPerTick );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ using Server.Spells.Second;
|
|||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Ninjitsu;
|
||||
using System.Collections.Generic;
|
||||
using Server.Spells.Spellweaving;
|
||||
using Server.Spells.Bushido;
|
||||
|
||||
namespace Server.Spells
|
||||
{
|
||||
|
|
@ -23,7 +25,6 @@ namespace Server.Spells
|
|||
public SpellInfo Info{ get{ return m_Info; } }
|
||||
public string Name{ get{ return m_Info.Name; } }
|
||||
public string Mantra{ get{ return m_Info.Mantra; } }
|
||||
public SpellCircle Circle{ get{ return m_Info.Circle; } }
|
||||
public Type[] Reagents{ get{ return m_Info.Reagents; } }
|
||||
public Item Scroll{ get{ return m_Scroll; } }
|
||||
public DateTime StartCastTime { get { return m_StartCastTime; } }
|
||||
|
|
@ -46,65 +47,55 @@ namespace Server.Spells
|
|||
//the possibility of stacking 'em. Note that a MA & an Explosion will stack, but
|
||||
//of course, two MA's won't.
|
||||
|
||||
private static Dictionary<Mobile, List<DelayedDamageContext>> m_ContextTable = new Dictionary<Mobile, List<DelayedDamageContext>>();
|
||||
private static Dictionary<Type, DelayedDamageContextWrapper> m_ContextTable = new Dictionary<Type, DelayedDamageContextWrapper>();
|
||||
|
||||
private class DelayedDamageContext {
|
||||
public Mobile Target;
|
||||
public Type Type;
|
||||
public Timer Timer;
|
||||
private class DelayedDamageContextWrapper
|
||||
{
|
||||
private Dictionary<Mobile, Timer> m_Contexts = new Dictionary<Mobile, Timer>();
|
||||
|
||||
public DelayedDamageContext( Mobile target, Type type, Timer timer ) {
|
||||
Target = target;
|
||||
Type = type;
|
||||
Timer = timer;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartDelayedDamageContext( Mobile target, Timer timer )
|
||||
{
|
||||
if( DelayedDamageStacking )
|
||||
return; //Sanity
|
||||
|
||||
List<DelayedDamageContext> contexts;
|
||||
Type type = this.GetType();
|
||||
|
||||
if( !m_ContextTable.TryGetValue( m_Caster, out contexts ) )
|
||||
contexts = new List<DelayedDamageContext>();
|
||||
else {
|
||||
for ( int i = 0; i < contexts.Count; i++ ) {
|
||||
DelayedDamageContext ddc = contexts[i];
|
||||
|
||||
if ( ddc.Target == target && ddc.Type == type ) {
|
||||
ddc.Timer.Stop();
|
||||
contexts.RemoveAt( i );
|
||||
break;
|
||||
}
|
||||
public void Add( Mobile m, Timer t )
|
||||
{
|
||||
Timer oldTimer;
|
||||
if( m_Contexts.TryGetValue( m, out oldTimer ) )
|
||||
{
|
||||
oldTimer.Stop();
|
||||
m_Contexts.Remove( m );
|
||||
}
|
||||
|
||||
m_Contexts.Add( m, t );
|
||||
}
|
||||
|
||||
contexts.Add( new DelayedDamageContext( target, type, timer ) );
|
||||
public void Remove( Mobile m )
|
||||
{
|
||||
m_Contexts.Remove( m );
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveDelayedDamageContext( Mobile target )
|
||||
{
|
||||
List<DelayedDamageContext> contexts;
|
||||
Type type = this.GetType();
|
||||
public void StartDelayedDamageContext( Mobile m, Timer t )
|
||||
{
|
||||
if( DelayedDamageStacking )
|
||||
return; //Sanity
|
||||
|
||||
if( !m_ContextTable.TryGetValue( m_Caster, out contexts ) )
|
||||
DelayedDamageContextWrapper contexts;
|
||||
|
||||
if( !m_ContextTable.TryGetValue( GetType(), out contexts ) )
|
||||
{
|
||||
contexts = new DelayedDamageContextWrapper();
|
||||
m_ContextTable.Add( GetType(), contexts );
|
||||
}
|
||||
|
||||
contexts.Add( m, t );
|
||||
}
|
||||
|
||||
public void RemoveDelayedDamageContext( Mobile m )
|
||||
{
|
||||
DelayedDamageContextWrapper contexts;
|
||||
|
||||
if( !m_ContextTable.TryGetValue( GetType(), out contexts ) )
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < contexts.Count; i++ ) {
|
||||
DelayedDamageContext ddc = contexts[i];
|
||||
|
||||
if ( ddc.Target == target && ddc.Type == type ) {
|
||||
contexts.RemoveAt( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( contexts.Count == 0 )
|
||||
m_ContextTable.Remove( m_Caster );
|
||||
}
|
||||
contexts.Remove( m );
|
||||
}
|
||||
|
||||
public Spell( Mobile caster, Item scroll, SpellInfo info )
|
||||
{
|
||||
|
|
@ -146,8 +137,14 @@ namespace Server.Spells
|
|||
// PvP spell damage increase cap of 15% from an item’s magic property
|
||||
if ( playerVsPlayer && sdiBonus > 15 )
|
||||
sdiBonus = 15;
|
||||
|
||||
damageBonus += sdiBonus;
|
||||
|
||||
TransformContext context = TransformationSpellHelper.GetContext( Caster );
|
||||
|
||||
if( context != null && context.Spell is ReaperFormSpell )
|
||||
damageBonus += ((ReaperFormSpell)context.Spell).SpellDamageBonus;
|
||||
|
||||
damage = AOS.Scale( damage, 100 + damageBonus );
|
||||
|
||||
int evalSkill = GetDamageFixed( m_Caster );
|
||||
|
|
@ -160,27 +157,6 @@ namespace Server.Spells
|
|||
return damage / 100;
|
||||
}
|
||||
|
||||
/*
|
||||
public virtual double GetAosDamage( int min, int random, double div )
|
||||
{
|
||||
double scale = 1.0;
|
||||
|
||||
scale += GetInscribeSkill( m_Caster ) * 0.001;
|
||||
|
||||
if ( Caster.Player )
|
||||
{
|
||||
scale += Caster.Int * 0.001;
|
||||
scale += AosAttributes.GetValue( m_Caster, AosAttribute.SpellDamage ) * 0.01;
|
||||
}
|
||||
|
||||
int baseDamage = min + (int)(GetDamageSkill( m_Caster ) / div);
|
||||
|
||||
double damage = Utility.RandomMinMax( baseDamage, baseDamage + random );
|
||||
|
||||
return damage * scale;
|
||||
}
|
||||
*/
|
||||
|
||||
public virtual bool IsCasting{ get{ return m_State == SpellState.Casting; } }
|
||||
|
||||
public virtual void OnCasterHurt()
|
||||
|
|
@ -263,36 +239,9 @@ namespace Server.Spells
|
|||
if ( pack.ConsumeTotal( m_Info.Reagents, m_Info.Amounts ) == -1 )
|
||||
return true;
|
||||
|
||||
if ( GetType().BaseType == typeof( Spell ) )
|
||||
{
|
||||
if ( ArcaneGem.ConsumeCharges( m_Caster, ( Core.SE ? 1 : 1 + (int)Circle ) ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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, 120.0 );
|
||||
|
||||
return ( n >= Utility.RandomDouble() );
|
||||
}
|
||||
|
||||
public virtual double GetInscribeSkill( Mobile m )
|
||||
{
|
||||
// There is no chance to gain
|
||||
|
|
@ -323,41 +272,11 @@ namespace Server.Spells
|
|||
return m.Skills[DamageSkill].Value;
|
||||
}
|
||||
|
||||
public virtual int GetResistFixed( Mobile m )
|
||||
{
|
||||
int maxSkill = (1 + (int)Circle) * 10;
|
||||
maxSkill += (1 + ((int)Circle / 6)) * 25;
|
||||
|
||||
if ( m.Skills[SkillName.MagicResist].Value < maxSkill )
|
||||
m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );
|
||||
|
||||
return m.Skills[SkillName.MagicResist].Fixed;
|
||||
}
|
||||
|
||||
public virtual double GetResistSkill( Mobile m )
|
||||
{
|
||||
int maxSkill = (1 + (int)Circle) * 10;
|
||||
maxSkill += (1 + ((int)Circle / 6)) * 25;
|
||||
|
||||
if ( m.Skills[SkillName.MagicResist].Value < maxSkill )
|
||||
m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );
|
||||
|
||||
return m.Skills[SkillName.MagicResist].Value;
|
||||
}
|
||||
|
||||
public virtual double GetResistPercentForCircle( Mobile target, SpellCircle circle )
|
||||
{
|
||||
double firstPercent = target.Skills[SkillName.MagicResist].Value / 5.0;
|
||||
double secondPercent = target.Skills[SkillName.MagicResist].Value - (((m_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, m_Info.Circle );
|
||||
}
|
||||
|
||||
public virtual double GetDamageScalar( Mobile target )
|
||||
{
|
||||
double scalar = 1.0;
|
||||
|
|
@ -397,6 +316,9 @@ namespace Server.Spells
|
|||
|
||||
target.Region.SpellDamageScalar( m_Caster, target, ref scalar );
|
||||
|
||||
if( Evasion.CheckSpellEvasion( target ) ) //Only single target spells an be evaded
|
||||
scalar = 0;
|
||||
|
||||
return scalar;
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +339,7 @@ namespace Server.Spells
|
|||
}
|
||||
|
||||
|
||||
TransformContext context = TransformationSpell.GetContext( defender );
|
||||
TransformContext context = TransformationSpellHelper.GetContext( defender );
|
||||
|
||||
if( (atkBook.Slayer == SlayerName.Silver || atkBook.Slayer2 == SlayerName.Silver) && context != null && context.Type != typeof( HorrificBeastSpell ) )
|
||||
scalar +=.25; // Every necromancer transformation other than horrific beast take an additional 25% damage
|
||||
|
|
@ -481,7 +403,7 @@ namespace Server.Spells
|
|||
|
||||
if ( m_State == SpellState.Casting )
|
||||
{
|
||||
if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
|
||||
if( !firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First )
|
||||
return;
|
||||
|
||||
m_State = SpellState.None;
|
||||
|
|
@ -502,7 +424,7 @@ namespace Server.Spells
|
|||
}
|
||||
else if ( m_State == SpellState.Sequencing )
|
||||
{
|
||||
if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
|
||||
if( !firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First )
|
||||
return;
|
||||
|
||||
m_State = SpellState.None;
|
||||
|
|
@ -564,7 +486,7 @@ namespace Server.Spells
|
|||
{
|
||||
m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
|
||||
}
|
||||
else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
|
||||
else if ( BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
|
||||
{
|
||||
m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
|
||||
}
|
||||
|
|
@ -636,19 +558,9 @@ namespace Server.Spells
|
|||
{
|
||||
}
|
||||
|
||||
private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0;
|
||||
|
||||
public virtual void GetCastSkills( out double min, out double max )
|
||||
{
|
||||
int circle = (int)m_Info.Circle;
|
||||
|
||||
if ( m_Scroll != null )
|
||||
circle -= 2;
|
||||
|
||||
double avg = ChanceLength * circle;
|
||||
|
||||
min = avg - ChanceOffset;
|
||||
max = avg + ChanceOffset;
|
||||
min = max = 0; //Intended but not required for overriding.
|
||||
}
|
||||
|
||||
public virtual bool CheckFizzle()
|
||||
|
|
@ -663,15 +575,7 @@ namespace Server.Spells
|
|||
return Caster.CheckSkill( CastSkill, minSkill, maxSkill );
|
||||
}
|
||||
|
||||
private static int[] m_ManaTable = new int[]{ 4, 6, 9, 11, 14, 20, 40, 50 };
|
||||
|
||||
public virtual int GetMana()
|
||||
{
|
||||
if ( m_Scroll is BaseWand )
|
||||
return 0;
|
||||
|
||||
return m_ManaTable[(int)Circle];
|
||||
}
|
||||
public abstract int GetMana();
|
||||
|
||||
public virtual int ScaleMana( int mana )
|
||||
{
|
||||
|
|
@ -704,7 +608,6 @@ namespace Server.Spells
|
|||
}
|
||||
|
||||
public virtual int CastRecoveryBase{ get{ return 6; } }
|
||||
public virtual int CastRecoveryCircleScalar{ get{ return 0; } }
|
||||
public virtual int CastRecoveryFastScalar{ get{ return 1; } }
|
||||
public virtual int CastRecoveryPerSecond{ get{ return 4; } }
|
||||
public virtual int CastRecoveryMinimum{ get{ return 0; } }
|
||||
|
|
@ -716,10 +619,11 @@ namespace Server.Spells
|
|||
|
||||
int fcr = AosAttributes.GetValue( m_Caster, AosAttribute.CastRecovery );
|
||||
|
||||
int circleDelay = CastRecoveryCircleScalar * (1 + (int)Circle); // Note: Circle is 0-based so we must offset
|
||||
fcr -= ThunderstormSpell.GetCastRecoveryMalus( m_Caster );
|
||||
|
||||
int fcrDelay = -(CastRecoveryFastScalar * fcr);
|
||||
|
||||
int delay = CastRecoveryBase + circleDelay + fcrDelay;
|
||||
int delay = CastRecoveryBase + fcrDelay;
|
||||
|
||||
if ( delay < CastRecoveryMinimum )
|
||||
delay = CastRecoveryMinimum;
|
||||
|
|
@ -727,20 +631,24 @@ namespace Server.Spells
|
|||
return TimeSpan.FromSeconds( (double)delay / CastRecoveryPerSecond );
|
||||
}
|
||||
|
||||
public virtual int CastDelayBase{ get{ return 3; } }
|
||||
public virtual int CastDelayCircleScalar{ get{ return 1; } }
|
||||
public virtual int CastDelayFastScalar{ get{ return 1; } }
|
||||
public virtual int CastDelayPerSecond{ get{ return 4; } }
|
||||
public virtual int CastDelayMinimum{ get{ return 1; } }
|
||||
|
||||
|
||||
public abstract TimeSpan CastDelayBase { get; }
|
||||
|
||||
public virtual double CastDelayFastScalar { get { return 1; } }
|
||||
public virtual double CastDelaySecondsPerTick { get { return 0.25; } }
|
||||
public virtual TimeSpan CastDelayMinimum { get { return TimeSpan.FromSeconds( 0.25 ); } }
|
||||
|
||||
//public virtual int CastDelayBase{ get{ return 3; } }
|
||||
//public virtual int CastDelayFastScalar{ get{ return 1; } }
|
||||
//public virtual int CastDelayPerSecond{ get{ return 4; } }
|
||||
//public virtual int CastDelayMinimum{ get{ return 1; } }
|
||||
|
||||
public virtual TimeSpan GetCastDelay()
|
||||
{
|
||||
if ( m_Scroll is BaseWand )
|
||||
return TimeSpan.Zero;
|
||||
|
||||
if ( !Core.AOS )
|
||||
return TimeSpan.FromSeconds( 0.5 + (0.25 * (int)Circle) );
|
||||
|
||||
// Faster casting cap of 2 (if not using the protection spell)
|
||||
// Faster casting cap of 0 (if using the protection spell)
|
||||
// Paladin spells are subject to a faster casting cap of 4
|
||||
|
|
@ -758,17 +666,21 @@ namespace Server.Spells
|
|||
if ( ProtectionSpell.Registry.Contains( m_Caster ) )
|
||||
fc -= 2;
|
||||
|
||||
// Circle is 0-based but we must not offset, first circle spells are cast at base delay.
|
||||
int circleDelay = CastDelayCircleScalar * (int)Circle;
|
||||
if( EssenceOfWindSpell.IsDebuffed( m_Caster ) )
|
||||
fc -= EssenceOfWindSpell.GetFCMalus( m_Caster );
|
||||
|
||||
int fcDelay = -(CastDelayFastScalar * fc);
|
||||
TimeSpan baseDelay = CastDelayBase;
|
||||
|
||||
int delay = CastDelayBase + circleDelay + fcDelay;
|
||||
TimeSpan fcDelay = TimeSpan.FromSeconds( -(CastDelayFastScalar * fc * CastDelaySecondsPerTick) );
|
||||
|
||||
//int delay = CastDelayBase + circleDelay + fcDelay;
|
||||
TimeSpan delay = baseDelay + fcDelay;
|
||||
|
||||
if ( delay < CastDelayMinimum )
|
||||
delay = CastDelayMinimum;
|
||||
|
||||
return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond );
|
||||
//return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond );
|
||||
return delay;
|
||||
}
|
||||
|
||||
public virtual void FinishSequence()
|
||||
|
|
@ -840,7 +752,7 @@ namespace Server.Spells
|
|||
if ( karma != 0 )
|
||||
Misc.Titles.AwardKarma( Caster, karma, true );
|
||||
|
||||
if ( TransformationSpell.UnderTransformation( m_Caster, typeof( VampiricEmbraceSpell ) ) )
|
||||
if( TransformationSpellHelper.UnderTransformation( m_Caster, typeof( VampiricEmbraceSpell ) ) )
|
||||
{
|
||||
bool garlic = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ using Server.Targeting;
|
|||
using Server.Engines.PartySystem;
|
||||
using Server.Misc;
|
||||
using Server.Spells.Bushido;
|
||||
using Server.Spells.Ninjitsu;
|
||||
using System.Collections.Generic;
|
||||
using Server.Spells.Seventh;
|
||||
using Server.Spells.Fifth;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -423,6 +427,16 @@ namespace Server.Spells
|
|||
creature.Mana = creature.ManaMax;
|
||||
}
|
||||
|
||||
Point3D p = new Point3D( caster );
|
||||
|
||||
if( SpellHelper.FindValidSpawnLocation( map, ref p, true ) )
|
||||
{
|
||||
BaseCreature.Summon( creature, caster, p, sound, duration );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int offset = Utility.Random( 8 ) * 2;
|
||||
|
||||
for( int i = 0; i < m_Offsets.Length; i += 2 )
|
||||
|
|
@ -446,11 +460,61 @@ namespace Server.Spells
|
|||
}
|
||||
}
|
||||
}
|
||||
* */
|
||||
|
||||
creature.Delete();
|
||||
caster.SendLocalizedMessage( 501942 ); // That location is blocked.
|
||||
}
|
||||
|
||||
public static bool FindValidSpawnLocation( Map map, ref Point3D p, bool surroundingsOnly )
|
||||
{
|
||||
if( map == null ) //sanity
|
||||
return false;
|
||||
|
||||
if( !surroundingsOnly )
|
||||
{
|
||||
if( map.CanSpawnMobile( p ) ) //p's fine.
|
||||
{
|
||||
p = new Point3D( p );
|
||||
return true;
|
||||
}
|
||||
|
||||
int z = map.GetAverageZ( p.X, p.Y );
|
||||
|
||||
if( map.CanSpawnMobile( p.X, p.Y, z ) )
|
||||
{
|
||||
p = new Point3D( p.X, p.Y, z );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int offset = Utility.Random( 8 ) * 2;
|
||||
|
||||
for( int i = 0; i < m_Offsets.Length; i += 2 )
|
||||
{
|
||||
int x = p.X + m_Offsets[(offset + i) % m_Offsets.Length];
|
||||
int y = p.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];
|
||||
|
||||
if( map.CanSpawnMobile( x, y, p.Z ) )
|
||||
{
|
||||
p = new Point3D( x, y, p.Z );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int z = map.GetAverageZ( x, y );
|
||||
|
||||
if( map.CanSpawnMobile( x, y, z ) )
|
||||
{
|
||||
p = new Point3D( x, y, z );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private delegate bool TravelValidator( Map map, Point3D loc );
|
||||
|
||||
private static TravelValidator[] m_Validators = new TravelValidator[]
|
||||
|
|
@ -789,9 +853,6 @@ namespace Server.Spells
|
|||
{
|
||||
int iDamage = (int)damage;
|
||||
|
||||
if( Evasion.CheckSpellEvasion( target ) )
|
||||
iDamage = 0;
|
||||
|
||||
if( delay == TimeSpan.Zero )
|
||||
{
|
||||
if( from is BaseCreature )
|
||||
|
|
@ -844,9 +905,6 @@ namespace Server.Spells
|
|||
{
|
||||
int iDamage = (int)damage;
|
||||
|
||||
if( Evasion.CheckSpellEvasion( target ) )
|
||||
iDamage = 0;
|
||||
|
||||
if( delay == TimeSpan.Zero )
|
||||
{
|
||||
if( from is BaseCreature )
|
||||
|
|
@ -868,6 +926,16 @@ namespace Server.Spells
|
|||
((BaseCreature)target).OnDamagedBySpell( from );
|
||||
}
|
||||
|
||||
public static void Heal( int amount, Mobile target, Mobile from )
|
||||
{
|
||||
Heal( amount, target, from, true );
|
||||
}
|
||||
public static void Heal( int amount, Mobile target, Mobile from, bool message )
|
||||
{
|
||||
//TODO: All Healing *spells* go through ArcaneEmpowerment
|
||||
target.Heal( amount, from, message );
|
||||
}
|
||||
|
||||
private class SpellDamageTimer : Timer
|
||||
{
|
||||
private Mobile m_Target, m_From;
|
||||
|
|
@ -950,4 +1018,244 @@ namespace Server.Spells
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TransformationSpellHelper
|
||||
{
|
||||
#region Context Stuff
|
||||
private static Dictionary<Mobile, TransformContext> m_Table = new Dictionary<Mobile, TransformContext>();
|
||||
|
||||
public static void AddContext( Mobile m, TransformContext context )
|
||||
{
|
||||
m_Table[m] = context;
|
||||
}
|
||||
|
||||
public static void RemoveContext( Mobile m, bool resetGraphics )
|
||||
{
|
||||
TransformContext context = GetContext( m );
|
||||
|
||||
if( context != null )
|
||||
RemoveContext( m, context, resetGraphics );
|
||||
}
|
||||
|
||||
public static void RemoveContext( Mobile m, TransformContext context, bool resetGraphics )
|
||||
{
|
||||
if( m_Table.ContainsKey( m ) )
|
||||
{
|
||||
m_Table.Remove( m );
|
||||
|
||||
List<ResistanceMod> mods = context.Mods;
|
||||
|
||||
for( int i = 0; i < mods.Count; ++i )
|
||||
m.RemoveResistanceMod( mods[i] );
|
||||
|
||||
if( resetGraphics )
|
||||
{
|
||||
m.HueMod = -1;
|
||||
m.BodyMod = 0;
|
||||
}
|
||||
|
||||
context.Timer.Stop();
|
||||
context.Spell.RemoveEffect( m );
|
||||
}
|
||||
}
|
||||
|
||||
public static TransformContext GetContext( Mobile m )
|
||||
{
|
||||
TransformContext context = null;
|
||||
|
||||
m_Table.TryGetValue( m, out context );
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
public static bool UnderTransformation( Mobile m )
|
||||
{
|
||||
return (GetContext( m ) != null);
|
||||
}
|
||||
|
||||
public static bool UnderTransformation( Mobile m, Type type )
|
||||
{
|
||||
TransformContext context = GetContext( m );
|
||||
|
||||
return (context != null && context.Type == type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static bool CheckCast( Mobile caster, Spell spell )
|
||||
{
|
||||
if( Factions.Sigil.ExistsOn( caster ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
|
||||
return false;
|
||||
}
|
||||
else if( !caster.CanBeginAction( typeof( PolymorphSpell ) ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061628 ); // You can't do that while polymorphed.
|
||||
return false;
|
||||
}
|
||||
else if( AnimalForm.UnderTransformation( caster ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool OnCast( Mobile caster, Spell spell )
|
||||
{
|
||||
ITransformationSpell transformSpell = spell as ITransformationSpell;
|
||||
|
||||
if( transformSpell == null )
|
||||
return false;
|
||||
|
||||
if( Factions.Sigil.ExistsOn( caster ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
|
||||
}
|
||||
else if( !caster.CanBeginAction( typeof( PolymorphSpell ) ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061628 ); // You can't do that while polymorphed.
|
||||
}
|
||||
else if( AnimalForm.UnderTransformation( caster ) )
|
||||
{
|
||||
caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
|
||||
}
|
||||
else if( !caster.CanBeginAction( typeof( IncognitoSpell ) ) || (caster.IsBodyMod && GetContext( caster ) == null) )
|
||||
{
|
||||
spell.DoFizzle();
|
||||
}
|
||||
else if( spell.CheckSequence() )
|
||||
{
|
||||
TransformContext context = GetContext( caster );
|
||||
Type ourType = spell.GetType();
|
||||
|
||||
bool wasTransformed = (context != null);
|
||||
bool ourTransform = (wasTransformed && context.Type == ourType);
|
||||
|
||||
if( wasTransformed )
|
||||
{
|
||||
RemoveContext( caster, context, ourTransform );
|
||||
|
||||
if( ourTransform )
|
||||
{
|
||||
caster.PlaySound( 0xFA );
|
||||
caster.FixedParticles( 0x3728, 1, 13, 5042, EffectLayer.Waist );
|
||||
}
|
||||
}
|
||||
|
||||
if( !ourTransform )
|
||||
{
|
||||
List<ResistanceMod> mods = new List<ResistanceMod>();
|
||||
|
||||
if( transformSpell.PhysResistOffset != 0 )
|
||||
mods.Add( new ResistanceMod( ResistanceType.Physical, transformSpell.PhysResistOffset ) );
|
||||
|
||||
if( transformSpell.FireResistOffset != 0 )
|
||||
mods.Add( new ResistanceMod( ResistanceType.Fire, transformSpell.FireResistOffset ) );
|
||||
|
||||
if( transformSpell.ColdResistOffset != 0 )
|
||||
mods.Add( new ResistanceMod( ResistanceType.Cold, transformSpell.ColdResistOffset ) );
|
||||
|
||||
if( transformSpell.PoisResistOffset != 0 )
|
||||
mods.Add( new ResistanceMod( ResistanceType.Poison, transformSpell.PoisResistOffset ) );
|
||||
|
||||
if( transformSpell.NrgyResistOffset != 0 )
|
||||
mods.Add( new ResistanceMod( ResistanceType.Energy, transformSpell.NrgyResistOffset ) );
|
||||
|
||||
if( !((Body)transformSpell.Body).IsHuman )
|
||||
{
|
||||
Mobiles.IMount mt = caster.Mount;
|
||||
|
||||
if( mt != null )
|
||||
mt.Rider = null;
|
||||
}
|
||||
|
||||
caster.BodyMod = transformSpell.Body;
|
||||
caster.HueMod = transformSpell.Hue;
|
||||
|
||||
for( int i = 0; i < mods.Count; ++i )
|
||||
caster.AddResistanceMod( mods[i] );
|
||||
|
||||
transformSpell.DoEffect( caster );
|
||||
|
||||
Timer timer = new TransformTimer( caster, transformSpell );
|
||||
timer.Start();
|
||||
|
||||
AddContext( caster, new TransformContext( timer, mods, ourType, transformSpell ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITransformationSpell
|
||||
{
|
||||
int Body { get; }
|
||||
int Hue { get; }
|
||||
|
||||
int PhysResistOffset { get; }
|
||||
int FireResistOffset { get; }
|
||||
int ColdResistOffset { get; }
|
||||
int PoisResistOffset { get; }
|
||||
int NrgyResistOffset { get; }
|
||||
|
||||
double TickRate { get; }
|
||||
void OnTick( Mobile m );
|
||||
|
||||
void DoEffect( Mobile m );
|
||||
void RemoveEffect( Mobile m );
|
||||
}
|
||||
|
||||
|
||||
public class TransformContext
|
||||
{
|
||||
private Timer m_Timer;
|
||||
private List<ResistanceMod> m_Mods;
|
||||
private Type m_Type;
|
||||
private ITransformationSpell m_Spell;
|
||||
|
||||
public Timer Timer { get { return m_Timer; } }
|
||||
public List<ResistanceMod> Mods { get { return m_Mods; } }
|
||||
public Type Type { get { return m_Type; } }
|
||||
public ITransformationSpell Spell { get { return m_Spell; } }
|
||||
|
||||
public TransformContext( Timer timer, List<ResistanceMod> mods, Type type, ITransformationSpell spell )
|
||||
{
|
||||
m_Timer = timer;
|
||||
m_Mods = mods;
|
||||
m_Type = type;
|
||||
m_Spell = spell;
|
||||
}
|
||||
}
|
||||
|
||||
public class TransformTimer : Timer
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private ITransformationSpell m_Spell;
|
||||
|
||||
public TransformTimer( Mobile from, ITransformationSpell spell )
|
||||
: base( TimeSpan.FromSeconds( spell.TickRate ), TimeSpan.FromSeconds( spell.TickRate ) )
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Spell = spell;
|
||||
|
||||
Priority = TimerPriority.TwoFiftyMS;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if( m_Mobile.Deleted || !m_Mobile.Alive || m_Mobile.Body != m_Spell.Body || m_Mobile.Hue != m_Spell.Hue )
|
||||
{
|
||||
TransformationSpellHelper.RemoveContext( m_Mobile, true );
|
||||
Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Spell.OnTick( m_Mobile );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,42 +7,40 @@ namespace Server.Spells
|
|||
{
|
||||
private string m_Name;
|
||||
private string m_Mantra;
|
||||
private SpellCircle m_Circle;
|
||||
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, SpellCircle circle, params Type[] regs ) : this( name, mantra, circle, 16, 0, 0, true, regs )
|
||||
public SpellInfo( string name, string mantra, params Type[] regs ) : this( name, mantra, 16, 0, 0, true, regs )
|
||||
{
|
||||
}
|
||||
|
||||
public SpellInfo( string name, string mantra, SpellCircle circle, bool allowTown, params Type[] regs ) : this( name, mantra, circle, 16, 0, 0, allowTown, 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, SpellCircle circle, int action, params Type[] regs ) : this( name, mantra, circle, action, 0, 0, true, 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, SpellCircle circle, int action, bool allowTown, params Type[] regs ) : this( name, mantra, circle, action, 0, 0, allowTown, 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, SpellCircle circle, int action, int handEffect, params Type[] regs ) : this( name, mantra, circle, action, handEffect, handEffect, true, 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, SpellCircle circle, int action, int handEffect, bool allowTown, params Type[] regs ) : this( name, mantra, circle, action, handEffect, handEffect, allowTown, 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, SpellCircle circle, int action, int leftHandEffect, int rightHandEffect, bool allowTown, params Type[] regs )
|
||||
public SpellInfo( string name, string mantra, int action, int leftHandEffect, int rightHandEffect, bool allowTown, params Type[] regs )
|
||||
{
|
||||
m_Name = name;
|
||||
m_Mantra = mantra;
|
||||
m_Circle = circle;
|
||||
m_Action = action;
|
||||
m_Reagents = regs;
|
||||
m_AllowTown = allowTown;
|
||||
|
|
@ -59,7 +57,6 @@ namespace Server.Spells
|
|||
public int Action{ get{ return m_Action; } set{ m_Action = value; } }
|
||||
public bool AllowTown{ get{ return m_AllowTown; } set{ m_AllowTown = value; } }
|
||||
public int[] Amounts{ get{ return m_Amounts; } set{ m_Amounts = value; } }
|
||||
public SpellCircle Circle{ get{ return m_Circle; } set{ m_Circle = value; } }
|
||||
public string Mantra{ get{ return m_Mantra; } set{ m_Mantra = value; } }
|
||||
public string Name{ get{ return m_Name; } set{ m_Name = value; } }
|
||||
public Type[] Reagents{ get{ return m_Reagents; } set{ m_Reagents = value; } }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Spells
|
|||
{
|
||||
public class SpellRegistry
|
||||
{
|
||||
private static Type[] m_Types = new Type[600];
|
||||
private static Type[] m_Types = new Type[700];
|
||||
private static int m_Count;
|
||||
|
||||
public static Type[] Types
|
||||
|
|
@ -146,7 +146,8 @@ namespace Server.Spells
|
|||
"Necromancy",
|
||||
"Chivalry",
|
||||
"Bushido",
|
||||
"Ninjitsu"
|
||||
"Ninjitsu",
|
||||
"SpellWeaving"
|
||||
};
|
||||
|
||||
public static Spell NewSpell( string name, Mobile caster, Item scroll )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue