This commit is contained in:
Kamron Batman 2020-04-10 14:41:39 -07:00 committed by GitHub
parent 4f75cd9251
commit 5b5bfeb4b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1696 additions and 728 deletions

View file

@ -589,17 +589,11 @@ namespace Server.Multis
return fromSecures + fromVendors + fromLockdowns + fromMovingCrate;
}
public bool InRange(IPoint2D from, int range)
public override bool InRange(IPoint2D from, int range)
{
if (Region == null)
return false;
foreach (Rectangle3D rect in Region.Area)
if (from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range &&
from.Y < rect.End.Y + range)
return true;
return false;
return Region?.Area.Any(rect =>
from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range
) == true;
}
public virtual int GetNewVendorSystemMaxVendors()
@ -651,25 +645,11 @@ namespace Server.Multis
eable.Free();
}
public List<Mobile> AvailableVendorsFor(Mobile m)
{
List<Mobile> list = new List<Mobile>();
public List<Mobile> AvailableVendorsFor(Mobile m) =>
PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).Cast<Mobile>().ToList();
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor.CanInteractWith(m, false))
list.Add(vendor);
return list;
}
public bool AreThereAvailableVendorsFor(Mobile m)
{
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor.CanInteractWith(m, false))
return true;
return false;
}
public bool AreThereAvailableVendorsFor(Mobile m) =>
PlayerVendors.Any(vendor => vendor.CanInteractWith(m, false));
public void MoveAllToCrate()
{
@ -811,25 +791,10 @@ namespace Server.Multis
if (m_Trash != null && m_Trash.Map != Map.Internal)
list.Add(m_Trash);
foreach (Item item in LockDowns)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
foreach (Item item in VendorRentalContracts)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
foreach (SecureInfo info in Secures)
{
Item item = info.Item;
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
}
foreach (Item item in Addons)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
list.AddRange(LockDowns.Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(VendorRentalContracts.Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(Secures.Select(info => info.Item).Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(Addons.Where(item => item.Parent == null && item.Map != Map.Internal));
foreach (PlayerVendor mobile in PlayerVendors)
{
@ -839,9 +804,7 @@ namespace Server.Multis
list.Add(mobile);
}
foreach (Mobile mobile in PlayerBarkeepers)
if (mobile.Map != Map.Internal)
list.Add(mobile);
list.AddRange(PlayerBarkeepers.Where(mobile => mobile.Map != Map.Internal));
return list;
}
@ -1409,6 +1372,216 @@ namespace Server.Multis
return new[] { westDoor, eastDoor };
}
protected BaseDoor AddDoor(int itemID, int xOffset, int yOffset, int zOffset) =>
AddDoor(null, itemID, xOffset, yOffset, zOffset);
protected BaseDoor AddDoor(Mobile from, int itemID, int xOffset, int yOffset, int zOffset)
{
BaseDoor door = null;
if (itemID >= 0x675 && itemID < 0x6F5)
{
int type = (itemID - 0x675) / 16;
DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8);
door = type switch
{
0 => new GenericHouseDoor(facing, 0x675, 0xEC, 0xF3),
1 => new GenericHouseDoor(facing, 0x685, 0xEC, 0xF3),
2 => new GenericHouseDoor(facing, 0x695, 0xEB, 0xF2),
3 => new GenericHouseDoor(facing, 0x6A5, 0xEA, 0xF1),
4 => new GenericHouseDoor(facing, 0x6B5, 0xEA, 0xF1),
5 => new GenericHouseDoor(facing, 0x6C5, 0xEC, 0xF3),
6 => new GenericHouseDoor(facing, 0x6D5, 0xEA, 0xF1),
7 => new GenericHouseDoor(facing, 0x6E5, 0xEA, 0xF1),
_ => null
};
}
else if (itemID >= 0x314 && itemID < 0x364)
{
int type = (itemID - 0x314) / 16;
DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8);
door = new GenericHouseDoor(facing, 0x314 + (type * 16), 0xED, 0xF4);
}
else if (itemID >= 0x824 && itemID < 0x834)
{
DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8);
door = new GenericHouseDoor(facing, 0x824, 0xEC, 0xF3);
}
else if (itemID >= 0x839 && itemID < 0x849)
{
DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8);
door = new GenericHouseDoor(facing, 0x839, 0xEB, 0xF2);
}
else if (itemID >= 0x84C && itemID < 0x85C)
{
DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8);
door = new GenericHouseDoor(facing, 0x84C, 0xEC, 0xF3);
}
else if (itemID >= 0x866 && itemID < 0x876)
{
DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8);
door = new GenericHouseDoor(facing, 0x866, 0xEB, 0xF2);
}
else if (itemID >= 0xE8 && itemID < 0xF8)
{
DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8);
door = new GenericHouseDoor(facing, 0xE8, 0xED, 0xF4);
}
else if (itemID >= 0x1FED && itemID < 0x1FFD)
{
DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8);
door = new GenericHouseDoor(facing, 0x1FED, 0xEC, 0xF3);
}
else if (itemID >= 0x241F && itemID < 0x2421)
{
//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
door = new GenericHouseDoor(DoorFacing.NorthCCW, 0x2415, -1, -1);
}
else if (itemID >= 0x2423 && itemID < 0x2425)
{
//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
//This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these
door = new GenericHouseDoor(DoorFacing.WestCW, 0x2423, -1, -1);
}
else if (itemID >= 0x2A05 && itemID < 0x2A1D)
{
DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8);
int sound = (itemID >= 0x2A0D && itemID < 0x2a15) ? 0x539 : -1;
door = new GenericHouseDoor(facing, 0x29F5 + (8 * ((itemID - 0x2A05) / 8)), sound, sound);
}
else if (itemID == 0x2D46)
{
door = new GenericHouseDoor(DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false);
}
else if (itemID == 0x2D48 || itemID == 0x2FE2)
{
door = new GenericHouseDoor(DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x2D63 && itemID < 0x2D70)
{
int mod = (itemID - 0x2D63) / 2 % 2;
DoorFacing facing = ((mod == 0) ? DoorFacing.SouthCCW : DoorFacing.WestCCW);
int type = (itemID - 0x2D63) / 4;
door = new GenericHouseDoor(facing, 0x2D63 + 4 * type + mod * 2, 0xEA, 0xF1, false);
}
else if (itemID == 0x2FE4 || itemID == 0x31AE)
{
door = new GenericHouseDoor(DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x319C && itemID < 0x31AE)
{
//special case for 0x31aa <-> 0x31a8 (a9)
int mod = (itemID - 0x319C) / 2 % 2;
var facing = itemID switch
{
0x31AA => ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW),
0x31A8 => ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW),
_ => ((mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW)
};
int type = (itemID - 0x319C) / 4;
door = new GenericHouseDoor(facing, 0x319C + 4 * type + mod * 2, 0xEA, 0xF1, false);
}
else if (itemID >= 0x367B && itemID < 0x369B)
{
int type = (itemID - 0x367B) / 16;
DoorFacing facing = (DoorFacing)(((itemID - 0x367B) / 2) % 8);
door = type switch
{
0 => new GenericHouseDoor(facing, 0x367B, 0xED, 0xF4),
1 => new GenericHouseDoor(facing, 0x368B, 0xEC, 0x3E7),
_ => null
};
}
else if (itemID >= 0x409B && itemID < 0x40A3)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x409B), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x410C && itemID < 0x4114)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x410C), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x41C2 && itemID < 0x41CA)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41C2), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x41CF && itemID < 0x41D7)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41CF), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x436E && itemID < 0x437E)
{
/* These ones had to be different...
* Offset 0 2 4 6 8 10 12 14
* DoorFacing 2 3 2 3 6 7 6 7
*/
int offset = itemID - 0x436E;
DoorFacing facing = (DoorFacing)((offset / 2 + 2 * ((1 + offset / 4) % 2)) % 8);
door = new GenericHouseDoor(facing, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x46DD && itemID < 0x46E5)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x46DD), itemID, 0xEB, 0xF2, false);
}
else if (itemID >= 0x4D22 && itemID < 0x4D2A)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x4D22), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x50C8 && itemID < 0x50D0)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50C8), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x50D0 && itemID < 0x50D8)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50D0), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x5142 && itemID < 0x514A)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x5142), itemID, 0xF0, 0xEF, false);
}
else if (itemID >= 0x9AD7 && itemID <= 0x9AE6)
{
int type = (itemID - 0x9AD7) / 16;
DoorFacing facing = (DoorFacing)(((itemID - 0x9AD7) / 2) % 8);
door = new GenericHouseDoor(facing, 0x9AD7 + (type * 16), 0xED, 0xF4);
}
else if (itemID >= 0x9B3C && itemID <= 0x9B4B)
{
int type = (itemID - 0x9B3C) / 16;
DoorFacing facing = (DoorFacing)(((itemID - 0x9B3C) / 2) % 8);
door = new GenericHouseDoor(facing, 0x9B3C + (type * 16), 0xED, 0xF4);
}
if (door != null)
{
if (from != null) door.KeyValue = CreateKeys(@from);
AddDoor(door, xOffset, yOffset, zOffset);
}
else
{
Console.WriteLine("BaseHouse: Door ItemID {0} not supported.", itemID);
}
return door;
}
private static DoorFacing GetSADoorFacing(int offset)
{
/* Offset 0 2 4 6
* DoorFacing 2 3 6 7
*/
return (DoorFacing)((offset / 2 + 2 * (1 + offset / 4)) % 8);
}
public uint CreateKeys(Mobile m)
{
uint value = Key.RandomValue();
@ -1581,8 +1754,8 @@ namespace Server.Multis
m.SendLocalizedMessage(501736); // You must lockdown the container first!
}
else if (!(item is VendorRentalContract) && (IsAosRules
? !CheckAosLockdowns(amt) || !CheckAosStorage(amt)
: LockDownCount + amt > MaxLockDowns))
? !CheckAosLockdowns(amt) || !CheckAosStorage(amt)
: LockDownCount + amt > MaxLockDowns))
{
m.SendLocalizedMessage(1005379); //That would exceed the maximum lock down limit for this house
}
@ -2950,7 +3123,7 @@ namespace Server.Multis
bool xEast = false, ySouth = false;
bool valid = m_House != null && Sextant.Format(m_House.Location, m_House.Map, ref xLong, ref yLat, ref xMins,
ref yMins, ref xEast, ref ySouth);
ref yMins, ref xEast, ref ySouth);
string location =
valid ? $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}° {xMins}'{(xEast ? "E" : "W")}" : "unknown";