ModernUO/Projects/UOContent/Engines/Virtues/Valor.cs
mark1145 053dbcbad0
fix: Fixes ignoring mobs, champions, party crash, slayer rarity, boat speedhack, etc (#1222)
* Movie ignore mobiles to Mobile class
* Allow necromancer familiars to ignore mobiles
* ChampionSpawn should not quietly fail when creating new spawn
* Fix client party crash bug: 2 people partied, the leader logs out, other client is hung
* Fix spellbooks creating with magery/meditation only and creating magery multiple times
* Fix BaseRunicTool.GetRandomSlayer() creating more undead slayers than intended
* Do not allow players to dismount each other whilst mounted
* Fix AOS onwards damage increase tooltip and wrong formula in AOS
* Fix monsters killing other monster revenants + animate dead should not attack player pets + other animates
* Fix fire steed having loot pack added twice
* Fix oaks spawn not able to create Unicorns + Kirins via Activator.CreateInstace() due to constructor having name as parametr
* Fix ignoreMobiles flag not propagated to client for non-players.
* Fix harrower tents not leeching from players
* Fix boats speedhacking around the map
* Fix bless, agility etc. not renewing duration
* Fix reveal always worked
* Fix empty constructor for steeds so they don't throw now.
2022-10-31 22:16:50 -07:00

134 lines
4.2 KiB
C#

using System;
using System.Runtime.CompilerServices;
using Server.Engines.CannedEvil;
using Server.Mobiles;
using Server.Targeting;
namespace Server;
public static class ValorVirtue
{
private const int LossAmount = 250;
private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{
VirtueGump.Register(112, OnVirtueUsed);
}
public static void OnVirtueUsed(Mobile from)
{
if (from.Alive)
{
from.SendLocalizedMessage(1054034); // Target the Champion Idol of the Champion you wish to challenge!.
from.Target = new InternalTarget();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ShouldAtrophy(PlayerMobile pm) => pm.LastValorLoss + LossDelay < Core.Now;
public static void CheckAtrophy(PlayerMobile pm)
{
if (ShouldAtrophy(pm))
{
if (VirtueHelper.Atrophy(pm, VirtueName.Valor, LossAmount))
{
pm.SendLocalizedMessage(1054040); // You have lost some Valor.
}
pm.LastValorLoss = Core.Now;
}
}
public static void Valor(Mobile from, object targ)
{
if (targ is not IdolOfTheChampion idol || idol.Deleted || idol.Spawn?.Deleted != false)
{
from.SendLocalizedMessage(1054035); // You must target a Champion Idol to challenge the Champion's spawn!
}
else if (from.Hidden)
{
from.SendLocalizedMessage(1052015); // You cannot do that while hidden.
}
else if (idol.Spawn.HasBeenAdvanced)
{
from.SendLocalizedMessage(1054038); // The Champion of this region has already been challenged!
}
else if (idol.Spawn.Active)
{
if (idol.Spawn.Champion != null) // TODO: Message?
{
return;
}
int needed, consumed;
switch (idol.Spawn.GetSubLevel())
{
case 0:
{
needed = consumed = 2500;
break;
}
case 1:
{
needed = consumed = 5000;
break;
}
case 2:
{
needed = 10000;
consumed = 7500;
break;
}
default:
{
needed = 20000;
consumed = 10000;
break;
}
}
if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed)
{
VirtueHelper.Atrophy(from, VirtueName.Valor, consumed);
// Your challenge is heard by the Champion of this region! Beware its wrath!
from.SendLocalizedMessage(1054037);
idol.Spawn.HasBeenAdvanced = true;
idol.Spawn.AdvanceLevel();
}
else
{
// The Champion of this region ignores your challenge. You must further prove your valor.
from.SendLocalizedMessage(1054039);
}
}
else if (VirtueHelper.GetLevel(from, VirtueName.Valor) == VirtueLevel.Knight)
{
VirtueHelper.Atrophy(from, VirtueName.Valor, 11000);
// Your challenge is heard by the Champion of this region! Beware its wrath!
from.SendLocalizedMessage(1054037);
idol.Spawn.Start();
idol.Spawn.ActivatedByValor = true;
// Uncomment to not allow advancing level after starting with valor.
// idol.Spawn.HasBeenAdvanced = true;
}
else
{
// You must be a Knight of Valor to summon the champion's spawn in this manner!
from.SendLocalizedMessage(1054036);
}
}
private class InternalTarget : Target
{
public InternalTarget() : base(14, false, TargetFlags.None)
{
}
protected override void OnTarget(Mobile from, object targeted)
{
Valor(from, targeted);
}
}
}