fix: Fixes champion titles atrophying immediately (#1210)

This commit is contained in:
Kamron Batman 2022-10-27 22:15:18 -07:00 • committed by GitHub
parent be19d9aae6
commit deabab575a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 196 additions and 186 deletions

View file

@ -585,7 +585,7 @@ namespace Server.Engines.CannedEvil
}
}
int mobSubLevel = GetSubLevelfor (m) + 1;
int mobSubLevel = GetSubLevelfor(m) + 1;
if (mobSubLevel >= 0)
{
@ -604,12 +604,10 @@ namespace Server.Engines.CannedEvil
m.SendLocalizedMessage(1054030); // You have gained in Valor!
}
//No delay on Valor gains
// No delay on Valor gains
}
ChampionTitleInfo info = pm.ChampionTitles;
info.Award(m_Type, mobSubLevel);
pm.ChampionTitles.Award(m_Type, mobSubLevel);
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using Server.Mobiles;
namespace Server
@ -18,25 +19,19 @@ namespace Server
from.SendLocalizedMessage(1053001); // This virtue is not activated through the virtue menu.
}
public static void CheckAtrophy(Mobile from)
{
if (from is not PlayerMobile pm)
{
return;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ShouldAtrophy(PlayerMobile pm) => pm.LastCompassionLoss + LossDelay < Core.Now;
try
public static void CheckAtrophy(PlayerMobile pm)
{
if (ShouldAtrophy(pm))
{
if (pm.LastCompassionLoss + LossDelay < Core.Now)
if (VirtueHelper.Atrophy(pm, VirtueName.Compassion, LossAmount))
{
VirtueHelper.Atrophy(from, VirtueName.Compassion, LossAmount);
// OSI has no cliloc message for losing compassion. Weird.
pm.LastCompassionLoss = Core.Now;
pm.SendLocalizedMessage(1114420); // You have lost some Compassion.
}
}
catch
{
// ignored
pm.LastCompassionLoss = Core.Now;
}
}
}

View file

@ -68,20 +68,13 @@ namespace Server
public static void ActivateEmbrace(PlayerMobile pm)
{
var duration = GetHonorDuration(pm);
int usedPoints;
if (pm.Virtues.Honor < 4399)
int usedPoints = pm.Virtues.Honor switch
{
usedPoints = 400;
}
else if (pm.Virtues.Honor < 10599)
{
usedPoints = 600;
}
else
{
usedPoints = 1000;
}
< 4399 => 400,
< 10599 => 600,
_ => 1000
};
VirtueHelper.Atrophy(pm, VirtueName.Honor, usedPoints);

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
@ -6,7 +7,7 @@ using Server.Targeting;
namespace Server
{
#pragma warning disable CA1052
#pragma warning disable CA1052 // Cannot be static because its used as a generic for CanBeginAction.
public class JusticeVirtue
{
private const int LossAmount = 950;
@ -71,14 +72,13 @@ namespace Server
public static void OnVirtueTargeted(Mobile from, object obj)
{
var protector = from as PlayerMobile;
var pm = obj as PlayerMobile;
if (protector == null)
if (from is not PlayerMobile protector)
{
return;
}
var pm = obj as PlayerMobile;
if (!VirtueHelper.IsSeeker(protector, VirtueName.Justice))
{
protector.SendLocalizedMessage(1049610); // You must reach the first path in this virtue to invoke it.
@ -175,28 +175,20 @@ namespace Server
}
}
public static void CheckAtrophy(Mobile from)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ShouldAtrophy(PlayerMobile pm) => pm.LastJusticeLoss + LossDelay < Core.Now;
public static void CheckAtrophy(PlayerMobile pm)
{
if (from is not PlayerMobile pm)
if (ShouldAtrophy(pm))
{
return;
}
try
{
if (pm.LastJusticeLoss + LossDelay < Core.Now)
if (VirtueHelper.Atrophy(pm, VirtueName.Justice, LossAmount))
{
if (VirtueHelper.Atrophy(from, VirtueName.Justice, LossAmount))
{
from.SendLocalizedMessage(1049373); // You have lost some Justice.
}
pm.LastJusticeLoss = Core.Now;
pm.SendLocalizedMessage(1049373); // You have lost some Justice.
}
}
catch
{
// ignored
pm.LastJusticeLoss = Core.Now;
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
@ -36,31 +37,22 @@ namespace Server
}
}
public static void CheckAtrophy(Mobile from)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ShouldAtrophy(PlayerMobile pm) => pm.LastSacrificeLoss + LossDelay < Core.Now;
public static void CheckAtrophy(PlayerMobile pm)
{
if (from is not PlayerMobile pm)
if (ShouldAtrophy(pm))
{
return;
}
try
{
if (pm.LastSacrificeLoss + LossDelay < Core.Now)
if (VirtueHelper.Atrophy(pm, VirtueName.Sacrifice, LossAmount))
{
if (VirtueHelper.Atrophy(from, VirtueName.Sacrifice, LossAmount))
{
from.SendLocalizedMessage(1052041); // You have lost some Sacrifice.
}
var level = VirtueHelper.GetLevel(from, VirtueName.Sacrifice);
pm.AvailableResurrects = (int)level;
pm.LastSacrificeLoss = Core.Now;
pm.SendLocalizedMessage(1052041); // You have lost some Sacrifice.
}
}
catch
{
// ignored
var level = VirtueHelper.GetLevel(pm, VirtueName.Sacrifice);
pm.AvailableResurrects = (int)level;
pm.LastSacrificeLoss = Core.Now;
}
}
@ -183,15 +175,9 @@ namespace Server
}
}
public static bool ValidateCreature(Mobile m)
{
if (m is BaseCreature creature && (creature.Controlled || creature.Summoned))
{
return false;
}
return m is Lich or Succubus or Daemon or EvilMage or EnslavedGargoyle or GargoyleEnforcer;
}
public static bool ValidateCreature(Mobile m) =>
(m is not BaseCreature creature || !creature.Controlled && !creature.Summoned) &&
m is Lich or Succubus or Daemon or EvilMage or EnslavedGargoyle or GargoyleEnforcer;
private class InternalTarget : Target
{

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using Server.Engines.CannedEvil;
using Server.Mobiles;
using Server.Targeting;
@ -24,28 +25,19 @@ public static class ValorVirtue
}
}
public static void CheckAtrophy(Mobile from)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ShouldAtrophy(PlayerMobile pm) => pm.LastValorLoss + LossDelay < Core.Now;
public static void CheckAtrophy(PlayerMobile pm)
{
if (from is not PlayerMobile pm)
if (ShouldAtrophy(pm))
{
return;
}
try
{
if (pm.LastValorLoss + LossDelay < Core.Now)
if (VirtueHelper.Atrophy(pm, VirtueName.Valor, LossAmount))
{
if (VirtueHelper.Atrophy(from, VirtueName.Valor, LossAmount))
{
from.SendLocalizedMessage(1054040); // You have lost some Valor.
}
pm.LastValorLoss = Core.Now;
pm.SendLocalizedMessage(1054040); // You have lost some Valor.
}
}
catch
{
// ignored
pm.LastValorLoss = Core.Now;
}
}