fix: Fixes ethics causing crashes when not used (#1972)

This commit is contained in:
Kamron Batman 2024-10-15 17:02:11 -07:00 • committed by GitHub
parent b7316a5bd6
commit f16bce60e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 82 deletions

View file

@ -54,15 +54,19 @@ public partial class UnholyFamiliar : BaseCreature
public override string ApplyNameSuffix(string suffix)
{
if (suffix.Length == 0)
var ethic = Ethic.Evil;
if (ethic == null)
{
suffix = Ethic.Evil.Definition.Adjunct.String;
}
else
{
suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}";
return base.ApplyNameSuffix("");
}
return base.ApplyNameSuffix(suffix);
var adjunct = ethic.Definition.Adjunct;
if (suffix.Length == 0)
{
return base.ApplyNameSuffix(adjunct);
}
return base.ApplyNameSuffix($"{suffix} {adjunct}");
}
}

View file

@ -53,17 +53,25 @@ public partial class UnholySteed : BaseMount
public override string ApplyNameSuffix(string suffix)
{
if (suffix.Length == 0)
var ethic = Ethic.Evil;
if (ethic == null)
{
return base.ApplyNameSuffix(Ethic.Evil.Definition.Adjunct.String);
return base.ApplyNameSuffix("");
}
return base.ApplyNameSuffix($"{suffix} {Ethic.Evil.Definition.Adjunct.String}");
var adjunct = ethic.Definition.Adjunct;
if (suffix.Length == 0)
{
return base.ApplyNameSuffix(adjunct);
}
return base.ApplyNameSuffix($"{suffix} {adjunct}");
}
public override void OnDoubleClick(Mobile from)
{
if (Ethic.Find(from) != Ethic.Evil)
if (Ethic.Evil == null || Ethic.Find(from) != Ethic.Evil)
{
from.SendMessage("You may not ride this steed.");
}