Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fix: Cleans up spell system & fixes bugs #831

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
15ee854
WIP
kamronbatman Oct 16, 2021
a9dae7e
WIP
kamronbatman Oct 17, 2021
5f16fb2
More spell cleanup
kamronbatman Oct 18, 2021
846fa14
Cleans up comments
kamronbatman Oct 18, 2021
c644244
Changes to UOML
kamronbatman Oct 18, 2021
4235645
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Oct 24, 2021
a905063
Fixes spell plague. Cleans up other code
kamronbatman Oct 24, 2021
d72732c
Converts to using pooled ref queue
kamronbatman Oct 24, 2021
95254a3
Adds cleansing winds. Fixes mindrot
kamronbatman Oct 28, 2021
f20323d
Adds sleep spell
kamronbatman Oct 29, 2021
4ed6973
Cleanup
kamronbatman Oct 29, 2021
3d78442
Adds mass sleep spell
kamronbatman Oct 29, 2021
bef8ae3
Cleanup
kamronbatman Oct 29, 2021
0b71e6e
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 1, 2021
53d3c33
WIP
kamronbatman Nov 7, 2021
223af1b
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 12, 2021
f39dcbc
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 14, 2021
74243f6
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 15, 2021
bf64b9e
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 15, 2021
e07f8d0
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Nov 15, 2021
9352ae7
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Dec 1, 2021
25cc77b
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Dec 3, 2021
389cdd7
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Dec 24, 2021
6e5b656
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Dec 24, 2021
b64d9ee
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Dec 24, 2021
10a0025
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jan 11, 2022
c311540
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman May 10, 2022
724c8f8
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jul 17, 2022
44272da
Cleanup
kamronbatman Jul 17, 2022
4d95f56
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jul 17, 2022
d68451d
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jul 17, 2022
c7b6a43
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jul 17, 2022
28f0b21
Merge branch 'main' into kbatman/cleanup_ninjas
kamronbatman Jul 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions Projects/Server/Targeting/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,36 +164,33 @@ public void Invoke(Mobile from, object targeted)
{
OnTargetOutOfRange(from, targeted);
}
else
else if (!from.CanSee(targeted))
{
if (!from.CanSee(targeted))
{
OnCantSeeTarget(from, targeted);
}
else if (CheckLOS && !from.InLOS(targeted))
{
OnTargetOutOfLOS(from, targeted);
}
else if (item?.InSecureTrade == true)
{
OnTargetInSecureTrade(from, targeted);
}
else if (item?.IsAccessibleTo(from) == false)
{
OnTargetNotAccessible(from, targeted);
}
else if (item?.CheckTarget(from, this, targeted) == false)
{
OnTargetUntargetable(from, targeted);
}
else if (mobile?.CheckTarget(from, this, mobile) == false)
{
OnTargetUntargetable(from, mobile);
}
else if (from.Region.OnTarget(from, this, targeted))
{
OnTarget(from, targeted);
}
OnCantSeeTarget(from, targeted);
}
else if (CheckLOS && !from.InLOS(targeted))
{
OnTargetOutOfLOS(from, targeted);
}
else if (item?.InSecureTrade == true)
{
OnTargetInSecureTrade(from, targeted);
}
else if (item?.IsAccessibleTo(from) == false)
{
OnTargetNotAccessible(from, targeted);
}
else if (item?.CheckTarget(from, this, targeted) == false)
{
OnTargetUntargetable(from, targeted);
}
else if (mobile?.CheckTarget(from, this, mobile) == false)
{
OnTargetUntargetable(from, mobile);
}
else if (from.Region.OnTarget(from, this, targeted))
{
OnTarget(from, targeted);
}

OnTargetFinish(from);
Expand Down
14 changes: 5 additions & 9 deletions Projects/UOContent/Engines/ConPVP/DuelContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,12 @@ public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move)
return false;
}

string title = null;

if (move is NinjaMove)
{
title = "Bushido";
}
else if (move is SamuraiMove)
string title = move switch
{
title = "Ninjitsu";
}
NinjaMove => "Bushido",
SamuraiMove => "Ninjitsu",
_ => null
};

if (title == null || name == null || Ruleset.GetOption(title, name))
{
Expand Down
76 changes: 31 additions & 45 deletions Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static void HandleKill(Mobile victim, Mobile killer)

pm.ToTTotalMonsterFame += (int)(bc.Fame * (1 + Math.Sqrt(pm.Luck) / 100));

// This is the Exponentional regression with only 2 datapoints.
// This is the Exponential regression with only 2 datapoints.
// A log. func would also work, but it didn't make as much sense.
// This function isn't OSI exact being that I don't know OSI's func they used ;p
var x = pm.ToTTotalMonsterFame;
Expand Down Expand Up @@ -263,16 +263,12 @@ public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Alive && m is PlayerMobile pm)
{
var range = 3;

if (pm.Alive && (Z - pm.Z).Abs() < 16 && InRange(m, range) && !InRange(oldLocation, range))
if (pm.Alive && (Z - pm.Z).Abs() < 16 && InRange(m, 3) && !InRange(oldLocation, 3))
{
if (pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
{
SayTo(
pm,
1070980
); // Congratulations! You have turned in enough minor treasures to earn a greater reward.
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
SayTo(pm, 1070980);

pm.CloseGump<ToTTurnInGump>(); // Sanity

Expand All @@ -285,18 +281,16 @@ public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (pm.ToTItemsTurnedIn == 0)
{
SayTo(
pm,
1071013
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
SayTo(pm, 1071013);
}
else
{
SayTo(
pm,
1070981,
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
);
}

var buttons = ToTTurnInGump.FindRedeemableItems(pm);
Expand Down Expand Up @@ -331,7 +325,7 @@ public class ItemTileButtonInfo : ImageTileButtonInfo
public ItemTileButtonInfo(Item i) : base(
i.ItemID,
i.Hue,
i.Name == null || i.Name.Length <= 0 ? i.LabelNumber : i.Name
i.Name is not { Length: > 0 } ? i.LabelNumber : i.Name
) =>
Item = i;

Expand All @@ -343,11 +337,9 @@ public class ToTTurnInGump : BaseImageTileButtonsGump
private readonly Mobile m_Collector;

public ToTTurnInGump(Mobile collector, List<ItemTileButtonInfo> buttons) : base(
1071012,
1071012, // Click a minor artifact to give it to Ihara Soko.
buttons.ToList<ImageTileButtonInfo>()
) // Click a minor artifact to give it to Ihara Soko.
=>
m_Collector = collector;
) => m_Collector = collector;

public static List<ItemTileButtonInfo> FindRedeemableItems(Mobile m)
{
Expand Down Expand Up @@ -400,10 +392,8 @@ public override void HandleButtonResponse(NetState sender, int adjustedButton, I

if (++pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
{
m_Collector.SayTo(
pm,
1070980
); // Congratulations! You have turned in enough minor treasures to earn a greater reward.
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
m_Collector.SayTo(pm, 1070980);

pm.CloseGump<ToTTurnInGump>(); // Sanity

Expand All @@ -416,9 +406,9 @@ public override void HandleButtonResponse(NetState sender, int adjustedButton, I
{
m_Collector.SayTo(
pm,
1070981,
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
);

var buttons = FindRedeemableItems(pm);

Expand All @@ -433,26 +423,24 @@ public override void HandleButtonResponse(NetState sender, int adjustedButton, I

public override void HandleCancel(NetState sender)
{
if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7))
if (sender.Mobile is not PlayerMobile pm || !pm.InRange(m_Collector.Location, 7))
{
return;
}

if (pm.ToTItemsTurnedIn == 0)
{
m_Collector.SayTo(
pm,
1071013
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
m_Collector.SayTo(pm, 1071013);
}
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward
) // This case should ALWAYS be true with this gump, jsut a sanity check
// This case should ALWAYS be true with this gump, just a sanity check
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward)
{
m_Collector.SayTo(
pm,
1070981,
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
);
}
else
{
Expand Down Expand Up @@ -611,11 +599,11 @@ public override void HandleButtonResponse(NetState sender, int adjustedButton, I
pm.ToTItemsTurnedIn -= TreasuresOfTokuno.ItemsPerReward;
m_Collector.SayTo(
pm,
1070984,
item.Name == null || item.Name.Length <= 0
1070984, // You have earned the gratitude of the Empire. I have placed the ~1_OBJTYPE~ in your backpack.
item.Name is not { Length: > 0 }
? $"#{item.LabelNumber}"
: item.Name
); // You have earned the gratitude of the Empire. I have placed the ~1_OBJTYPE~ in your backpack.
);
}
else
{
Expand All @@ -634,19 +622,17 @@ public override void HandleCancel(NetState sender)

if (pm.ToTItemsTurnedIn == 0)
{
m_Collector.SayTo(
pm,
1071013
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
m_Collector.SayTo(pm, 1071013);
}
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward
) // This and above case should ALWAYS be FALSE with this gump, jsut a sanity check
// This and above case should ALWAYS be FALSE with this gump, just a sanity check
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward)
{
m_Collector.SayTo(
pm,
1070981,
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
);
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Mobiles.Clone.v0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Mobiles.Clone"
}
20 changes: 6 additions & 14 deletions Projects/UOContent/Skills/RemoveTrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static TimeSpan OnUse(Mobile m)
else
{
m.Target = new InternalTarget();

m.SendLocalizedMessage(502368); // Which trap will you attempt to disarm?
}

Expand Down Expand Up @@ -78,19 +77,17 @@ protected override void OnTarget(Mobile from, object targeted)

if (faction == null)
{
from.SendLocalizedMessage(
1010538
); // You may not disarm faction traps unless you are in an opposing faction
// You may not disarm faction traps unless you are in an opposing faction
from.SendLocalizedMessage(1010538);
}
else if (trap.Faction != null && faction == trap.Faction && !isOwner)
{
from.SendLocalizedMessage(1010537); // You may not disarm traps set by your own faction!
}
else if (!isOwner && kit == null)
{
from.SendLocalizedMessage(
1042530
); // You must have a trap removal kit at the base level of your pack to disarm a faction trap.
// You must have a trap removal kit at the base level of your pack to disarm a faction trap.
from.SendLocalizedMessage(1042530);
}
else
{
Expand All @@ -110,13 +107,8 @@ protected override void OnTarget(Mobile from, object targeted)

if (silver > 0)
{
from.SendLocalizedMessage(
1008113,
true,
silver.ToString(
"N0"
)
); // You have been granted faction silver for removing the enemy trap :
// You have been granted faction silver for removing the enemy trap :
from.SendLocalizedMessage(1008113, true, silver.ToString("N0"));
}
}

Expand Down
27 changes: 13 additions & 14 deletions Projects/UOContent/Spells/Base/MagerySpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace Server.Spells
{
public abstract class MagerySpell : Spell
{
private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0;
private static readonly int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };
private static readonly double[] _requiredSkill =
Core.AOS ? new[] { 0.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } :
kamronbatman marked this conversation as resolved.
Show resolved Hide resolved
new[] { 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 };

private static readonly int[] m_ManaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };

public MagerySpell(Mobile caster, Item scroll, SpellInfo info)
: base(caster, scroll, info)
public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
{
}

Expand All @@ -30,13 +30,11 @@ public override void GetCastSkills(out double min, out double max)
circle -= 2;
}

var avg = ChanceLength * circle;

min = avg - ChanceOffset;
max = avg + ChanceOffset;
min = _requiredSkill[circle];
max = min + 40;
}

public override int GetMana() => Scroll is BaseWand ? 0 : m_ManaTable[(int)Circle];
public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle];

public override double GetResistSkill(Mobile m)
{
Expand Down Expand Up @@ -80,12 +78,13 @@ public virtual bool CheckResisted(Mobile target)

public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle)
{
var firstPercent = target.Skills.MagicResist.Value / 5.0;
var secondPercent = target.Skills.MagicResist.Value -
var magicResist = target.Skills.MagicResist.Value;
var firstPercent = magicResist / 5.0;
var secondPercent = magicResist -
((Caster.Skills[CastSkill].Value - 20.0) / 5.0 + (1 + (int)circle) * 5.0);

return (firstPercent > secondPercent ? firstPercent : secondPercent) /
2.0; // Seems should be about half of what stratics says.
// Seems should be about half of what stratics says.
return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0;
}

public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle);
Expand Down
Loading