ModernUO/Scripts/Spells/Ninjitsu/KiAttack.cs
asayre ce54fe8635 Bug fix for :
skillcaps and things that exceed it
Possible threading issue
Addition of Generic FindItemsByType  - List<T> findItemsByType<T>()
Change to make polymorph not have a timer and instead a toggle skill
KiAttack no longer works with ranged weapons
Poison strike speed and damage changed
Necro spells now affected by FC
Must have atleast 50 weapon skill if no shield equipped to use Evasion
Stalking bonus capped at 10 + skill/10
Stalking bonus now Clears
Bugfix w/Guilds
Crashguard Exception message moved closer to the top of the file.
Character creation of Pallys and necros using advanced skills now gives skill items 
Honor no longer works on Players
Pre-ML area HitArea attacks nolonger require LoS
Serialization fix for BladeOfTheRighteous
RidingSwipe now has paralyzation immunity as with NerveStrike and ParaBlow
AnkhEast renamed to AnkhNorth
LeggingsOfBane no longer have 510 HP
ElvenWashBasinEastAddon Fixed
AnsellaGryen won't be renamed each time the server Restarts
DiseasedCats are properly named
Localization fixes in DefBlacksmithy
BearMasks/DearMAsks and things that extend from them now can be repaired
2006-08-19 23:24:47 +00:00

140 lines
No EOL
3.3 KiB
C#

using System;
using System.Collections;
using Server.Network;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Spells.Ninjitsu
{
public class KiAttack : NinjaMove
{
public KiAttack()
{
}
public override int BaseMana{ get{ return 25; } }
public override double RequiredSkill{ get{ return 80.0; } }
public override TextDefinition AbilityMessage{ get{ return new TextDefinition( 1063099 ); } } // Your Ki Attack must be complete within 2 seconds for the damage bonus!
public override void OnUse( Mobile from )
{
if ( !Validate( from ) )
return;
KiAttackInfo info = new KiAttackInfo( from );
info.m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 2.0 ), new TimerStateCallback( EndKiAttack ), info );
m_Table[from] = info;
}
public override bool Validate( Mobile from )
{
if ( from.Hidden && from.AllowedStealthSteps > 0 )
{
from.SendLocalizedMessage( 1063127 ); // You cannot use this ability while in stealth mode.
return false;
}
if( Core.ML )
{
BaseRanged ranged = from.Weapon as BaseRanged;
if( ranged != null )
{
from.SendLocalizedMessage( 1075858 ); // You can only use this with melee attacks.
return false;
}
}
return base.Validate( from );
}
public override double GetDamageScalar( Mobile attacker, Mobile defender )
{
if ( attacker.Hidden )
return 1.0;
return 1.0 + GetBonus( attacker ) / 10;
}
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
if ( !Validate( attacker ) || !CheckMana( attacker, true ) )
return;
if ( GetBonus( attacker ) == 0.0 )
{
attacker.SendLocalizedMessage( 1063101 ); // You were too close to your target to cause any additional damage.
}
else
{
attacker.SendLocalizedMessage( 1063100 ); // Your quick flight to your target causes extra damage as you strike!
defender.FixedParticles( 0x37BE, 1, 5, 0x26BD, 0, 0x1, EffectLayer.Waist );
}
ClearCurrentMove( attacker );
}
public override void OnClearMove( Mobile from )
{
KiAttackInfo info = m_Table[from] as KiAttackInfo;
if ( info != null )
{
if ( info.m_Timer != null )
info.m_Timer.Stop();
m_Table.Remove( info.m_Mobile );
}
}
private static Hashtable m_Table = new Hashtable();
public static double GetBonus( Mobile from )
{
KiAttackInfo info = m_Table[from] as KiAttackInfo;
if ( info == null )
return 0.0;
int xDelta = info.m_Location.X - from.X;
int yDelta = info.m_Location.Y - from.Y;
double bonus = Math.Sqrt( (xDelta * xDelta) + (yDelta * yDelta) );
if ( bonus > 20.0 )
bonus = 20.0;
return bonus;
}
private class KiAttackInfo
{
public Mobile m_Mobile;
public Point3D m_Location;
public Timer m_Timer;
public KiAttackInfo( Mobile m )
{
m_Mobile = m;
m_Location = m.Location;
}
}
private static void EndKiAttack( object state )
{
KiAttackInfo info = (KiAttackInfo)state;
if ( info.m_Timer != null )
info.m_Timer.Stop();
ClearCurrentMove( info.m_Mobile );
info.m_Mobile.SendLocalizedMessage( 1063102 ); // You failed to complete your Ki Attack in time.
m_Table.Remove( info.m_Mobile );
}
}
}