From 638065dcde7f12dd00dc5b699fb9a22969643c6e Mon Sep 17 00:00:00 2001 From: xavier Date: Thu, 18 Nov 2010 15:19:29 +0000 Subject: [PATCH] fix summon+logout problem, fix for an exploit. --- Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs | 15 ++++++----- .../Skill Items/Ninjitsu/LeatherNinjaBelt.cs | 15 ++++++----- Scripts/Mobiles/BaseCreature.cs | 1 - Scripts/Mobiles/PlayerMobile.cs | 26 +++++++++++++++++-- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs b/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs index 1f25d1e12..ca3ee8355 100644 --- a/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs +++ b/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs @@ -4,13 +4,13 @@ using Server.Targeting; using System.Collections; using System.Collections.Generic; using Server.ContextMenus; +using Server.Mobiles; namespace Server.Items { [FlipableAttribute( 0x27AA, 0x27F5 )] public class Fukiya : Item, IUsesRemaining { - private bool m_Using; private int m_UsesRemaining; private Poison m_Poison; @@ -70,7 +70,7 @@ namespace Server.Items // You have no fukiya darts! from.SendLocalizedMessage( 1063325 ); } - else if ( m_Using ) + else if (((PlayerMobile)from).NinjaWepCooldown) { // You are already using that fukiya. from.SendLocalizedMessage( 1063326 ); @@ -96,7 +96,7 @@ namespace Server.Items // You have no fukiya darts! from.SendLocalizedMessage( 1063325 ); } - else if ( m_Using ) + else if (((PlayerMobile)from).NinjaWepCooldown) { // You are already using that fukiya. from.SendLocalizedMessage( 1063326 ); @@ -108,7 +108,7 @@ namespace Server.Items } else if ( from.CanBeHarmful( target ) ) { - m_Using = true; + ((PlayerMobile)from).NinjaWepCooldown = true; from.Direction = from.GetDirectionTo( target ); @@ -125,7 +125,7 @@ namespace Server.Items else ConsumeUse(); - Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerCallback( ResetUsing ) ); + Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerStateCallback( ResetUsing ), from ); } } @@ -164,9 +164,10 @@ namespace Server.Items } } - public void ResetUsing() + public void ResetUsing(object state) { - m_Using = false; + PlayerMobile from = (PlayerMobile)state; + from.NinjaWepCooldown = false; } private const int MaxUses = 10; diff --git a/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs b/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs index c026860c5..6e01b35ee 100644 --- a/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs +++ b/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs @@ -4,6 +4,7 @@ using Server.Targeting; using System.Collections; using System.Collections.Generic; using Server.ContextMenus; +using Server.Mobiles; namespace Server.Items { @@ -12,7 +13,6 @@ namespace Server.Items { public override CraftResource DefaultResource{ get{ return CraftResource.RegularLeather; } } - private bool m_Using; private int m_UsesRemaining; private Poison m_Poison; @@ -81,7 +81,7 @@ namespace Server.Items // You have no shuriken in your ninja belt! from.SendLocalizedMessage( 1063297 ); } - else if ( m_Using ) + else if (((PlayerMobile)from).NinjaWepCooldown) { // You cannot throw another shuriken yet. from.SendLocalizedMessage( 1063298 ); @@ -107,7 +107,7 @@ namespace Server.Items // You have no shuriken in your ninja belt! from.SendLocalizedMessage( 1063297 ); } - else if ( m_Using ) + else if (((PlayerMobile)from).NinjaWepCooldown) { // You cannot throw another shuriken yet. from.SendLocalizedMessage( 1063298 ); @@ -123,7 +123,7 @@ namespace Server.Items } else if ( from.CanBeHarmful( target ) ) { - m_Using = true; + ((PlayerMobile)from).NinjaWepCooldown = true; from.Direction = from.GetDirectionTo( target ); @@ -140,7 +140,7 @@ namespace Server.Items else ConsumeUse(); - Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerCallback( ResetUsing ) ); + Timer.DelayCall(TimeSpan.FromSeconds(2.5), new TimerStateCallback( ResetUsing ), from ); } } @@ -179,9 +179,10 @@ namespace Server.Items } } - public void ResetUsing() + public void ResetUsing(object state) { - m_Using = false; + PlayerMobile from = (PlayerMobile)state; + from.NinjaWepCooldown = false; } private const int MaxUses = 10; diff --git a/Scripts/Mobiles/BaseCreature.cs b/Scripts/Mobiles/BaseCreature.cs index 90a9e0fae..d3fbbffe3 100644 --- a/Scripts/Mobiles/BaseCreature.cs +++ b/Scripts/Mobiles/BaseCreature.cs @@ -132,7 +132,6 @@ namespace Server.Mobiles [AttributeUsage( AttributeTargets.Class )] public class FriendlyNameAttribute : Attribute { - //future use: Talisman 'Protection/Bonus vs. Specific Creature private TextDefinition m_FriendlyName; diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 57a3fe373..6b37f9f37 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -105,7 +105,7 @@ namespace Server.Mobiles private bool m_IsStealthing; // IsStealthing should be moved to Server.Mobiles private bool m_IgnoreMobiles; // IgnoreMobiles should be moved to Server.Mobiles private int m_NonAutoreinsuredItems; // number of items that could not be automaitically reinsured because gold in bank was not enough - + private bool m_NinjaWepCooldown; /* * a value of zero means, that the mobile is not executing the spell. Otherwise, * the value should match the BaseMana required @@ -123,6 +123,18 @@ namespace Server.Mobiles #region Getters & Setters public List AutoStabled { get { return m_AutoStabled; } } + public bool NinjaWepCooldown + { + get + { + return m_NinjaWepCooldown; + } + set + { + m_NinjaWepCooldown = value; + } + } + public List AllFollowers { get @@ -4247,9 +4259,19 @@ namespace Server.Mobiles { BaseCreature pet = AllFollowers[i] as BaseCreature; - if ( pet == null || pet.ControlMaster == null || pet.Summoned ) + if (pet == null || pet.ControlMaster == null) continue; + if (pet.Summoned) + { + if (pet.Map != Map) + { + pet.PlaySound(pet.GetAngerSound()); + pet.Delete(); + } + continue; + } + if ( pet is IMount && ((IMount)pet).Rider != null ) continue;