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,99 +1,103 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.SkillHandlers
{
class Meditation
{
public static void Initialize()
{
SkillInfo.Table[46].Callback = OnUse;
}
internal class Meditation
{
public static void Initialize()
{
SkillInfo.Table[46].Callback = OnUse;
}
public static bool CheckOkayHolding( Item item )
{
if ( item == null )
return true;
public static bool CheckOkayHolding(Item item)
{
if (item == null)
return true;
if ( item is Spellbook || item is Runebook )
return true;
if (item is Spellbook || item is Runebook)
return true;
if ( Core.AOS && item is BaseWeapon && ((BaseWeapon)item).Attributes.SpellChanneling != 0 )
return true;
if (Core.AOS && item is BaseWeapon && ((BaseWeapon)item).Attributes.SpellChanneling != 0)
return true;
if ( Core.AOS && item is BaseArmor && ((BaseArmor)item).Attributes.SpellChanneling != 0 )
return true;
if (Core.AOS && item is BaseArmor && ((BaseArmor)item).Attributes.SpellChanneling != 0)
return true;
return false;
}
return false;
}
public static TimeSpan OnUse( Mobile m )
{
m.RevealingAction();
public static TimeSpan OnUse(Mobile m)
{
m.RevealingAction();
if ( m.Target != null )
{
m.SendLocalizedMessage( 501845 ); // You are busy doing something else and cannot focus.
if (m.Target != null)
{
m.SendLocalizedMessage(501845); // You are busy doing something else and cannot focus.
return TimeSpan.FromSeconds( 5.0 );
}
return TimeSpan.FromSeconds(5.0);
}
if ( !Core.AOS && m.Hits < (m.HitsMax / 10) ) // Less than 10% health
{
m.SendLocalizedMessage( 501849 ); // The mind is strong but the body is weak.
if (!Core.AOS && m.Hits < m.HitsMax / 10) // Less than 10% health
{
m.SendLocalizedMessage(501849); // The mind is strong but the body is weak.
return TimeSpan.FromSeconds( 5.0 );
}
if ( m.Mana >= m.ManaMax )
{
m.SendLocalizedMessage( 501846 ); // You are at peace.
return TimeSpan.FromSeconds(5.0);
}
return TimeSpan.FromSeconds( Core.AOS ? 10.0 : 5.0 );
}
if ( Core.AOS && Misc.RegenRates.GetArmorOffset( m ) > 0 )
{
m.SendLocalizedMessage( 500135 ); // Regenerative forces cannot penetrate your armor!
if (m.Mana >= m.ManaMax)
{
m.SendLocalizedMessage(501846); // You are at peace.
return TimeSpan.FromSeconds( 10.0 );
}
Item oneHanded = m.FindItemOnLayer( Layer.OneHanded );
Item twoHanded = m.FindItemOnLayer( Layer.TwoHanded );
return TimeSpan.FromSeconds(Core.AOS ? 10.0 : 5.0);
}
if ( Core.AOS && m.Player )
{
if ( !CheckOkayHolding( oneHanded ) )
m.AddToBackpack( oneHanded );
if (Core.AOS && RegenRates.GetArmorOffset(m) > 0)
{
m.SendLocalizedMessage(500135); // Regenerative forces cannot penetrate your armor!
if ( !CheckOkayHolding( twoHanded ) )
m.AddToBackpack( twoHanded );
}
else if ( !CheckOkayHolding( oneHanded ) || !CheckOkayHolding( twoHanded ) )
{
m.SendLocalizedMessage( 502626 ); // Your hands must be free to cast spells or meditate.
return TimeSpan.FromSeconds(10.0);
}
return TimeSpan.FromSeconds( 2.5 );
}
Item oneHanded = m.FindItemOnLayer(Layer.OneHanded);
Item twoHanded = m.FindItemOnLayer(Layer.TwoHanded);
double skillVal = m.Skills[SkillName.Meditation].Value;
double chance = (50.0 + (( skillVal - ( m.ManaMax - m.Mana ) ) * 2)) / 100;
if (Core.AOS && m.Player)
{
if (!CheckOkayHolding(oneHanded))
m.AddToBackpack(oneHanded);
if ( chance > Utility.RandomDouble() )
{
m.CheckSkill( SkillName.Meditation, 0.0, 100.0 );
if (!CheckOkayHolding(twoHanded))
m.AddToBackpack(twoHanded);
}
else if (!CheckOkayHolding(oneHanded) || !CheckOkayHolding(twoHanded))
{
m.SendLocalizedMessage(502626); // Your hands must be free to cast spells or meditate.
m.SendLocalizedMessage( 501851 ); // You enter a meditative trance.
m.Meditating = true;
BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.ActiveMeditation, 1075657 ) );
return TimeSpan.FromSeconds(2.5);
}
if ( m.Player || m.Body.IsHuman )
m.PlaySound( 0xF9 );
}
else
{
m.SendLocalizedMessage( 501850 ); // You cannot focus your concentration.
}
double skillVal = m.Skills[SkillName.Meditation].Value;
double chance = (50.0 + (skillVal - (m.ManaMax - m.Mana)) * 2) / 100;
return TimeSpan.FromSeconds( 10.0 );
}
}
}
if (chance > Utility.RandomDouble())
{
m.CheckSkill(SkillName.Meditation, 0.0, 100.0);
m.SendLocalizedMessage(501851); // You enter a meditative trance.
m.Meditating = true;
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.ActiveMeditation, 1075657));
if (m.Player || m.Body.IsHuman)
m.PlaySound(0xF9);
}
else
{
m.SendLocalizedMessage(501850); // You cannot focus your concentration.
}
return TimeSpan.FromSeconds(10.0);
}
}
}