Fixes to bola: thrower+target dismount time is equal, Core.ML is 10s, 4 sec delay from throw to hit victim, dismount info moved to playermobile rather than mount, to prevent exploit.

This commit is contained in:
xavier 2013-01-12 23:56:40 +00:00
parent 48e08198fe
commit 2120f4fb5b
5 changed files with 208 additions and 176 deletions

View file

@ -32,22 +32,6 @@ namespace Server.Mobiles
m_InternalItem = new MountItem( this, itemID );
}
public BaseMount( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( m_NextMountAbility );
writer.Write( m_Rider );
writer.Write( m_InternalItem );
}
[Hue, CommandProperty( AccessLevel.GameMaster )]
public override int Hue
{
@ -88,6 +72,23 @@ namespace Server.Mobiles
base.OnDelete();
}
public BaseMount( Serial serial )
: base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( ( int )1 ); // version
writer.Write( m_NextMountAbility );
writer.Write( m_Rider );
writer.Write( m_InternalItem );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
@ -134,7 +135,7 @@ namespace Server.Mobiles
return;
}
if ( !CheckMountAllowed( from, true ) )
if ( !CheckMountAllowed( from ) )
return;
if ( from.Mounted )
@ -262,97 +263,22 @@ namespace Server.Mobiles
}
}
private class BlockEntry
// 1040024 You are still too dazed from being knocked off your mount to ride!
// 1062910 You cannot mount while recovering from a bola throw.
// 1070859 You cannot mount while recovering from a dismount special maneuver.
public static bool CheckMountAllowed( Mobile mob )
{
public BlockMountType m_Type;
public DateTime m_Expiration;
bool result = true;
public bool IsExpired{ get{ return ( DateTime.Now >= m_Expiration ); } }
public BlockEntry( BlockMountType type, DateTime expiration )
if( ( mob is PlayerMobile ) && ( mob as PlayerMobile ).BlockReason != BlockMountType.None )
{
m_Type = type;
m_Expiration = expiration;
}
}
mob.SendLocalizedMessage( ( int )( mob as PlayerMobile ).BlockReason );
private static Hashtable m_Table = new Hashtable();
public static void SetMountPrevention( Mobile mob, BlockMountType type, TimeSpan duration )
{
if ( mob == null )
return;
DateTime expiration = DateTime.Now + duration;
BlockEntry entry = m_Table[mob] as BlockEntry;
if ( entry != null )
{
entry.m_Type = type;
entry.m_Expiration = expiration;
}
else
{
m_Table[mob] = entry = new BlockEntry( type, expiration );
}
}
public static void ClearMountPrevention( Mobile mob )
{
if ( mob != null )
m_Table.Remove( mob );
}
public static BlockMountType GetMountPrevention( Mobile mob )
{
if ( mob == null )
return BlockMountType.None;
BlockEntry entry = m_Table[mob] as BlockEntry;
if ( entry == null )
return BlockMountType.None;
if ( entry.IsExpired )
{
m_Table.Remove( mob );
return BlockMountType.None;
result = false;
}
return entry.m_Type;
}
public static bool CheckMountAllowed( Mobile mob, bool message )
{
BlockMountType type = GetMountPrevention( mob );
if ( type == BlockMountType.None )
return true;
if ( message )
{
switch ( type )
{
case BlockMountType.Dazed:
{
mob.SendLocalizedMessage( 1040024 ); // You are still too dazed from being knocked off your mount to ride!
break;
}
case BlockMountType.BolaRecovery:
{
mob.SendLocalizedMessage( 1062910 ); // You cannot mount while recovering from a bola throw.
break;
}
case BlockMountType.DismountRecovery:
{
mob.SendLocalizedMessage( 1070859 ); // You cannot mount while recovering from a dismount special maneuver.
break;
}
}
}
return false;
return result;
}
public virtual void OnRiderDamaged( int amount, Mobile from, bool willKill )
@ -451,12 +377,5 @@ namespace Server.Mobiles
}
}
}
}
public enum BlockMountType
{
None = -1,
Dazed,
BolaRecovery,
DismountRecovery
}
}

View file

@ -133,7 +133,7 @@ namespace Server.Mobiles
// CheckIsUsableBy sends the message
return false;
}
else if( !BaseMount.CheckMountAllowed( from, true ) )
else if( !BaseMount.CheckMountAllowed( from ) )
{
// CheckMountAllowed sends the message
return false;

View file

@ -71,6 +71,15 @@ namespace Server.Mobiles
Red,
Black
}
public enum BlockMountType
{
None = -1,
Dazed = 1040024,
BolaRecovery = 1062910,
DismountRecovery = 1070859
}
#endregion
public partial class PlayerMobile : Mobile, IHonorTarget
@ -657,6 +666,74 @@ namespace Server.Mobiles
}
}
private List<MountBlock> m_Blocks;
public BlockMountType BlockReason { get { return ( CheckList() ) ? m_Blocks[ 0 ].type : BlockMountType.None; } }
private class MountBlock
{
public BlockMountType type;
public Timer m_Timer;
public MountBlock( TimeSpan duration, BlockMountType Type, List<MountBlock> list )
{
type = Type;
m_Timer = Timer.DelayCall( duration, new TimerStateCallback<List<MountBlock>>( RemoveBlock ), list );
}
private void RemoveBlock( List<MountBlock> list )
{
if( list != null )
{
list.Remove( this );
}
}
}
public void AddMountBlock( BlockMountType type, TimeSpan duration )
{
CheckList();
m_Blocks.Add( new MountBlock( duration, type, m_Blocks ) );
IMount mount = this.Mount;
if( mount != null )
{
mount.Rider = null;
}
}
private bool CheckList()
{
if( m_Blocks == null )
{
m_Blocks = new List<MountBlock>();
}
else if( m_Blocks.Count > 0 )
{
List<MountBlock> toRemove = new List<MountBlock>();
int count = m_Blocks.Count;
for( int i = 0; i < count; i++ )
{
if( !m_Blocks[ i ].m_Timer.Running )
{
toRemove.Add( m_Blocks[ i ] );
}
}
foreach( MountBlock block in toRemove )
{
m_Blocks.Remove( block );
}
}
return m_Blocks.Count > 0;
}
public override void OnSkillInvalidated( Skill skill )
{
if ( Core.AOS && skill.SkillName == SkillName.MagicResist )