Formats UO Content (#201)

This commit is contained in:
Kamron Batman 2020-08-27 18:30:38 -07:00 • committed by GitHub
parent 86b7b3aed1
commit ad3775c4d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3249 changed files with 431083 additions and 440981 deletions

View file

@ -6,99 +6,102 @@ using Server.Targeting;
namespace Server.SkillHandlers
{
public static class DetectHidden
{
public static void Initialize()
public static class DetectHidden
{
SkillInfo.Table[(int)SkillName.DetectHidden].Callback = OnUse;
}
public static TimeSpan OnUse(Mobile src)
{
src.SendLocalizedMessage(500819); // Where will you search?
src.Target = new InternalTarget();
return TimeSpan.FromSeconds(6.0);
}
private class InternalTarget : Target
{
public InternalTarget() : base(12, true, TargetFlags.None)
{
}
protected override void OnTarget(Mobile src, object targ)
{
bool foundAnyone = false;
Point3D p;
if (targ is Mobile mobile)
p = mobile.Location;
else if (targ is Item item)
p = item.Location;
else if (targ is IPoint3D d)
p = new Point3D(d);
else
p = src.Location;
double srcSkill = src.Skills.DetectHidden.Value;
int range = (int)(srcSkill / 10.0);
if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
range /= 2;
BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16);
bool inHouse = house?.IsFriend(src) == true;
if (inHouse)
range = 22;
if (range > 0)
public static void Initialize()
{
IPooledEnumerable<Mobile> inRange = src.Map.GetMobilesInRange(p, range);
foreach (Mobile trg in inRange)
if (trg.Hidden && src != trg)
{
double ss = srcSkill + Utility.Random(21) - 10;
double ts = trg.Skills.Hiding.Value + Utility.Random(21) - 10;
if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || (inHouse && house.IsInside(trg))))
{
if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y))
continue;
trg.RevealingAction();
trg.SendLocalizedMessage(500814); // You have been revealed!
foundAnyone = true;
}
}
inRange.Free();
if (Faction.Find(src) != null)
{
IPooledEnumerable<BaseFactionTrap> itemsInRange = src.Map.GetItemsInRange<BaseFactionTrap>(p, range);
foreach (BaseFactionTrap trap in itemsInRange)
if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
{
src.SendLocalizedMessage(1042712, true,
$" {(trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)}"); // You reveal a trap placed by a faction:
trap.Visible = true;
trap.BeginConceal();
foundAnyone = true;
}
itemsInRange.Free();
}
SkillInfo.Table[(int)SkillName.DetectHidden].Callback = OnUse;
}
if (!foundAnyone) src.SendLocalizedMessage(500817); // You can see nothing hidden there.
}
public static TimeSpan OnUse(Mobile src)
{
src.SendLocalizedMessage(500819); // Where will you search?
src.Target = new InternalTarget();
return TimeSpan.FromSeconds(6.0);
}
private class InternalTarget : Target
{
public InternalTarget() : base(12, true, TargetFlags.None)
{
}
protected override void OnTarget(Mobile src, object targ)
{
var foundAnyone = false;
Point3D p;
if (targ is Mobile mobile)
p = mobile.Location;
else if (targ is Item item)
p = item.Location;
else if (targ is IPoint3D d)
p = new Point3D(d);
else
p = src.Location;
var srcSkill = src.Skills.DetectHidden.Value;
var range = (int)(srcSkill / 10.0);
if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
range /= 2;
var house = BaseHouse.FindHouseAt(p, src.Map, 16);
var inHouse = house?.IsFriend(src) == true;
if (inHouse)
range = 22;
if (range > 0)
{
var inRange = src.Map.GetMobilesInRange(p, range);
foreach (var trg in inRange)
if (trg.Hidden && src != trg)
{
var ss = srcSkill + Utility.Random(21) - 10;
var ts = trg.Skills.Hiding.Value + Utility.Random(21) - 10;
if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || inHouse && house.IsInside(trg)))
{
if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y))
continue;
trg.RevealingAction();
trg.SendLocalizedMessage(500814); // You have been revealed!
foundAnyone = true;
}
}
inRange.Free();
if (Faction.Find(src) != null)
{
var itemsInRange = src.Map.GetItemsInRange<BaseFactionTrap>(p, range);
foreach (var trap in itemsInRange)
if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
{
src.SendLocalizedMessage(
1042712,
true,
$" {(trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)}"
); // You reveal a trap placed by a faction:
trap.Visible = true;
trap.BeginConceal();
foundAnyone = true;
}
itemsInRange.Free();
}
}
if (!foundAnyone) src.SendLocalizedMessage(500817); // You can see nothing hidden there.
}
}
}
}
}