diff --git a/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnList.cs b/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnList.cs new file mode 100644 index 000000000..04fcb6fd8 --- /dev/null +++ b/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnList.cs @@ -0,0 +1,331 @@ +using System; +using Server; +using Server.Mobiles; +using Server.Items; + +namespace Server.Custom.DynamicSpawns +{ + public enum Terrain + { + None, Water, Cave, Dirt, Forest, Grass, Jungle, Rock, Sand, Swamp, Snow + } + + public static class SpawnList + { + private static readonly Terrain[] _terrainLookup = new Terrain[0x4000]; + + static SpawnList() + { + + foreach (int id in new[] { 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x0136, 0x0138 }) + _terrainLookup[id] = Terrain.Water; + + foreach (int id in new[] { + 0x024A, 0x024B, 0x024C, 0x024D, 0x024E, 0x024F, 0x0250, 0x0251, 0x0252, 0x0253, + 0x0254, 0x0255, 0x0256, 0x0257, 0x0258, 0x0259, 0x025A, 0x025B, 0x025C, 0x025D, + 0x025E, 0x025F, 0x0260, 0x0261, 0x0262, 0x0263, 0x0264, 0x0265, 0x0266, 0x0267, + 0x0268, 0x0269, 0x026A, 0x026B, 0x026C, 0x026D, 0x02BC, 0x02BD, 0x02BE, 0x02BF, + 0x02C0, 0x02C1, 0x02C2, 0x02C3, 0x02C4, 0x02C5, 0x02C6, 0x02C7, 0x02C8, 0x02C9, + 0x02CA, 0x02CB, 0x0245, 0x0246, 0x0247, 0x0248, 0x0249, 0x063B, 0x063C, 0x063D, + 0x063E + }) + _terrainLookup[id] = Terrain.Cave; + + foreach (int id in new[] { + + 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, + 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, 0x00A0, + 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00DC, 0x00DD, 0x00DE, + 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x02D0, 0x02D1, 0x02D2, 0x02D3, 0x02D4, + 0x02D5, 0x02D6, 0x02D7, 0x02E5, 0x02E6, 0x02E7, 0x02E8, 0x02E9, 0x02EA, 0x02EB, + 0x02EC, 0x02ED, 0x02EE, 0x02EF, 0x02F0, 0x02F1, 0x02F2, 0x02F3, 0x02F4, 0x02F5, + 0x02F6, 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC, 0x02FD, 0x02FE, 0x02FF, + 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, + 0x030D, 0x030E, 0x030F, 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, + 0x0317, 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F, 0x06F4, + 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D, 0x077E, 0x077F, 0x0780, + 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786, 0x0787, 0x0788, 0x0789, 0x078A, + 0x078B, 0x078C, 0x078D, 0x078E, 0x078F, 0x0790, 0x0791, 0x0071, 0x0072, 0x0073, + 0x0074, 0x75, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x0082, + 0x0083, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x00E8, + 0x00E9, 0x00EA, 0x00EB, 0x0141, 0x0142, 0x0143, 0x0144, 0x014C, 0x014D, 0x014E, + 0x014F, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F, 0x0170, 0x0171, + 0x0172, 0x0173, 0x0174, 0x01DC, 0x01DD, 0x01DE, 0x01DF, 0x01E0, 0x01E1, 0x01E2, + 0x01E3, 0x01E4, 0x01E5, 0x01E6, 0x01E7, 0x01EC, 0x01ED, 0x01EE, 0x01EF, 0x0272, + 0x0273, 0x0274, 0x0275, 0x027E, 0x027F, 0x0280, 0x0281, 0x032C, 0x032D, 0x032E, + 0x032F, 0x033D, 0x033E, 0x033F, 0x0340, 0x0345, 0x0346, 0x0347, 0x0348, 0x0349, + 0x034A, 0x034B, 0x034C, 0x0355, 0x0356, 0x0357, 0x0358, 0x0367, 0x0368, 0x0369, + 0x036A, 0x036B, 0x036C, 0x036D, 0x036E, 0x0377, 0x0378, 0x0379, 0x037A, 0x038D, + 0x038E, 0x038F, 0x0390, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, + 0x039C, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03F6, 0x03F7, 0x03F9, 0x03FA, 0x03FB, + 0x03FC, 0x03FD, 0x03FE, 0x03FF, 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, + 0x0547, 0x0548, 0x0549, 0x054A, 0x054B, 0x054C, 0x054D, 0x054E, 0x0553, 0x0554, + 0x0555, 0x0556, 0x0597, 0x0598, 0x0599, 0x059A, 0x059B, 0x059C, 0x059D, 0x059E, + 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, + 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, + 0x0637, 0x0638, 0x0639, 0x063A, 0x06F3, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9, + 0x06FA + }) + _terrainLookup[id] = Terrain.Dirt; + + foreach (int id in new[] { + 0x00ED, 0x00EE, 0x00EF, 0x3AF0, 0x3AF1, 0x3AF2, 0x3AF3, 0x3AF4, 0x3AF5, 0x3AF6, + 0x3AF7, 0x3AF8, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, + 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, + 0x00D6, 0x00D7, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F8, 0x00F9, 0x00FA, 0x00FB, + 0x015D, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0166, + 0x0167, 0x0168, 0x0324, 0x0325, 0x0326, 0x0327, 0x0328, 0x0329, 0x032A, 0x032B, + 0x054F, 0x0550, 0x0551, 0x0552, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F9, 0x05FA, + 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF, 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, + 0x0611, 0x0612, 0x0613, 0x0614, 0x0653, 0x0654, 0x0655, 0x0656, 0x065B, 0x065C, + 0x065D, 0x065E, 0x065F, 0x0660, 0x0661, 0x0662, 0x066B, 0x066C, 0x066D, 0x066E, + 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06BB, 0x06BC, 0x06BD, 0x06BE, + 0x0709, 0x070A, 0x070B, 0x070C, 0x0715, 0x0716, 0x0717, 0x0718, 0x0719, 0x071A, + 0x071B, 0x071C + }) + _terrainLookup[id] = Terrain.Forest; + + foreach (int id in new[] { + 0x0231, 0x0232, 0x0233, 0x0234, 0x0239, 0x023A, 0x023B, 0x023C, 0x023D, 0x023E, + 0x023F, 0x0240, 0x0241, 0x06D2, 0x06D3, 0x06D4, 0x06D5, 0x06D6, 0x06D7, 0x06D8, + 0x06D9, 0x3, 0x0004, 0x0005, 0x0006, 0x003B, 0x003C, 0x003D, 0x003E, 0x007D, + 0x007E, 0x007F, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00D8, 0x00D9, 0x00DA, 0x00DB, + 0x01A4, 0x01A5, 0x01A6, 0x01A7, 0x0242, 0x0243, 0x036F, 0x0370, 0x0371, 0x0372, + 0x0373, 0x0374, 0x0375, 0x0376, 0x037B, 0x037C, 0x037D, 0x037E, 0x03BF, 0x03C0, + 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03CB, 0x03CC, 0x03CD, 0x03CE, + 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F, 0x0580, 0x058B, 0x058C, + 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05E3, 0x05E4, + 0x05E5, 0x05E6, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, + 0x0689, 0x068A, 0x068B, 0x068C, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, + 0x069B, 0x069C, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06B5, 0x06B6, 0x06B7, 0x06B8, + 0x06B9, 0x06BA, 0x06BF, 0x06C0, 0x06C1, 0x06C2, 0x06DE, 0x06DF, 0x06E0, 0x06E1 + }) + _terrainLookup[id] = Terrain.Grass; + + foreach (int id in new[] { + 0x00EC, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x072A, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B3, 0x00B6, 0x00B9, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x0100, 0x0101, + 0x0102, 0x0103, 0x0108, 0x0109, 0x010A, 0x010B, 0x01F0, 0x01F1, 0x01F2, 0x01F3, + 0x026E, 0x026F, 0x0270, 0x0271, 0x0276, 0x0277, 0x0278, 0x0279, 0x027A, 0x027B, + 0x027C, 0x027D, 0x0286, 0x0287, 0x0288, 0x0289, 0x0292, 0x0293, 0x0294, 0x0295, + 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0587, 0x0588, 0x0589, 0x058A, + 0x058D, 0x058E, 0x058F, 0x0590, 0x059F, 0x05A0, 0x05A1, 0x05A2, 0x05A3, 0x05A4, + 0x05A5, 0x05A6, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, 0x05B8, 0x05B9, 0x05BA, + 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x0605, 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, + 0x060B, 0x060C, 0x060D, 0x060E, 0x060F, 0x0610, 0x0615, 0x0616, 0x0617, 0x0618, + 0x0727, 0x0728, 0x0729, 0x0733, 0x0734, 0x0735, 0x0736, 0x0737, 0x0738, 0x0739, + 0x073A + }) + _terrainLookup[id] = Terrain.Jungle; + + foreach (int id in new[] { + 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x0104, 0x0105, + 0x0106, 0x0107, 0x0110, 0x0111, 0x0112, 0x0113, 0x0122, 0x0123, 0x0124, 0x0125, + 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7, 0x01D8, 0x01D9, 0x01DA, 0x021F, 0x0220, + 0x0221, 0x0222, 0x0223, 0x0224, 0x0225, 0x0226, 0x0227, 0x0228, 0x0229, 0x022A, + 0x022B, 0x022C, 0x022D, 0x022E, 0x022F, 0x0230, 0x0235, 0x0236, 0x0237, 0x0238, + 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06DA, 0x06DB, 0x06DC, 0x06DD, 0x06EB, + 0x06EC, 0x06ED, 0x06EE, 0x06EF, 0x06F0, 0x06F1, 0x06F2, 0x06FB, 0x06FC, 0x06FD, + 0x06FE, 0x070E, 0x070F, 0x0710, 0x0711, 0x0712, 0x0713, 0x0714, 0x071D, 0x071E, + 0x071F, 0x0720, 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x0730, 0x0731, 0x0732, + 0x073B, 0x073C, 0x073D, 0x073E, 0x0749, 0x074A, 0x074B, 0x074C, 0x074D, 0x074E, + 0x074F, 0x0750, 0x0759, 0x075A, 0x075B, 0x075C, 0x09EC, 0x09ED, 0x09EE, 0x09EF, + 0x09F0, 0x09F1, 0x09F2, 0x09F3, 0x09F4, 0x09F5, 0x09F6, 0x09F7, 0x09F8, 0x09F9, + 0x09FA, 0x09FB, 0x09FC, 0x09FD, 0x09FE, 0x09FF, 0x0A00, 0x0A01, 0x0A02, 0x0A03, + 0x3F39, 0x3F3A, 0x3F3B, 0x3F3C, 0x3F3D, 0x3F3E, 0x3F3F, 0x3F40, 0x3F41, 0x3F42, + 0x3F43, 0x3F44, 0x3F45, 0x3F46, 0x3F47, 0x3F48, 0x3F49, 0x3F4A, 0x3F4B, 0x3F4C, + 0x3F4D, 0x3F4E, 0x3F4F, 0x3F50, 0x3F51, 0x3F52, 0x3F53, 0x3F54, 0x3F55, 0x3F56, + 0x3F57, 0x3F58, 0x3F59, 0x3F5A, 0x3F5B, 0x3F5C, 0x3F5D, 0x3F5E, 0x3F5F, 0x3F60, + 0x3F61, 0x3F62, 0x3F63, 0x3F64, 0x3F65, 0x3F66, 0x3F67, 0x3F68, 0x3F82, 0x3F83, + 0x3F84, 0x3F85, 0x3F86, 0x3F87, 0x3F88, 0x3F89, 0x3F8A, 0x3F8B, 0x3F8C, 0x3F8D, + 0x3F8E, 0x3F8F, 0x3F92, 0x3F93, 0x3F94, 0x3F95, 0x3F96, 0x3F97, 0x3F98, 0x3F99, + 0x3F9A, 0x3F9B, 0x3F9C, 0x3F9D, 0x3F9E, 0x3F9F, 0x3FA0, 0x3FA1, 0x3FA2, 0x3FA3, + 0x3FA4, 0x3FA5, 0x3FA6, 0x3FA7, 0x3FA8, 0x3FA9, 0x3FAA, 0x3FAB, 0x3FAC, 0x3FAD, + 0x3FAE, 0x3FAF, 0x3FB0, 0x3FB1, 0x3FB2, 0x3FB3, 0x3FB4, 0x3FB5, 0x3FB6, 0x3FB7, + 0x3FB8, 0x3FB9, 0x3FBA, 0x3FBB, 0x3FBC, 0x3FBD, 0x3FBE, 0x3FBF, 0x3FC0, 0x3FC1, + 0x3FC2, 0x3FC3, 0x3FC4, 0x3FC5, 0x3FC6, 0x3FC7, 0x3FC8, 0x3FC9, 0x3FCA, 0x3FCB, + 0x3FCC, 0x3FCD, 0x3FCE, 0x3FCF, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, + 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445 + }) + _terrainLookup[id] = Terrain.Rock; + + foreach (int id in new[] { + 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, + 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, + 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, + 0x0049, 0x004A, 0x004B, 0x0126, 0x0127, 0x0128, 0x0129, 0x01B9, 0x01BA, 0x01BB, + 0x01BC, 0x01BD, 0x01BE, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C4, 0x01C5, + 0x01C6, 0x01C7, 0x01C8, 0x01C9, 0x01CA, 0x01CB, 0x01CC, 0x01CD, 0x01CE, 0x01CF, + 0x01D0, 0x01D1, 0x0016, 0x0017, 0x0018, 0x0019, 0x0033, 0x0034, 0x0035, 0x0036, + 0x0037, 0x0038, 0x0039, 0x003A, 0x011E, 0x011F, 0x0120, 0x0121, 0x12A, 0x012B, + 0x012C, 0x012D, 0x01A8, 0x01A9, 0x01AA, 0x01AB, 0x0282, 0x0283, 0x0284, 0x0285, + 0x028A, 0x028B, 0x028C, 0x028D, 0x028E, 0x028F, 0x0290, 0x0291, 0x0335, 0x0336, + 0x0337, 0x0338, 0x0339, 0x033A, 0x033B, 0x033C, 0x0341, 0x0342, 0x0343, 0x0344, + 0x034D, 0x034E, 0x034F, 0x0350, 0x0351, 0x0352, 0x0353, 0x0354, 0x0359, 0x035A, + 0x035B, 0x035C, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, + 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x05A7, 0x05A8, 0x05A9, 0x05AA, 0x05AB, 0x05AC, + 0x05AD, 0x05AE, 0x05AF, 0x05B0, 0x05B1, 0x05B2, 0x064B, 0x064C, 0x064D, 0x064E, + 0x064F, 0x0650, 0x0651, 0x0652, 0x0657, 0x0658, 0x0659, 0x065A, 0x0663, 0x0664, + 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0x066A, 0x066F, 0x0670, 0x0671, 0x0672 + }) + _terrainLookup[id] = Terrain.Sand; + + foreach (int id in new[] { + 0x3D65, 0x3D66, 0x3D67, 0x3D68, 0x3D69, 0x3D6A, 0x3D6B, 0x3D6C, 0x3D6D, 0x3D6E, + 0x3D6F, 0x3D70, 0x3D71, 0x3D72, 0x3D73, 0x3D74, 0x3D75, 0x3D76, 0x3D77, 0x3D78, + 0x3D79, 0x3D7A, 0x3D7B, 0x3D7C, 0x3D7D, 0x3D7E, 0x3D7F, 0x3D80, 0x3D81, 0x3D82, + 0x3D83, 0x3D84, 0x3D85, 0x3D86, 0x3D87, 0x3D88, 0x3D89, 0x3D8A, 0x3D8B, 0x3D8C, + 0x3D8D, 0x3D8E, 0x3D8F, 0x3D90, 0x3D91, 0x3D92, 0x3D93, 0x3D94, 0x3D95, 0x3D96, + 0x3D97, 0x3D98, 0x3D99, 0x3D9A, 0x3D9B, 0x3D9C, 0x3D9D, 0x3D9E, 0x3D9F, 0x3DA0, + 0x3DA1, 0x3DA2, 0x3DA3, 0x3DA4, 0x3DA5, 0x3DA6, 0x3DA7, 0x3DA8, 0x3DA9, 0x3DAA, + 0x3DAB, 0x3DAC, 0x3DAD, 0x3DAE, 0x3DAF, 0x3DB0, 0x3DB1, 0x3DB2, 0x3DB3, 0x3DB4, + 0x3DB5, 0x3DB6, 0x3DB7, 0x3DB8, 0x3DB9, 0x3DBA, 0x3DBB, 0x3DBC, 0x3DBD, 0x3DBE, + 0x3DBF, 0x3DC0, 0x3DC1, 0x3DC2, 0x3DC3, 0x3DC4, 0x3DC5, 0x3DC6, 0x3DC7, 0x3DC8, + 0x3DC9, 0x3DCA, 0x3DCB, 0x3DCC, 0x3DCD, 0x3DCE, 0x3DCF, 0x3DD0, 0x3DD1, 0x3DD2, + 0x3DD3, 0x3DD4, 0x3DD5, 0x3DD6, 0x3DD7, 0x3DD8, 0x3DD9, 0x3DDA, 0x3DDB, 0x3DDC, + 0x3DDD, 0x3DDE, 0x3DDF, 0x3DE0, 0x3DE1, 0x3DE2, 0x3DE3, 0x3DE4, 0x3DE5, 0x3DE6, + 0x3DE7, 0x3DE8, 0x3DE9, 0x3DEA, 0x3DEB, 0x3DEC, 0x3DED, 0x3DEE, 0x3DEF, 0x3DF0, + 0x3DF1 + }) + _terrainLookup[id] = Terrain.Swamp; + + foreach (int id in new[] { + 0x010C, 0x010D, 0x010E, 0x010F, 0x0114, 0x0115, 0x0116, 0x0117, 0x017C, 0x017D, + 0x017E, 0x017F, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0185, 0x0186, 0x0187, + 0x0188, 0x0189, 0x018A, 0x0755, 0x0756, 0x0757, 0x0758, 0x076D, 0x076E, 0x076F, + 0x0770, 0x0771, 0x0772, 0x0773, 0x011A, 0x011B, 0x011C, 0x011D, 0x012E, 0x012F, + 0x0130, 0x0131, 0x0179, 0x017A, 0x017B, 0x0385, 0x0386, 0x0387, 0x0388, 0x0389, + 0x038A, 0x038B, 0x038C, 0x0391, 0x0392, 0x0393, 0x0394, 0x039D, 0x039E, 0x039F, + 0x03A0, 0x03A1, 0x03A2, 0x03A3, 0x03A4, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x05BF, + 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05C4, 0x05C5, 0x05C6, 0x05C7, 0x05C8, 0x05C9, + 0x05CA, 0x05CB, 0x05CC, 0x05CD, 0x05CE, 0x05CF, 0x05D0, 0x05D1, 0x05D2, 0x05D3, + 0x05D4, 0x05D5, 0x05D6, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x0745, 0x0746, 0x0747, + 0x0748, 0x0751, 0x0752, 0x0753, 0x0754, 0x075D, 0x075E, 0x075F, 0x0760 + }) + _terrainLookup[id] = Terrain.Snow; + } + + private static readonly Type[] CaveCritters = [typeof(Rat) ]; + private static readonly Type[] DirtCritters = [typeof(Rat) ]; + private static readonly Type[] ForestCritters = [typeof(GreatHart) ]; + private static readonly Type[] GrassCritters = [typeof(Squirrel) ]; + private static readonly Type[] JungleCritters = [typeof(Gorilla) ]; + private static readonly Type[] RockCritters = [ ]; + private static readonly Type[] SandCritters = [typeof(Scorpion) ]; + private static readonly Type[] SwampCritters = [typeof(Slime) ]; + private static readonly Type[] SnowCritters = [typeof(PolarBear) ]; + private static readonly Type[] WaterCritters = [typeof(Dolphin) ]; + + public static Terrain GetTerrain(Map map, Point3D location, int x, int y) + { + if (map == Map.Internal || x < 0 || y < 0 || x >= map.Width || y >= map.Height) + return Terrain.None; + + LandTile lTile = map.Tiles.GetLandTile(x, y); + + if (lTile.ID < _terrainLookup.Length) + { + Terrain t = _terrainLookup[lTile.ID]; + if (t != Terrain.None) return t; + } + + return Terrain.None; + } + + public static Terrain TestAround(Terrain ground, Map map, int x, int y, int distance) + { + Point3D p = new(9000, 9000, 0); + Terrain terrain = Terrain.None; + int tries = 8; + + while (tries > 0) + { + tries--; + int g = Utility.Random(8); + + terrain = g switch + { + 0 => GetTerrain(map, p, x - distance, y - distance), + 1 => GetTerrain(map, p, x, y - distance), + 2 => GetTerrain(map, p, x + distance, y - distance), + 3 => GetTerrain(map, p, x - distance, y), + 4 => GetTerrain(map, p, x + distance, y), + 5 => GetTerrain(map, p, x - distance, y + distance), + 6 => GetTerrain(map, p, x, y + distance), + 7 => GetTerrain(map, p, x + distance, y + distance), + _ => Terrain.None + }; + + if (terrain != Terrain.Water && terrain != Terrain.Cave && terrain != Terrain.Dirt && terrain != Terrain.Rock) + return terrain; + } + + return ground; + } + + public static Mobile RandomSpawn(Item spawn, Point3D loc, Map map) + { + Mobile m = null; + spawn.MoveToWorld(loc, map); + int tries = 100; + + Terrain terrain = GetTerrain(map, loc, spawn.X, spawn.Y); + + if (terrain != Terrain.Water && terrain != Terrain.Cave && terrain != Terrain.Dirt && terrain != Terrain.Rock) + terrain = TestAround(terrain, map, spawn.X, spawn.Y, 15); + + while (m == null && tries > 0) + { + tries--; + + m = spawn switch + { + SpawnCritters => terrain switch + { + Terrain.Water => Construct(WaterCritters), + Terrain.Cave => Construct(CaveCritters), + Terrain.Dirt => Construct(DirtCritters), + Terrain.Forest => Construct(ForestCritters), + Terrain.Grass => Construct(GrassCritters), + Terrain.Jungle => Construct(JungleCritters), + Terrain.Rock => Construct(RockCritters), + Terrain.Sand => Construct(SandCritters), + Terrain.Swamp => Construct(SwampCritters), + Terrain.Snow => Construct(SnowCritters), + _ => null + }, + SpawnWater => terrain == Terrain.Water ? Construct(WaterCritters) : null, + SpawnCave => terrain == Terrain.Cave ? Construct(CaveCritters) : null, + SpawnDirt => terrain == Terrain.Dirt ? Construct(DirtCritters) : null, + SpawnForest => terrain == Terrain.Forest ? Construct(ForestCritters) : null, + SpawnGrass => terrain == Terrain.Grass ? Construct(GrassCritters) : null, + SpawnJungle => terrain == Terrain.Jungle ? Construct(JungleCritters) : null, + SpawnRock => terrain == Terrain.Rock ? Construct(RockCritters) : null, + SpawnSand => terrain == Terrain.Sand ? Construct(SandCritters) : null, + SpawnSwamp => terrain == Terrain.Swamp ? Construct(SwampCritters) : null, + SpawnSnow => terrain == Terrain.Snow ? Construct(SnowCritters) : null, + _ => null + }; + } + + return m; + } + + public static Mobile Construct(Type[] types) + { + if (types.Length > 0) + { + Type typeToSpawn = types[Utility.Random(types.Length)]; + try + { + return Activator.CreateInstance(typeToSpawn) as Mobile; + } + catch + { + return null; + } + } + return null; + } + } +} diff --git a/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnRef.cs b/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnRef.cs new file mode 100644 index 000000000..854946ebf --- /dev/null +++ b/Projects/UOContent/Engines/Spawners/DynamicSpawner/SpawnRef.cs @@ -0,0 +1,248 @@ +using System; +using Server; +using Server.Regions; +using Server.Custom.DynamicSpawns; + +namespace Server.Items +{ + public abstract class BaseProxySpawner : Item, ISpawner + { + private Mobile _trackedMobile; + + public bool UnlinkOnTaming => true; + public Point3D HomeLocation => Location; + public int HomeRange => 5; + + public Guid Guid { get; } = Guid.NewGuid(); + public int WalkingRange => HomeRange; + public Region Region => Region.Find(Location, Map); + public Rectangle3D SpawnBounds => new Rectangle3D(Location.X - HomeRange, Location.Y - HomeRange, -128, HomeRange * 2, HomeRange * 2, 256); + public bool ReturnOnDeactivate => false; + public bool Running { get; set; } = true; + + public Point3D GetSpawnPosition(ISpawnable spawnable, Map map) + { + return Location; + } + + public void Respawn() + { + // Proxy spawners do not handle their own respawns. + // When the monster dies, the proxy deletes itself, + // and the parent Master Spawner drops a new proxy. + } + + public bool IsInSpawnBounds(Point3D loc) + { + return Utility.InRange(Location, loc, WalkingRange); + } + + public void Remove(ISpawnable spawn) + { + if (!Deleted) + Delete(); + } + + public BaseProxySpawner() : base(0x6519) + { + Name = "spawn ref"; + Visible = false; + Movable = false; + + Timer.DelayCall(TimeSpan.FromSeconds(1.0), ExecuteSpawn); + } + + public BaseProxySpawner(Serial serial) : base(serial) + { + } + + public override void Serialize(IGenericWriter writer) + { + base.Serialize(writer); + writer.Write(0); + writer.Write(_trackedMobile); + } + + public override void Deserialize(IGenericReader reader) + { + base.Deserialize(reader); + int version = reader.ReadInt(); + _trackedMobile = reader.ReadEntity(); + + if (_trackedMobile != null && !_trackedMobile.Deleted && _trackedMobile.Alive) + { + if (_trackedMobile is ISpawnable spawnable) + { + spawnable.Spawner = this; + } + } + else + { + Timer.DelayCall(TimeSpan.FromSeconds(1.0), Delete); + } + } + + private void ExecuteSpawn() + { + if (Deleted || Map == null || Map == Map.Internal) + return; + + Point3D savedLocation = Location; + Map savedMap = Map; + + Region reg = Region.Find(savedLocation, savedMap); + if (reg.IsPartOf() || reg.IsPartOf() || + reg.IsPartOf() || reg.IsPartOf() || + reg.IsPartOf() || reg.IsPartOf() || + reg.IsPartOf() + ) + { + Delete(); + return; + } + + _trackedMobile = SpawnList.RandomSpawn(this, savedLocation, savedMap); + + if (_trackedMobile != null) + { + if (_trackedMobile is ISpawnable spawnable) + { + spawnable.Spawner = this; + } + + int scatterRange = 25; + + foreach (Item item in savedMap.GetItemsInRange(savedLocation, 0)) + { + if (item is ISpawner spawner && item != this) + { + scatterRange = spawner.WalkingRange; + break; + } + } + + Point3D spawnPoint = savedLocation; + + for (int i = 0; i < 15; i++) + { + int x = savedLocation.X + Utility.RandomMinMax(-scatterRange, scatterRange); + int y = savedLocation.Y + Utility.RandomMinMax(-scatterRange, scatterRange); + int z = savedMap.GetAverageZ(x, y); + Point3D testPoint = new(x, y, z); + + if (this is SpawnWater) + { + if (SpawnList.GetTerrain(savedMap, testPoint, x, y) == Terrain.Water) + { + spawnPoint = testPoint; + break; + } + } + else + { + if (savedMap.CanFit(x, y, z, 16, false, false)) + { + spawnPoint = testPoint; + break; + } + } + } + + _trackedMobile.MoveToWorld(spawnPoint, savedMap); + Internalize(); + } + else + { + Delete(); + } + } + } + + public class SpawnWater : BaseProxySpawner + { + [Constructible] public SpawnWater() {} + public SpawnWater(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnCave : BaseProxySpawner + { + [Constructible] public SpawnCave() {} + public SpawnCave(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnDirt : BaseProxySpawner + { + [Constructible] public SpawnDirt() {} + public SpawnDirt(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnForest : BaseProxySpawner + { + [Constructible] public SpawnForest() {} + public SpawnForest(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnGrass : BaseProxySpawner + { + [Constructible] public SpawnGrass() {} + public SpawnGrass(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnJungle : BaseProxySpawner + { + [Constructible] public SpawnJungle() {} + public SpawnJungle(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnRock : BaseProxySpawner + { + [Constructible] public SpawnRock() {} + public SpawnRock(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnSand : BaseProxySpawner + { + [Constructible] public SpawnSand() {} + public SpawnSand(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnSwamp : BaseProxySpawner + { + [Constructible] public SpawnSwamp() {} + public SpawnSwamp(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnSnow : BaseProxySpawner + { + [Constructible] public SpawnSnow() {} + public SpawnSnow(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } + + public class SpawnCritters : BaseProxySpawner + { + [Constructible] public SpawnCritters() {} + public SpawnCritters(Serial serial) : base(serial) {} + public override void Serialize(IGenericWriter writer) { base.Serialize(writer); writer.Write(0); } + public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } + } +}