From d530fa2ffab2de948a5d4cba8412622e8d0e0fce Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 26 Jun 2011 20:49:50 +0000 Subject: [PATCH] Numerous corrections and fixes to the honor virtue. http://www.runuo.com/community/threads/ready-honour-virtue-bugs.428439/ --- Scripts/Engines/Craft/DefInscription.cs | 2 +- Scripts/Engines/Virtues/Honor.cs | 117 +++++++++++++--------- Scripts/Engines/Virtues/VirtueGump.cs | 14 +-- Scripts/Engines/Virtues/VirtueHelper.cs | 3 +- Scripts/Engines/Virtues/VirtueInfoGump.cs | 40 ++++---- Scripts/Gumps/honorself.cs | 35 +++++++ Scripts/Mobiles/PlayerMobile.cs | 2 +- 7 files changed, 137 insertions(+), 76 deletions(-) create mode 100644 Scripts/Gumps/honorself.cs diff --git a/Scripts/Engines/Craft/DefInscription.cs b/Scripts/Engines/Craft/DefInscription.cs index 7deb6766a..e5314c95c 100644 --- a/Scripts/Engines/Craft/DefInscription.cs +++ b/Scripts/Engines/Craft/DefInscription.cs @@ -304,7 +304,7 @@ namespace Server.Engines.Craft } if ( Core.SE ) - AddCraft( typeof( Spellbook ), 1044294, 1023834, 50.0, 150.0, typeof( BlankScroll ), 1044377, 10, 1044378 ); + AddCraft( typeof( Spellbook ), 1044294, 1023834, 50.0, 140, typeof( BlankScroll ), 1044377, 10, 1044378 ); MarkOption = true; } diff --git a/Scripts/Engines/Virtues/Honor.cs b/Scripts/Engines/Virtues/Honor.cs index 0b83e7010..24a588a95 100644 --- a/Scripts/Engines/Virtues/Honor.cs +++ b/Scripts/Engines/Virtues/Honor.cs @@ -1,15 +1,15 @@ using System; using Server; using Server.Mobiles; +using Server.Gumps; using Server.Targeting; +using Server.Regions; namespace Server { public class HonorVirtue { - private static readonly TimeSpan LossDelay = TimeSpan.FromDays( 7.0 ); - private static readonly int LossAmount = 500; - + private static readonly TimeSpan UseDelay = TimeSpan.FromMinutes( 5.0 ); public static void Initialize() @@ -17,28 +17,6 @@ namespace Server VirtueGump.Register( 107, new OnVirtueUsed( OnVirtueUsed ) ); } - public static void CheckAtrophy( Mobile from ) - { - PlayerMobile pm = from as PlayerMobile; - - if ( pm == null ) - return; - - try - { - if ( (pm.LastHonorLoss + LossDelay) < DateTime.Now ) - { - if ( VirtueHelper.Atrophy( from, VirtueName.Honor, LossAmount ) ) - from.SendLocalizedMessage( 1063227 ); // You have lost some Honor. - - pm.LastHonorLoss = DateTime.Now; - } - } - catch - { - } - } - private static void OnVirtueUsed( Mobile from ) { if ( from.Alive ) @@ -62,7 +40,9 @@ namespace Server return; if ( targeted == pm ) + { EmbraceHonor( pm ); + } else if ( targeted is Mobile ) Honor( pm, (Mobile) targeted ); } @@ -93,8 +73,7 @@ namespace Server return; } - int duration = GetHonorDuration( pm ); - if ( duration == 0 ) + if ( GetHonorDuration( pm ) == 0 ) { pm.SendLocalizedMessage( 1063234 ); // You do not have enough honor to do that return; @@ -109,8 +88,23 @@ namespace Server pm.SendLocalizedMessage( 1063240, remainingMinutes.ToString() ); // You must wait ~1_HONOR_WAIT~ minutes before embracing honor again return; } + + pm.SendGump( new HonorSelf( pm ) ); + + } + + public static void ActivateEmbrace( PlayerMobile pm ) + { + int duration = GetHonorDuration( pm ); + int usedPoints; + + if ( pm.Virtues.Honor < 4399) + usedPoints = 400; + else if ( pm.Virtues.Honor < 10599 ) + usedPoints = 600; + else + usedPoints = 1000; - int usedPoints = pm.Virtues.Honor / 20; VirtueHelper.Atrophy( pm, VirtueName.Honor, usedPoints ); pm.HonorActive = true; @@ -127,8 +121,10 @@ namespace Server private static void Honor( PlayerMobile source, Mobile target ) { IHonorTarget honorTarget = target as IHonorTarget; + GuardedRegion reg = (GuardedRegion) source.Region.GetRegion( typeof( GuardedRegion ) ); + Map map = source.Map; - if ( honorTarget == null || !source.CanBeHarmful( target, true ) ) + if ( honorTarget == null ) return; if ( honorTarget.ReceivedHonorContext != null ) @@ -149,6 +145,25 @@ namespace Server return; } + BaseCreature cret = target as BaseCreature; + if ( target.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) ) + { + + if( reg == null || reg.IsDisabled() ) + { + //Allow honor on blue if Out of guardzone + } + else if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 ) + { + //Allow honor on blue if in Fel + } + else + { + source.SendLocalizedMessage( 1001018 ); // You cannot perform negative acts + return; //cannot honor in trammel town on blue + } + } + if( Core.ML && target is PlayerMobile ) { source.SendLocalizedMessage( 1075614 ); // You cannot honor other players. @@ -165,8 +180,6 @@ namespace Server if ( !source.Mounted ) source.Animate( 32, 5, 1, true, true, 0 ); - // OSI apparently removed this message... it's nice though - source.Say( 1063231 ); // I honor you } } @@ -180,7 +193,7 @@ namespace Server private PlayerMobile m_Source; private Mobile m_Target; - private int m_HonorDamageTwentieths; + private double m_HonorDamage; private int m_TotalDamage; private int m_Perfection; @@ -218,6 +231,15 @@ namespace Server m_Timer = new InternalTimer( this ); m_Timer.Start(); + source.m_hontime = (DateTime.Now + TimeSpan.FromMinutes( 40 )); + + Timer.DelayCall( TimeSpan.FromMinutes( 40 ), + delegate() { + if (source.m_hontime < DateTime.Now && source.SentHonorContext != null) + { + Cancel(); + } + } ); } public void OnSourceDamaged( Mobile from, int amount ) @@ -241,7 +263,7 @@ namespace Server if ( m_Poisoned ) { - m_TotalDamage += amount * 2; + m_HonorDamage += amount * 0.8; m_Poisoned = false; // Reset the flag return; @@ -254,16 +276,16 @@ namespace Server if ( m_Target.CanSee( m_Source ) && m_Target.InLOS( m_Source ) && ( m_Source.InRange( m_Target, 1 ) || ( m_Source.Location == m_InitialLocation && m_Source.Map == m_InitialMap ) ) ) { - m_HonorDamageTwentieths += amount * 20; + m_HonorDamage += amount; } else { - m_HonorDamageTwentieths += amount * 2; + m_HonorDamage += amount * 0.8; } } - else if ( from is BaseCreature && ((BaseCreature)from).GetMaster() == from ) + else if ( from is BaseCreature && ((BaseCreature)from).GetMaster() == m_Source ) { - m_HonorDamageTwentieths += amount; + m_HonorDamage += amount * 0.8; } } @@ -321,7 +343,7 @@ namespace Server public void OnSourceKilled() { - Cancel(); + return; } public void OnTargetKilled() @@ -342,16 +364,17 @@ namespace Server if ( m_Source.Virtues.Honor > targetFame ) return; - double dGain = ( targetFame * m_HonorDamageTwentieths ) / (double)( 20 * m_TotalDamage ); - dGain = dGain * dGain / 2000000.0; + double dGain = ( targetFame / 100 ) * (m_HonorDamage / m_TotalDamage ); //Initial honor gain is 100th of the monsters honor - if ( m_FirstHit == FirstHit.Granted ) - dGain *= 1.1; // Is this correct? + if ( m_HonorDamage == m_TotalDamage && m_FirstHit == FirstHit.Granted) + dGain = dGain * 1.5; //honor gain is increased alot more if the combat was fully honorable + else + dGain = dGain * 0.9; int gain = Math.Min( (int)dGain, 200 ); - if ( gain <= 0 ) - return; + if ( gain < 1 ) + gain=1; //Minimum gain of 1 honor when the honor is under the monsters fame if ( VirtueHelper.IsHighestPath( m_Source, VirtueName.Honor ) ) { @@ -381,12 +404,6 @@ namespace Server public bool CheckDistance() { - if ( m_Source.Map == Map.Internal || m_Source.Map != m_Target.Map || !m_Source.InRange( m_Target, 24 ) ) - { - Cancel(); - return false; - } - return true; } diff --git a/Scripts/Engines/Virtues/VirtueGump.cs b/Scripts/Engines/Virtues/VirtueGump.cs index 43901b5e7..51507dfc2 100644 --- a/Scripts/Engines/Virtues/VirtueGump.cs +++ b/Scripts/Engines/Virtues/VirtueGump.cs @@ -136,20 +136,22 @@ namespace Server if( value >= 30000 ) value = 20000; //Sanity - /* + int vl; - vl = (value/10000) - if( value < 10000 ) vl = 0; - else if( value > 20000 ) + else if( value >= 20000 && index == 5) + vl = 2; + else if( value >= 21000 && index != 1) + vl = 2; + else if( value >= 22000 && index == 1) vl = 2; else vl = 1; - */ + - return m_Table[(index * 3) + (int)(value/10000)]; + return m_Table[(index * 3) + (int) vl]; } private class InternalEntry : GumpImage diff --git a/Scripts/Engines/Virtues/VirtueHelper.cs b/Scripts/Engines/Virtues/VirtueHelper.cs index ce73efa05..9ce18bb1a 100644 --- a/Scripts/Engines/Virtues/VirtueHelper.cs +++ b/Scripts/Engines/Virtues/VirtueHelper.cs @@ -38,10 +38,11 @@ namespace Server { int v = from.Virtues.GetValue( (int)virtue ); int vl; + int vmax = GetMaxAmount( virtue ); if ( v < 4000 ) vl = 0; - else if ( v >= 20000 ) + else if ( v >= vmax) vl = 3; else vl = ( v + 9999 ) / 10000; diff --git a/Scripts/Engines/Virtues/VirtueInfoGump.cs b/Scripts/Engines/Virtues/VirtueInfoGump.cs index ae2af8c42..c9b663df0 100644 --- a/Scripts/Engines/Virtues/VirtueInfoGump.cs +++ b/Scripts/Engines/Virtues/VirtueInfoGump.cs @@ -39,19 +39,37 @@ namespace Server int maxValue = VirtueHelper.GetMaxAmount( m_Virtue ); int valueDesc; + int dots; + + if( value < 4000 ) + dots = value / 400; + else if( value < 10000 ) + dots = (value - 4000) / 600; + else if( value < maxValue ) + dots = (value - 10000) / ((maxValue-10000)/10); + else + dots = 10; + + for ( int i = 0; i < 10; ++i ) + AddImage( 95 + (i * 17), 50, i < dots ? 2362 : 2360 ); + if( value < 1 ) valueDesc = 1052044; // You have not started on the path of this Virtue. - else if( value < maxValue/6 ) + else if( value < 400 ) valueDesc = 1052045; // You have barely begun your journey through the path of this Virtue. - else if( value < maxValue/3 ) + else if( value < 2000 ) valueDesc = 1052046; // You have progressed in this Virtue, but still have much to do. - else if( value < maxValue/2 ) + else if( value < 3600 ) valueDesc = 1052047; // Your journey through the path of this Virtue is going well. - else if( value < 2*maxValue/3 ) + else if( value < 4000 ) valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. - else if( value < 5*maxValue/6 ) + else if( dots < 1 ) valueDesc = 1052049; // You have achieved a path in this Virtue. + else if( dots < 9 ) + valueDesc = 1052047; // Your journey through the path of this Virtue is going well. + else if( dots < 10 ) + valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. else valueDesc = 1052050; // You have achieved the highest path in this Virtue. @@ -66,19 +84,7 @@ namespace Server AddHtmlLocalized( 83, 275, 400, 40, (webPage == null) ? 1052055 : 1052052, false, false ); // This virtue is not yet defined. OR -click to learn more (opens webpage) - int dots; - if( value < 4000 ) - dots = value / 400; - else if( value < 10000 ) - dots = (value - 4000) / 600; - else if( value < maxValue ) - dots = (value - 10000) / ((maxValue-10000)/10); - else - dots = 10; - - for ( int i = 0; i < 10; ++i ) - AddImage( 95 + (i * 17), 50, i < dots ? 2362 : 2360 ); } public override void OnResponse( NetState state, RelayInfo info ) diff --git a/Scripts/Gumps/honorself.cs b/Scripts/Gumps/honorself.cs new file mode 100644 index 000000000..f8b11f3a2 --- /dev/null +++ b/Scripts/Gumps/honorself.cs @@ -0,0 +1,35 @@ +using System; +using Server; +using Server.Network; +using Server.Mobiles; +using Server.Accounting; + +namespace Server.Gumps +{ + public class HonorSelf: Gump + { + PlayerMobile m_from; + public HonorSelf( PlayerMobile from ) : base( 150, 50 ) + { + m_from = from; + AddBackground(0, 0, 245, 145, 9250); + AddButton(157, 101, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(81, 100, 241, 248, 0, GumpButtonType.Reply, 0); + AddHtml( 21, 20, 203, 70, @"Are you sure you want to use +honor points on yourself?", true, false); + } + + public override void OnResponse( NetState sender, RelayInfo info ) + { + + if ( info.ButtonID == 1 ) + { + HonorVirtue.ActivateEmbrace(m_from); + } + else + { + return; + } + } + } +} diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 583bbbf70..72c9f01bd 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -3099,7 +3099,6 @@ namespace Server.Mobiles JusticeVirtue.CheckAtrophy( m ); CompassionVirtue.CheckAtrophy( m ); ValorVirtue.CheckAtrophy( m ); - HonorVirtue.CheckAtrophy( m ); if( m is PlayerMobile ) ChampionTitleInfo.CheckAtrophy( (PlayerMobile)m ); @@ -3663,6 +3662,7 @@ namespace Server.Mobiles private bool m_HonorActive; private HonorContext m_ReceivedHonorContext; private HonorContext m_SentHonorContext; + public DateTime m_hontime; public DateTime LastHonorLoss{ get{ return m_LastHonorLoss; } set{ m_LastHonorLoss = value; } } public DateTime LastHonorUse{ get{ return m_LastHonorUse; } set{ m_LastHonorUse = value; } }