BritainKnights/Scripts/Skills/Stealth.cs

67 lines
No EOL
1.7 KiB
C#

using System;
using Server.Items;
using Server.Mobiles;
namespace Server.SkillHandlers
{
public class Stealth
{
public static void Initialize()
{
SkillInfo.Table[(int)SkillName.Stealth].Callback = new SkillUseCallback( OnUse );
}
public static TimeSpan OnUse( Mobile m )
{
if ( !m.Hidden )
{
m.SendLocalizedMessage( 502725 ); // You must hide first
}
else if ( m.Skills[SkillName.Hiding].Value < Utility.Random(101) )
{
m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
m.RevealingAction();
}
else if( !m.CanBeginAction( typeof( Stealth ) ) )
{
m.SendLocalizedMessage( 1063086 ); // You cannot use this skill right now.
m.RevealingAction();
}
else
{
int armorRating = (int)( BaseWeapon.ArmorRating( m ) / 2 );
if( armorRating >= 26 )
{
m.SendLocalizedMessage( 502727 ); // You could not hope to move quietly wearing this much armor.
m.RevealingAction();
}
else if( m.CheckSkill( SkillName.Stealth, -20.0 + (armorRating * 2), 80.0 + (armorRating * 2) ) )
{
int steps = (int)(m.Skills[SkillName.Stealth].Value / 10.0);
if( steps < 1 )
steps = 1;
m.AllowedStealthSteps = steps;
PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
if( pm != null )
pm.IsStealthing = true;
m.SendLocalizedMessage( 502730 ); // You begin to move quietly.
return TimeSpan.FromSeconds( 10.0 );
}
else
{
m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
m.RevealingAction();
}
}
return TimeSpan.FromSeconds( 10.0 );
}
}
}