fix: Fixes champion drop logic (#1731)

### Summary
- Fixes which maps can drop SoT and PS
- Fixes the percentage chance that SoT/PS can drop
This commit is contained in:
Kamron Batman 2024-04-14 16:40:09 -07:00 • committed by GitHub
parent 4140209df2
commit ada2378e33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 92 additions and 108 deletions

View file

@ -409,40 +409,44 @@ public partial class ChampionSpawn : Item
ReadyToActivate = true; ReadyToActivate = true;
} }
private ScrollofTranscendence CreateRandomTramSoT() private static ScrollofTranscendence CreateRandomSoT(bool isFel)
{ {
int level = Utility.Random(5) + 1; var min = isFel ? 1 : 6;
return ScrollofTranscendence.CreateRandom(level, level); var max = isFel ? 5 : 10;
return ScrollofTranscendence.CreateRandom(min, max);
} }
private ScrollofTranscendence CreateRandomFelSoT() private static PowerScroll CreateRandomPS() => PowerScroll.CreateRandomNoCraft(5, 5);
{
int level = Utility.Random(5) + 1;
return ScrollofTranscendence.CreateRandom(level, level);
}
private static PowerScroll CreateRandomFelPS() => PowerScroll.CreateRandomNoCraft(5, 5); public static void GiveScrollTo(Mobile killer, SpecialScroll scroll, bool isFelucca = true)
public static void GiveScrollOfTranscendenceFelTo(Mobile killer, ScrollofTranscendence SoTF)
{ {
if (SoTF == null || killer == null) //sanity if (scroll == null || killer == null) // sanity
{ {
return; return;
} }
killer.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence! if (scroll is ScrollofTranscendence)
if (killer.Alive)
{ {
killer.AddToBackpack(SoTF); killer.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence!
}
else if (killer.Corpse is { Deleted: false })
{
killer.Corpse.DropItem(SoTF);
} }
else else
{ {
killer.AddToBackpack(SoTF); killer.SendLocalizedMessage(1049524); // You have received a scroll of power!
}
if (!isFelucca)
{
killer.AddToBackpack(scroll);
return;
}
if (killer.Alive || killer.Corpse is not { Deleted: false })
{
killer.AddToBackpack(scroll);
}
else
{
killer.Corpse.DropItem(scroll);
} }
// Justice reward // Justice reward
@ -464,55 +468,22 @@ public partial class ChampionSpawn : Item
if (chance > 0 && chance > Utility.Random(100)) if (chance > 0 && chance > Utility.Random(100))
{ {
prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice! try
ScrollofTranscendence SoTFduplicate = new ScrollofTranscendence (SoTF.Skill, SoTF.Value); {
prot.AddToBackpack(SoTFduplicate); var scrollDupe = scroll.GetType().CreateEntityInstance<SpecialScroll>();
}
}
public static void GivePowerScrollFelTo (Mobile killer, PowerScroll PS) if (scrollDupe != null)
{ {
if (PS == null || killer == null) //sanity prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice!
{ scrollDupe.Skill = scroll.Skill;
return; scrollDupe.Value = scroll.Value;
} prot.AddToBackpack(scrollDupe);
}
killer.SendLocalizedMessage(1049524); // You have received a scroll of power! }
catch
if (killer.Alive) {
{ // ignored
killer.AddToBackpack(PS); }
}
else if (killer.Corpse is { Deleted: false })
{
killer.Corpse.DropItem(PS);
}
else
{
killer.AddToBackpack(PS);
}
// Justice reward
var pm = (PlayerMobile)killer;
var prot = JusticeVirtue.GetProtector(pm);
if (prot == null || prot.Map != killer.Map || prot.Kills >= 5 || prot.Criminal ||
!JusticeVirtue.CheckMapRegion(killer, prot))
{
return;
}
var chance = VirtueSystem.GetLevel(prot, VirtueName.Justice) switch
{
VirtueLevel.Seeker => 60,
VirtueLevel.Follower => 80,
VirtueLevel.Knight => 100,
_ => 0
};
if (chance > 0 && chance > Utility.Random(100))
{
prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice!
prot.AddToBackpack(CreateRandomFelPS());
} }
} }
@ -583,55 +554,68 @@ public partial class ChampionSpawn : Item
killer = creature.GetMaster(); killer = creature.GetMaster();
} }
if (killer is PlayerMobile pm) if (killer is not PlayerMobile pm)
{ {
if (Core.ML) continue;
}
int mobSubLevel = GetSubLevelfor(m) + 1;
if (mobSubLevel >= 0)
{
bool gainedPath = false;
int pointsToGain = mobSubLevel * 40;
if (VirtueSystem.Award(pm, VirtueName.Valor, pointsToGain, ref gainedPath))
{ {
if (Map == Map.Felucca) if (gainedPath)
{ {
// 1 in 1000 you get either a scroll of transcendence or a powerscroll pm.SendLocalizedMessage(1054032); // You have gained a path in Valor!
var random = Utility.Random(2000); }
if (random == 0) else
{ {
GiveScrollOfTranscendenceFelTo(pm, CreateRandomFelSoT()); pm.SendLocalizedMessage(1054030); // You have gained in Valor!
}
else if (random == 1)
{
GivePowerScrollFelTo(pm, CreateRandomFelPS());
}
} }
if ((Map == Map.Ilshenar || Map == Map.Tokuno) && Utility.Random(10000) < 15) // No delay on Valor gains
{
pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence!
pm.AddToBackpack(CreateRandomTramSoT());
}
} }
int mobSubLevel = GetSubLevelfor(m) + 1; pm.ChampionTitles.Award(_type, mobSubLevel);
}
if (mobSubLevel >= 0) if (!Core.ML)
{ {
bool gainedPath = false; continue;
}
int pointsToGain = mobSubLevel * 40; var isFel = Map == Map.Felucca;
double mapChance;
if (isFel)
{
mapChance = 0.001;
}
else if (Map == Map.Ilshenar || Map == Map.Tokuno)
{
mapChance = 0.0015;
}
else // Nothing drops in Trammel, Malas or TerMur
{
continue;
}
if (VirtueSystem.Award(pm, VirtueName.Valor, pointsToGain, ref gainedPath)) if (Utility.RandomDouble() >= mapChance)
{ {
if (gainedPath) continue;
{ }
pm.SendLocalizedMessage(1054032); // You have gained a path in Valor!
}
else
{
pm.SendLocalizedMessage(1054030); // You have gained in Valor!
}
// No delay on Valor gains if (!isFel || Utility.RandomBool())
} {
GiveScrollTo(pm, CreateRandomSoT(isFel), isFel);
pm.ChampionTitles.Award(_type, mobSubLevel); }
} else
{
GiveScrollTo(pm, CreateRandomPS());
} }
} }
} }

View file

@ -28,7 +28,7 @@ public partial class ScrollofTranscendence : SpecialScroll
$"<basefont color=#FFFFFF>Scroll of Transcendence ({Math.Floor(Value * 10) / 10:0.#} Skill):</basefont>"; $"<basefont color=#FFFFFF>Scroll of Transcendence ({Math.Floor(Value * 10) / 10:0.#} Skill):</basefont>";
public static ScrollofTranscendence CreateRandom(int min, int max) => public static ScrollofTranscendence CreateRandom(int min, int max) =>
new(Utility.RandomSkill(), Utility.RandomMinMax(min, max) * 0.1); new(Utility.RandomSkill(), Utility.RandomMinMax(min, max) / 10.0);
public override void GetProperties(IPropertyList list) public override void GetProperties(IPropertyList list)
{ {