Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,213 +1,205 @@
using System;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Gumps;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Spellweaving
{
public class GiftOfLifeSpell : ArcanistSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Gift of Life", "Illorae",
-1
);
public class GiftOfLifeSpell : ArcanistSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Gift of Life", "Illorae",
-1
);
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds( 4.0 );
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
public override double RequiredSkill => 38.0;
public override int RequiredMana => 70;
public GiftOfLifeSpell(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)
{
}
public GiftOfLifeSpell( Mobile caster, Item scroll )
: base( caster, scroll, m_Info )
{
}
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(4.0);
public static void Initialize()
{
EventSink.PlayerDeath += delegate( PlayerDeathEventArgs e )
{
HandleDeath( e.Mobile );
};
}
public override double RequiredSkill => 38.0;
public override int RequiredMana => 70;
public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}
public double HitsScalar => (Caster.Skills.Spellweaving.Value / 2.4 + FocusLevel) / 100;
public void Target( Mobile m )
{
BaseCreature bc = m as BaseCreature;
public static void Initialize()
{
EventSink.PlayerDeath += delegate(PlayerDeathEventArgs e) { HandleDeath(e.Mobile); };
}
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( m.IsDeadBondedPet || !m.Alive )
{
// As per Osi: Nothing happens.
}
else if ( m != Caster && (bc == null || !bc.IsBonded || bc.ControlMaster != Caster) )
{
Caster.SendLocalizedMessage( 1072077 ); // You may only cast this spell on yourself or a bonded pet.
}
else if ( m_Table.ContainsKey( m ) )
{
Caster.SendLocalizedMessage( 501775 ); // This spell is already in effect.
}
else if ( CheckBSequence( m ) )
{
if ( Caster == m )
{
Caster.SendLocalizedMessage( 1074774 ); // You weave powerful magic, protecting yourself from death.
}
else
{
Caster.SendLocalizedMessage( 1074775 ); // You weave powerful magic, protecting your pet from death.
SpellHelper.Turn( Caster, m );
}
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
}
public void Target(Mobile m)
{
BaseCreature bc = m as BaseCreature;
if (!Caster.CanSee(m))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (m.IsDeadBondedPet || !m.Alive)
{
// As per Osi: Nothing happens.
}
else if (m != Caster && (bc == null || !bc.IsBonded || bc.ControlMaster != Caster))
{
Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
else if (m_Table.ContainsKey(m))
{
Caster.SendLocalizedMessage(501775); // This spell is already in effect.
}
else if (CheckBSequence(m))
{
if (Caster == m)
{
Caster.SendLocalizedMessage(1074774); // You weave powerful magic, protecting yourself from death.
}
else
{
Caster.SendLocalizedMessage(1074775); // You weave powerful magic, protecting your pet from death.
SpellHelper.Turn(Caster, m);
}
m.PlaySound( 0x244 );
m.FixedParticles( 0x3709, 1, 30, 0x26ED, 5, 2, EffectLayer.Waist );
m.FixedParticles( 0x376A, 1, 30, 0x251E, 5, 3, EffectLayer.Waist );
m.PlaySound(0x244);
m.FixedParticles(0x3709, 1, 30, 0x26ED, 5, 2, EffectLayer.Waist);
m.FixedParticles(0x376A, 1, 30, 0x251E, 5, 3, EffectLayer.Waist);
double skill = Caster.Skills[SkillName.Spellweaving].Value;
double skill = Caster.Skills[SkillName.Spellweaving].Value;
TimeSpan duration = TimeSpan.FromMinutes( ((int)(skill / 24))* 2 + FocusLevel );
TimeSpan duration = TimeSpan.FromMinutes((int)(skill / 24) * 2 + FocusLevel);
ExpireTimer t = new ExpireTimer( m, duration, this );
t.Start();
ExpireTimer t = new ExpireTimer(m, duration, this);
t.Start();
m_Table[m] = t;
m_Table[m] = t;
BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.GiftOfLife, 1031615, 1075807, duration, m, null, true ) );
}
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.GiftOfLife, 1031615, 1075807, duration, m, null, true));
}
FinishSequence();
}
FinishSequence();
}
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
public static void HandleDeath(Mobile m)
{
if (m_Table.ContainsKey(m))
Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(2, 4)), HandleDeath_OnCallback, m);
}
public static void HandleDeath( Mobile m )
{
if ( m_Table.ContainsKey( m ) )
Timer.DelayCall<Mobile>( TimeSpan.FromSeconds( Utility.RandomMinMax( 2, 4 ) ), HandleDeath_OnCallback, m );
}
private static void HandleDeath_OnCallback(Mobile m)
{
if (m_Table.TryGetValue(m, out ExpireTimer timer))
{
double hitsScalar = timer.Spell.HitsScalar;
private static void HandleDeath_OnCallback( Mobile m )
{
if (m_Table.TryGetValue( m, out ExpireTimer timer ))
{
double hitsScalar = timer.Spell.HitsScalar;
if (m is BaseCreature && m.IsDeadBondedPet)
{
BaseCreature pet = (BaseCreature)m;
Mobile master = pet.GetMaster();
if ( m is BaseCreature && m.IsDeadBondedPet )
{
BaseCreature pet = (BaseCreature)m;
Mobile master = pet.GetMaster();
if (master?.NetState != null && Utility.InUpdateRange(pet, master))
{
master.CloseGump(typeof(PetResurrectGump));
master.SendGump(new PetResurrectGump(master, pet, hitsScalar));
}
else
{
List<Mobile> friends = pet.Friends;
if ( master?.NetState != null && Utility.InUpdateRange( pet, master ) )
{
master.CloseGump( typeof( PetResurrectGump ) );
master.SendGump( new PetResurrectGump( master, pet, hitsScalar ) );
}
else
{
List<Mobile> friends = pet.Friends;
for (int i = 0; friends != null && i < friends.Count; i++)
{
Mobile friend = friends[i];
for( int i = 0; friends != null && i < friends.Count; i++ )
{
Mobile friend = friends[i];
if (friend.NetState != null && Utility.InUpdateRange(pet, friend))
{
friend.CloseGump(typeof(PetResurrectGump));
friend.SendGump(new PetResurrectGump(friend, pet));
break;
}
}
}
}
else
{
m.CloseGump(typeof(ResurrectGump));
m.SendGump(new ResurrectGump(m, hitsScalar));
}
if ( friend.NetState != null && Utility.InUpdateRange( pet, friend ) )
{
friend.CloseGump( typeof( PetResurrectGump ) );
friend.SendGump( new PetResurrectGump( friend, pet ) );
break;
}
}
}
}
else
{
m.CloseGump( typeof( ResurrectGump ) );
m.SendGump( new ResurrectGump( m, hitsScalar ) );
}
//Per OSI, buff is removed when gump sent, irregardless of online status or acceptence
timer.DoExpire();
}
}
//Per OSI, buff is removed when gump sent, irregardless of online status or acceptence
timer.DoExpire();
}
public static void OnLogin(LoginEventArgs e)
{
Mobile m = e.Mobile;
}
if (m == null || m.Alive || m_Table[m] == null)
return;
public double HitsScalar => ((Caster.Skills.Spellweaving.Value/2.4) + FocusLevel)/100;
HandleDeath_OnCallback(m);
}
public static void OnLogin( LoginEventArgs e )
{
Mobile m = e.Mobile;
private class ExpireTimer : Timer
{
private Mobile m_Mobile;
if ( m == null || m.Alive || m_Table[m] == null )
return;
public ExpireTimer(Mobile m, TimeSpan delay, GiftOfLifeSpell spell)
: base(delay)
{
m_Mobile = m;
Spell = spell;
}
HandleDeath_OnCallback( m );
}
public GiftOfLifeSpell Spell{ get; }
private class ExpireTimer : Timer
{
private Mobile m_Mobile;
protected override void OnTick()
{
DoExpire();
}
public GiftOfLifeSpell Spell { get; }
public void DoExpire()
{
Stop();
public ExpireTimer( Mobile m, TimeSpan delay, GiftOfLifeSpell spell )
: base( delay )
{
m_Mobile = m;
Spell = spell;
}
m_Mobile.SendLocalizedMessage(1074776); // You are no longer protected with Gift of Life.
m_Table.Remove(m_Mobile);
protected override void OnTick()
{
DoExpire();
}
BuffInfo.RemoveBuff(m_Mobile, BuffIcon.GiftOfLife);
}
}
public void DoExpire()
{
Stop();
public class InternalTarget : Target
{
private GiftOfLifeSpell m_Owner;
m_Mobile.SendLocalizedMessage( 1074776 ); // You are no longer protected with Gift of Life.
m_Table.Remove( m_Mobile );
public InternalTarget(GiftOfLifeSpell owner)
: base(10, false, TargetFlags.Beneficial)
{
m_Owner = owner;
}
BuffInfo.RemoveBuff( m_Mobile, BuffIcon.GiftOfLife );
}
}
protected override void OnTarget(Mobile m, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
else
m.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
public class InternalTarget : Target
{
private GiftOfLifeSpell m_Owner;
public InternalTarget( GiftOfLifeSpell owner )
: base( 10, false, TargetFlags.Beneficial )
{
m_Owner = owner;
}
protected override void OnTarget( Mobile m, object o )
{
if ( o is Mobile )
{
m_Owner.Target( (Mobile)o );
}
else
{
m.SendLocalizedMessage( 1072077 ); // You may only cast this spell on yourself or a bonded pet.
}
}
protected override void OnTargetFinish( Mobile m )
{
m_Owner.FinishSequence();
}
}
}
}
protected override void OnTargetFinish(Mobile m)
{
m_Owner.FinishSequence();
}
}
}
}