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

@ -4,125 +4,119 @@ using Server.SkillHandlers;
namespace Server.Spells.Ninjitsu
{
public class SurpriseAttack : NinjaMove
{
public SurpriseAttack()
{
}
public class SurpriseAttack : NinjaMove
{
private static Hashtable m_Table = new Hashtable();
public override int BaseMana => 20;
public override double RequiredSkill => Core.ML ? 60.0 : 30.0;
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 TextDefinition AbilityMessage => new TextDefinition(1063128); // You prepare to surprise your prey.
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;
}
public override bool ValidatesDuringHit => false;
return base.Validate( from );
}
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;
}
public override bool OnBeforeSwing( Mobile attacker, Mobile defender )
{
bool valid = Validate( attacker ) && CheckMana( attacker, true );
return base.Validate(from);
}
if ( valid )
{
attacker.BeginAction( typeof( Stealth ) );
Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), delegate { attacker.EndAction( typeof( Stealth ) ); } );
}
public override bool OnBeforeSwing(Mobile attacker, Mobile defender)
{
bool valid = Validate(attacker) && CheckMana(attacker, true);
return valid;
if (valid)
{
attacker.BeginAction(typeof(Stealth));
Timer.DelayCall(TimeSpan.FromSeconds(5.0), delegate { attacker.EndAction(typeof(Stealth)); });
}
}
return valid;
}
public override bool ValidatesDuringHit => false;
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
//Validates before swing
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
//Validates before swing
ClearCurrentMove(attacker);
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!
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);
defender.FixedParticles( 0x37B9, 1, 5, 0x26DA, 0, 3, EffectLayer.Head );
attacker.RevealingAction();
attacker.RevealingAction();
SurpriseAttackInfo info;
SurpriseAttackInfo info;
if (m_Table.Contains(defender))
{
info = (SurpriseAttackInfo)m_Table[defender];
if ( m_Table.Contains( defender ) )
{
info = (SurpriseAttackInfo)m_Table[defender];
info.m_Timer?.Stop();
info.m_Timer?.Stop();
m_Table.Remove(defender);
}
m_Table.Remove( defender );
}
int ninjitsu = attacker.Skills[SkillName.Ninjitsu].Fixed;
int ninjitsu = attacker.Skills[SkillName.Ninjitsu].Fixed;
int malus = ninjitsu / 60 + (int)Tracking.GetStalkingBonus(attacker, defender);
int malus = ninjitsu / 60 + (int)Tracking.GetStalkingBonus( attacker, defender );
info = new SurpriseAttackInfo(defender, malus);
info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(8.0), new TimerStateCallback(EndSurprise), info);
info = new SurpriseAttackInfo( defender, malus );
info.m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 8.0 ), new TimerStateCallback( EndSurprise ), info );
m_Table[defender] = info;
m_Table[defender] = info;
CheckGain(attacker);
}
CheckGain( attacker );
}
public override void OnMiss(Mobile attacker, Mobile defender)
{
ClearCurrentMove(attacker);
public override void OnMiss( Mobile attacker, Mobile defender )
{
ClearCurrentMove( attacker );
attacker.SendLocalizedMessage(1063161); // You failed to properly use the element of surprise.
attacker.SendLocalizedMessage( 1063161 ); // You failed to properly use the element of surprise.
attacker.RevealingAction();
}
attacker.RevealingAction();
}
public static bool GetMalus(Mobile target, ref int malus)
{
SurpriseAttackInfo info = m_Table[target] as SurpriseAttackInfo;
if (info == null)
return false;
private static Hashtable m_Table = new Hashtable();
malus = info.m_Malus;
return true;
}
public static bool GetMalus( Mobile target, ref int malus )
{
SurpriseAttackInfo info = m_Table[target] as SurpriseAttackInfo;
private static void EndSurprise(object state)
{
SurpriseAttackInfo info = (SurpriseAttackInfo)state;
if ( info == null )
return false;
info.m_Timer?.Stop();
malus = info.m_Malus;
return true;
}
info.m_Target.SendLocalizedMessage(1063131); // Your defenses have returned to normal.
private class SurpriseAttackInfo
{
public Mobile m_Target;
public int m_Malus;
public Timer m_Timer;
m_Table.Remove(info.m_Target);
}
public SurpriseAttackInfo( Mobile target, int effect )
{
m_Target = target;
m_Malus = effect;
}
}
private class SurpriseAttackInfo
{
public int m_Malus;
public Mobile m_Target;
public Timer m_Timer;
private static void EndSurprise( object state )
{
SurpriseAttackInfo info = (SurpriseAttackInfo)state;
info.m_Timer?.Stop();
info.m_Target.SendLocalizedMessage( 1063131 ); // Your defenses have returned to normal.
m_Table.Remove( info.m_Target );
}
}
}
public SurpriseAttackInfo(Mobile target, int effect)
{
m_Target = target;
m_Malus = effect;
}
}
}
}