feat: Adds Monster Abilities (#1179)

* Adds ability to create monster abilities
* Adds Fire/Cold/Chaos Breath
* Adds Grasping Claw
* Adds Summon Skeletons & Summon Undead w/ Polymorph
This commit is contained in:
Kamron Batman 2022-10-01 21:09:36 -07:00 • committed by GitHub
parent 8a2c0ead3d
commit 43e7fe29c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
91 changed files with 1262 additions and 977 deletions

View file

@ -1062,6 +1062,9 @@ public static class Utility
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool RandomBool() => RandomSources.Source.NextBool();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TimeSpan RandomMinMax(TimeSpan min, TimeSpan max) => new(RandomMinMax(min.Ticks, max.Ticks));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double RandomMinMax(double min, double max)
{
@ -1540,4 +1543,67 @@ public static class Utility
return combined;
}
public static Point3D GetValidLocation(Map map, Point3D center, int range, int retries = 10)
{
if (map == null)
{
return center;
}
var loc = new Point3D(center.Z, center.Y, center.Z);
for (var i = 0; i < retries; i++)
{
loc.X = center.X + (Random(range * 2 + 1) - range);
loc.Y = center.Y + (Random(range * 2 + 1) - range);
loc.Z = center.Z;
if (map.CanSpawnMobile(loc))
{
return loc;
}
loc.Z = map.GetAverageZ(loc.X, loc.Y);
if (map.CanSpawnMobile(loc))
{
return loc;
}
}
return center;
}
public static Point3D GetValidLocationInLOS(Map map, Mobile from, int range, int retries = 10)
{
if (map == null)
{
return from.Location;
}
var center = from.Location;
var loc = center;
for (var i = 0; i < retries; i++)
{
loc.X = center.X + (Random(range * 2 + 1) - range);
loc.Y = center.Y + (Random(range * 2 + 1) - range);
loc.Z = center.Z;
if (map.CanSpawnMobile(loc) && map.LineOfSight(from, loc))
{
return loc;
}
loc.Z = map.GetAverageZ(loc.X, loc.Y);
if (map.CanSpawnMobile(loc) && map.LineOfSight(from, loc))
{
return loc;
}
}
return center;
}
}