discard Spawner setter. various fixes to dismount, pets, bolas, specials, spells...

This commit is contained in:
xavier 2013-02-09 23:57:01 +00:00
parent 3b94a24a9a
commit 91273d85d6
8 changed files with 137 additions and 143 deletions

View file

@ -1,53 +1,50 @@
using System;
using System.Collections;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
using System;
namespace Server.Items
{
public class Bola : Item
{
[Constructable]
public Bola()
: this( 1 )
public Bola() : this( 1 )
{
}
[Constructable]
public Bola( int amount )
: base( 0x26AC )
public Bola( int amount ) : base( 0x26AC )
{
Weight = 4.0;
Stackable = true;
Amount = amount;
}
public static TimeSpan BolaRecoveryTime { get { return TimeSpan.FromSeconds( Core.ML ? 10 : 3 ); } }
public override void OnDoubleClick( Mobile from )
{
if( !IsChildOf( from.Backpack ) )
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1040019 ); // The bola must be in your pack to use it.
}
else if( !from.CanBeginAction( typeof( Bola ) ) )
else if ( !from.CanBeginAction( typeof( Bola ) ) )
{
from.SendLocalizedMessage( 1049624 ); // You have to wait a few moments before you can use another bola!
}
else if( from.Target is BolaTarget )
else if ( from.Target is BolaTarget )
{
from.SendLocalizedMessage( 1049631 ); // This bola is already being used.
}
else if( !Core.AOS && ( from.FindItemOnLayer( Layer.OneHanded ) != null || from.FindItemOnLayer( Layer.TwoHanded ) != null ) )
else if ( !Core.AOS && (from.FindItemOnLayer( Layer.OneHanded ) != null || from.FindItemOnLayer( Layer.TwoHanded ) != null) )
{
from.SendLocalizedMessage( 1040015 ); // Your hands must be free to use this
}
else if( from.Mounted )
else if ( from.Mounted )
{
from.SendLocalizedMessage( 1040016 ); // You cannot use this while riding a mount
}
else if( Server.Spells.Ninjitsu.AnimalForm.UnderTransformation( from ) )
else if ( Server.Spells.Ninjitsu.AnimalForm.UnderTransformation( from ) )
{
from.SendLocalizedMessage( 1070902 ); // You can't use this while in an animal form!
}
@ -55,15 +52,14 @@ namespace Server.Items
{
EtherealMount.StopMounting( from );
if( Core.AOS )
{
if ( Core.AOS ) {
Item one = from.FindItemOnLayer( Layer.OneHanded );
Item two = from.FindItemOnLayer( Layer.TwoHanded );
if( one != null )
if ( one != null )
from.AddToBackpack( one );
if( two != null )
if ( two != null )
from.AddToBackpack( two );
}
@ -73,126 +69,121 @@ namespace Server.Items
}
}
private static void ReleaseBolaLock( object state )
{
((Mobile)state).EndAction( typeof( Bola ) );
}
private static void FinishThrow( object state )
{
object[] states = ( object[] )state;
object[] states = (object[])state;
Mobile from = ( Mobile )states[ 0 ];
Mobile to = ( Mobile )states[ 1 ];
Mobile from = (Mobile)states[0];
Mobile to = (Mobile)states[1];
Timer.DelayCall( TimeSpan.FromSeconds( 2.0 ), new TimerStateCallback( ReleaseBolaLock ), from );
if( Core.AOS )
if ( Core.AOS )
new Bola().MoveToWorld( to.Location, to.Map );
to.Damage( 1, from );
if( to is ChaosDragoon || to is ChaosDragoonElite )
{
if ( to is ChaosDragoon || to is ChaosDragoonElite )
from.SendLocalizedMessage( 1042047 ); // You fail to knock the rider from its mount.
IMount mt = to.Mount;
if ( mt != null && !( to is ChaosDragoon || to is ChaosDragoonElite ) )
mt.Rider = null;
if (to is PlayerMobile)
{
if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(to))
{
to.SendLocalizedMessage(1114066, from.Name); // ~1_NAME~ knocked you out of animal form!
}
else if (to.Mounted)
{
to.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
}
(to as PlayerMobile).SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(10), true);
}
else
{
if( from.InRange( to.Location, 8 ) && ( to.Map == from.Map ) && ( to.Map != Map.Internal ) )
{
IMount mt = to.Mount;
if( mt != null )
{
mt.Rider = null;
}
from.Direction = from.GetDirectionTo( to );
from.Animate( 11, 5, 1, true, false, 0 );
from.MovingEffect( to, 0x26AC, 10, 0, false, false );
from.DoHarmful( to );
to.SendLocalizedMessage( 1040023 ); // You have been knocked off of your mount!
if( to is PlayerMobile )
{
( to as PlayerMobile ).AddMountBlock( BlockMountType.Dazed, BolaRecoveryTime );
}
if( from is PlayerMobile )
{
( from as PlayerMobile ).AddMountBlock( BlockMountType.BolaRecovery, BolaRecoveryTime ); // TODO validate durations
}
}
else
{
from.SendLocalizedMessage( 1042060 ); //You cannot see that target!
}
to.Mount.Rider = null;
}
}
private static void ReleaseBolaLock( object state )
{
( ( Mobile )state ).EndAction( typeof( Bola ) );
if (Core.AOS && from is PlayerMobile) /* only failsafe, attacker should already be dismounted */
{
(from as PlayerMobile).SetMountBlock( BlockMountType.BolaRecovery, TimeSpan.FromSeconds(10), true );
}
to.Damage(1);
Timer.DelayCall( TimeSpan.FromSeconds( 2.0 ), new TimerStateCallback( ReleaseBolaLock ), from );
}
public class BolaTarget : Target
{
private Bola m_Bola;
public BolaTarget( Bola bola )
: base( 8, false, TargetFlags.Harmful )
public BolaTarget( Bola bola ) : base( 8, false, TargetFlags.Harmful )
{
m_Bola = bola;
}
protected override void OnTarget( Mobile from, object obj )
{
if( m_Bola.Deleted )
if ( m_Bola.Deleted )
return;
if( obj is Mobile )
if ( obj is Mobile )
{
Mobile to = ( Mobile )obj;
Mobile to = (Mobile)obj;
if( !m_Bola.IsChildOf( from.Backpack ) )
if ( !m_Bola.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1040019 ); // The bola must be in your pack to use it.
}
else if( !Core.AOS && ( from.FindItemOnLayer( Layer.OneHanded ) != null || from.FindItemOnLayer( Layer.TwoHanded ) != null ) )
else if ( !Core.AOS && (from.FindItemOnLayer( Layer.OneHanded ) != null || from.FindItemOnLayer( Layer.TwoHanded ) != null) )
{
from.SendLocalizedMessage( 1040015 ); // Your hands must be free to use this
}
else if( from.Mounted )
else if ( from.Mounted )
{
from.SendLocalizedMessage( 1040016 ); // You cannot use this while riding a mount
}
else if( Server.Spells.Ninjitsu.AnimalForm.UnderTransformation( from ) )
else if ( Server.Spells.Ninjitsu.AnimalForm.UnderTransformation( from ) )
{
from.SendLocalizedMessage( 1070902 ); // You can't use this while in an animal form!
}
else if( !to.Mounted )
else if (!to.Mounted && !Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(to))
{
from.SendLocalizedMessage( 1049628 ); // You have no reason to throw a bola at that.
}
else if( !from.CanBeHarmful( to ) )
else if ( !from.CanBeHarmful( to ) )
{
}
else if( from.BeginAction( typeof( Bola ) ) )
else if ( from.BeginAction( typeof( Bola ) ) )
{
EtherealMount.StopMounting( from );
if( Core.AOS )
{
if ( Core.AOS ) {
Item one = from.FindItemOnLayer( Layer.OneHanded );
Item two = from.FindItemOnLayer( Layer.TwoHanded );
if( one != null )
if ( one != null )
from.AddToBackpack( one );
if( two != null )
if ( two != null )
from.AddToBackpack( two );
}
from.DoHarmful( to );
m_Bola.Consume();
Timer.DelayCall( TimeSpan.FromSeconds( Core.ML ? 4 : .5 ), new TimerStateCallback( FinishThrow ), new object[] { from, to } );
from.Direction = from.GetDirectionTo( to );
from.Animate( 11, 5, 1, true, false, 0 );
from.MovingEffect( to, 0x26AC, 10, 0, false, false );
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), new TimerStateCallback( FinishThrow ), new object[]{ from, to } );
}
else
{
@ -206,8 +197,7 @@ namespace Server.Items
}
}
public Bola( Serial serial )
: base( serial )
public Bola( Serial serial ) : base( serial )
{
}
@ -215,7 +205,7 @@ namespace Server.Items
{
base.Serialize( writer );
writer.Write( ( int )0 );
writer.Write( (int) 0 );
}
public override void Deserialize( GenericReader reader )
@ -225,5 +215,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -41,14 +41,14 @@ namespace Server.Items
if ( defender is ChaosDragoon || defender is ChaosDragoonElite )
return;
if ( attacker.Mounted && !(defender.Weapon is Lance) ) // TODO: Should there be a message here?
if ( attacker.Mounted && ( !(attacker.Weapon is Lance) || !(defender.Weapon is Lance) ) ) // TODO: Should there be a message here?
return;
ClearCurrentAbility( attacker );
IMount mount = defender.Mount;
if ( mount == null )
if (mount == null && !Server.Spells.Ninjitsu.AnimalForm.UnderTransformation( defender ) )
{
attacker.SendLocalizedMessage( 1060848 ); // This attack only works on mounted targets
return;
@ -72,16 +72,28 @@ namespace Server.Items
defender.PlaySound( 0x140 );
defender.FixedParticles( 0x3728, 10, 15, 9955, EffectLayer.Waist );
if( defender is PlayerMobile )
if (defender is PlayerMobile)
{
( defender as PlayerMobile ).AddMountBlock( BlockMountType.Dazed, RemountDelay );
if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(defender))
{
defender.SendLocalizedMessage(1114066, attacker.Name); // ~1_NAME~ knocked you out of animal form!
}
else if (defender.Mounted)
{
defender.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
}
(defender as PlayerMobile).SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(10), true);
}
else
{
defender.Mount.Rider = null;
}
if( attacker is PlayerMobile )
{
( attacker as PlayerMobile ).AddMountBlock( BlockMountType.DismountRecovery, RemountDelay );
(attacker as PlayerMobile).SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, true );
}
else if( Core.ML && attacker is BaseCreature )
{
BaseCreature bc = attacker as BaseCreature;
@ -90,7 +102,7 @@ namespace Server.Items
{
PlayerMobile pm = bc.ControlMaster as PlayerMobile;
pm.AddMountBlock( BlockMountType.DismountRecovery, RemountDelay );
pm.SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, false );
}
}

View file

@ -247,8 +247,10 @@ namespace Server.Mobiles
}
else
{
if ( m_Rider != null )
if( m_Rider != null )
{
Dismount( m_Rider );
}
Dismount( value );
@ -259,8 +261,10 @@ namespace Server.Mobiles
Internalize();
if ( value.Target is Bola.BolaTarget )
if( value.Target is Bola.BolaTarget )
{
Target.Cancel( value );
}
}
m_Rider = value;
@ -276,9 +280,9 @@ namespace Server.Mobiles
{
bool result = true;
if( ( mob is PlayerMobile ) && ( mob as PlayerMobile ).BlockReason != BlockMountType.None )
if ((mob is PlayerMobile) && (mob as PlayerMobile).MountBlockReason != BlockMountType.None)
{
mob.SendLocalizedMessage( ( int )( mob as PlayerMobile ).BlockReason );
mob.SendLocalizedMessage((int)(mob as PlayerMobile).MountBlockReason);
result = false;
}

View file

@ -8,6 +8,8 @@ namespace Server.Mobiles
[CorpseName( "a hiryu corpse" )]
public class Hiryu : BaseMount
{
public override double WeaponAbilityChance { get { return 0.07; } } /* 1 in 15 chance of using per landed hit */
public override WeaponAbility GetWeaponAbility()
{
return WeaponAbility.Dismount;

View file

@ -8,6 +8,8 @@ namespace Server.Mobiles
[CorpseName( "a hiryu corpse" )]
public class LesserHiryu : BaseMount
{
public override double WeaponAbilityChance { get { return 0.07; } } /* 1 in 15 chance of using; 1 in 5 chance of success */
public override WeaponAbility GetWeaponAbility()
{
return WeaponAbility.Dismount;

View file

@ -425,10 +425,6 @@ namespace Server.Mobiles
}
set
{
if( value is ISpawner )
{
Spawner = value as ISpawner;
}
}
}

View file

@ -667,72 +667,57 @@ namespace Server.Mobiles
}
}
private List<MountBlock> m_Blocks;
private MountBlock m_MountBlock;
public BlockMountType BlockReason { get { return ( CheckList() ) ? m_Blocks[ 0 ].type : BlockMountType.None; } }
public BlockMountType MountBlockReason
{
get
{
return ( CheckBlock( m_MountBlock ) ) ? m_MountBlock.m_Type : BlockMountType.None;
}
}
private static bool CheckBlock( MountBlock block )
{
return ( !( block is MountBlock ) || !block.m_Timer.Running );
}
private class MountBlock
{
public BlockMountType type;
public BlockMountType m_Type;
public Timer m_Timer;
public MountBlock( TimeSpan duration, BlockMountType Type, List<MountBlock> list )
public MountBlock( TimeSpan duration, BlockMountType type, Mobile mobile )
{
type = Type;
m_Type = type;
m_Timer = Timer.DelayCall( duration, new TimerStateCallback<List<MountBlock>>( RemoveBlock ), list );
m_Timer = Timer.DelayCall( duration, new TimerStateCallback<Mobile>( RemoveBlock ), mobile );
}
private void RemoveBlock( List<MountBlock> list )
private void RemoveBlock( Mobile mobile )
{
if( list != null )
{
list.Remove( this );
}
( mobile as PlayerMobile ).m_MountBlock = null;
}
}
public void AddMountBlock( BlockMountType type, TimeSpan duration )
public void SetMountBlock( BlockMountType type, TimeSpan duration, bool dismount )
{
CheckList();
m_Blocks.Add( new MountBlock( duration, type, m_Blocks ) );
IMount mount = this.Mount;
if( mount != null )
if( dismount )
{
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 (this.Mount != null)
{
if( !m_Blocks[ i ].m_Timer.Running )
{
toRemove.Add( m_Blocks[ i ] );
}
this.Mount.Rider = null;
}
foreach( MountBlock block in toRemove )
else if (AnimalForm.UnderTransformation(this))
{
m_Blocks.Remove( block );
AnimalForm.RemoveContext(this, true);
}
}
return m_Blocks.Count > 0;
if( ( m_MountBlock == null ) || !m_MountBlock.m_Timer.Running || ( m_MountBlock.m_Timer.Next < ( DateTime.UtcNow + duration ) ) )
{
m_MountBlock = new MountBlock( duration, type, this );
}
}
public override void OnSkillInvalidated( Skill skill )

View file

@ -472,6 +472,10 @@ namespace Server.Spells.Ninjitsu
{
m_Caster.SendLocalizedMessage(1060174, mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
}
else if( ( m_Caster is PlayerMobile ) && ( m_Caster as PlayerMobile ).MountBlockReason != BlockMountType.None )
{
m_Caster.SendLocalizedMessage( 1063108 ); // You cannot use this ability right now.
}
else if (BaseFormTalisman.EntryEnabled(sender.Mobile, entry.Type))
{
#region Dueling