Numerous corrections and fixes to the honor virtue.

http://www.runuo.com/community/threads/ready-honour-virtue-bugs.428439/
This commit is contained in:
xavier 2011-06-26 20:49:50 +00:00
parent f5e7b9ed30
commit d530fa2ffa
7 changed files with 137 additions and 76 deletions

View file

@ -304,7 +304,7 @@ namespace Server.Engines.Craft
} }
if ( Core.SE ) 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; MarkOption = true;
} }

View file

@ -1,14 +1,14 @@
using System; using System;
using Server; using Server;
using Server.Mobiles; using Server.Mobiles;
using Server.Gumps;
using Server.Targeting; using Server.Targeting;
using Server.Regions;
namespace Server namespace Server
{ {
public class HonorVirtue 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 ); private static readonly TimeSpan UseDelay = TimeSpan.FromMinutes( 5.0 );
@ -17,28 +17,6 @@ namespace Server
VirtueGump.Register( 107, new OnVirtueUsed( OnVirtueUsed ) ); 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 ) private static void OnVirtueUsed( Mobile from )
{ {
if ( from.Alive ) if ( from.Alive )
@ -62,7 +40,9 @@ namespace Server
return; return;
if ( targeted == pm ) if ( targeted == pm )
{
EmbraceHonor( pm ); EmbraceHonor( pm );
}
else if ( targeted is Mobile ) else if ( targeted is Mobile )
Honor( pm, (Mobile) targeted ); Honor( pm, (Mobile) targeted );
} }
@ -93,8 +73,7 @@ namespace Server
return; return;
} }
int duration = GetHonorDuration( pm ); if ( GetHonorDuration( pm ) == 0 )
if ( duration == 0 )
{ {
pm.SendLocalizedMessage( 1063234 ); // You do not have enough honor to do that pm.SendLocalizedMessage( 1063234 ); // You do not have enough honor to do that
return; return;
@ -110,7 +89,22 @@ namespace Server
return; return;
} }
int usedPoints = pm.Virtues.Honor / 20; 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;
VirtueHelper.Atrophy( pm, VirtueName.Honor, usedPoints ); VirtueHelper.Atrophy( pm, VirtueName.Honor, usedPoints );
pm.HonorActive = true; pm.HonorActive = true;
@ -127,8 +121,10 @@ namespace Server
private static void Honor( PlayerMobile source, Mobile target ) private static void Honor( PlayerMobile source, Mobile target )
{ {
IHonorTarget honorTarget = target as IHonorTarget; 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; return;
if ( honorTarget.ReceivedHonorContext != null ) if ( honorTarget.ReceivedHonorContext != null )
@ -149,6 +145,25 @@ namespace Server
return; 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 ) if( Core.ML && target is PlayerMobile )
{ {
source.SendLocalizedMessage( 1075614 ); // You cannot honor other players. source.SendLocalizedMessage( 1075614 ); // You cannot honor other players.
@ -165,8 +180,6 @@ namespace Server
if ( !source.Mounted ) if ( !source.Mounted )
source.Animate( 32, 5, 1, true, true, 0 ); 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 PlayerMobile m_Source;
private Mobile m_Target; private Mobile m_Target;
private int m_HonorDamageTwentieths; private double m_HonorDamage;
private int m_TotalDamage; private int m_TotalDamage;
private int m_Perfection; private int m_Perfection;
@ -218,6 +231,15 @@ namespace Server
m_Timer = new InternalTimer( this ); m_Timer = new InternalTimer( this );
m_Timer.Start(); 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 ) public void OnSourceDamaged( Mobile from, int amount )
@ -241,7 +263,7 @@ namespace Server
if ( m_Poisoned ) if ( m_Poisoned )
{ {
m_TotalDamage += amount * 2; m_HonorDamage += amount * 0.8;
m_Poisoned = false; // Reset the flag m_Poisoned = false; // Reset the flag
return; return;
@ -254,16 +276,16 @@ namespace Server
if ( m_Target.CanSee( m_Source ) && m_Target.InLOS( m_Source ) && ( m_Source.InRange( m_Target, 1 ) 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_Source.Location == m_InitialLocation && m_Source.Map == m_InitialMap ) ) )
{ {
m_HonorDamageTwentieths += amount * 20; m_HonorDamage += amount;
} }
else 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() public void OnSourceKilled()
{ {
Cancel(); return;
} }
public void OnTargetKilled() public void OnTargetKilled()
@ -342,16 +364,17 @@ namespace Server
if ( m_Source.Virtues.Honor > targetFame ) if ( m_Source.Virtues.Honor > targetFame )
return; return;
double dGain = ( targetFame * m_HonorDamageTwentieths ) / (double)( 20 * m_TotalDamage ); double dGain = ( targetFame / 100 ) * (m_HonorDamage / m_TotalDamage ); //Initial honor gain is 100th of the monsters honor
dGain = dGain * dGain / 2000000.0;
if ( m_FirstHit == FirstHit.Granted ) if ( m_HonorDamage == m_TotalDamage && m_FirstHit == FirstHit.Granted)
dGain *= 1.1; // Is this correct? 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 ); int gain = Math.Min( (int)dGain, 200 );
if ( gain <= 0 ) if ( gain < 1 )
return; gain=1; //Minimum gain of 1 honor when the honor is under the monsters fame
if ( VirtueHelper.IsHighestPath( m_Source, VirtueName.Honor ) ) if ( VirtueHelper.IsHighestPath( m_Source, VirtueName.Honor ) )
{ {
@ -381,12 +404,6 @@ namespace Server
public bool CheckDistance() 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; return true;
} }

View file

@ -136,20 +136,22 @@ namespace Server
if( value >= 30000 ) if( value >= 30000 )
value = 20000; //Sanity value = 20000; //Sanity
/*
int vl;
vl = (value/10000) int vl;
if( value < 10000 ) if( value < 10000 )
vl = 0; 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; vl = 2;
else else
vl = 1; vl = 1;
*/
return m_Table[(index * 3) + (int)(value/10000)];
return m_Table[(index * 3) + (int) vl];
} }
private class InternalEntry : GumpImage private class InternalEntry : GumpImage

View file

@ -38,10 +38,11 @@ namespace Server
{ {
int v = from.Virtues.GetValue( (int)virtue ); int v = from.Virtues.GetValue( (int)virtue );
int vl; int vl;
int vmax = GetMaxAmount( virtue );
if ( v < 4000 ) if ( v < 4000 )
vl = 0; vl = 0;
else if ( v >= 20000 ) else if ( v >= vmax)
vl = 3; vl = 3;
else else
vl = ( v + 9999 ) / 10000; vl = ( v + 9999 ) / 10000;

View file

@ -39,19 +39,37 @@ namespace Server
int maxValue = VirtueHelper.GetMaxAmount( m_Virtue ); int maxValue = VirtueHelper.GetMaxAmount( m_Virtue );
int valueDesc; 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 ) if( value < 1 )
valueDesc = 1052044; // You have not started on the path of this Virtue. 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. 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. 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. 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. 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. 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 else
valueDesc = 1052050; // You have achieved the highest path in this Virtue. 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) 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 ) public override void OnResponse( NetState state, RelayInfo info )

View file

@ -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;
}
}
}
}

View file

@ -3099,7 +3099,6 @@ namespace Server.Mobiles
JusticeVirtue.CheckAtrophy( m ); JusticeVirtue.CheckAtrophy( m );
CompassionVirtue.CheckAtrophy( m ); CompassionVirtue.CheckAtrophy( m );
ValorVirtue.CheckAtrophy( m ); ValorVirtue.CheckAtrophy( m );
HonorVirtue.CheckAtrophy( m );
if( m is PlayerMobile ) if( m is PlayerMobile )
ChampionTitleInfo.CheckAtrophy( (PlayerMobile)m ); ChampionTitleInfo.CheckAtrophy( (PlayerMobile)m );
@ -3663,6 +3662,7 @@ namespace Server.Mobiles
private bool m_HonorActive; private bool m_HonorActive;
private HonorContext m_ReceivedHonorContext; private HonorContext m_ReceivedHonorContext;
private HonorContext m_SentHonorContext; private HonorContext m_SentHonorContext;
public DateTime m_hontime;
public DateTime LastHonorLoss{ get{ return m_LastHonorLoss; } set{ m_LastHonorLoss = value; } } public DateTime LastHonorLoss{ get{ return m_LastHonorLoss; } set{ m_LastHonorLoss = value; } }
public DateTime LastHonorUse{ get{ return m_LastHonorUse; } set{ m_LastHonorUse = value; } } public DateTime LastHonorUse{ get{ return m_LastHonorUse; } set{ m_LastHonorUse = value; } }