Compare commits
693 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 343bfd1003 | |||
| c4446736a6 | |||
| d482265994 | |||
| 4621b657e4 | |||
| d7159758a1 | |||
| d3dd190a69 | |||
| 7236ed918a | |||
| 7e9df52c11 | |||
| 9e531b0b8f | |||
| 9615f85f0d | |||
| b4720a2db5 | |||
| 25e9f28746 | |||
| 8dc51fa2f8 | |||
| 21989da97c | |||
| 44f38b9ac3 | |||
| 34efa3dd65 | |||
| f94648c5dd | |||
| c426a84db0 | |||
| 1b5738f9b3 | |||
| d502a889a6 | |||
| 1ee8851fe0 | |||
| 72dea668f9 | |||
| 7fe5f8b5ac | |||
| a54612a947 | |||
| 92293ebed1 | |||
| f5200abf61 | |||
| 60b7cab0fe | |||
| 7a3f824816 | |||
| aca0ff52d6 | |||
| 7203d66ace | |||
| 3e50782979 | |||
| fc15e9310d | |||
| 6aff5307c7 | |||
| d45b55d97b | |||
| 17ddd7d1ff | |||
| 25b508a101 | |||
| 2166a0a440 | |||
| 19d43cbcb0 | |||
| e473aa5f08 | |||
| 016919675a | |||
| bb433f6f4a | |||
| a8ccf0c67c | |||
| 45e9311822 | |||
| c81c910019 | |||
| b6ac5735c6 | |||
| 9aa89a544c | |||
| 19cbbd7176 | |||
| 40443a82a7 | |||
| 24a58db3a9 | |||
| bdb901afce | |||
| 7e54426c95 | |||
| 7236c9369a | |||
| 12ee06e128 | |||
| 6e22ff53d7 | |||
| 77c32f9081 | |||
| 2e36c01537 | |||
| 4229999848 | |||
| a2c7fd2404 | |||
| 67af6f8c18 | |||
| e128f60519 | |||
| d57e5df356 | |||
| f002de704b | |||
| c63c5e6896 | |||
| d7c7491746 | |||
| 8cf1f1e60b | |||
| 6cc6713650 | |||
| bf1182dd2c | |||
| 51e0098aa0 | |||
| 66d5752ca9 | |||
| 136c8c4756 | |||
| 7af63d1519 | |||
| 31ba1f2c4c | |||
| 33afd13a8c | |||
| b341ffacbf | |||
| 0d1d1f0f37 | |||
| 3f59ed48d2 | |||
| de832ff497 | |||
| 1aef82f422 | |||
| 065a1c9ceb | |||
| ff219ce696 | |||
| 8bd406bcf4 | |||
| 7b70b680f0 | |||
| c3586a70fd | |||
| cc7d741681 | |||
| ce0dfdabfb | |||
| 737327fa8a | |||
| b1e79284e4 | |||
| 29b5955e9e | |||
| 3986dc0686 | |||
| 59190e33c9 | |||
| 091b1a1d5b | |||
| cb0ba901de | |||
| 14ba9d0f7f | |||
| ec9bc437f3 | |||
| 930aa73657 | |||
| cf2bf2dacf | |||
| 5a8508c16c | |||
| 5bcc0ed84d | |||
| 4795a315ad | |||
| 6559f232a3 | |||
| db8b33a621 | |||
| 781a4ee16d | |||
| 7ce94a5166 | |||
| a487a7bd2f | |||
| f0fedcc049 | |||
| 3a63f98ac3 | |||
| 4c994e6e55 | |||
| 1c93846ed3 | |||
| 3ef444c128 | |||
| eaaba8ab0c | |||
| 1daa45d604 | |||
| cf7e19bfde | |||
| 6a76cc7a29 | |||
| fff16d2211 | |||
| a2df7cda22 | |||
| 5858fa4de4 | |||
| fb6ec0caf4 | |||
| 944bcb7e84 | |||
| 4274e6a148 | |||
| 5e629e7890 | |||
| e991a01b50 | |||
| 7a1700cec3 | |||
| 79eb5b9cdf | |||
| 7886aa6041 | |||
| b928bedeb6 | |||
| beb2b47162 | |||
| 2cc37481ca | |||
| 5ac62d60be | |||
| 6fb1e2e5f1 | |||
| 385695a610 | |||
| 838776c471 | |||
| 44743b772b | |||
| 88f67efd51 | |||
| a04bdc147f | |||
| 145d9bafa0 | |||
| d2c00cce70 | |||
| 602f8bc843 | |||
| 89cb808481 | |||
| 4d290c9064 | |||
| 9ee60c9361 | |||
| 77cc91319a | |||
| ee4009bf8d | |||
| ff1c0bd347 | |||
| e1add3c7e6 | |||
| bf06734a9b | |||
| 5ed21f9b76 | |||
| e689cb541a | |||
| da32765902 | |||
| 9392ceda61 | |||
| 694b10d3b2 | |||
| 6b3c64faea | |||
| ab17dd08cd | |||
| f889bcf927 | |||
| 34024c9fb4 | |||
| 9d5e16aa5c | |||
| f1a2bea67c | |||
| 5d4192bbcf | |||
| ea6ea4b0ee | |||
| 7f4d47505e | |||
| f9a3b17677 | |||
| d0374a2dea | |||
| cb89cc17be | |||
| d506807a8f | |||
| 1a0fc309f9 | |||
| 5ed7662798 | |||
| e3d6a32554 | |||
| 6f990d488f | |||
| 610de198e9 | |||
| 928be0facb | |||
| 80799753be | |||
| f9d2232a9b | |||
| cbd8685d4b | |||
| 274cf08dad | |||
| 2cbe5f38cd | |||
| 3d4058ad01 | |||
| 761ec6f4af | |||
| 5900068898 | |||
| 13f5e3eff2 | |||
| db9e950558 | |||
| 3f93bf08fb | |||
| 65eebcbb5d | |||
| 6ed3495780 | |||
| 06049a7135 | |||
| 12e073ca46 | |||
| 4ee4054ab3 | |||
| 11664a9218 | |||
| d414c19904 | |||
| 279a0aed91 | |||
| c6e0e36531 | |||
| 10b9f19036 | |||
| ad661ea464 | |||
| affe6b08ab | |||
| 1b2c218e83 | |||
| 9e96add299 | |||
| 9f9c3ba7f1 | |||
| d15b8a5246 | |||
| c1e1c730bb | |||
| a53c68054d | |||
| 99a79df02d | |||
| 1a0f318968 | |||
| 6ac65c73d5 | |||
| dc5a778610 | |||
| 20d9a232cc | |||
| 280bd61e2a | |||
| dadfc15d39 | |||
| 1764041272 | |||
| b9ef4eee63 | |||
| 823061c699 | |||
| 6809988e9c | |||
| a1a3ea6234 | |||
| 3684296959 | |||
| 68c8d91871 | |||
| 7655b67338 | |||
| 68aef50283 | |||
| 6494e07e9e | |||
| 859de1004e | |||
| 0afc8a2dc5 | |||
| f73184ac1e | |||
| 52b66be43b | |||
| bd208bd1ab | |||
| f7952008cd | |||
| a0c82d3f3f | |||
| dd01fd1688 | |||
| d2dc95c169 | |||
| 53f7165e24 | |||
| c90a250ba7 | |||
| e80dd66809 | |||
| 95558371df | |||
| 085f79cefd | |||
| a17b9fdd13 | |||
| 73b6854266 | |||
| fe8d512596 | |||
| ef8754c018 | |||
| 483ccbff00 | |||
| 07f736b8e6 | |||
| cd1de763e3 | |||
| d6d4008348 | |||
| 4bbbbf9fa2 | |||
| a3d29bb8f0 | |||
| 0d58aee2fe | |||
| bc5d0cc4a9 | |||
| 59c3bea2d6 | |||
| 13163ddb7e | |||
| 02a9256950 | |||
| d31d6c1f95 | |||
| bc099e9dc0 | |||
| 79bf0523a5 | |||
| a0d2ccb5ab | |||
| df54840a88 | |||
| 4b62517d99 | |||
| 0ce9ec3ae2 | |||
| 5279fa8fbe | |||
| 0d75e6db9b | |||
| ffb541a12e | |||
| 5fdaa11367 | |||
| 6b339da061 | |||
| f454fb5e1c | |||
| 5db8c47aa8 | |||
| e7571f3e83 | |||
| d9b513e88c | |||
| 7dcde390cd | |||
| 6a750f4eb2 | |||
| c6d24d25cc | |||
| c19ec913cb | |||
| 438ea04a1a | |||
| d7044c1663 | |||
| 3497d275a8 | |||
| 6fd61889a8 | |||
| 85983954de | |||
| 1e9eec2c48 | |||
| bd97745ed1 | |||
| 34d450fecf | |||
| be107c0858 | |||
| 8289786099 | |||
| 56f159d50a | |||
| 61961bab05 | |||
| e0387dce00 | |||
| 46b3db033b | |||
| bf9fdae58b | |||
| 7b8cafc8ac | |||
| 7793fab5d2 | |||
| 1ddcda5c5d | |||
| 9714393538 | |||
| d46f369599 | |||
| 2dfd2a53c2 | |||
| e3675ec9a4 | |||
| cb2ed0c766 | |||
| 6638fdcaff | |||
| d0b4634429 | |||
| 1fdf1f1339 | |||
| 6290c6d0af | |||
| 26a3ea4b18 | |||
| c7b2245005 | |||
| 5ba06796b1 | |||
| e359b1dfdf | |||
| cbc8216fe0 | |||
| da238b9986 | |||
| 897ddfe77a | |||
| 80f2db794f | |||
| 913a2601d5 | |||
| 40c27eef79 | |||
| df45e00fbd | |||
| a323f1ffb7 | |||
| ea6092db8a | |||
| 8c6eb48876 | |||
| 37d2f8a8ad | |||
| f18acf3e68 | |||
| 3fb08ca2c3 | |||
| 83be09d643 | |||
| 6de8249fb0 | |||
| 013ddcff66 | |||
| 8ece4caf1c | |||
| a94b12e8cd | |||
| c38103068e | |||
| f8caaf0e99 | |||
| ee809ddb37 | |||
| 227bd0523e | |||
| c096b29521 | |||
| 6a0520b126 | |||
| 240373898a | |||
| d33ad0cdef | |||
| a3a3070158 | |||
| b717c3d550 | |||
| 9aa5820ac2 | |||
| 1ac65dd9bd | |||
| 797a6951a8 | |||
| 7268de6e1e | |||
| fc602ce9f4 | |||
| 403bff27b4 | |||
| 44b9ba911d | |||
| c24f8fc85b | |||
| 75c56cbeee | |||
| 15f42c9658 | |||
| 525d0c21bb | |||
| cbf05cfe5b | |||
| aaa506a581 | |||
| a2fbfad00e | |||
| 031c52e25a | |||
| 693dfd827c | |||
| d26a2d35bf | |||
| 9839de128c | |||
| 12872ee51e | |||
| 2af08d6823 | |||
| f646075311 | |||
| dfca767476 | |||
| fd7b5952c2 | |||
| 4b46eddc47 | |||
| e26121177f | |||
| 91eb0c314f | |||
| 1d7a2d4eae | |||
| e4235d4d75 | |||
| 41a83115be | |||
| 3ce887cb34 | |||
| 874eb6189e | |||
| 5c5c491597 | |||
| ff78c1443c | |||
| cdc1c2d776 | |||
| a004c247ab | |||
| 048e90fb8f | |||
| c1498145e6 | |||
| 7654d5183a | |||
| 9b7fc0a93b | |||
| 200318ddcf | |||
| 1fdd0a1b32 | |||
| 8869772fa4 | |||
| 96bc894962 | |||
| 5a9f5f2eca | |||
| bd9dbcbb42 | |||
| f8269bb764 | |||
| c215047c00 | |||
| a313e3f364 | |||
| b34be1184e | |||
| e23c5527da | |||
| 847e62dd27 | |||
| f5d83aa259 | |||
| 4a5c0ae5a0 | |||
| b4a4323906 | |||
| 48fc5af5f7 | |||
| a1753a28ec | |||
| fa4039cf63 | |||
| 4b0814c0a1 | |||
| 78d0b06b36 | |||
| 426bdf5df3 | |||
| 5dbad7ebd0 | |||
| 6ef33c5b7f | |||
| 3737a6eace | |||
| 967e129724 | |||
| e9d549377e | |||
| 924b8af827 | |||
| 045ee73b61 | |||
| 5d9d13ce07 | |||
| 5a1347ec50 | |||
| c705f45856 | |||
| 83fc129d05 | |||
| d7cde3a77f | |||
| afb1ad8e94 | |||
| 15a79ee9bd | |||
| 68794c170b | |||
| a9d84749ba | |||
| dd5fc323ef | |||
| cf1547d077 | |||
| 9664c99e06 | |||
| 17b7fb6999 | |||
| 21a4db8a81 | |||
| eabdabcfcd | |||
| c548383a4c | |||
| 7337f4be1e | |||
| d84f223b9d | |||
| 5431112186 | |||
| ff743151c6 | |||
| b923392b53 | |||
| 15d272c621 | |||
| eefa50b2c3 | |||
| ecc7a152f7 | |||
| 7bf31f9a47 | |||
| 7dc970ff53 | |||
| 97d71ec361 | |||
| 003b939d33 | |||
| 9989cbff24 | |||
| 426ef989f8 | |||
| ca6e079053 | |||
| 13644fd308 | |||
| 1ec76ae3fc | |||
| 51d75146cc | |||
| bc4222646d | |||
| c3e206e3b1 | |||
| 04147e11cc | |||
| 545cb4cddf | |||
| 0f948d4e2a | |||
| 5fb3e0fe14 | |||
| fb87dfd91e | |||
| be8967b05f | |||
| 8acfff7faa | |||
| 18e1f4bd28 | |||
| 74f88a6643 | |||
| 47fe764cb0 | |||
| 9e53770e6c | |||
| a9cc001791 | |||
| c24913d124 | |||
| 63bf0b6070 | |||
| 50792327a4 | |||
| 46e67be8ca | |||
| e7c3ba5eba | |||
| ea86ab2300 | |||
| 501e8c937f | |||
| cae5c36d84 | |||
| 1b92fa76e1 | |||
| bbdb683061 | |||
| 2d04547c74 | |||
| 5192c801f7 | |||
| d966d50bd5 | |||
| 7e20db33f2 | |||
| 669ee7215b | |||
| 6fa00a43a4 | |||
| 4edf740179 | |||
| c7abb4c920 | |||
| df3964110a | |||
| 96231260bc | |||
| 967303d2de | |||
| 955481773d | |||
| d66a7049e8 | |||
| e73b8d2826 | |||
| ea23003807 | |||
| 23f41f8ae7 | |||
| 3f416f83d3 | |||
| 931d1992b6 | |||
| fd927a7052 | |||
| dd46224afe | |||
| be2b29ccc7 | |||
| c93e3bc947 | |||
| 7d49395c41 | |||
| f4c9e6d7b8 | |||
| b7a907c8c8 | |||
| 36485a0f01 | |||
| efec1b4444 | |||
| bdf6500260 | |||
| db4eb0579e | |||
| 76f33534d4 | |||
| 39fea5bc2f | |||
| 660d5c1270 | |||
| 781e2fc9b2 | |||
| c2a2464fe8 | |||
| beb3c15eb3 | |||
| 553010bb7b | |||
| 8d12bbf453 | |||
| fa7588826a | |||
| 332f191e19 | |||
| 8151382a6b | |||
| ae44a21be1 | |||
| b0ff0995de | |||
| e711095ecd | |||
| 08de97a2a8 | |||
| 5eb6302d2a | |||
| 2e346ae7fd | |||
| 1285d12915 | |||
| 8b5cb9258e | |||
| ef3e3a0392 | |||
| 8fca6572f9 | |||
| 33eaf0e583 | |||
| 16acd1c08c | |||
| a8e8804ce3 | |||
| b8c0f997f6 | |||
| 11e63f38b1 | |||
| ff36d8f3db | |||
| 975542d8af | |||
| d71a9415b4 | |||
| e948da95b5 | |||
| 9a6510c320 | |||
| 57ff1ede97 | |||
| 7c0f2563f7 | |||
| d11a954b40 | |||
| f354339af1 | |||
| 89658bb77a | |||
| 1ff0238b6e | |||
| e777434d57 | |||
| ee6efc30a3 | |||
| 0758bb5f38 | |||
| 299d5725a6 | |||
| d7c9b31ec7 | |||
| 6c78bee5c1 | |||
| dba0cbd5f9 | |||
| 0752e780f2 | |||
| c43919ce01 | |||
| 0d95510b72 | |||
| 60fb2571a2 | |||
| 90cbe90492 | |||
| 95c203b0ed | |||
| 449c5c5c77 | |||
| 9aff208403 | |||
| 4318849127 | |||
| 29e8cdf699 | |||
| 4427dbdcad | |||
| af4c3819b9 | |||
| 39379e1ac0 | |||
| 71eeb3f6b8 | |||
| d409ef49af | |||
| e7a80e9280 | |||
| 65c2d2ea0b | |||
| 92666dca21 | |||
| 3e1a79c248 | |||
| 73a1ce083a | |||
| 22dacebc5e | |||
| 80d0948e24 | |||
| 58b427b977 | |||
| a4cab3565a | |||
| 205c9580e3 | |||
| 70a0ed135b | |||
| f556181d77 | |||
| d48e26904e | |||
| 19232ac405 | |||
| 9ee2ccc8af | |||
| 7079bb6a63 | |||
| 0ab5827ee5 | |||
| c5443f622c | |||
| e4aa276cca | |||
| 90ff2d679e | |||
| da26c35d5a | |||
| 779e3da74e | |||
| e358c08773 | |||
| 2945fa3a47 | |||
| ab1541e741 | |||
| 3aeaa709a5 | |||
| 91e627df6b | |||
| d0795e9e1c | |||
| 0e12dd4874 | |||
| 25c0e48181 | |||
| 0d43c3620d | |||
| 2f6137f8df | |||
| 2843b86a93 | |||
| 8235de07ff | |||
| e2f9a4c7f0 | |||
| 55c6e3cf93 | |||
| 11c154e564 | |||
| 7fc0d27c3c | |||
| 1ac76cfcd8 | |||
| c8ed04aaaf | |||
| 6641651f3c | |||
| dbf164bfb2 | |||
| 8a617c3008 | |||
| a50a2430ba | |||
| 5c3c552288 | |||
| 69fdddfc71 | |||
| db5b988275 | |||
| 4284757035 | |||
| b93a47acc0 | |||
| d59f9857ce | |||
| 8ce212b74b | |||
| e78aea5735 | |||
| 9a3c5c3f40 | |||
| 60ca3f9c34 | |||
| e7e740dff1 | |||
| 8343a98d77 | |||
| 5862039a00 | |||
| 8af989b75f | |||
| 08d0e5ff75 | |||
| 5196d10e5c | |||
| 3392ec463d | |||
| 33529404cf | |||
| 00e7a36013 | |||
| 3060b394ab | |||
| a43d9022fe | |||
| 6abdc68ca5 | |||
| 61c66b0e96 | |||
| 36cc23457a | |||
| d573b238de | |||
| 8afe25fe85 | |||
| f80647ff0d | |||
| 7e64cbabf8 | |||
| 14a06410ae | |||
| 85c2a4f4f0 | |||
| da9e211ec7 | |||
| a81070c471 | |||
| e3ad7efa4f | |||
| a4dafd7155 | |||
| 645aec853e | |||
| d8d5e4a3c4 | |||
| 7a48c04057 | |||
| 64aaaa707e | |||
| 445d40dc5f | |||
| ebdcb531f2 | |||
| c9cdb891d6 | |||
| f5c6c002a8 | |||
| d171c6bb9a | |||
| 1c81a4faed | |||
| e7d1d5cb71 | |||
| 060d831d50 | |||
| 316bd6dd01 | |||
| 34081e5903 | |||
| e2d843b65e | |||
| a796f5fe4b | |||
| 51ee41c773 | |||
| 7e5ed3efe5 | |||
| 8dd25ac315 | |||
| 1cdaa58e7a | |||
| fa3aa24a3d | |||
| 091431d95b | |||
| 1ecf0122ab | |||
| 79980a1725 | |||
| 8badcc3f6e | |||
| 4d6e57257c | |||
| a7a93b8500 | |||
| 85cc34fb4c | |||
| 772a996b6e | |||
| e67eff822d | |||
| c39ed6120f | |||
| c38f4e6543 | |||
| 098433b697 | |||
| c8e20c905b | |||
| bd2446ba0a | |||
| c179e4aaf3 | |||
| 2f8de2a919 | |||
| 338110973d | |||
| 3c9c4495bc | |||
| 93476f782c | |||
| 3aec6ee578 | |||
| 3bca76d4c8 | |||
| b9d6f35aac | |||
| 9b6959414a | |||
| 400dd6aa5e | |||
| 14af2f6efd | |||
| 0a2de9e0d5 | |||
| 89bfad78a6 | |||
| 52486fa278 | |||
| dc0e14eb21 | |||
| 70278374e7 | |||
| ac3588c76a | |||
| ab335aef2a | |||
| 719c855bdb | |||
| f283e50018 | |||
| 99b952ee28 | |||
| 24639b62c0 | |||
| 573cc531bf | |||
| 29e24bae93 | |||
| 22e4cc07c0 | |||
| 9264347698 | |||
| 579c26ac59 | |||
| ef577dd313 | |||
| 62c7e52487 | |||
| 3534ac6477 | |||
| 1738f7b311 | |||
| eb25caec81 | |||
| a6c60e2c04 | |||
| adafbdf6d3 | |||
| 7eab14938d | |||
| 039e55673b | |||
| ec3a9b6cb4 | |||
| 17a6494b2b | |||
| 0b05c7074f | |||
| 876ccc7cbf | |||
| bdf14b8f24 | |||
| 43375a6f5b | |||
| e00328ae13 | |||
| 07c553294b |
+15
-13
@@ -469,7 +469,7 @@ public class Enum {
|
||||
|
||||
// 14001 does not have a banestone to bind at
|
||||
|
||||
if (ruinZone.getLoadNum() == 14001)
|
||||
if (ruinZone.templateID == 14001)
|
||||
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30);
|
||||
else
|
||||
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc()
|
||||
@@ -2310,10 +2310,10 @@ public class Enum {
|
||||
ZONE(875),
|
||||
PLACEMENT(876);
|
||||
|
||||
public final float extents;
|
||||
public final float halfExtents;
|
||||
|
||||
CityBoundsType(float extents) {
|
||||
this.extents = extents;
|
||||
CityBoundsType(float halfExtents) {
|
||||
this.halfExtents = halfExtents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2822,7 +2822,6 @@ public class Enum {
|
||||
|
||||
public enum MobBehaviourType {
|
||||
None(null, false, false, false, false, false),
|
||||
//Power
|
||||
Power(null, false, true, true, true, false),
|
||||
PowerHelpee(Power, false, true, true, false, true),
|
||||
PowerHelpeeWimpy(Power, true, false, true, false, false),
|
||||
@@ -2847,6 +2846,7 @@ public class Enum {
|
||||
//Independent Types
|
||||
SimpleStandingGuard(null, false, false, false, false, false),
|
||||
Pet1(null, false, false, true, false, false),
|
||||
SiegeEngine(null, false, false, false, false, false),
|
||||
Simple(null, false, false, true, false, false),
|
||||
Helpee(null, false, true, true, false, true),
|
||||
HelpeeWimpy(null, true, false, true, false, false),
|
||||
@@ -2857,13 +2857,12 @@ public class Enum {
|
||||
HamletGuard(null, false, true, false, false, false),
|
||||
AggroWanderer(null, false, false, true, false, false);
|
||||
|
||||
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
|
||||
public MobBehaviourType BehaviourHelperType;
|
||||
public boolean isWimpy;
|
||||
public boolean isAgressive;
|
||||
public boolean canRoam;
|
||||
public boolean callsForHelp;
|
||||
public boolean respondsToCallForHelp;
|
||||
public final MobBehaviourType BehaviourHelperType;
|
||||
public final boolean isWimpy;
|
||||
public final boolean isAgressive;
|
||||
public final boolean canRoam;
|
||||
public final boolean callsForHelp;
|
||||
public final boolean respondsToCallForHelp;
|
||||
|
||||
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
|
||||
this.BehaviourHelperType = helpeebehaviourType;
|
||||
@@ -2878,8 +2877,11 @@ public class Enum {
|
||||
|
||||
public enum AIAgentType {
|
||||
MOBILE,
|
||||
GUARDCAPTAIN,
|
||||
GUARDMINION,
|
||||
GUARDWALLARCHER,
|
||||
PET,
|
||||
CHARMED,
|
||||
GUARD;
|
||||
SIEGEENGINE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,706 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.InterestManagement;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.Zone;
|
||||
import engine.util.MapLoader;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class HeightMap {
|
||||
|
||||
// Class variables
|
||||
|
||||
// Heightmap data for all zones.
|
||||
|
||||
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
|
||||
|
||||
// Bootstrap Tracking
|
||||
|
||||
public static int heightMapsCreated = 0;
|
||||
public static HeightMap PlayerCityHeightMap;
|
||||
|
||||
// Heightmap data for this heightmap
|
||||
|
||||
public BufferedImage heightmapImage;
|
||||
|
||||
private int heightMapID;
|
||||
private int maxHeight;
|
||||
private int fullExtentsX;
|
||||
private int fullExtentsY;
|
||||
|
||||
private float bucketWidthX;
|
||||
private float bucketWidthY;
|
||||
private int zoneLoadID;
|
||||
private float seaLevel = 0;
|
||||
private float outsetX;
|
||||
private float outsetZ;
|
||||
private int[][] pixelColorValues;
|
||||
|
||||
public HeightMap(ResultSet rs) throws SQLException {
|
||||
|
||||
this.heightMapID = rs.getInt("heightMapID");
|
||||
this.maxHeight = rs.getInt("maxHeight");
|
||||
int halfExtentsX = rs.getInt("xRadius");
|
||||
int halfExtentsY = rs.getInt("zRadius");
|
||||
this.zoneLoadID = rs.getInt("zoneLoadID");
|
||||
this.seaLevel = rs.getFloat("seaLevel");
|
||||
this.outsetX = rs.getFloat("outsetX");
|
||||
this.outsetZ = rs.getFloat("outsetZ");
|
||||
|
||||
|
||||
// Cache the full extents to avoid the calculation
|
||||
|
||||
this.fullExtentsX = halfExtentsX * 2;
|
||||
this.fullExtentsY = halfExtentsY * 2;
|
||||
|
||||
this.heightmapImage = null;
|
||||
File imageFile = new File(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/" + this.heightMapID + ".bmp");
|
||||
|
||||
// early exit if no image file was found. Will log in caller.
|
||||
|
||||
if (!imageFile.exists())
|
||||
return;
|
||||
|
||||
// load the heightmap image.
|
||||
|
||||
try {
|
||||
this.heightmapImage = ImageIO.read(imageFile);
|
||||
} catch (IOException e) {
|
||||
Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e.toString());
|
||||
}
|
||||
|
||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
||||
|
||||
this.heightmapImage = MapLoader.flipImage(this.heightmapImage);
|
||||
|
||||
// Calculate the data we do not load from table
|
||||
|
||||
float numOfBuckets = this.heightmapImage.getWidth() - 1;
|
||||
float calculatedWidth = this.fullExtentsX / numOfBuckets;
|
||||
this.bucketWidthX = calculatedWidth;
|
||||
this.bucketWidthY = this.bucketWidthX; // This makes no sense.
|
||||
|
||||
// Generate pixel array from image data
|
||||
|
||||
generatePixelData();
|
||||
|
||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
||||
|
||||
heightMapsCreated++;
|
||||
}
|
||||
|
||||
//Created for PlayerCities
|
||||
public HeightMap() {
|
||||
|
||||
this.heightMapID = 999999;
|
||||
this.maxHeight = 5; // for real...
|
||||
int halfExtentsX = (int) Enum.CityBoundsType.ZONE.extents;
|
||||
int halfExtentsY = (int) Enum.CityBoundsType.ZONE.extents;
|
||||
this.zoneLoadID = 0;
|
||||
this.seaLevel = 0;
|
||||
this.outsetX = 128;
|
||||
this.outsetZ = 128;
|
||||
|
||||
|
||||
// Cache the full extents to avoid the calculation
|
||||
|
||||
this.fullExtentsX = halfExtentsX * 2;
|
||||
this.fullExtentsY = halfExtentsY * 2;
|
||||
|
||||
|
||||
// load the heightmap image.
|
||||
|
||||
|
||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
||||
|
||||
this.heightmapImage = null;
|
||||
|
||||
// Calculate the data we do not load from table
|
||||
|
||||
this.bucketWidthX = 1;
|
||||
this.bucketWidthY = 1;
|
||||
|
||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
||||
|
||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
||||
pixelColorValues[x][y] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
||||
}
|
||||
|
||||
public HeightMap(Zone zone) {
|
||||
|
||||
this.heightMapID = 999999;
|
||||
this.maxHeight = 0;
|
||||
int halfExtentsX = (int) zone.getBounds().getHalfExtents().x;
|
||||
int halfExtentsY = (int) zone.getBounds().getHalfExtents().y;
|
||||
this.zoneLoadID = 0;
|
||||
this.seaLevel = 0;
|
||||
this.outsetX = 0;
|
||||
this.outsetZ = 0;
|
||||
|
||||
// Cache the full extents to avoid the calculation
|
||||
|
||||
this.fullExtentsX = halfExtentsX * 2;
|
||||
this.fullExtentsY = halfExtentsY * 2;
|
||||
|
||||
|
||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
||||
|
||||
this.heightmapImage = null;
|
||||
|
||||
// Calculate the data we do not load from table
|
||||
|
||||
this.bucketWidthX = 1;
|
||||
this.bucketWidthY = 1;
|
||||
|
||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
||||
|
||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
||||
pixelColorValues[x][y] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
||||
}
|
||||
|
||||
public static void GeneratePlayerCityHeightMap() {
|
||||
|
||||
HeightMap.PlayerCityHeightMap = new HeightMap();
|
||||
|
||||
}
|
||||
|
||||
public static void GenerateCustomHeightMap(Zone zone) {
|
||||
|
||||
HeightMap heightMap = new HeightMap(zone);
|
||||
|
||||
HeightMap.heightmapByLoadNum.put(zone.getLoadNum(), heightMap);
|
||||
|
||||
}
|
||||
|
||||
public static Zone getNextZoneWithTerrain(Zone zone) {
|
||||
|
||||
Zone nextZone = zone;
|
||||
|
||||
if (zone.getHeightMap() != null)
|
||||
return zone;
|
||||
|
||||
if (zone.equals(ZoneManager.getSeaFloor()))
|
||||
return zone;
|
||||
|
||||
while (nextZone.getHeightMap() == null)
|
||||
nextZone = nextZone.getParent();
|
||||
|
||||
return nextZone;
|
||||
}
|
||||
|
||||
public static float getWorldHeight(AbstractWorldObject worldObject) {
|
||||
|
||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
||||
Zone currentZone = ZoneManager.findSmallestZone(worldObject.getLoc());
|
||||
|
||||
if (currentZone == null)
|
||||
return worldObject.getAltitude();
|
||||
|
||||
currentZone = getNextZoneWithTerrain(currentZone);
|
||||
|
||||
if (currentZone == ZoneManager.getSeaFloor())
|
||||
return currentZone.getAbsY() + worldObject.getAltitude();
|
||||
|
||||
Zone parentZone = getNextZoneWithTerrain(currentZone.getParent());
|
||||
HeightMap heightMap = currentZone.getHeightMap();
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), currentZone);
|
||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldObject.getLoc(), currentZone);
|
||||
|
||||
if ((parentZone != null) && (parentZone.getHeightMap() != null))
|
||||
parentLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), parentZone);
|
||||
|
||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
|
||||
float worldAltitude = currentZone.getWorldAltitude();
|
||||
|
||||
float realWorldAltitude = interaltitude + worldAltitude;
|
||||
|
||||
//OUTSET
|
||||
|
||||
if (parentZone != null) {
|
||||
|
||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
||||
|
||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
||||
|
||||
float bucketScaleX = heightMap.outsetX / parentXRadius;
|
||||
float bucketScaleZ = heightMap.outsetZ / parentZRadius;
|
||||
|
||||
if (bucketScaleX <= 0.40000001)
|
||||
bucketScaleX = heightMap.outsetZ / parentXRadius;
|
||||
|
||||
if (bucketScaleX > 0.40000001)
|
||||
bucketScaleX = 0.40000001f;
|
||||
|
||||
if (bucketScaleZ <= 0.40000001)
|
||||
bucketScaleZ = heightMap.outsetX / parentZRadius;
|
||||
|
||||
if (bucketScaleZ > 0.40000001)
|
||||
bucketScaleZ = 0.40000001f;
|
||||
|
||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
||||
float weight;
|
||||
|
||||
double scale;
|
||||
|
||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
||||
realWorldAltitude = outsetALt;
|
||||
|
||||
} else if (offsetZ > outsideGridSizeZ) {
|
||||
|
||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
||||
realWorldAltitude = outsetALt;
|
||||
}
|
||||
}
|
||||
|
||||
return realWorldAltitude;
|
||||
}
|
||||
|
||||
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
||||
|
||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
||||
Zone currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||
|
||||
if (currentZone == null)
|
||||
return 0;
|
||||
|
||||
currentZone = getNextZoneWithTerrain(currentZone);
|
||||
|
||||
if (currentZone == ZoneManager.getSeaFloor())
|
||||
return currentZone.getAbsY();
|
||||
|
||||
Zone parentZone = getNextZoneWithTerrain(currentZone.getParent());
|
||||
HeightMap heightMap = currentZone.getHeightMap();
|
||||
|
||||
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor()))
|
||||
return currentZone.getAbsY();
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone);
|
||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLoc, currentZone);
|
||||
|
||||
if ((parentZone != null) && (parentZone.getHeightMap() != null))
|
||||
parentLoc = ZoneManager.worldToZoneSpace(worldLoc, parentZone);
|
||||
|
||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
|
||||
float worldAltitude = currentZone.getWorldAltitude();
|
||||
|
||||
float realWorldAltitude = interaltitude + worldAltitude;
|
||||
|
||||
//OUTSET
|
||||
|
||||
if (parentZone != null) {
|
||||
|
||||
// if (currentZone.getHeightMap() != null && parentZone.getHeightMap() != null && parentZone.getParent() != null && parentZone.getParent().getHeightMap() != null)
|
||||
// return realWorldAltitude;
|
||||
|
||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
||||
|
||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
||||
|
||||
float bucketScaleX = heightMap.outsetX / parentXRadius;
|
||||
float bucketScaleZ = heightMap.outsetZ / parentZRadius;
|
||||
|
||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
||||
float weight;
|
||||
|
||||
double scale;
|
||||
|
||||
|
||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
||||
realWorldAltitude = outsetALt;
|
||||
|
||||
} else if (offsetZ > outsideGridSizeZ) {
|
||||
|
||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
||||
realWorldAltitude = outsetALt;
|
||||
}
|
||||
}
|
||||
|
||||
return realWorldAltitude;
|
||||
}
|
||||
|
||||
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
|
||||
|
||||
Vector2f parentLoc;
|
||||
float outsetALt = 0;
|
||||
|
||||
if (zone.getParent() == null || zone.getParent().getHeightMap() == null)
|
||||
return interpolatedAltitude + zone.getWorldAltitude();
|
||||
|
||||
if (zone.getParent() != null && zone.getParent().getHeightMap() != null) {
|
||||
|
||||
parentLoc = ZoneManager.worldToZoneSpace(worldLocation, zone.getParent());
|
||||
|
||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLocation, zone);
|
||||
|
||||
float parentXRadius = zone.getBounds().getHalfExtents().x;
|
||||
float parentZRadius = zone.getBounds().getHalfExtents().y;
|
||||
|
||||
float bucketScaleX = zone.getHeightMap().outsetX / parentXRadius;
|
||||
float bucketScaleZ = zone.getHeightMap().outsetZ / parentZRadius;
|
||||
|
||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
||||
|
||||
float weight;
|
||||
double scale;
|
||||
|
||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
||||
|
||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
|
||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone.getParent()));
|
||||
|
||||
parentCenterAltitude += zone.getYCoord();
|
||||
parentCenterAltitude += interpolatedAltitude;
|
||||
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += zone.getParent().getAbsY();
|
||||
|
||||
} else if (offsetZ > outsideGridSizeZ) {
|
||||
|
||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = zone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone));
|
||||
|
||||
parentCenterAltitude += zone.getYCoord();
|
||||
parentCenterAltitude += interpolatedAltitude;
|
||||
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += zone.getParent().getAbsY();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return outsetALt;
|
||||
}
|
||||
|
||||
public static Vector2f getGridOffset(Vector2f gridSquare) {
|
||||
|
||||
int floorX = (int) gridSquare.x;
|
||||
int floorY = (int) gridSquare.y;
|
||||
|
||||
return new Vector2f(gridSquare.x - floorX, gridSquare.y - floorY);
|
||||
|
||||
}
|
||||
|
||||
public static void loadAlHeightMaps() {
|
||||
|
||||
// Load the heightmaps into staging hashmap keyed by HashMapID
|
||||
|
||||
DbManager.HeightMapQueries.LOAD_ALL_HEIGHTMAPS();
|
||||
|
||||
//generate static player city heightmap.
|
||||
|
||||
HeightMap.GeneratePlayerCityHeightMap();
|
||||
|
||||
|
||||
// Clear all heightmap image data as it's no longer needed.
|
||||
|
||||
for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) {
|
||||
heightMap.heightmapImage = null;
|
||||
}
|
||||
|
||||
Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached.");
|
||||
}
|
||||
|
||||
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
|
||||
|
||||
float localAltitude = HeightMap.getWorldHeight(currentLoc);
|
||||
Zone zone = ZoneManager.findSmallestZone(currentLoc);
|
||||
|
||||
if (localAltitude < zone.getSeaLevel())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vector2f getGridSquare(Vector2f zoneLoc) {
|
||||
|
||||
if (zoneLoc.x < 0)
|
||||
zoneLoc.setX(0);
|
||||
|
||||
if (zoneLoc.x > this.fullExtentsX - 1)
|
||||
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
|
||||
|
||||
if (zoneLoc.y < 0)
|
||||
zoneLoc.setY(0);
|
||||
|
||||
if (zoneLoc.y > this.fullExtentsY - 1)
|
||||
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
|
||||
|
||||
float xBucket = (zoneLoc.x / this.bucketWidthX);
|
||||
float yBucket = (zoneLoc.y / this.bucketWidthY);
|
||||
|
||||
return new Vector2f(xBucket, yBucket);
|
||||
}
|
||||
|
||||
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
|
||||
|
||||
Vector2f gridSquare;
|
||||
|
||||
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
|
||||
return -1;
|
||||
|
||||
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
|
||||
return -1;
|
||||
|
||||
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
|
||||
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
|
||||
|
||||
//flip the Y so it grabs from the bottom left instead of top left.
|
||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
||||
|
||||
gridSquare = getGridSquare(zoneLoc);
|
||||
|
||||
int gridX = (int) gridSquare.x;
|
||||
int gridY = (int) (gridSquare.y);
|
||||
|
||||
if (gridX > maxX)
|
||||
gridX = maxX;
|
||||
if (gridY > maxY)
|
||||
gridY = maxY;
|
||||
|
||||
float offsetX = (gridSquare.x - gridX);
|
||||
float offsetY = gridSquare.y - gridY;
|
||||
|
||||
//get height of the 4 vertices.
|
||||
|
||||
float topLeftHeight = 0;
|
||||
float topRightHeight = 0;
|
||||
float bottomLeftHeight = 0;
|
||||
float bottomRightHeight = 0;
|
||||
|
||||
int nextY = gridY + 1;
|
||||
int nextX = gridX + 1;
|
||||
|
||||
if (nextY > maxY)
|
||||
nextY = gridY;
|
||||
|
||||
if (nextX > maxX)
|
||||
nextX = gridX;
|
||||
|
||||
topLeftHeight = pixelColorValues[gridX][gridY];
|
||||
topRightHeight = pixelColorValues[nextX][gridY];
|
||||
bottomLeftHeight = pixelColorValues[gridX][nextY];
|
||||
bottomRightHeight = pixelColorValues[nextX][nextY];
|
||||
|
||||
float interpolatedHeight;
|
||||
|
||||
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
|
||||
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
|
||||
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
||||
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
||||
|
||||
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
|
||||
|
||||
return interpolatedHeight;
|
||||
}
|
||||
|
||||
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
|
||||
|
||||
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
|
||||
|
||||
Vector2f gridSquare;
|
||||
|
||||
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
|
||||
return -1;
|
||||
|
||||
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
|
||||
return -1;
|
||||
|
||||
//flip the Y so it grabs from the bottom left instead of top left.
|
||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
||||
|
||||
gridSquare = getGridSquare(zoneLoc);
|
||||
|
||||
int gridX = (int) gridSquare.x;
|
||||
int gridY = (int) (gridSquare.y);
|
||||
|
||||
float offsetX = (gridSquare.x - gridX);
|
||||
float offsetY = gridSquare.y - gridY;
|
||||
|
||||
//get height of the 4 vertices.
|
||||
|
||||
float topLeftHeight = pixelColorValues[gridX][gridY];
|
||||
float topRightHeight = pixelColorValues[gridX + 1][gridY];
|
||||
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
|
||||
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
|
||||
|
||||
float interpolatedHeight;
|
||||
|
||||
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
|
||||
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
|
||||
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
||||
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
||||
|
||||
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
|
||||
|
||||
return interpolatedHeight;
|
||||
}
|
||||
|
||||
private void generatePixelData() {
|
||||
|
||||
Color color;
|
||||
|
||||
// Generate altitude lookup table for this heightmap
|
||||
|
||||
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
|
||||
|
||||
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
|
||||
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
|
||||
|
||||
color = new Color(this.heightmapImage.getRGB(x, y));
|
||||
pixelColorValues[x][y] = color.getRed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public float getScaledHeightForColor(float color) {
|
||||
|
||||
return (color / 256) * this.maxHeight;
|
||||
}
|
||||
|
||||
public float getBucketWidthX() {
|
||||
return bucketWidthX;
|
||||
}
|
||||
|
||||
public float getBucketWidthY() {
|
||||
return bucketWidthY;
|
||||
}
|
||||
|
||||
public int getHeightMapID() {
|
||||
return heightMapID;
|
||||
}
|
||||
|
||||
public BufferedImage getHeightmapImage() {
|
||||
return heightmapImage;
|
||||
}
|
||||
|
||||
public float getSeaLevel() {
|
||||
return seaLevel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public enum InterestManager implements Runnable {
|
||||
|
||||
else {
|
||||
if (pc != null)
|
||||
if (pcc.getSeeInvis() < pc.getHidden())
|
||||
if (pcc.getSeeInvis() < pc.hidden)
|
||||
continue;
|
||||
|
||||
if (!cc.sendMsg(uom)) {
|
||||
@@ -340,7 +340,7 @@ public enum InterestManager implements Runnable {
|
||||
if (loadedPlayer.getObjectUUID() == player.getObjectUUID())
|
||||
continue;
|
||||
|
||||
if (player.getSeeInvis() < loadedPlayer.getHidden())
|
||||
if (player.getSeeInvis() < loadedPlayer.hidden)
|
||||
continue;
|
||||
|
||||
if (loadedPlayer.safemodeInvis())
|
||||
@@ -372,7 +372,7 @@ public enum InterestManager implements Runnable {
|
||||
|
||||
if (playerLoadedObject.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
PlayerCharacter loadedPlayer = (PlayerCharacter) playerLoadedObject;
|
||||
if (player.getSeeInvis() < loadedPlayer.getHidden())
|
||||
if (player.getSeeInvis() < loadedPlayer.hidden)
|
||||
toRemove.add(playerLoadedObject);
|
||||
else if (loadedPlayer.safemodeInvis())
|
||||
toRemove.add(playerLoadedObject);
|
||||
@@ -437,7 +437,7 @@ public enum InterestManager implements Runnable {
|
||||
|
||||
// dont load if invis
|
||||
|
||||
if (player.getSeeInvis() < awopc.getHidden())
|
||||
if (player.getSeeInvis() < awopc.hidden)
|
||||
continue;
|
||||
|
||||
lcm = new LoadCharacterMsg(awopc, PlayerCharacter.hideNonAscii());
|
||||
@@ -467,7 +467,7 @@ public enum InterestManager implements Runnable {
|
||||
if (awonpc.despawned == true)
|
||||
continue;
|
||||
|
||||
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
|
||||
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
|
||||
((Mob) awonpc).setCombatTarget(null);
|
||||
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
|
||||
|
||||
@@ -480,7 +480,7 @@ public enum InterestManager implements Runnable {
|
||||
if (!awonpc.isAlive())
|
||||
continue;
|
||||
|
||||
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
|
||||
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
|
||||
|
||||
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
|
||||
((Mob) awonpc).setCombatTarget(null);
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.InterestManagement;
|
||||
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public class Terrain {
|
||||
public static final HashMap<Integer, short[][]> _heightmap_pixel_cache = new HashMap<>();
|
||||
public short[][] terrain_pixel_data;
|
||||
public Vector2f terrain_size = new Vector2f();
|
||||
public Vector2f cell_size = new Vector2f();
|
||||
public Vector2f cell_count = new Vector2f();
|
||||
public float terrain_scale;
|
||||
public Vector2f blend_values = new Vector2f();
|
||||
public Vector2f blend_ratio = new Vector2f();
|
||||
public int heightmap;
|
||||
Zone zone;
|
||||
|
||||
public Terrain(Zone zone) {
|
||||
|
||||
this.zone = zone;
|
||||
this.heightmap = this.zone.template.terrain_image;
|
||||
|
||||
// Configure PLANAR zones to use the same 16x16 pixel image
|
||||
// that all similar terrains share. (See JSON)
|
||||
|
||||
if (this.zone.template.terrain_type.equals("PLANAR"))
|
||||
this.heightmap = 1006300; // all 0
|
||||
|
||||
// Load pixel data for this terrain from cache
|
||||
|
||||
this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap);
|
||||
|
||||
if (terrain_pixel_data == null)
|
||||
Logger.error("Pixel map empty for zone: " + this.zone.getObjectUUID() + ":" + this.zone.zoneName);
|
||||
|
||||
// Configure terrain based on zone properties
|
||||
|
||||
this.terrain_size.x = this.zone.major_radius * 2;
|
||||
this.terrain_size.y = this.zone.minor_radius * 2;
|
||||
|
||||
this.cell_count.x = this.terrain_pixel_data.length - 1;
|
||||
this.cell_count.y = this.terrain_pixel_data[0].length - 1;
|
||||
|
||||
this.cell_size.x = terrain_size.x / this.cell_count.x;
|
||||
this.cell_size.y = terrain_size.y / this.cell_count.y;
|
||||
|
||||
// Blending configuration. These ratios are used to calculate
|
||||
// the blending area between child and parent terrains when
|
||||
// they are stitched together.
|
||||
|
||||
this.blend_values.x = this.zone.template.max_blend;
|
||||
this.blend_values.y = this.zone.template.min_blend;
|
||||
|
||||
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
|
||||
this.blend_values.y / this.zone.major_radius);
|
||||
|
||||
Vector2f minor_blend = new Vector2f(this.blend_values.x / this.zone.minor_radius,
|
||||
this.blend_values.y / this.zone.minor_radius);
|
||||
|
||||
if (major_blend.y > 0.4f)
|
||||
blend_ratio.x = major_blend.y;
|
||||
else
|
||||
blend_ratio.x = Math.min(major_blend.x, 0.4f);
|
||||
|
||||
if (minor_blend.y > 0.4f)
|
||||
blend_ratio.y = minor_blend.y;
|
||||
else
|
||||
blend_ratio.y = Math.min(minor_blend.x, 0.4f);
|
||||
|
||||
// Scale coefficient for this terrain
|
||||
|
||||
this.terrain_scale = this.zone.template.terrain_max_y / 255f;
|
||||
}
|
||||
|
||||
public static Zone getNextZoneWithTerrain(Zone zone) {
|
||||
|
||||
// Not all zones have a terrain. Some are for display only
|
||||
// and heights returned are from the parent heightmap. This
|
||||
// is controlled in the JSON via the has_terrain_gen field.
|
||||
|
||||
Zone terrain_zone = zone;
|
||||
|
||||
if (zone == null)
|
||||
return ZoneManager.seaFloor;
|
||||
|
||||
if (zone.terrain != null)
|
||||
return zone;
|
||||
|
||||
if (zone.equals(ZoneManager.seaFloor))
|
||||
return zone;
|
||||
|
||||
while (terrain_zone.terrain == null)
|
||||
terrain_zone = terrain_zone.parent;
|
||||
|
||||
return terrain_zone;
|
||||
}
|
||||
|
||||
public static float getWorldHeight(Zone zone, Vector3fImmutable world_loc) {
|
||||
|
||||
// Retrieve the next zone with a terrain defined.
|
||||
|
||||
Zone terrainZone = getNextZoneWithTerrain(zone);
|
||||
Zone parentZone = getNextZoneWithTerrain(zone.parent);
|
||||
|
||||
// Transform world loc into zone space coordinate system
|
||||
|
||||
Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(world_loc, terrainZone);
|
||||
Vector2f parentLoc = ZoneManager.worldToTerrainSpace(world_loc, parentZone);
|
||||
|
||||
// Offset from origin needed for blending function
|
||||
|
||||
Vector2f terrainOffset = ZoneManager.worldToZoneOffset(world_loc, terrainZone);
|
||||
|
||||
// Interpolate height for this position in both terrains
|
||||
|
||||
float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc);
|
||||
interpolatedChildHeight += terrainZone.global_height;
|
||||
|
||||
float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc);
|
||||
interpolatedParentTerrainHeight += parentZone.global_height;
|
||||
|
||||
// Blend between terrains
|
||||
|
||||
float blendCoefficient = terrainZone.terrain.getTerrainBlendCoefficient(terrainOffset);
|
||||
|
||||
float terrainHeight = interpolatedChildHeight * blendCoefficient;
|
||||
terrainHeight += interpolatedParentTerrainHeight * (1 - blendCoefficient);
|
||||
|
||||
return terrainHeight;
|
||||
|
||||
}
|
||||
|
||||
public static float getWorldHeight(Vector3fImmutable world_loc) {
|
||||
|
||||
Zone currentZone = ZoneManager.findSmallestZone(world_loc);
|
||||
|
||||
return getWorldHeight(currentZone, world_loc);
|
||||
|
||||
}
|
||||
|
||||
public Vector2f getTerrainCell(Vector2f terrain_loc) {
|
||||
|
||||
// Calculate terrain cell with offset
|
||||
|
||||
Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y);
|
||||
|
||||
// Clamp values when standing directly on pole
|
||||
|
||||
terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x));
|
||||
terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y));
|
||||
|
||||
return terrain_cell;
|
||||
}
|
||||
|
||||
public float getInterpolatedTerrainHeight(Vector2f terrain_loc) {
|
||||
|
||||
float interpolatedHeight;
|
||||
|
||||
// Early exit for guild zones
|
||||
|
||||
if (this.zone.guild_zone)
|
||||
return 5.0f;
|
||||
|
||||
// Determine terrain and offset from top left vertex
|
||||
|
||||
Vector2f terrain_cell = getTerrainCell(terrain_loc);
|
||||
|
||||
int pixel_x = (int) Math.floor(terrain_cell.x);
|
||||
int pixel_y = (int) Math.floor(terrain_cell.y);
|
||||
|
||||
Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1);
|
||||
|
||||
// 4 surrounding vertices from the pixel array.
|
||||
|
||||
short top_left_pixel = terrain_pixel_data[pixel_x][pixel_y];
|
||||
short top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y];
|
||||
short bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1];
|
||||
short bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1];
|
||||
|
||||
// Interpolate between the 4 vertices
|
||||
|
||||
interpolatedHeight = top_left_pixel * (1 - pixel_offset.x) * (1 - pixel_offset.y);
|
||||
interpolatedHeight += top_right_pixel * (1 - pixel_offset.y) * (pixel_offset.x);
|
||||
interpolatedHeight += (bottom_left_pixel * (1 - pixel_offset.x) * pixel_offset.y);
|
||||
interpolatedHeight += (bottom_right_pixel * pixel_offset.y * pixel_offset.x);
|
||||
|
||||
interpolatedHeight *= this.terrain_scale; // Scale height
|
||||
|
||||
return interpolatedHeight;
|
||||
|
||||
}
|
||||
|
||||
public float getTerrainBlendCoefficient(Vector2f zone_offset) {
|
||||
|
||||
// Normalize terrain offset
|
||||
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.major_radius,
|
||||
Math.abs(zone_offset.y) / this.zone.template.minor_radius);
|
||||
|
||||
float blendCoefficient;
|
||||
|
||||
if (normalizedOffset.x <= 1 - blend_ratio.x || normalizedOffset.x <= normalizedOffset.y) {
|
||||
|
||||
if (normalizedOffset.y < 1 - blend_ratio.y)
|
||||
return 1;
|
||||
|
||||
blendCoefficient = (normalizedOffset.y - (1 - blend_ratio.y)) / blend_ratio.y;
|
||||
} else
|
||||
blendCoefficient = (normalizedOffset.x - (1 - blend_ratio.x)) / blend_ratio.x;
|
||||
|
||||
blendCoefficient = (float) Math.atan((0.5f - blendCoefficient) * PI);
|
||||
|
||||
return (blendCoefficient + 1) * 0.5f;
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class CityRecord extends DataRecord {
|
||||
cityRecord.locX = cityRecord.city.getTOL().getLoc().x;
|
||||
cityRecord.locY = -cityRecord.city.getTOL().getLoc().z; // flip sign on 'y' coordinate
|
||||
|
||||
cityRecord.zoneHash = cityRecord.city.getParent().getHash();
|
||||
cityRecord.zoneHash = cityRecord.city.getParent().hash;
|
||||
|
||||
if (cityRecord.eventType.equals(Enum.RecordEventType.CREATE))
|
||||
cityRecord.establishedDatetime = cityRecord.city.established;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MineRecord extends DataRecord {
|
||||
mineRecord.eventType = eventType;
|
||||
}
|
||||
|
||||
mineRecord.zoneHash = mine.getParentZone().getHash();
|
||||
mineRecord.zoneHash = mine.getParentZone().hash;
|
||||
|
||||
if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
player = (PlayerCharacter) character;
|
||||
|
||||
@@ -281,7 +281,7 @@ public class PvpRecord extends DataRecord {
|
||||
outStatement.setInt(8, this.victim.getLevel());
|
||||
|
||||
outStatement.setString(9, DataWarehouse.hasher.encrypt(zone.getObjectUUID()));
|
||||
outStatement.setString(10, zone.getName());
|
||||
outStatement.setString(10, zone.zoneName);
|
||||
outStatement.setFloat(11, this.location.getX());
|
||||
outStatement.setFloat(12, -this.location.getZ()); // flip sign on 'y' coordinate
|
||||
outStatement.setBoolean(13, this.pvpExp);
|
||||
|
||||
@@ -13,7 +13,9 @@ import engine.Enum;
|
||||
import engine.Enum.DbObjectType;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.Enum.TaxType;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -27,6 +29,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
@@ -88,14 +91,12 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return removeFromBuildings(b);
|
||||
}
|
||||
|
||||
public ArrayList<Building> GET_ALL_BUILDINGS_FOR_ZONE(Zone zone) {
|
||||
public ArrayList<Building> GET_ALL_BUILDINGS() {
|
||||
|
||||
ArrayList<Building> buildings = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
buildings = getObjectsFromRs(rs, 1000);
|
||||
@@ -425,26 +426,28 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LOAD_ALL_FRIENDS_FOR_BUILDING(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return;
|
||||
public void LOAD_BUILDING_FRIENDS() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends` WHERE `buildingUID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends`")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
BuildingFriends friend = new BuildingFriends(rs);
|
||||
switch (friend.getFriendType()) {
|
||||
|
||||
// Create map if it does not yet exist
|
||||
|
||||
if (!BuildingManager._buildingFriends.containsKey(friend.buildingUID))
|
||||
BuildingManager._buildingFriends.put(friend.buildingUID, new ConcurrentHashMap<>());
|
||||
|
||||
switch (friend.friendType) {
|
||||
case 7:
|
||||
building.getFriends().put(friend.getPlayerUID(), friend);
|
||||
BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.playerUID, friend);
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
building.getFriends().put(friend.getGuildUID(), friend);
|
||||
BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.guildUID, friend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -455,26 +458,29 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return;
|
||||
public void LOAD_BUILDING_CONDEMNED() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned` WHERE `buildingUID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned`")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
Condemned condemned = new Condemned(rs);
|
||||
switch (condemned.getFriendType()) {
|
||||
|
||||
// Create map if it does not yet exist
|
||||
|
||||
if (!BuildingManager._buildingCondemned.containsKey(condemned.buildingUUID))
|
||||
BuildingManager._buildingCondemned.put(condemned.buildingUUID, new ConcurrentHashMap<>());
|
||||
|
||||
switch (condemned.friendType) {
|
||||
case 2:
|
||||
building.getCondemned().put(condemned.getPlayerUID(), condemned);
|
||||
BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.playerUID, condemned);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
building.getCondemned().put(condemned.getGuildUID(), condemned);
|
||||
BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.guildUID, condemned);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -484,35 +490,27 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Vector3fImmutable> LOAD_PATROL_POINTS(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return null;
|
||||
|
||||
ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>();
|
||||
public void LOAD_BARRACKS_PATROL_POINTS() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points` WHERE `buildingUID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
float x1 = rs.getFloat("patrolX");
|
||||
float y1 = rs.getFloat("patrolY");
|
||||
float z1 = rs.getFloat("patrolZ");
|
||||
Vector3fImmutable patrolPoint = new Vector3fImmutable(x1, y1, z1);
|
||||
patrolPoints.add(patrolPoint);
|
||||
|
||||
int buildingUUID = rs.getInt("buildingUID");
|
||||
|
||||
if (!BuildingManager._buildingPatrolPoints.containsKey(buildingUUID))
|
||||
BuildingManager._buildingPatrolPoints.put(buildingUUID, new ArrayList<>());
|
||||
|
||||
Vector3fImmutable patrolPoint = new Vector3fImmutable(rs.getFloat("patrolX"), rs.getFloat("patrolY"), rs.getFloat("patrolZ"));
|
||||
BuildingManager._buildingPatrolPoints.get(buildingUUID).add(patrolPoint);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return patrolPoints;
|
||||
|
||||
}
|
||||
|
||||
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) {
|
||||
@@ -551,6 +549,86 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void POPULATE_RENDER_LOOKUP() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_renders`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
int structureID = rs.getInt("structureID");
|
||||
int renderID = rs.getInt("renderID");
|
||||
|
||||
if (!BuildingManager._render_lookup.containsKey(structureID))
|
||||
BuildingManager._render_lookup.put(structureID, new ArrayList<>());
|
||||
|
||||
BuildingManager._render_lookup.get(structureID).add(renderID);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_MESH_HULLS() {
|
||||
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_verts")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
int propID = rs.getInt("propID");
|
||||
String[] vertStrings = rs.getString("vertices").split(";");
|
||||
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
|
||||
|
||||
// Filter things that couldn't be wrapped
|
||||
|
||||
if (vertStrings.length < 3) {
|
||||
Logger.error("Prop : " + propID + " has less than 3 vertices.");
|
||||
continue;
|
||||
}
|
||||
ArrayList<Vector2f> vectors = new ArrayList<>();
|
||||
ArrayList<Float> floats = new ArrayList<>();
|
||||
for(String read : vertStrings){
|
||||
floats.add(Float.parseFloat(read));
|
||||
if(floats.size() == 2) {
|
||||
vectors.add(new Vector2f(floats.get(0), floats.get(1)));
|
||||
floats = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//for (int i = 0; i < vertStrings.length; i += 2)
|
||||
// vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[i]), Float.parseFloat(vertStrings[1 + 1])));
|
||||
|
||||
ArrayList<ArrayList<Vector2f>> meshList;
|
||||
|
||||
if (BuildingManager._hull_data.get(propID) == null) {
|
||||
meshList = new ArrayList<>();
|
||||
meshList.add(vectors);
|
||||
BuildingManager._hull_data.put(propID, meshList);
|
||||
|
||||
} else {
|
||||
meshList = BuildingManager._hull_data.get(propID);
|
||||
meshList.add(vectors);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + BuildingManager._hull_data.size());
|
||||
}
|
||||
|
||||
public HashMap<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() {
|
||||
|
||||
HashMap<Integer, ArrayList<BuildingRegions>> regionList = new HashMap<>();
|
||||
@@ -722,10 +800,10 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) {
|
||||
|
||||
preparedStatement.setBoolean(1, active);
|
||||
preparedStatement.setInt(2, condemn.getParent());
|
||||
preparedStatement.setInt(3, condemn.getPlayerUID());
|
||||
preparedStatement.setInt(4, condemn.getGuildUID());
|
||||
preparedStatement.setInt(5, condemn.getFriendType());
|
||||
preparedStatement.setInt(2, condemn.buildingUUID);
|
||||
preparedStatement.setInt(3, condemn.playerUID);
|
||||
preparedStatement.setInt(4, condemn.guildUID);
|
||||
preparedStatement.setInt(5, condemn.friendType);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
|
||||
@@ -96,14 +96,12 @@ public class dbCityHandler extends dbHandlerBase {
|
||||
return objectList;
|
||||
}
|
||||
|
||||
public ArrayList<City> GET_CITIES_BY_ZONE(final int objectUUID) {
|
||||
public ArrayList<City> GET_ALL_CITIES() {
|
||||
|
||||
ArrayList<City> cityList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;")) {
|
||||
|
||||
preparedStatement.setLong(1, objectUUID);
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
cityList = getObjectsFromRs(rs, 100);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.gameManager.DbManager;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class dbHeightMapHandler extends dbHandlerBase {
|
||||
|
||||
public dbHeightMapHandler() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_ALL_HEIGHTMAPS() {
|
||||
|
||||
HeightMap thisHeightmap;
|
||||
HeightMap.heightMapsCreated = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_heightmap INNER JOIN static_zone_size ON static_zone_size.loadNum = static_zone_heightmap.zoneLoadID")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
thisHeightmap = new HeightMap(rs);
|
||||
|
||||
if (thisHeightmap.getHeightmapImage() == null) {
|
||||
Logger.info("Imagemap for " + thisHeightmap.getHeightMapID() + " was null");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -28,31 +27,27 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
}
|
||||
|
||||
public Mob ADD_MOB(Mob toAdd) {
|
||||
public Mob PERSIST(Mob toAdd) {
|
||||
|
||||
Mob mobile = null;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||
|
||||
preparedStatement.setLong(1, toAdd.getParentZoneID());
|
||||
preparedStatement.setInt(2, toAdd.getMobBaseID());
|
||||
preparedStatement.setInt(3, toAdd.getGuildUUID());
|
||||
preparedStatement.setFloat(4, toAdd.getSpawnX());
|
||||
preparedStatement.setFloat(5, toAdd.getSpawnY());
|
||||
preparedStatement.setFloat(6, toAdd.getSpawnZ());
|
||||
preparedStatement.setLong(1, toAdd.parentZoneUUID);
|
||||
preparedStatement.setInt(2, toAdd.loadID);
|
||||
preparedStatement.setInt(3, toAdd.guildUUID);
|
||||
preparedStatement.setFloat(4, toAdd.bindLoc.x);
|
||||
preparedStatement.setFloat(5, toAdd.bindLoc.y);
|
||||
preparedStatement.setFloat(6, toAdd.bindLoc.z);
|
||||
preparedStatement.setInt(7, 0);
|
||||
preparedStatement.setFloat(8, toAdd.getSpawnRadius());
|
||||
preparedStatement.setInt(9, toAdd.getTrueSpawnTime());
|
||||
|
||||
if (toAdd.getContract() != null)
|
||||
preparedStatement.setInt(10, toAdd.getContract().getContractID());
|
||||
else
|
||||
preparedStatement.setInt(10, 0);
|
||||
|
||||
preparedStatement.setInt(11, toAdd.getBuildingID());
|
||||
preparedStatement.setInt(12, toAdd.getLevel());
|
||||
preparedStatement.setString(13, toAdd.getFirstName());
|
||||
preparedStatement.setFloat(8, toAdd.spawnRadius);
|
||||
preparedStatement.setInt(9, toAdd.spawnDelay);
|
||||
preparedStatement.setInt(10, toAdd.contractUUID);
|
||||
preparedStatement.setInt(11, toAdd.buildingUUID);
|
||||
preparedStatement.setInt(12, toAdd.level);
|
||||
preparedStatement.setString(13, toAdd.firstName);
|
||||
preparedStatement.setString(14, toAdd.behaviourType.toString());
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
@@ -69,6 +64,23 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public ArrayList<Mob> GET_ALL_MOBS() {
|
||||
|
||||
ArrayList<Mob> mobileList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
mobileList = getObjectsFromRs(rs, 1000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return mobileList;
|
||||
}
|
||||
|
||||
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
@@ -106,17 +118,17 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
return row_count;
|
||||
}
|
||||
|
||||
public void LOAD_PATROL_POINTS(Mob captain) {
|
||||
public void LOAD_GUARD_MINIONS(Mob guardCaptain) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, captain.getObjectUUID());
|
||||
preparedStatement.setInt(1, guardCaptain.getObjectUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String name = rs.getString("name");
|
||||
Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name);
|
||||
String minionName = rs.getString("minionName");
|
||||
Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
|
||||
|
||||
if (toCreate == null)
|
||||
return;
|
||||
@@ -131,15 +143,13 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean ADD_TO_GUARDS(final long captainUID, final int mobBaseID, final String name, final int slot) {
|
||||
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `mobBaseID`,`name`, `slot`) VALUES (?,?,?,?)")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
|
||||
|
||||
preparedStatement.setLong(1, captainUID);
|
||||
preparedStatement.setInt(2, mobBaseID);
|
||||
preparedStatement.setString(3, name);
|
||||
preparedStatement.setInt(4, slot);
|
||||
preparedStatement.setString(2, minionName);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
@@ -149,14 +159,13 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean REMOVE_FROM_GUARDS(final long captainUID, final int mobBaseID, final int slot) {
|
||||
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `mobBaseID`=? AND `slot` =?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
|
||||
|
||||
preparedStatement.setLong(1, captainUID);
|
||||
preparedStatement.setInt(2, mobBaseID);
|
||||
preparedStatement.setInt(3, slot);
|
||||
preparedStatement.setString(2, minionName);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
@@ -166,24 +175,19 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Mob> GET_ALL_MOBS_FOR_ZONE(Zone zone) {
|
||||
|
||||
ArrayList<Mob> mobileList = new ArrayList<>();
|
||||
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
preparedStatement.setLong(1, captainUID);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
mobileList = getObjectsFromRs(rs, 1000);
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return mobileList;
|
||||
}
|
||||
|
||||
public Mob GET_MOB(final int objectUUID) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import engine.math.Vector3fImmutable;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.NPCProfits;
|
||||
import engine.objects.ProducedItem;
|
||||
import engine.objects.Zone;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -94,14 +93,12 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
return row_count;
|
||||
}
|
||||
|
||||
public ArrayList<NPC> GET_ALL_NPCS_FOR_ZONE(Zone zone) {
|
||||
public ArrayList<NPC> GET_ALL_NPCS() {
|
||||
|
||||
ArrayList<NPC> npcList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
npcList = getObjectsFromRs(rs, 1000);
|
||||
|
||||
@@ -15,15 +15,9 @@ import engine.gameManager.PowersManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.MobPowerEntry;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class dbPowerHandler extends dbHandlerBase {
|
||||
@@ -86,43 +80,4 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> LOAD_MOB_POWERS() {
|
||||
|
||||
HashMap<Integer, ArrayList<MobPowerEntry>> mobPowers = new HashMap<>();
|
||||
MobPowerEntry mobPowerEntry;
|
||||
|
||||
int mobbaseID;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_mobbase_powers ORDER BY `id` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
mobbaseID = rs.getInt("mobbaseUUID");
|
||||
mobPowerEntry = new MobPowerEntry(rs);
|
||||
|
||||
if (mobPowers.get(mobbaseID) == null) {
|
||||
ArrayList<MobPowerEntry> powerList = new ArrayList<>();
|
||||
powerList.add(mobPowerEntry);
|
||||
mobPowers.put(mobbaseID, powerList);
|
||||
} else {
|
||||
ArrayList<MobPowerEntry> powerList = mobPowers.get(mobbaseID);
|
||||
powerList.add(mobPowerEntry);
|
||||
mobPowers.put(mobbaseID, powerList);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return mobPowers;
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + mobPowers.size());
|
||||
return mobPowers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.RuneBase;
|
||||
import engine.powers.RunePowerEntry;
|
||||
import engine.powers.RuneSkillAdjustEntry;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -27,6 +29,84 @@ public class dbRuneBaseHandler extends dbHandlerBase {
|
||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrayList<RunePowerEntry>> LOAD_RUNE_POWERS() {
|
||||
|
||||
HashMap<Integer, ArrayList<RunePowerEntry>> mobPowers = new HashMap<>();
|
||||
RunePowerEntry runePowerEntry;
|
||||
|
||||
int rune_id;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
rune_id = rs.getInt("rune_id");
|
||||
runePowerEntry = new RunePowerEntry(rs);
|
||||
|
||||
if (mobPowers.get(rune_id) == null) {
|
||||
ArrayList<RunePowerEntry> runePowerList = new ArrayList<>();
|
||||
runePowerList.add(runePowerEntry);
|
||||
mobPowers.put(rune_id, runePowerList);
|
||||
} else {
|
||||
ArrayList<RunePowerEntry> powerList = mobPowers.get(rune_id);
|
||||
powerList.add(runePowerEntry);
|
||||
mobPowers.put(rune_id, powerList);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return mobPowers;
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + mobPowers.size());
|
||||
return mobPowers;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> LOAD_RUNE_SKILL_ADJUSTS() {
|
||||
|
||||
HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> runeSkillAdjusts = new HashMap<>();
|
||||
RuneSkillAdjustEntry runeSkillAdjustEntry;
|
||||
|
||||
int rune_id;
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_skill_adjusts")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
rune_id = rs.getInt("rune_id");
|
||||
runeSkillAdjustEntry = new RuneSkillAdjustEntry(rs);
|
||||
|
||||
if (runeSkillAdjusts.get(rune_id) == null) {
|
||||
ArrayList<RuneSkillAdjustEntry> skillAdjustList = new ArrayList<>();
|
||||
skillAdjustList.add(runeSkillAdjustEntry);
|
||||
runeSkillAdjusts.put(rune_id, skillAdjustList);
|
||||
} else {
|
||||
ArrayList<RuneSkillAdjustEntry> powerList = runeSkillAdjusts.get(rune_id);
|
||||
powerList.add(runeSkillAdjustEntry);
|
||||
runeSkillAdjusts.put(rune_id, powerList);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return runeSkillAdjusts;
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + runeSkillAdjusts.size());
|
||||
return runeSkillAdjusts;
|
||||
}
|
||||
|
||||
public void GET_RUNE_REQS(final RuneBase rb) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
|
||||
@@ -12,8 +12,8 @@ package engine.db.handlers;
|
||||
import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.ZoneTemplate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -29,25 +29,21 @@ public class dbZoneHandler extends dbHandlerBase {
|
||||
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
}
|
||||
|
||||
public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
|
||||
ArrayList<Zone> wsmList = new ArrayList<>();
|
||||
wsmList.addAll(zone.getNodes());
|
||||
if (zone.absX == 0.0f) {
|
||||
zone.absX = zone.getXCoord();
|
||||
public ArrayList<Zone> GET_ALL_ZONES() {
|
||||
|
||||
ArrayList<Zone> zoneList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
zoneList = getObjectsFromRs(rs, 2000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
if (zone.absY == 0.0f) {
|
||||
zone.absY = zone.getYCoord();
|
||||
}
|
||||
if (zone.absZ == 0.0f) {
|
||||
zone.absZ = zone.getZCoord();
|
||||
}
|
||||
for (Zone child : zone.getNodes()) {
|
||||
child.absX = child.getXCoord() + zone.absX;
|
||||
child.absY = child.getYCoord() + zone.absY;
|
||||
child.absZ = child.getZCoord() + zone.absZ;
|
||||
wsmList.addAll(this.GET_ALL_NODES(child));
|
||||
}
|
||||
return wsmList;
|
||||
|
||||
return zoneList;
|
||||
}
|
||||
|
||||
public Zone GET_BY_UID(long ID) {
|
||||
@@ -72,43 +68,38 @@ public class dbZoneHandler extends dbHandlerBase {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public ArrayList<Zone> GET_MAP_NODES(final int objectUUID) {
|
||||
|
||||
ArrayList<Zone> zoneList = new ArrayList<>();
|
||||
public void LOAD_ALL_ZONE_TEMPLATES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, objectUUID);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
zoneList = getObjectsFromRs(rs, 2000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return zoneList;
|
||||
}
|
||||
|
||||
public void LOAD_ZONE_EXTENTS() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_templates")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
Vector2f zoneSize = new Vector2f();
|
||||
int loadNum = rs.getInt("loadNum");
|
||||
zoneSize.x = rs.getFloat("xRadius");
|
||||
zoneSize.y = rs.getFloat("zRadius");
|
||||
ZoneManager._zone_size_data.put(loadNum, zoneSize);
|
||||
ZoneTemplate zoneTemplate = new ZoneTemplate(rs);
|
||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
||||
}
|
||||
|
||||
// Add player city
|
||||
|
||||
ZoneTemplate zoneTemplate = new ZoneTemplate();
|
||||
|
||||
zoneTemplate.templateID = 0;
|
||||
zoneTemplate.sea_level_type = "PARENT";
|
||||
zoneTemplate.sea_level = 0;
|
||||
zoneTemplate.max_blend = 128;
|
||||
zoneTemplate.min_blend = 128;
|
||||
zoneTemplate.terrain_max_y = 5;
|
||||
zoneTemplate.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
zoneTemplate.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
zoneTemplate.terrain_type = "PLANAR";
|
||||
|
||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean DELETE_ZONE(final Zone zone) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
@@ -43,7 +44,7 @@ public class AddMobCmd extends AbstractDevCmd {
|
||||
MobBase mb = (MobBase) mobbaseAGO;
|
||||
int loadID = mb.getObjectUUID();
|
||||
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
|
||||
null, true, zone, null, 0, "", 1);
|
||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
if (mob != null) {
|
||||
mob.updateDatabase();
|
||||
this.setResult(String.valueOf(mob.getDBID()));
|
||||
@@ -77,14 +78,14 @@ public class AddMobCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
if (zone.isPlayerCity()) {
|
||||
if (zone.guild_zone) {
|
||||
throwbackError(pc, "Cannot use ./mob on Player cities. Try ./servermob instead.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Mob mob = Mob.createMob(loadID, pc.getLoc(),
|
||||
null, true, zone, null, 0, "", 1);
|
||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
if (mob != null) {
|
||||
mob.updateDatabase();
|
||||
ChatManager.chatSayInfo(pc,
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Zone;
|
||||
|
||||
public class AuditHeightMapCmd extends AbstractDevCmd {
|
||||
|
||||
public AuditHeightMapCmd() {
|
||||
super("auditheightmap");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
int count = Integer.parseInt(words[0]);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
|
||||
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
||||
|
||||
|
||||
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);
|
||||
|
||||
if (currentZone != null && currentZone.getHeightMap() != null) {
|
||||
float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc());
|
||||
}
|
||||
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
long delta = end - start;
|
||||
|
||||
this.throwbackInfo(pcSender, "Audit Heightmap took " + delta + " ms to run " + count + " times!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /auditmobs [zone.UUID]'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Audits all the mobs in a zone.";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,8 +40,8 @@ public class AuditMobsCmd extends AbstractDevCmd {
|
||||
|
||||
if (size >= count) {
|
||||
plusplus++;
|
||||
throwbackInfo(pcSender, zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
System.out.println(zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
throwbackInfo(pcSender, zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
System.out.println(zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AuditMobsCmd extends AbstractDevCmd {
|
||||
//ConcurrentHashMap<Mob, Long> respawnMap = Mob.getRespawnMap();
|
||||
// ConcurrentHashMap<Mob, Long> despawnMap = Mob.getDespawnMap();
|
||||
|
||||
throwbackInfo(pcSender, zone.getName() + ", numMobs: " + zone.zoneMobSet.size());
|
||||
throwbackInfo(pcSender, zone.zoneName + ", numMobs: " + zone.zoneMobSet.size());
|
||||
throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc");
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,10 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Zone;
|
||||
@@ -22,205 +21,79 @@ public class GetHeightCmd extends AbstractDevCmd {
|
||||
|
||||
public GetHeightCmd() {
|
||||
super("getHeight");
|
||||
this.addCmdString("height");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
boolean end = true;
|
||||
Zone currentZone;
|
||||
Zone parentZone;
|
||||
Zone heightmapZone;
|
||||
|
||||
float height = HeightMap.getWorldHeight(pc);
|
||||
currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc());
|
||||
heightmapZone = Terrain.getNextZoneWithTerrain(currentZone);
|
||||
parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent);
|
||||
|
||||
this.throwbackInfo(pc, "Altitude : " + height);
|
||||
Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
|
||||
Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.major_radius,
|
||||
Math.abs(childZoneOffset.y) / heightmapZone.template.minor_radius);
|
||||
Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone);
|
||||
|
||||
this.throwbackInfo(pc, "Character Height: " + pc.getCharacterHeight());
|
||||
this.throwbackInfo(pc, "Character Height to start swimming: " + pc.centerHeight);
|
||||
float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc);
|
||||
childHeight = childHeight + heightmapZone.global_height;
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel());
|
||||
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()));
|
||||
float parentHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentZoneLoc);
|
||||
parentHeight += parentZone.global_height;
|
||||
|
||||
if (end)
|
||||
return;
|
||||
float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||
|
||||
Vector2f gridSquare;
|
||||
Vector2f gridOffset;
|
||||
Vector2f parentGrid;
|
||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
||||
Vector2f terrainCell = heightmapZone.terrain.getTerrainCell(childZoneLoc);
|
||||
Vector2f cell_offset = new Vector2f(terrainCell.x % 1, terrainCell.y % 1);
|
||||
|
||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
|
||||
if (currentZone == null)
|
||||
return;
|
||||
|
||||
Zone parentZone = currentZone.getParent();
|
||||
|
||||
HeightMap heightMap = currentZone.getHeightMap();
|
||||
terrainCell.x = (float) Math.floor(terrainCell.x);
|
||||
terrainCell.y = (float) Math.floor(terrainCell.y);
|
||||
|
||||
|
||||
//find the next parents heightmap if the currentzone heightmap is null.
|
||||
while (heightMap == null) {
|
||||
short top_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y];
|
||||
short top_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y];
|
||||
short bottom_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y + 1];
|
||||
short bottom_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y + 1];
|
||||
|
||||
if (currentZone == ZoneManager.getSeaFloor()) {
|
||||
this.throwbackInfo(pc, "Could not find a heightmap to get height.");
|
||||
break;
|
||||
}
|
||||
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
|
||||
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
|
||||
this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
|
||||
|
||||
this.throwbackError(pc, "Heightmap does not exist for " + currentZone.getName());
|
||||
this.throwbackInfo(pc, "Using parent zone instead: ");
|
||||
currentZone = currentZone.getParent();
|
||||
heightMap = currentZone.getHeightMap();
|
||||
}
|
||||
this.throwbackInfo(playerCharacter, "Player loc: " + "[" + playerCharacter.loc.x + "]" + "[" + playerCharacter.loc.y + "]" + "[" + playerCharacter.loc.z + "]");
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Terrain Cell : " + "[" + terrainCell.x + "]" + "[" + terrainCell.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Cell Offset : " + "[" + cell_offset.x + "]" + "[" + cell_offset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + top_left_pixel + "]" + "[" + top_right_pixel + "]");
|
||||
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + bottom_left_pixel + "]" + "[" + bottom_right_pixel + "]");
|
||||
|
||||
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) {
|
||||
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap ");
|
||||
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY);
|
||||
return;
|
||||
}
|
||||
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
|
||||
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone);
|
||||
|
||||
Vector3fImmutable seaFloorLocalLoc = ZoneManager.worldToLocal(pc.getLoc(), ZoneManager.getSeaFloor());
|
||||
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
|
||||
|
||||
|
||||
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
|
||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
|
||||
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
|
||||
this.throwbackInfo(pc, "Local Zone Location from center : " + localLocFromCenter);
|
||||
this.throwbackInfo(pc, "parent Zone Location from center : " + parentLocFromCenter);
|
||||
|
||||
Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent());
|
||||
this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc);
|
||||
|
||||
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
|
||||
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
|
||||
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
|
||||
} else
|
||||
parentGrid = new Vector2f(-1, -1);
|
||||
|
||||
gridSquare = heightMap.getGridSquare(zoneLoc);
|
||||
gridOffset = HeightMap.getGridOffset(gridSquare);
|
||||
|
||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
|
||||
this.throwbackInfo(pc, currentZone.getName());
|
||||
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y);
|
||||
this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y);
|
||||
this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y);
|
||||
|
||||
if (parentGrid.x != -1) {
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
this.throwbackInfo(pc, "Parent ALTITUDE: " + (parentAltitude));
|
||||
this.throwbackInfo(pc, "Parent Interpolation: " + (parentAltitude + parentZone.getWorldAltitude()));
|
||||
}
|
||||
this.throwbackInfo(pc, "interpolated height: " + interaltitude);
|
||||
|
||||
this.throwbackInfo(pc, "interpolated height with World: " + (interaltitude + currentZone.getWorldAltitude()));
|
||||
|
||||
float realWorldAltitude = interaltitude + currentZone.getWorldAltitude();
|
||||
|
||||
//OUTSET
|
||||
if (parentZone != null) {
|
||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
||||
|
||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
||||
|
||||
float bucketScaleX = 100 / parentXRadius;
|
||||
float bucketScaleZ = 200 / parentZRadius;
|
||||
|
||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
||||
float weight;
|
||||
|
||||
double scale;
|
||||
|
||||
|
||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
|
||||
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getAbsY();
|
||||
realWorldAltitude = outsetALt;
|
||||
|
||||
} else if (offsetZ > outsideGridSizeZ) {
|
||||
|
||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||
|
||||
float scaleChild = (float) ((scale + 1) * .5);
|
||||
float scaleParent = 1 - scaleChild;
|
||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
||||
|
||||
parentCenterAltitude += currentZone.getYCoord();
|
||||
parentCenterAltitude += interaltitude;
|
||||
float firstScale = parentAltitude * scaleParent;
|
||||
float secondScale = parentCenterAltitude * scaleChild;
|
||||
float outsetALt = firstScale + secondScale;
|
||||
|
||||
outsetALt += currentZone.getParent().getAbsY();
|
||||
realWorldAltitude = outsetALt;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
float strMod = pc.statStrBase - 40;
|
||||
|
||||
strMod *= .00999999998f;
|
||||
|
||||
strMod += 1f;
|
||||
|
||||
float radius = 0;
|
||||
switch (pc.getRaceID()) {
|
||||
case 2017:
|
||||
radius = 3.1415927f;
|
||||
case 2000:
|
||||
|
||||
|
||||
}
|
||||
strMod *= 1.5707964f;
|
||||
|
||||
strMod += 3.1415927f;
|
||||
|
||||
strMod -= .5f;
|
||||
|
||||
|
||||
realWorldAltitude += strMod;
|
||||
|
||||
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
|
||||
this.throwbackInfo(playerCharacter, "------------");
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Child Height at loc: " + Math.ceil(childHeight));
|
||||
this.throwbackInfo(playerCharacter, "Parent Height at loc: " + Math.ceil(parentHeight));
|
||||
this.throwbackInfo(playerCharacter, "Blended Height (Ceil): " + blendedHeight + " (" + Math.ceil(blendedHeight) + ")");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Temporarily Changes SubRace";
|
||||
return "Queries heightmap engine";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /subrace mobBaseID";
|
||||
return "' /getheight";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GetOffsetCmd extends AbstractDevCmd {
|
||||
float difY = pcSender.getLoc().y - zone.absY;
|
||||
float difZ = pcSender.getLoc().z - zone.absZ;
|
||||
|
||||
throwbackInfo(pcSender, zone.getName() + ": (x: " + difX + ", y: " + difY + ", z: " + difZ + ')');
|
||||
throwbackInfo(pcSender, zone.zoneName + ": (x: " + difX + ", y: " + difY + ", z: " + difZ + ')');
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GetZoneCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
for (Zone zone : allIn)
|
||||
throwbackInfo(pcSender, zone.getName() + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.getLoadNum());
|
||||
throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.templateID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,7 +81,7 @@ public class GotoCmd extends AbstractDevCmd {
|
||||
continue;
|
||||
Zone zone = city.getParent();
|
||||
if (zone != null) {
|
||||
if (zone.isNPCCity() || zone.isPlayerCity())
|
||||
if (zone.isNPCCity || zone.guild_zone)
|
||||
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
||||
else
|
||||
loc = zone.getLoc();
|
||||
@@ -97,10 +97,10 @@ public class GotoCmd extends AbstractDevCmd {
|
||||
Zone zone = (Zone) zoneAgo;
|
||||
if (zone == null)
|
||||
continue;
|
||||
if (!zone.getName().equalsIgnoreCase(cityName))
|
||||
if (!zone.zoneName.equalsIgnoreCase(cityName))
|
||||
continue;
|
||||
if (zone != null) {
|
||||
if (zone.isNPCCity() || zone.isPlayerCity())
|
||||
if (zone.isNPCCity || zone.guild_zone)
|
||||
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
||||
else
|
||||
loc = zone.getLoc();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class HotzoneCmd extends AbstractDevCmd {
|
||||
String input = data.toString().trim();
|
||||
|
||||
if (input.length() == 0) {
|
||||
outString = "Current hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
|
||||
outString = "Current hotZone: " + ZoneManager.hotZone.zoneName + "\r\n";
|
||||
outString += "Available hotZones: " + ZoneManager.availableHotZones();
|
||||
throwbackInfo(playerCharacter, outString);
|
||||
return;
|
||||
@@ -48,7 +48,7 @@ public class HotzoneCmd extends AbstractDevCmd {
|
||||
|
||||
if (input.equalsIgnoreCase("random")) {
|
||||
ZoneManager.generateAndSetRandomHotzone();
|
||||
outString = "New hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
|
||||
outString = "New hotZone: " + ZoneManager.hotZone.zoneName + "\r\n";
|
||||
outString += "Available hotZones: " + ZoneManager.availableHotZones();
|
||||
throwbackInfo(playerCharacter, outString);
|
||||
return;
|
||||
|
||||
@@ -387,7 +387,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "EquipSet: " + targetNPC.getEquipmentSetID();
|
||||
output += newline;
|
||||
output += "Parent Zone LoadNum : " + targetNPC.getParentZone().getLoadNum();
|
||||
output += "Parent Zone LoadNum : " + targetNPC.getParentZone().templateID;
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "isSummonedPet: true";
|
||||
else
|
||||
output += "isSummonedPet: false";
|
||||
PlayerCharacter owner = targetMob.getOwner();
|
||||
|
||||
|
||||
PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain;
|
||||
if (owner != null)
|
||||
output += " owner: " + owner.getObjectUUID();
|
||||
output += newline;
|
||||
@@ -471,7 +473,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "EquipSet: " + targetMob.equipmentSetID;
|
||||
output += newline;
|
||||
try {
|
||||
output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum();
|
||||
output += "Parent Zone LoadNum : " + targetMob.getParentZone().templateID;
|
||||
} catch (Exception ex) {
|
||||
//who cares
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@ public class MakeBaneCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!zone.isPlayerCity()) {
|
||||
if (!zone.guild_zone) {
|
||||
throwbackError(pc, "This is not a player city.");
|
||||
return;
|
||||
}
|
||||
|
||||
City city = City.getCity(zone.getPlayerCityUUID());
|
||||
City city = City.getCity(zone.playerCityUUID);
|
||||
if (city == null) {
|
||||
throwbackError(pc, "Unable to find the city associated with this zone.");
|
||||
return;
|
||||
@@ -167,7 +167,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
stone.addEffectBit((1 << 19));
|
||||
stone.setRank((byte) rank);
|
||||
BuildingManager.setRank(stone, (byte) rank);
|
||||
stone.setMaxHitPoints(blueprint.getMaxHealth(stone.getRank()));
|
||||
stone.setCurrentHitPoints(stone.getMaxHitPoints());
|
||||
BuildingManager.setUpgradeDateTime(stone, null, 0);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
public class PrintEffectsCmd extends AbstractDevCmd {
|
||||
|
||||
public PrintEffectsCmd() {
|
||||
super("printeffects");
|
||||
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
||||
if (equip.containsKey(slot)) {
|
||||
MobEquipment item = equip.get(slot);
|
||||
if (item != null && item.getItemBase() != null) {
|
||||
return item.getItemBase();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
AbstractCharacter tar;
|
||||
|
||||
if (target != null && target instanceof AbstractCharacter) {
|
||||
tar = (AbstractCharacter) target;
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output = "Effects For Character: " + tar.getName() + newline;
|
||||
|
||||
for(String effect : tar.effects.keySet()){
|
||||
output += effect + newline;
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Returns the player's current stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /printstats'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
public class PrintRunesCmd extends AbstractDevCmd {
|
||||
|
||||
public PrintRunesCmd() {
|
||||
super("printrunes");
|
||||
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
||||
if (equip.containsKey(slot)) {
|
||||
MobEquipment item = equip.get(slot);
|
||||
if (item != null && item.getItemBase() != null) {
|
||||
return item.getItemBase();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
AbstractCharacter tar;
|
||||
|
||||
if (target != null && target instanceof AbstractCharacter) {
|
||||
tar = (AbstractCharacter) target;
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output = "Applied Runes For Character: " + ((AbstractCharacter) target).getName() + newline;
|
||||
|
||||
for(CharacterRune rune : ((AbstractCharacter)target).runes){
|
||||
output += rune.getRuneBaseID() + " " + rune.getRuneBase().getName() + newline;
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Returns the player's current stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /printstats'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,15 +103,19 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
main = getWeaponBase(1, equip);
|
||||
ItemBase off = null;
|
||||
|
||||
if (equip != null)
|
||||
getWeaponBase(2, equip);
|
||||
if (main == null && off == null) {
|
||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + ", range: 6" + newline;
|
||||
} else {
|
||||
if (main != null)
|
||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + ", range: " + main.getRange() + newline;
|
||||
if (off != null)
|
||||
out += "Main Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + ", range: " + off.getRange() + newline;
|
||||
if(equip != null){
|
||||
if(equip.get(2) != null && !equip.get(2).getItemBase().isShield()){
|
||||
//off hand weapon
|
||||
out += "Attack Rating: " + tar.atrHandTwo + newline;
|
||||
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;
|
||||
out += "Range: " + tar.rangeHandTwo + newline;
|
||||
out += "Attack Speed: " + tar.speedHandTwo + newline;
|
||||
} else{
|
||||
out += "Attack Rating: " + tar.atrHandOne + newline;
|
||||
out += "Damage: " + tar.minDamageHandOne + " - " + tar.maxDamageHandOne + newline;
|
||||
out += "Range: " + tar.rangeHandOne + newline;
|
||||
out += "Attack Speed: " + tar.speedHandOne + newline;
|
||||
}
|
||||
}
|
||||
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
||||
|
||||
private static void PurgeWalls(Zone zone, PlayerCharacter pc) {
|
||||
|
||||
if (!zone.isPlayerCity())
|
||||
if (!zone.guild_zone)
|
||||
return;
|
||||
|
||||
for (Building building : zone.zoneBuildingSet) {
|
||||
@@ -59,22 +59,25 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
||||
|
||||
|
||||
if (npc != null) {
|
||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
||||
for (Integer minionUUID : npc.minions) {
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
|
||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
||||
DbManager.removeFromCache(GameObjectType.NPC,
|
||||
npc.getObjectUUID());
|
||||
WorldGrid.RemoveWorldObject(npc);
|
||||
} else if (mobA != null) {
|
||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
||||
for (Integer minionUUID : mobA.minions) {
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
@@ -151,10 +154,11 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
||||
|
||||
|
||||
if (npc != null) {
|
||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
||||
for (Integer minionUUID : npc.minions) {
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
@@ -163,10 +167,11 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
|
||||
npc.getObjectUUID());
|
||||
WorldGrid.RemoveWorldObject(npc);
|
||||
} else if (mobA != null) {
|
||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
||||
for (Integer minionUUID : mobA.minions) {
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ public class RealmInfoCmd extends AbstractDevCmd {
|
||||
outString += ")";
|
||||
outString += newline;
|
||||
|
||||
outString += " Zone: " + serverZone.getName();
|
||||
outString += " Zone: " + serverZone.zoneName;
|
||||
|
||||
outString += newline;
|
||||
|
||||
if (serverZone.getParent() != null)
|
||||
outString += " Parent: " + serverZone.getParent().getName();
|
||||
if (serverZone.parent != null)
|
||||
outString += " Parent: " + serverZone.parent.zoneName;
|
||||
else
|
||||
outString += "Parent: NONE";
|
||||
|
||||
|
||||
@@ -9,12 +9,25 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.NavigationManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static java.awt.geom.Path2D.WIND_EVEN_ODD;
|
||||
import static java.awt.geom.Path2D.WIND_NON_ZERO;
|
||||
|
||||
public class RegionCmd extends AbstractDevCmd {
|
||||
|
||||
public RegionCmd() {
|
||||
@@ -25,43 +38,45 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output;
|
||||
output = "Target Region Information:" + newline;
|
||||
|
||||
if (pc.region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
return;
|
||||
Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
|
||||
if(building == null){
|
||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||
}
|
||||
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
String result = "";
|
||||
result += (pc.region.getClass().getSimpleName());
|
||||
result += (" {");
|
||||
result += (newLine);
|
||||
Field[] fields = pc.region.getClass().getDeclaredFields();
|
||||
|
||||
//print field names paired with their values
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
result += (" ");
|
||||
try {
|
||||
|
||||
if (field.getName().contains("Furniture"))
|
||||
continue;
|
||||
result += (field.getName());
|
||||
result += (": ");
|
||||
//requires access to private field:
|
||||
result += (field.get(pc.region).toString());
|
||||
} catch (IllegalAccessException ex) {
|
||||
System.out.println(ex);
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
output += "In Floor: " + ((AbstractCharacter) target).getInFloorID() + newline;
|
||||
output += "In Building: " + ((AbstractCharacter) target).getInBuilding() + newline;
|
||||
if (region == null) {
|
||||
output += "No Region Found." + newline;
|
||||
}else{
|
||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY(((AbstractCharacter)target).loc) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "is Outside: " + region.isOutside() + newline;
|
||||
output += "is Entrance: " + region.isExit() + newline;
|
||||
for(Vector3f point : region.regionPoints)
|
||||
output += point + newline;
|
||||
output += "NavMesh Data" + newline;
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
result.trim();
|
||||
result += (newLine);
|
||||
}
|
||||
result += ("}");
|
||||
//Zone zone = ZoneManager.findSmallestZone(((AbstractCharacter) target).loc);
|
||||
//if(zone != null) {
|
||||
// output += "zone: " + zone.zoneName + newline;
|
||||
// output += "on navmesh: " + zone.navMesh.contains(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z) + newline;
|
||||
//}else {
|
||||
// output += "zone: null" + newline;
|
||||
//}
|
||||
|
||||
this.throwbackInfo(pc, result.toString());
|
||||
output += "pointBlocked: " + NavigationManager.pointIsBlocked(((AbstractCharacter)target).loc);
|
||||
|
||||
|
||||
|
||||
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,12 +34,12 @@ public class RemoveBaneCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!zone.isPlayerCity()) {
|
||||
if (!zone.guild_zone) {
|
||||
throwbackError(pc, "This is not a player city.");
|
||||
return;
|
||||
}
|
||||
|
||||
City city = City.getCity(zone.getPlayerCityUUID());
|
||||
City city = City.getCity(zone.playerCityUUID);
|
||||
if (city == null) {
|
||||
throwbackError(pc, "Unable to find the city associated with this zone.");
|
||||
return;
|
||||
|
||||
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.DbObjectType;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
@@ -131,56 +130,23 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
||||
building.disableSpire(false);
|
||||
|
||||
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) {
|
||||
City city = City.getCity(building.getParentZone().getPlayerCityUUID());
|
||||
City city = City.getCity(building.getParentZone().playerCityUUID);
|
||||
if (city != null) {
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
|
||||
}
|
||||
|
||||
|
||||
//remove cached shrines.
|
||||
if ((building.getBlueprintUUID() != 0)
|
||||
&& (building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
Shrine.RemoveShrineFromCacheByBuilding(building);
|
||||
|
||||
for (AbstractCharacter ac : building.getHirelings().keySet()) {
|
||||
NPC npc = null;
|
||||
Mob mobA = null;
|
||||
// Remove hirelings for this building
|
||||
|
||||
if (ac.getObjectType() == GameObjectType.NPC)
|
||||
npc = (NPC) ac;
|
||||
else if (ac.getObjectType() == GameObjectType.Mob)
|
||||
mobA = (Mob) ac;
|
||||
for (AbstractCharacter abstractCharacter : building.getHirelings().keySet())
|
||||
BuildingManager.removeHireling(building, abstractCharacter);
|
||||
|
||||
if (npc != null) {
|
||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
||||
DbManager.removeFromCache(npc);
|
||||
WorldGrid.RemoveWorldObject(npc);
|
||||
WorldGrid.removeObject(npc, pc);
|
||||
} else if (mobA != null) {
|
||||
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
//Mob.getRespawnMap().remove(mob);
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
}
|
||||
DbManager.MobQueries.DELETE_MOB(mobA);
|
||||
DbManager.removeFromCache(mobA);
|
||||
WorldGrid.RemoveWorldObject(mobA);
|
||||
WorldGrid.removeObject(mobA, pc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Zone zone = building.getParentZone();
|
||||
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||
DbManager.removeFromCache(building);
|
||||
@@ -209,11 +175,13 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
||||
if (npc.building != null)
|
||||
npc.building.getHirelings().remove(npc);
|
||||
|
||||
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
|
||||
WorldGrid.RemoveWorldObject(mob);
|
||||
WorldGrid.removeObject(mob, pc);
|
||||
if (mob.getParentZone() != null)
|
||||
mob.getParentZone().zoneMobSet.remove(mob);
|
||||
for (Integer minionUUID : npc.minions) {
|
||||
Mob minionMob = Mob.getMob(minionUUID);
|
||||
WorldGrid.RemoveWorldObject(minionMob);
|
||||
WorldGrid.removeObject(minionMob, pc);
|
||||
|
||||
if (minionMob.getParentZone() != null)
|
||||
minionMob.getParentZone().zoneMobSet.remove(minionMob);
|
||||
}
|
||||
|
||||
DbManager.NPCQueries.DELETE_NPC(npc);
|
||||
|
||||
@@ -41,12 +41,12 @@ public class SetBaneActiveCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!zone.isPlayerCity()) {
|
||||
if (!zone.guild_zone) {
|
||||
throwbackError(pc, "This is not a player city.");
|
||||
return;
|
||||
}
|
||||
|
||||
City city = City.getCity(zone.getPlayerCityUUID());
|
||||
City city = City.getCity(zone.playerCityUUID);
|
||||
if (city == null) {
|
||||
throwbackError(pc, "Unable to find the city associated with this zone.");
|
||||
return;
|
||||
|
||||
@@ -31,9 +31,9 @@ public class SetForceRenameCityCmd extends AbstractDevCmd {
|
||||
if (zone == null)
|
||||
return;
|
||||
boolean rename = words[0].equalsIgnoreCase("true") ? true : false;
|
||||
if (zone.getPlayerCityUUID() == 0)
|
||||
if (zone.playerCityUUID == 0)
|
||||
return;
|
||||
City city = City.getCity(zone.getPlayerCityUUID());
|
||||
City city = City.getCity(zone.playerCityUUID);
|
||||
if (city == null)
|
||||
return;
|
||||
city.setForceRename(rename);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
Blueprint blueprint = targetBuilding.getBlueprint();
|
||||
|
||||
if (blueprint == null) {
|
||||
targetBuilding.setRank(targetRank);
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
ChatManager.chatSayInfo(player, "Building ranked without blueprint" + targetBuilding.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
@@ -68,9 +68,8 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
// Set the current targetRank
|
||||
int lastMeshID = targetBuilding.getMeshUUID();
|
||||
targetBuilding.setRank(targetRank);
|
||||
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank);
|
||||
break;
|
||||
case NPC:
|
||||
@@ -114,7 +113,7 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
|
||||
// Set the current targetRank
|
||||
int lastMeshID = targetBuilding.getMeshUUID();
|
||||
targetBuilding.setRank(targetRank);
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
|
||||
if (lastMeshID != targetBuilding.getMeshUUID())
|
||||
targetBuilding.refresh(true);
|
||||
|
||||
@@ -159,7 +159,7 @@ public class SetSubRaceCmd extends AbstractDevCmd {
|
||||
// pum.setEffectID(token);
|
||||
// pum.setSourceType(pc.getObjectType().ordinal());
|
||||
// pum.setSourceID(pc.getObjectUUID());
|
||||
// pum.setTargetType(pc.getObjectType().ordinal());
|
||||
// pum.setStartLocType(pc.getObjectType().ordinal());
|
||||
// pum.setTargetID(pc.getObjectUUID());
|
||||
// pum.setNumTrains(40);
|
||||
// pum.setDuration(-1);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
@@ -110,7 +111,7 @@ public class SplatMobCmd extends AbstractDevCmd {
|
||||
|
||||
mobile = Mob.createMob(_mobileUUID,
|
||||
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
|
||||
null, true, serverZone, null, 0, "", 1);
|
||||
null, serverZone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
|
||||
if (mobile != null) {
|
||||
mobile.updateDatabase();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SummonCmd extends AbstractDevCmd {
|
||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
String location = "Somewhere";
|
||||
if (zone != null)
|
||||
location = zone.getName();
|
||||
location = zone.zoneName;
|
||||
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
|
||||
location, false);
|
||||
toSummon.getClientConnection().sendMsg(rsrm);
|
||||
|
||||
@@ -73,44 +73,41 @@ public class ZoneInfoCmd extends AbstractDevCmd {
|
||||
output = "Target Information:" + newline;
|
||||
output += StringUtils.addWS("UUID: " + objectUUID, 20);
|
||||
output += newline;
|
||||
output += "name: " + zone.getName();
|
||||
output += "name: " + zone.zoneName;
|
||||
output += newline;
|
||||
output += "loadNum: " + zone.getLoadNum();
|
||||
if (zone.getParent() != null) {
|
||||
output += StringUtils.addWS(", parent: " + zone.getParent().getObjectUUID(), 30);
|
||||
output += "Parentabs: x: " + zone.getParent().getAbsX() + ", y: " + zone.getParent().getAbsY() + ", z: " + zone.getParent().getAbsZ();
|
||||
output += "loadNum: " + zone.templateID;
|
||||
if (zone.parent != null) {
|
||||
output += StringUtils.addWS(", parent: " + zone.parent.getObjectUUID(), 30);
|
||||
output += "Parentabs: x: " + zone.parent.absX + ", y: " + zone.parent.absY + ", z: " + zone.parent.absZ;
|
||||
|
||||
} else
|
||||
output += StringUtils.addWS(", parent: none", 30);
|
||||
output += newline;
|
||||
output += "absLoc: x: " + zone.getAbsX() + ", y: " + zone.getAbsY() + ", z: " + zone.getAbsZ();
|
||||
output += "absLoc: x: " + zone.absX + ", y: " + zone.absY + ", z: " + zone.absZ;
|
||||
output += newline;
|
||||
output += "offset: x: " + zone.getXCoord() + ", y: " + zone.getYCoord() + ", z: " + zone.getZCoord();
|
||||
output += "offset: x: " + zone.xOffset + ", y: " + zone.yOffset + ", z: " + zone.zOffset;
|
||||
output += newline;
|
||||
output += "radius: x: " + zone.getBounds().getHalfExtents().x + ", z: " + zone.getBounds().getHalfExtents().y;
|
||||
output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
|
||||
output += newline;
|
||||
|
||||
if (zone.getHeightMap() != null) {
|
||||
output += "HeightMap ID: " + zone.getHeightMap().getHeightMapID();
|
||||
if (zone.terrain != null) {
|
||||
output += "Terrain image: " + zone.template.terrain_image;
|
||||
output += newline;
|
||||
output += "Bucket Width X : " + zone.getHeightMap().getBucketWidthX();
|
||||
output += newline;
|
||||
output += "Bucket Width Y : " + zone.getHeightMap().getBucketWidthY();
|
||||
|
||||
}
|
||||
output += "radius: x: " + zone.getBounds().getHalfExtents().x + ", z: " + zone.getBounds().getHalfExtents().y;
|
||||
|
||||
output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
|
||||
output += newline;
|
||||
// output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl();
|
||||
output += newline;
|
||||
output += "Sea Level = " + zone.getSeaLevel();
|
||||
output += "Sea Level = " + zone.sea_level;
|
||||
output += newline;
|
||||
output += "World Altitude = " + zone.getWorldAltitude();
|
||||
output += "World Altitude = " + zone.global_height;
|
||||
throwbackInfo(player, output);
|
||||
|
||||
City city = ZoneManager.getCityAtLocation(player.getLoc());
|
||||
|
||||
output += newline;
|
||||
output += (city == null) ? "None" : city.getParent().getName();
|
||||
output += (city == null) ? "None" : city.getParent().zoneName;
|
||||
|
||||
if (city != null) {
|
||||
|
||||
@@ -123,14 +120,14 @@ public class ZoneInfoCmd extends AbstractDevCmd {
|
||||
} else {
|
||||
output = "children:";
|
||||
|
||||
ArrayList<Zone> nodes = zone.getNodes();
|
||||
ArrayList<Zone> nodes = zone.nodes;
|
||||
|
||||
if (nodes.isEmpty())
|
||||
output += " none";
|
||||
|
||||
for (Zone child : nodes) {
|
||||
output += newline;
|
||||
output += child.getName() + " (" + child.getLoadNum() + ')';
|
||||
output += child.zoneName + " (" + child.templateID + ')';
|
||||
}
|
||||
}
|
||||
throwbackInfo(player, output);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ZoneSetCmd extends AbstractDevCmd {
|
||||
|
||||
zone = ZoneManager.findSmallestZone(playerCharacter.getLoc());
|
||||
|
||||
throwbackInfo(playerCharacter, zone.getName() + " (" + zone.getLoadNum() + ") " + zone.getObjectUUID());
|
||||
throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.templateID + ") " + zone.getObjectUUID());
|
||||
|
||||
// NPC
|
||||
|
||||
|
||||
@@ -9,12 +9,19 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.mobileAI.utilities.PathingUtilities;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.powers.RunePowerEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -56,18 +63,39 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
Mob mob = (Mob) target;
|
||||
output = "Mob AI Information:" + newline;
|
||||
output += mob.getName() + newline;
|
||||
if (mob.BehaviourType != null) {
|
||||
output += "BehaviourType: " + mob.BehaviourType.toString() + newline;
|
||||
if (mob.BehaviourType.BehaviourHelperType != null) {
|
||||
output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline;
|
||||
output += mob.agentType.toString() + newline;
|
||||
|
||||
int contractID = 0;
|
||||
|
||||
if (mob.isPlayerGuard() == true) {
|
||||
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION))
|
||||
contractID = mob.guardCaptain.contract.getContractID();
|
||||
else
|
||||
contractID = mob.contract.getContractID();
|
||||
}
|
||||
|
||||
if (contractID != 0) {
|
||||
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||
output += "Captain Contract: " + contractID + newline;
|
||||
output += "Captain UUID: " + mob.guardCaptain.getObjectUUID() + newline;
|
||||
} else
|
||||
output += "Contract: " + contractID + newline;
|
||||
}
|
||||
|
||||
if (mob.behaviourType != null) {
|
||||
output += "BehaviourType: " + mob.behaviourType.toString() + newline;
|
||||
if (mob.behaviourType.BehaviourHelperType != null) {
|
||||
output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline;
|
||||
} else {
|
||||
output += "Behaviour Helper Type: NULL" + newline;
|
||||
}
|
||||
output += "Wimpy: " + mob.BehaviourType.isWimpy + newline;
|
||||
output += "Agressive: " + mob.BehaviourType.isAgressive + newline;
|
||||
output += "Can Roam: " + mob.BehaviourType.canRoam + newline;
|
||||
output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline;
|
||||
output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline;
|
||||
output += "Wimpy: " + mob.behaviourType.isWimpy + newline;
|
||||
output += "Agressive: " + mob.behaviourType.isAgressive + newline;
|
||||
output += "Can Roam: " + mob.behaviourType.canRoam + newline;
|
||||
output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline;
|
||||
output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline;
|
||||
} else {
|
||||
output += "BehaviourType: NULL" + newline;
|
||||
}
|
||||
@@ -76,17 +104,58 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
if (mob.playerAgroMap.size() > 0) {
|
||||
output += "Players Loaded:" + newline;
|
||||
}
|
||||
for (Map.Entry<Integer, Boolean> entry : mob.playerAgroMap.entrySet()) {
|
||||
output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline;
|
||||
for (Map.Entry<Integer, Float> entry : mob.playerAgroMap.entrySet()) {
|
||||
output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline;
|
||||
}
|
||||
if (mob.getCombatTarget() != null)
|
||||
output += "Current Target: " + mob.getCombatTarget().getName() + newline;
|
||||
else
|
||||
output += "Current Target: NULL" + newline;
|
||||
|
||||
for (int token : mob.mobPowers.keySet())
|
||||
output += token + newline;
|
||||
if (mob.guardedCity != null)
|
||||
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
|
||||
output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline;
|
||||
output += "Can Cast: " + MobAI.canCast(mob) + newline;
|
||||
output += "Powers:" + newline;
|
||||
|
||||
ArrayList<RunePowerEntry> powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID()));
|
||||
|
||||
// Additional powers may come from the contract ID. This is to support
|
||||
// powers for player guards irrespective of the mobbase used.
|
||||
|
||||
if (mob.isPlayerGuard()) {
|
||||
|
||||
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>();
|
||||
|
||||
if (mob.contract != null)
|
||||
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.contractUUID));
|
||||
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION))
|
||||
contractEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.guardCaptain.contractUUID));
|
||||
|
||||
powerEntries.addAll(contractEntries);
|
||||
|
||||
}
|
||||
|
||||
for (RunePowerEntry runePowerEntry : powerEntries)
|
||||
output += PowersManager.getPowerByToken(runePowerEntry.token).getName() + newline;
|
||||
|
||||
// List outlaws defined for this player guard's city
|
||||
|
||||
if (mob.isPlayerGuard()) {
|
||||
|
||||
ArrayList<Integer> outlaws = new ArrayList(mob.guardedCity.cityOutlaws);
|
||||
|
||||
if (outlaws.isEmpty() == false)
|
||||
output += "Outlaws: " + newline;
|
||||
|
||||
for (Integer outlawUUID : outlaws)
|
||||
output += outlawUUID + newline;
|
||||
}
|
||||
output += "Walking: " + ((Mob) target).isMoving() + newline;
|
||||
output += "Destination: " + ((Mob) target).destination + newline;
|
||||
output += "is Pathing: " + mob.isPathing + newline;
|
||||
((Mob) target).isPathing = false;
|
||||
throwbackInfo(playerCharacter, output);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.utilities.PathingUtilities;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.ManageCityAssetsMsg;
|
||||
@@ -27,19 +29,26 @@ import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public enum BuildingManager {
|
||||
|
||||
BUILDINGMANAGER;
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> _render_lookup = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<ArrayList<Vector2f>>> _hull_data = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, BuildingFriends>> _buildingFriends = new HashMap<>();
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, Condemned>> _buildingCondemned = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<Vector3fImmutable>> _buildingPatrolPoints = new HashMap<>();
|
||||
public static int getAvailableSlot(Building building) {
|
||||
|
||||
ArrayList<BuildingLocation> slotLocations = _slotLocations.get(building.meshUUID);
|
||||
@@ -104,7 +113,6 @@ public enum BuildingManager {
|
||||
if (building == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
@@ -112,26 +120,25 @@ public enum BuildingManager {
|
||||
return true;
|
||||
|
||||
//individual friend.
|
||||
if (building.getFriends().get(player.getObjectUUID()) != null)
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
//Admin's can access stuff
|
||||
//Admins can access stuff
|
||||
|
||||
if (player.isCSR())
|
||||
return true;
|
||||
|
||||
//Guild stuff
|
||||
|
||||
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
if (building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 8)
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 9
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9
|
||||
&& GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
|
||||
@@ -308,6 +315,72 @@ public enum BuildingManager {
|
||||
|
||||
}
|
||||
|
||||
public static void removeHireling(Building building, AbstractCharacter hireling) {
|
||||
|
||||
if (hireling.getObjectType().equals(GameObjectType.Mob)) {
|
||||
|
||||
Mob guardCaptain = (Mob) hireling;
|
||||
|
||||
// Clear minions from database if a guard captain
|
||||
|
||||
if (guardCaptain.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||
DbManager.MobQueries.REMOVE_ALL_MINIONS(hireling.getObjectUUID());
|
||||
}
|
||||
|
||||
// Clear minions from world
|
||||
|
||||
for (Integer minionUUID : hireling.minions) {
|
||||
Mob minionMob = Mob.getMob(minionUUID);
|
||||
DbManager.removeFromCache(minionMob);
|
||||
WorldGrid.RemoveWorldObject(minionMob);
|
||||
WorldGrid.unloadObject(minionMob);
|
||||
|
||||
if (minionMob.getParentZone() != null)
|
||||
minionMob.getParentZone().zoneMobSet.remove(minionMob);
|
||||
}
|
||||
|
||||
// Remove hireling from building
|
||||
|
||||
building.getHirelings().remove(hireling);
|
||||
|
||||
// Remove from zone mob set
|
||||
|
||||
if (hireling.getObjectType().equals(GameObjectType.Mob)) {
|
||||
|
||||
Mob hirelingMob = (Mob) hireling;
|
||||
|
||||
if (hirelingMob.getParentZone() != null)
|
||||
if (hirelingMob.getParentZone().zoneMobSet.contains(hirelingMob))
|
||||
hirelingMob.getParentZone().zoneMobSet.remove(hireling);
|
||||
|
||||
}
|
||||
|
||||
if (hireling.getObjectType().equals(GameObjectType.NPC)) {
|
||||
|
||||
NPC hirelingNPC = (NPC) hireling;
|
||||
|
||||
if (hirelingNPC.getParentZone() != null)
|
||||
if (hirelingNPC.getParentZone().zoneNPCSet.contains(hirelingNPC))
|
||||
hirelingNPC.getParentZone().zoneNPCSet.remove(hireling);
|
||||
|
||||
}
|
||||
|
||||
// Unload hireling from world
|
||||
|
||||
DbManager.removeFromCache(hireling);
|
||||
WorldGrid.RemoveWorldObject(hireling);
|
||||
WorldGrid.removeObject(hireling);
|
||||
|
||||
// Delete hireling from database
|
||||
|
||||
if (hireling.getObjectType().equals(GameObjectType.Mob))
|
||||
DbManager.MobQueries.DELETE_MOB((Mob) hireling);
|
||||
else
|
||||
DbManager.NPCQueries.DELETE_NPC((NPC) hireling);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void cleanupHirelings(Building building) {
|
||||
|
||||
// Early exit: Cannot have hirelings in a building
|
||||
@@ -320,42 +393,18 @@ public enum BuildingManager {
|
||||
|
||||
if (building.getRank() < 1) {
|
||||
|
||||
for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) {
|
||||
for (AbstractCharacter slottedNPC : building.getHirelings().keySet())
|
||||
BuildingManager.removeHireling(building, slottedNPC);
|
||||
|
||||
if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC)
|
||||
((NPC) slottedNPC).remove();
|
||||
else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob)
|
||||
NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete hireling if building has deranked.
|
||||
|
||||
for (AbstractCharacter hireling : building.getHirelings().keySet()) {
|
||||
|
||||
NPC npc = null;
|
||||
Mob mob = null;
|
||||
|
||||
if (hireling.getObjectType() == Enum.GameObjectType.NPC)
|
||||
npc = (NPC) hireling;
|
||||
else if (hireling.getObjectType() == Enum.GameObjectType.Mob)
|
||||
mob = (Mob) hireling;
|
||||
|
||||
if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank()))
|
||||
|
||||
if (npc != null) {
|
||||
if (!npc.remove())
|
||||
Logger.error("Failed to remove npc " + npc.getObjectUUID()
|
||||
+ "from Building " + building.getObjectUUID());
|
||||
else
|
||||
building.getHirelings().remove(npc);
|
||||
} else if (mob != null) {
|
||||
if (!NPCManager.removeMobileFromBuilding(mob, building))
|
||||
Logger.error("Failed to remove npc " + npc.getObjectUUID()
|
||||
+ "from Building " + building.getObjectUUID());
|
||||
else
|
||||
building.getHirelings().remove(npc);
|
||||
}
|
||||
BuildingManager.removeHireling(building, hireling);
|
||||
|
||||
}
|
||||
|
||||
@@ -452,18 +501,18 @@ public enum BuildingManager {
|
||||
|
||||
Condemned condemn = building.getCondemned().get(player.getObjectUUID());
|
||||
|
||||
if (condemn != null && condemn.isActive())
|
||||
if (condemn != null && condemn.active)
|
||||
return true;
|
||||
|
||||
if (player.getGuild() != null) {
|
||||
|
||||
Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID());
|
||||
|
||||
if (guildCondemn != null && guildCondemn.isActive())
|
||||
if (guildCondemn != null && guildCondemn.active)
|
||||
return true;
|
||||
|
||||
Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID());
|
||||
return nationCondemn != null && nationCondemn.isActive() && nationCondemn.getFriendType() == Condemned.NATION;
|
||||
return nationCondemn != null && nationCondemn.active && nationCondemn.friendType == Condemned.NATION;
|
||||
} else {
|
||||
//TODO ADD ERRANT KOS CHECK
|
||||
}
|
||||
@@ -471,18 +520,18 @@ public enum BuildingManager {
|
||||
|
||||
Condemned condemn = building.getCondemned().get(player.getObjectUUID());
|
||||
|
||||
if (condemn != null && condemn.isActive())
|
||||
if (condemn != null && condemn.active)
|
||||
return false;
|
||||
|
||||
if (player.getGuild() != null) {
|
||||
|
||||
Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID());
|
||||
|
||||
if (guildCondemn != null && guildCondemn.isActive())
|
||||
if (guildCondemn != null && guildCondemn.active)
|
||||
return false;
|
||||
|
||||
Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID());
|
||||
return nationCondemn == null || !nationCondemn.isActive() || nationCondemn.getFriendType() != Condemned.NATION;
|
||||
return nationCondemn == null || !nationCondemn.active || nationCondemn.friendType != Condemned.NATION;
|
||||
} else {
|
||||
//TODO ADD ERRANT KOS CHECK
|
||||
}
|
||||
@@ -530,41 +579,63 @@ public enum BuildingManager {
|
||||
else
|
||||
rank = 10;
|
||||
|
||||
Mob mob;
|
||||
Mob mobile;
|
||||
NPC npc;
|
||||
|
||||
if (NPC.ISWallArcher(contract)) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDWALLARCHER);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardWallArcher;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NPC.ISGuardCaptain(contract.getContractID())) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (contract.getContractID() == 910) {
|
||||
|
||||
//guard dog
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -787,4 +858,170 @@ public enum BuildingManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void rebuildMine(Building mineBuilding) {
|
||||
setRank(mineBuilding, 1);
|
||||
mineBuilding.meshUUID = mineBuilding.getBlueprint().getMeshForRank(mineBuilding.rank);
|
||||
|
||||
// New rank mean new max hit points.
|
||||
|
||||
mineBuilding.healthMax = mineBuilding.getBlueprint().getMaxHealth(mineBuilding.rank);
|
||||
mineBuilding.setCurrentHitPoints(mineBuilding.healthMax);
|
||||
mineBuilding.getBounds().setBounds(mineBuilding);
|
||||
}
|
||||
|
||||
public static void setRank(Building building, int rank) {
|
||||
|
||||
int newMeshUUID;
|
||||
boolean success;
|
||||
|
||||
|
||||
// If this building has no blueprint then set rank and exit immediatly.
|
||||
|
||||
if (building.blueprintUUID == 0 || building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) {
|
||||
building.rank = rank;
|
||||
DbManager.BuildingQueries.CHANGE_RANK(building.getObjectUUID(), rank);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete any upgrade jobs before doing anything else. It won't quite work
|
||||
// if in a few lines we happen to delete this building.
|
||||
|
||||
JobContainer jc = building.getTimers().get("UPGRADE");
|
||||
|
||||
if (jc != null) {
|
||||
if (!JobScheduler.getInstance().cancelScheduledJob(jc))
|
||||
Logger.error("failed to cancel existing upgrade job.");
|
||||
}
|
||||
|
||||
// Attempt write to database, or delete the building
|
||||
// if we are destroying it.
|
||||
|
||||
if (rank == -1)
|
||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||
else
|
||||
success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
|
||||
|
||||
if (success == false) {
|
||||
Logger.error("Error writing to database UUID: " + building.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
building.isDeranking.compareAndSet(false, true);
|
||||
|
||||
// Change the building's rank
|
||||
|
||||
building.rank = rank;
|
||||
|
||||
// New rank means new mesh
|
||||
|
||||
newMeshUUID = building.getBlueprint().getMeshForRank(building.rank);
|
||||
building.meshUUID = newMeshUUID;
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
building.healthMax = building.getBlueprint().getMaxHealth(building.rank);
|
||||
building.setCurrentHitPoints(building.healthMax);
|
||||
|
||||
if (building.getUpgradeDateTime() != null)
|
||||
setUpgradeDateTime(building, null, 0);
|
||||
|
||||
// If we destroyed this building make sure to turn off
|
||||
// protection
|
||||
|
||||
if (building.rank == -1)
|
||||
building.protectionState = Enum.ProtectionState.NONE;
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
&& (building.rank == 8))
|
||||
building.meshUUID = Realm.getRealmMesh(building.getCity());
|
||||
|
||||
// update object to clients
|
||||
|
||||
building.refresh(true);
|
||||
|
||||
if (building.getBounds() != null)
|
||||
building.getBounds().setBounds(building);
|
||||
|
||||
// Cleanup hirelings resulting from rank change
|
||||
|
||||
cleanupHirelings(building);
|
||||
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc) {
|
||||
|
||||
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc, 64, MBServerStatics.MASK_BUILDING)) {
|
||||
Building building = (Building) awo;
|
||||
|
||||
if (building == null)
|
||||
continue;
|
||||
|
||||
if (Bounds.collide(loc, building.getBounds()))
|
||||
return building;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void bakeNavMesh(Building building) {
|
||||
building.meshes = new ArrayList<>();
|
||||
if (building.parentZone == null) {
|
||||
Logger.error("Attempt to bake navmesh with no parent: " + building.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// Build up navmesh by stencil of the
|
||||
// convex hull meshes that comprise the prop.
|
||||
|
||||
ArrayList<ArrayList<Vector2f>> convexHullList;
|
||||
convexHullList = _hull_data.get(building.meshUUID);
|
||||
|
||||
if (convexHullList == null) {
|
||||
Logger.error("Attempt to bake navmesh with no meshes: " + building.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
for (ArrayList<Vector2f> meshEntry : convexHullList) {
|
||||
Path2D.Float meshBound = new Path2D.Float();
|
||||
Vector3fImmutable offsetVect = new Vector3fImmutable(meshEntry.get(0).x + building.loc.x, building.loc.y,meshEntry.get(0).y + building.loc.z);
|
||||
Vector3fImmutable rotatedStart = Vector3fImmutable.rotateAroundPoint(building.loc,offsetVect,building.getRot().y);
|
||||
meshBound.moveTo(rotatedStart.x,rotatedStart.z);
|
||||
for (Vector2f vect : meshEntry) {
|
||||
if(meshEntry.indexOf(vect) == 0){
|
||||
continue;
|
||||
}
|
||||
Vector3fImmutable pos = new Vector3fImmutable(vect.x + building.loc.x, building.loc.y,vect.y + building.loc.z);
|
||||
Vector3fImmutable rotatedPos = Vector3fImmutable.rotateAroundPoint(building.loc,pos,building.getRot().getRotation());
|
||||
meshBound.lineTo(rotatedPos.x,rotatedPos.z);
|
||||
}
|
||||
meshBound.lineTo(rotatedStart.x,rotatedStart.z);
|
||||
meshBound.closePath();
|
||||
building.meshes.add(meshBound);
|
||||
building.parentZone.navObstacles.add(meshBound);
|
||||
}
|
||||
//add navNodes to parent zone list
|
||||
float X = building.getBounds().getHalfExtents().x;
|
||||
float Y = building.getBounds().getHalfExtents().y;
|
||||
ArrayList<Vector2f> cornersAndFaces = new ArrayList<>();
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z - Y));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z + Y));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z - Y));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z + Y));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x - X,building.loc.z));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x + X,building.loc.z));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z - Y));
|
||||
cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z + Y));
|
||||
for(Vector2f point : cornersAndFaces){
|
||||
if(!NavigationManager.pointIsBlocked(new Vector3fImmutable(point.x,building.loc.y,point.y))){
|
||||
building.parentZone.navNodes.add(new PathingUtilities.Node(point,null,building));
|
||||
}
|
||||
}
|
||||
|
||||
//add region centers to the zones navNodes list
|
||||
for(Regions region : building.getBounds().getRegions()){
|
||||
building.parentZone.navNodes.add(new PathingUtilities.Node(new Vector2f(region.center.x,region.center.z),region,building));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ public enum ChatManager {
|
||||
it.remove();
|
||||
else {
|
||||
PlayerCharacter pcc = (PlayerCharacter) awo;
|
||||
if (pcc.getSeeInvis() < pc.getHidden())
|
||||
if (pcc.getSeeInvis() < pc.hidden)
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
|
||||
public enum CombatManager {
|
||||
|
||||
COMBATMANAGER;
|
||||
@@ -41,63 +39,6 @@ public enum CombatManager {
|
||||
/**
|
||||
* Message sent by player to attack something.
|
||||
*/
|
||||
public static void setAttackTarget(AttackCmdMsg msg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
int targetType;
|
||||
AbstractWorldObject target;
|
||||
|
||||
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70)
|
||||
return;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
//source must match player this account belongs to
|
||||
|
||||
if (player.getObjectUUID() != msg.getSourceID() || player.getObjectType().ordinal() != msg.getSourceType()) {
|
||||
Logger.error("Msg Source ID " + msg.getSourceID() + " Does not Match Player ID " + player.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
targetType = msg.getTargetType();
|
||||
|
||||
if (targetType == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
target = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||
} else if (targetType == GameObjectType.Building.ordinal()) {
|
||||
target = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
||||
} else if (targetType == GameObjectType.Mob.ordinal()) {
|
||||
target = Mob.getFromCache(msg.getTargetID());
|
||||
} else {
|
||||
player.setCombatTarget(null);
|
||||
return; //not valid type to attack
|
||||
}
|
||||
|
||||
// quit of the combat target is already the current combat target
|
||||
// or there is no combat target
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
//set sources target
|
||||
|
||||
player.setCombatTarget(target);
|
||||
|
||||
//put in combat if not already
|
||||
|
||||
if (!player.isCombat())
|
||||
toggleCombat(true, origin);
|
||||
|
||||
//make character stand if sitting
|
||||
|
||||
if (player.isSit())
|
||||
toggleSit(false, origin);
|
||||
|
||||
AttackTarget(player, target);
|
||||
|
||||
}
|
||||
|
||||
public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) {
|
||||
|
||||
@@ -141,11 +82,6 @@ public enum CombatManager {
|
||||
if (off == null)
|
||||
CombatManager.createTimer(playerCharacter, MBServerStatics.SLOT_OFFHAND, 1, true); // attack in 0.1 of a second
|
||||
}
|
||||
|
||||
City playerCity = ZoneManager.getCityAtLocation(playerCharacter.getLoc());
|
||||
|
||||
if (playerCity != null && playerCity.getGuild().getNation().equals(playerCharacter.getGuild().getNation()) == false && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
|
||||
playerCity.cityOutlaws.add(playerCharacter.getObjectUUID());
|
||||
}
|
||||
|
||||
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) throws MsgSendException {
|
||||
@@ -523,7 +459,7 @@ public enum CombatManager {
|
||||
/**
|
||||
* Attempt to attack target
|
||||
*/
|
||||
private static void attack(AbstractCharacter ac, AbstractWorldObject target, Item weapon, ItemBase wb, boolean mainHand) {
|
||||
private static void attack(AbstractCharacter attacker, AbstractWorldObject target, Item weapon, ItemBase wb, boolean mainHand) {
|
||||
|
||||
float atr;
|
||||
int minDamage, maxDamage;
|
||||
@@ -531,20 +467,20 @@ public enum CombatManager {
|
||||
|
||||
try {
|
||||
|
||||
if (ac == null)
|
||||
if (attacker == null)
|
||||
return;
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (mainHand) {
|
||||
atr = ac.getAtrHandOne();
|
||||
minDamage = ac.getMinDamageHandOne();
|
||||
maxDamage = ac.getMaxDamageHandOne();
|
||||
atr = attacker.getAtrHandOne();
|
||||
minDamage = attacker.getMinDamageHandOne();
|
||||
maxDamage = attacker.getMaxDamageHandOne();
|
||||
} else {
|
||||
atr = ac.getAtrHandTwo();
|
||||
minDamage = ac.getMinDamageHandTwo();
|
||||
maxDamage = ac.getMaxDamageHandTwo();
|
||||
atr = attacker.getAtrHandTwo();
|
||||
minDamage = attacker.getMinDamageHandTwo();
|
||||
maxDamage = attacker.getMaxDamageHandTwo();
|
||||
}
|
||||
|
||||
boolean tarIsRat = false;
|
||||
@@ -563,9 +499,9 @@ public enum CombatManager {
|
||||
//Dont think we need to do this anymore.
|
||||
|
||||
if (tarIsRat)
|
||||
if (ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0) { //strip away current % dmg buffs then add with rat %
|
||||
if (attacker.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0) { //strip away current % dmg buffs then add with rat %
|
||||
|
||||
float percent = 1 + ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat);
|
||||
float percent = 1 + attacker.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat);
|
||||
|
||||
minDamage *= percent;
|
||||
maxDamage *= percent;
|
||||
@@ -576,24 +512,24 @@ public enum CombatManager {
|
||||
//subtract stamina
|
||||
|
||||
if (wb == null)
|
||||
ac.modifyStamina(-0.5f, ac, true);
|
||||
attacker.modifyStamina(-0.5f, attacker, true);
|
||||
else {
|
||||
float stam = wb.getWeight() / 3;
|
||||
stam = (stam < 1) ? 1 : stam;
|
||||
ac.modifyStamina(-(stam), ac, true);
|
||||
attacker.modifyStamina(-(stam), attacker, true);
|
||||
}
|
||||
|
||||
ac.cancelOnAttackSwing();
|
||||
attacker.cancelOnAttackSwing();
|
||||
|
||||
errorTrack = 2;
|
||||
|
||||
//set last time this player has attacked something.
|
||||
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter) && target.getObjectUUID() != ac.getObjectUUID() && ac.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
ac.setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter) && target.getObjectUUID() != attacker.getObjectUUID() && attacker.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
attacker.setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
||||
((PlayerCharacter) target).setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
|
||||
} else
|
||||
ac.setTimeStamp("LastCombatMob", System.currentTimeMillis());
|
||||
attacker.setTimeStamp("LastCombatMob", System.currentTimeMillis());
|
||||
|
||||
errorTrack = 3;
|
||||
|
||||
@@ -604,42 +540,16 @@ public enum CombatManager {
|
||||
if (target.getObjectType().equals(GameObjectType.Building)) {
|
||||
|
||||
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||
ac.setCombatTarget(null);
|
||||
attacker.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
defense = 0;
|
||||
|
||||
Building building = (Building) target;
|
||||
|
||||
if (building.getParentZone() != null && building.getParentZone().isPlayerCity()) {
|
||||
|
||||
if (System.currentTimeMillis() > building.getTimeStamp("CallForHelp")) {
|
||||
|
||||
building.getTimestamps().put("CallForHelp", System.currentTimeMillis() + 15000);
|
||||
|
||||
for (Mob mob : building.getParentZone().zoneMobSet) {
|
||||
if (!mob.isPlayerGuard())
|
||||
continue;
|
||||
|
||||
if (mob.getCombatTarget() != null)
|
||||
continue;
|
||||
|
||||
if (mob.getGuild() != null && building.getGuild() != null)
|
||||
if (!Guild.sameGuild(mob.getGuild().getNation(), building.getGuild().getNation()))
|
||||
continue;
|
||||
|
||||
if (mob.getLoc().distanceSquared2D(building.getLoc()) > sqr(300))
|
||||
continue;
|
||||
|
||||
mob.setCombatTarget(ac);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
AbstractCharacter tar = (AbstractCharacter) target;
|
||||
defense = tar.getDefenseRating();
|
||||
handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target
|
||||
handleRetaliate(tar, attacker); //Handle target attacking back if in combat and has no other target
|
||||
}
|
||||
|
||||
errorTrack = 4;
|
||||
@@ -665,11 +575,11 @@ public enum CombatManager {
|
||||
|
||||
if (roll < chance) {
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) attacker, target, true);
|
||||
|
||||
boolean skipPassives = false;
|
||||
PlayerBonuses bonuses = ac.getBonuses();
|
||||
PlayerBonuses bonuses = attacker.getBonuses();
|
||||
|
||||
if (bonuses != null && bonuses.getBool(ModType.IgnorePassiveDefense, SourceType.None))
|
||||
skipPassives = true;
|
||||
@@ -684,26 +594,26 @@ public enum CombatManager {
|
||||
// Apply Weapon power effect if any. don't try to apply twice if
|
||||
// dual wielding. Perform after passive test for sync purposes.
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||
|
||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
||||
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
|
||||
if (dpj != null) {
|
||||
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
PlayerBonuses bonus = attacker.getBonuses();
|
||||
float attackRange = getWeaponRange(wb, bonus);
|
||||
dpj.attack(target, attackRange);
|
||||
|
||||
if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518))
|
||||
((PlayerCharacter) ac).setWeaponPower(dpj);
|
||||
((PlayerCharacter) attacker).setWeaponPower(dpj);
|
||||
}
|
||||
}
|
||||
|
||||
//check to apply second backstab.
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand) {
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand) {
|
||||
|
||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
||||
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
|
||||
if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) {
|
||||
float attackRange = getWeaponRange(wb, bonuses);
|
||||
@@ -723,24 +633,24 @@ public enum CombatManager {
|
||||
|
||||
//Handle Block passive
|
||||
|
||||
if (testPassive(ac, tarAc, "Block") && canTestBlock(ac, target)) {
|
||||
if (testPassive(attacker, tarAc, "Block") && canTestBlock(attacker, target)) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj, mainHand);
|
||||
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj, mainHand);
|
||||
passiveFired = true;
|
||||
}
|
||||
|
||||
//Handle Parry passive
|
||||
|
||||
if (!passiveFired)
|
||||
if (canTestParry(ac, target) && testPassive(ac, tarAc, "Parry")) {
|
||||
if (canTestParry(attacker, target) && testPassive(attacker, tarAc, "Parry")) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj, mainHand);
|
||||
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj, mainHand);
|
||||
passiveFired = true;
|
||||
}
|
||||
|
||||
@@ -751,12 +661,12 @@ public enum CombatManager {
|
||||
//Handle Dodge passive
|
||||
|
||||
if (!passiveFired)
|
||||
if (testPassive(ac, tarAc, "Dodge")) {
|
||||
if (testPassive(attacker, tarAc, "Dodge")) {
|
||||
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj, mainHand);
|
||||
sendPassiveDefenseMessage(attacker, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj, mainHand);
|
||||
passiveFired = true;
|
||||
}
|
||||
}
|
||||
@@ -772,7 +682,7 @@ public enum CombatManager {
|
||||
//if target is player, set last attack timestamp
|
||||
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) target, ac, false);
|
||||
updateAttackTimers((PlayerCharacter) target, attacker, false);
|
||||
|
||||
//Get damage Type
|
||||
|
||||
@@ -780,7 +690,7 @@ public enum CombatManager {
|
||||
|
||||
if (wb != null)
|
||||
damageType = wb.getDamageType();
|
||||
else if (ac.getObjectType().equals(GameObjectType.Mob) && ((Mob) ac).isSiege())
|
||||
else if (attacker.getObjectType().equals(GameObjectType.Mob) && ((Mob) attacker).isSiege())
|
||||
damageType = DamageType.Siege;
|
||||
else
|
||||
damageType = DamageType.Crush;
|
||||
@@ -799,7 +709,7 @@ public enum CombatManager {
|
||||
//make sure target is not immune to damage type;
|
||||
|
||||
if (resists != null && resists.immuneTo(damageType)) {
|
||||
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
|
||||
sendCombatMessage(attacker, target, 0f, wb, dpj, mainHand);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -810,9 +720,9 @@ public enum CombatManager {
|
||||
float damage;
|
||||
|
||||
if (wb != null)
|
||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
damage = calculateDamage(attacker, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
else
|
||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
damage = calculateDamage(attacker, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
|
||||
float d = 0f;
|
||||
|
||||
@@ -825,40 +735,35 @@ public enum CombatManager {
|
||||
if (tarAc.isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
|
||||
if (tarAc.getObjectType() == GameObjectType.Mob) {
|
||||
ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER);
|
||||
((Mob) tarAc).handleDirectAggro(ac);
|
||||
}
|
||||
|
||||
if (tarAc.getHealth() > 0)
|
||||
d = tarAc.modifyHealth(-damage, ac, false);
|
||||
d = tarAc.modifyHealth(-damage, attacker, false);
|
||||
|
||||
} else if (target.getObjectType().equals(GameObjectType.Building)) {
|
||||
|
||||
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||
ac.setCombatTarget(null);
|
||||
attacker.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getHealth() > 0)
|
||||
d = ((Building) target).modifyHealth(-damage, ac);
|
||||
d = ((Building) target).modifyHealth(-damage, attacker);
|
||||
}
|
||||
|
||||
errorTrack = 13;
|
||||
|
||||
//Test to see if any damage needs done to weapon or armor
|
||||
|
||||
testItemDamage(ac, target, weapon, wb);
|
||||
testItemDamage(attacker, target, weapon, wb);
|
||||
|
||||
// if target is dead, we got the killing blow, remove attack timers on our weapons
|
||||
|
||||
if (tarAc != null && !tarAc.isAlive())
|
||||
removeAttackTimers(ac);
|
||||
removeAttackTimers(attacker);
|
||||
|
||||
//test double death fix
|
||||
|
||||
if (d != 0)
|
||||
sendCombatMessage(ac, target, damage, wb, dpj, mainHand); //send damage message
|
||||
sendCombatMessage(attacker, target, damage, wb, dpj, mainHand); //send damage message
|
||||
|
||||
errorTrack = 14;
|
||||
|
||||
@@ -885,7 +790,7 @@ public enum CombatManager {
|
||||
int procChance = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
if (procChance < MBServerStatics.PROC_CHANCE)
|
||||
((WeaponProcEffectModifier) aem).applyProc(ac, target);
|
||||
((WeaponProcEffectModifier) aem).applyProc(attacker, target);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -897,52 +802,52 @@ public enum CombatManager {
|
||||
|
||||
//handle damage shields
|
||||
|
||||
if (ac.isAlive() && tarAc != null && tarAc.isAlive())
|
||||
handleDamageShields(ac, tarAc, damage);
|
||||
if (attacker.isAlive() && tarAc != null && tarAc.isAlive())
|
||||
handleDamageShields(attacker, tarAc, damage);
|
||||
|
||||
} else {
|
||||
|
||||
// Apply Weapon power effect if any.
|
||||
// don't try to apply twice if dual wielding.
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||
dpj = ((PlayerCharacter) ac).getWeaponPower();
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter) && (mainHand || wb.isTwoHanded())) {
|
||||
dpj = ((PlayerCharacter) attacker).getWeaponPower();
|
||||
|
||||
if (dpj != null) {
|
||||
|
||||
PowersBase wp = dpj.getPower();
|
||||
|
||||
if (wp.requiresHitRoll() == false) {
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
PlayerBonuses bonus = attacker.getBonuses();
|
||||
float attackRange = getWeaponRange(wb, bonus);
|
||||
dpj.attack(target, attackRange);
|
||||
} else
|
||||
((PlayerCharacter) ac).setWeaponPower(null);
|
||||
((PlayerCharacter) attacker).setWeaponPower(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (target.getObjectType() == GameObjectType.Mob)
|
||||
((Mob) target).handleDirectAggro(ac);
|
||||
((Mob) target).handleDirectAggro(attacker);
|
||||
|
||||
errorTrack = 17;
|
||||
|
||||
//miss, Send miss message
|
||||
|
||||
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
|
||||
sendCombatMessage(attacker, target, 0f, wb, dpj, mainHand);
|
||||
|
||||
//if attacker is player, set last attack timestamp
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) attacker, target, true);
|
||||
}
|
||||
|
||||
errorTrack = 18;
|
||||
|
||||
//cancel effects that break on attack or attackSwing
|
||||
ac.cancelOnAttack();
|
||||
attacker.cancelOnAttack();
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(ac.getName() + ' ' + errorTrack + ' ' + e);
|
||||
Logger.error(attacker.getName() + ' ' + errorTrack + ' ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,7 +1125,7 @@ public enum CombatManager {
|
||||
toggleCombat(msg.getToggle(), origin);
|
||||
}
|
||||
|
||||
private static void toggleCombat(boolean toggle, ClientConnection origin) {
|
||||
public static void toggleCombat(boolean toggle, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
@@ -1237,7 +1142,7 @@ public enum CombatManager {
|
||||
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
}
|
||||
|
||||
private static void toggleSit(boolean toggle, ClientConnection origin) {
|
||||
public static void toggleSit(boolean toggle, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
@@ -1267,61 +1172,69 @@ public enum CombatManager {
|
||||
}
|
||||
|
||||
//Called when character takes damage.
|
||||
public static void handleRetaliate(AbstractCharacter tarAc, AbstractCharacter ac) {
|
||||
public static void handleRetaliate(AbstractCharacter target, AbstractCharacter attacker) {
|
||||
|
||||
if (ac == null || tarAc == null)
|
||||
if (attacker == null || target == null)
|
||||
return;
|
||||
|
||||
if (ac.equals(tarAc))
|
||||
if (attacker.equals(target))
|
||||
return;
|
||||
|
||||
if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
return;
|
||||
|
||||
if (!tarAc.isAlive() || !ac.isAlive())
|
||||
if (!target.isAlive() || !attacker.isAlive())
|
||||
return;
|
||||
|
||||
boolean isCombat = tarAc.isCombat();
|
||||
boolean isCombat = target.isCombat();
|
||||
|
||||
//If target in combat and has no target, then attack back
|
||||
|
||||
AbstractWorldObject awoCombTar = tarAc.getCombatTarget();
|
||||
AbstractWorldObject awoCombTar = target.getCombatTarget();
|
||||
|
||||
if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege()))
|
||||
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
||||
if ((target.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || target.isCombat() && NotInRange(target, awoCombTar, target.getRange()))) || (target != null && target.getObjectType() == GameObjectType.Mob && ((Mob) target).isSiege()))
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target
|
||||
|
||||
PlayerCharacter pc = (PlayerCharacter) tarAc;
|
||||
tarAc.setCombatTarget(ac);
|
||||
pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID());
|
||||
PlayerCharacter pc = (PlayerCharacter) target;
|
||||
target.setCombatTarget(attacker);
|
||||
pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID());
|
||||
|
||||
if (tarAc.getTimers() != null)
|
||||
if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
||||
CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget());
|
||||
if (target.getTimers() != null)
|
||||
if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND))
|
||||
CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget());
|
||||
}
|
||||
|
||||
//Handle pet retaliate if assist is on and pet doesn't have a target.
|
||||
|
||||
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
|
||||
Mob pet = ((PlayerCharacter) tarAc).getPet();
|
||||
Mob pet = ((PlayerCharacter) target).getPet();
|
||||
|
||||
if (pet != null && pet.assist && pet.getCombatTarget() == null)
|
||||
pet.setCombatTarget(ac);
|
||||
pet.setCombatTarget(attacker);
|
||||
}
|
||||
|
||||
//Handle Mob Retaliate.
|
||||
|
||||
if (tarAc.getObjectType() == GameObjectType.Mob) {
|
||||
if (target.getObjectType() == GameObjectType.Mob) {
|
||||
|
||||
Mob retaliater = (Mob) tarAc;
|
||||
Mob attackedMobile = (Mob) target;
|
||||
|
||||
if (retaliater.getCombatTarget() != null && !retaliater.isSiege())
|
||||
//handle minion informing his captain of an attack
|
||||
|
||||
if (attackedMobile.agentType.equals(AIAgentType.GUARDMINION) && attackedMobile.guardCaptain != null && attackedMobile.guardCaptain.isAlive()) {
|
||||
|
||||
if (attackedMobile.guardCaptain.combatTarget == null)
|
||||
attackedMobile.guardCaptain.setCombatTarget(attacker);
|
||||
|
||||
}
|
||||
|
||||
// Mobile already has a target; don't switch.
|
||||
|
||||
if (attackedMobile.getCombatTarget() != null && !attackedMobile.isSiege())
|
||||
return;
|
||||
|
||||
if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege())
|
||||
return;
|
||||
|
||||
retaliater.setCombatTarget(ac);
|
||||
attackedMobile.setCombatTarget(attacker);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ public enum DbManager {
|
||||
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
|
||||
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
|
||||
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
|
||||
public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler();
|
||||
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
|
||||
|
||||
public static final dbPowerHandler PowerQueries = new dbPowerHandler();
|
||||
|
||||
@@ -46,9 +46,11 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new GetZoneCmd());
|
||||
DevCmdManager.registerDevCmd(new ZoneSetCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintBankCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintEffectsCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintEquipCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintInventoryCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintVaultCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintRunesCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintStatsCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintSkillsCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintPowersCmd());
|
||||
@@ -128,7 +130,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
||||
DevCmdManager.registerDevCmd(new GotoObj());
|
||||
DevCmdManager.registerDevCmd(new convertLoc());
|
||||
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
|
||||
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
||||
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
||||
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
||||
@@ -143,7 +144,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||
DevCmdManager.registerDevCmd(new SlotTestCmd());
|
||||
|
||||
}
|
||||
|
||||
private static void registerDevCmd(AbstractDevCmd cmd) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public enum LootManager {
|
||||
if(ib == null)
|
||||
break;
|
||||
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?");
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + ib.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
@@ -330,6 +330,8 @@ public enum LootManager {
|
||||
|
||||
public static void GenerateEquipmentDrop(Mob mob) {
|
||||
|
||||
if(mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard))
|
||||
return; // safehold guards don't drop their equipment
|
||||
//do equipment here
|
||||
int dropCount = 0;
|
||||
if (mob.getEquip() != null)
|
||||
|
||||
@@ -116,8 +116,8 @@ public enum MovementManager {
|
||||
|
||||
// if inside a building, convert both locations from the building local reference frame to the world reference frame
|
||||
|
||||
if (msg.getTargetID() > 0) {
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
||||
if (msg.getInBuildingUUID() > 0) {
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getInBuildingUUID());
|
||||
if (building != null) {
|
||||
|
||||
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
|
||||
@@ -128,8 +128,8 @@ public enum MovementManager {
|
||||
// }
|
||||
// else {
|
||||
toMove.setInBuilding(msg.getInBuilding());
|
||||
toMove.setInFloorID(msg.getUnknown01());
|
||||
toMove.setInBuildingID(msg.getTargetID());
|
||||
toMove.setInFloorID(msg.getInBuildingFloor());
|
||||
toMove.setInBuildingID(msg.getInBuildingUUID());
|
||||
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
|
||||
|
||||
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
@@ -174,9 +174,9 @@ public enum MovementManager {
|
||||
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
|
||||
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
|
||||
msg.setInBuilding(toMove.region.level);
|
||||
msg.setUnknown01(toMove.region.room);
|
||||
msg.setTargetType(GameObjectType.Building.ordinal());
|
||||
msg.setTargetID(regionBuilding.getObjectUUID());
|
||||
msg.setInBuildingFloor(toMove.region.room);
|
||||
msg.setStartLocType(GameObjectType.Building.ordinal());
|
||||
msg.setInBuildingUUID(regionBuilding.getObjectUUID());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -185,8 +185,8 @@ public enum MovementManager {
|
||||
toMove.setInBuilding(-1);
|
||||
msg.setStartCoord(toMove.getLoc());
|
||||
msg.setEndCoord(endLocation);
|
||||
msg.setTargetType(0);
|
||||
msg.setTargetID(0);
|
||||
msg.setStartLocType(0);
|
||||
msg.setInBuildingUUID(0);
|
||||
}
|
||||
|
||||
//checks sync between character and server, if out of sync, teleport player to original position and return.
|
||||
@@ -233,7 +233,7 @@ public enum MovementManager {
|
||||
toMove.cancelOnMove();
|
||||
|
||||
//cancel any attacks for manual move.
|
||||
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getUnknown02() == 0)
|
||||
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getInitiatedFromAttack() == 0)
|
||||
toMove.setCombatTarget(null);
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ public enum MovementManager {
|
||||
Zone serverZone = null;
|
||||
|
||||
serverZone = ZoneManager.findSmallestZone(player.getLoc());
|
||||
cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.getPlayerCityUUID());
|
||||
cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.playerCityUUID);
|
||||
|
||||
// Do not send group messages if player is on grid
|
||||
|
||||
@@ -464,34 +464,20 @@ public enum MovementManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) {
|
||||
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc) {
|
||||
|
||||
|
||||
if (targetLoc == null)
|
||||
return;
|
||||
|
||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
||||
|
||||
teleporter.stopMovement(targetLoc);
|
||||
teleporter.setRegion(region);
|
||||
|
||||
//mobs ignore region sets for now.
|
||||
if (teleporter.getObjectType().equals(GameObjectType.Mob)) {
|
||||
teleporter.setInBuildingID(0);
|
||||
teleporter.setInBuilding(-1);
|
||||
teleporter.setInFloorID(-1);
|
||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
|
||||
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
return;
|
||||
}
|
||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
|
||||
//we shouldnt need to send teleport message to new area, as loadjob should pick it up.
|
||||
// DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
||||
teleporter.setLoc(targetLoc);
|
||||
if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) teleporter);
|
||||
|
||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, teleporter.loc.getX(), teleporter.loc.getY(), teleporter.loc.getZ(), 0, -1, -1);
|
||||
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
}
|
||||
|
||||
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
|
||||
|
||||
@@ -5,13 +5,17 @@ import engine.InterestManagement.WorldGrid;
|
||||
import engine.math.Quaternion;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.PowersBase;
|
||||
import engine.powers.RuneSkillAdjustEntry;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import javax.smartcardio.ATR;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -23,92 +27,6 @@ public enum NPCManager {
|
||||
NPC_MANAGER;
|
||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||
|
||||
public static void LoadAllRuneSets() {
|
||||
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
|
||||
}
|
||||
|
||||
public static void LoadAllBootySets() {
|
||||
LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();
|
||||
}
|
||||
|
||||
public static void applyRuneSetEffects(Mob mob) {
|
||||
|
||||
// Early exit
|
||||
|
||||
if (mob.runeSet == 0)
|
||||
return;
|
||||
|
||||
//Apply all rune effects.
|
||||
|
||||
if (NPCManager._runeSetMap.get(mob.runeSet).contains(252623)) {
|
||||
mob.isPlayerGuard = true;
|
||||
}
|
||||
|
||||
// Only captains have contracts
|
||||
|
||||
if (mob.contract != null || mob.isPlayerGuard)
|
||||
applyEffectsForRune(mob, 252621);
|
||||
|
||||
|
||||
// Apply effects from RuneSet
|
||||
|
||||
if (mob.runeSet != 0)
|
||||
for (int runeID : _runeSetMap.get(mob.runeSet))
|
||||
applyEffectsForRune(mob, runeID);
|
||||
|
||||
// Not sure why but apply Warrior effects for some reason?
|
||||
|
||||
applyEffectsForRune(mob, 2518);
|
||||
}
|
||||
|
||||
public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
|
||||
|
||||
EffectsBase effectsBase;
|
||||
RuneBase sourceRune = RuneBase.getRuneBase(runeID);
|
||||
|
||||
// Race runes are in the runeset but not in runebase for some reason
|
||||
|
||||
if (sourceRune == null)
|
||||
return;
|
||||
|
||||
for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
|
||||
|
||||
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
||||
|
||||
if (effectsBase == null) {
|
||||
Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to upgrade effects if needed.
|
||||
if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) character.level)
|
||||
continue;
|
||||
|
||||
Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
|
||||
|
||||
if (eff == null)
|
||||
continue;
|
||||
|
||||
//Current effect is a higher rank, dont apply.
|
||||
if (eff.getTrains() > mbe.getRank())
|
||||
continue;
|
||||
|
||||
//new effect is of a higher rank. remove old effect and apply new one.
|
||||
eff.cancelJob();
|
||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) character.level)
|
||||
continue;
|
||||
|
||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
||||
|
||||
necroPet.setCombatTarget(null);
|
||||
@@ -127,10 +45,12 @@ public enum NPCManager {
|
||||
|
||||
DbManager.removeFromCache(necroPet);
|
||||
|
||||
PlayerCharacter petOwner = necroPet.getOwner();
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
necroPet.setOwner(null);
|
||||
|
||||
necroPet.guardCaptain = null;
|
||||
petOwner.setPet(null);
|
||||
|
||||
if (updateOwner == false)
|
||||
@@ -202,78 +122,6 @@ public enum NPCManager {
|
||||
playerCharacter.necroPets.clear();
|
||||
}
|
||||
|
||||
|
||||
public static void removeSiegeMinions(Mob mobile) {
|
||||
|
||||
for (Mob toRemove : mobile.siegeMinionMap.keySet()) {
|
||||
|
||||
if (mobile.isMoving()) {
|
||||
|
||||
mobile.stopMovement(mobile.getLoc());
|
||||
|
||||
if (toRemove.parentZone != null)
|
||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
||||
}
|
||||
|
||||
try {
|
||||
toRemove.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (toRemove.parentZone != null)
|
||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
||||
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
WorldGrid.removeObject(toRemove);
|
||||
DbManager.removeFromCache(toRemove);
|
||||
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeMobileFromBuilding(Mob mobile, Building building) {
|
||||
|
||||
// Remove npc from it's building
|
||||
|
||||
try {
|
||||
mobile.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (mobile.parentZone != null)
|
||||
mobile.parentZone.zoneMobSet.remove(mobile);
|
||||
|
||||
if (building != null) {
|
||||
building.getHirelings().remove(mobile);
|
||||
removeSiegeMinions(mobile);
|
||||
}
|
||||
|
||||
// Delete npc from database
|
||||
|
||||
if (DbManager.MobQueries.DELETE_MOB(mobile) == 0)
|
||||
return false;
|
||||
|
||||
// Remove npc from the simulation
|
||||
|
||||
mobile.removeFromCache();
|
||||
DbManager.removeFromCache(mobile);
|
||||
WorldGrid.RemoveWorldObject(mobile);
|
||||
WorldGrid.removeObject(mobile);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void loadAllPirateNames() {
|
||||
|
||||
DbManager.NPCQueries.LOAD_PIRATE_NAMES();
|
||||
@@ -340,9 +188,18 @@ public enum NPCManager {
|
||||
else
|
||||
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building);
|
||||
|
||||
// Override slot for siege engines
|
||||
|
||||
if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) {
|
||||
Mob siegeMobile = (Mob) abstractCharacter;
|
||||
buildingSlot = siegeMobile.guardCaptain.minions.size() + 2;
|
||||
}
|
||||
|
||||
if (buildingSlot == -1)
|
||||
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
|
||||
|
||||
// Pets are regular mobiles not hirelings (Siege engines)
|
||||
if (abstractCharacter.contract != null)
|
||||
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
|
||||
|
||||
// Override bind and location for this npc derived
|
||||
@@ -370,4 +227,251 @@ public enum NPCManager {
|
||||
|
||||
return buildingSlot;
|
||||
}
|
||||
|
||||
public static void AssignPatrolPoints(Mob mob) {
|
||||
mob.patrolPoints = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
float patrolRadius = mob.getSpawnRadius();
|
||||
|
||||
if (patrolRadius > 256)
|
||||
patrolRadius = 256;
|
||||
|
||||
if (patrolRadius < 60)
|
||||
patrolRadius = 60;
|
||||
|
||||
Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius);
|
||||
mob.patrolPoints.add(newPatrolPoint);
|
||||
|
||||
if (i == 1) {
|
||||
mob.setLoc(newPatrolPoint);
|
||||
mob.endLoc = newPatrolPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyGuardStanceModifiers(Mob guard){
|
||||
float damageModifier = 1;
|
||||
float attackRatingModifier = 1;
|
||||
float defenseModifier = 1;
|
||||
float attackSpeedModifier = 1;
|
||||
float powerDamageModifier = 1;
|
||||
//handle stance modifiers for guard mob
|
||||
if(guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)){
|
||||
//apply rogue bonuses
|
||||
attackRatingModifier += 0.5f;
|
||||
defenseModifier += 0.5f;
|
||||
damageModifier += 0.5f;
|
||||
attackSpeedModifier -= 0.36f;
|
||||
}else {
|
||||
Integer contractID;
|
||||
if (guard.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||
contractID = guard.guardCaptain.contract.getContractID();
|
||||
} else{
|
||||
contractID = guard.contract.getContractID();
|
||||
}
|
||||
if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()){
|
||||
//apply mage offensive Stance
|
||||
powerDamageModifier += 0.5f;
|
||||
} else{
|
||||
//apply fighter offensive stance
|
||||
damageModifier += 0.5f;
|
||||
attackSpeedModifier -= 0.36f;
|
||||
}
|
||||
}
|
||||
guard.minDamageHandOne *= damageModifier;
|
||||
guard.minDamageHandTwo *= damageModifier;
|
||||
guard.maxDamageHandOne *= damageModifier;
|
||||
guard.maxDamageHandTwo *= damageModifier;
|
||||
guard.atrHandOne *= attackRatingModifier;
|
||||
guard.atrHandTwo *= attackRatingModifier;
|
||||
guard.defenseRating *= defenseModifier;
|
||||
guard.speedHandOne *= attackSpeedModifier;
|
||||
guard.speedHandTwo *= attackSpeedModifier;
|
||||
|
||||
//TODO figure out how to apply +50% powerdamage to mage guards
|
||||
}
|
||||
|
||||
public static void setDamageAndSpeedForGuard(Mob guard){
|
||||
|
||||
float rankModifier = 1 + (guard.getRank() * 0.1f);
|
||||
int primaryStat = 0;
|
||||
if(guard.equip == null) {
|
||||
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier);
|
||||
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier);
|
||||
guard.speedHandOne = 30.0f;
|
||||
}else{
|
||||
if(guard.equip.containsKey(1)){
|
||||
//has main hand weapon
|
||||
ItemBase weapon = guard.equip.get(1).getItemBase();
|
||||
if(weapon.isStrBased())
|
||||
primaryStat = guard.getStatStrCurrent();
|
||||
else
|
||||
primaryStat = guard.getStatDexCurrent();
|
||||
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
|
||||
guard.speedHandOne = weapon.getSpeed();
|
||||
guard.rangeHandOne = weapon.getRange();
|
||||
} else if(guard.equip.containsKey(2) && !guard.equip.get(2).getItemBase().isShield()){
|
||||
//has off hand weapon
|
||||
ItemBase weapon = guard.equip.get(2).getItemBase();
|
||||
if(weapon.isStrBased())
|
||||
primaryStat = guard.getStatStrCurrent();
|
||||
else
|
||||
primaryStat = guard.getStatDexCurrent();
|
||||
guard.minDamageHandTwo = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandTwo = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
|
||||
guard.speedHandTwo = weapon.getSpeed();
|
||||
guard.rangeHandTwo = weapon.getRange();
|
||||
} else {
|
||||
primaryStat = guard.getStatStrCurrent();
|
||||
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat;
|
||||
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier) + primaryStat;
|
||||
guard.speedHandOne = 30.0f;
|
||||
guard.rangeHandOne = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDefenseForGuard(Mob guard){
|
||||
int dexterity = guard.getStatDexCurrent();
|
||||
if(dexterity < 1)
|
||||
dexterity = 1;
|
||||
int baseDef = guard.mobBase.getDefenseRating();
|
||||
int armorDefense = 0;
|
||||
for(MobEquipment equipped : guard.equip.values())
|
||||
if(equipped.getItemBase().isArmor() || equipped.getItemBase().isShield())
|
||||
armorDefense += equipped.getItemBase().getDefense();
|
||||
guard.defenseRating = dexterity + baseDef + armorDefense;
|
||||
}
|
||||
|
||||
public static void setAttackRatingForGuard(Mob guard) {
|
||||
int strength = guard.getStatStrCurrent();
|
||||
int baseAtr = guard.mobBase.getAttackRating();
|
||||
if (guard.equip.get(1) != null)
|
||||
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(1).getItemBase().getPercentRequired() * 4) + (guard.equip.get(1).getItemBase().getPercentRequired() * 3));
|
||||
else if (guard.equip.get(2) != null && !guard.equip.get(2).getItemBase().isShield())
|
||||
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(2).getItemBase().getPercentRequired() * 4) + (guard.equip.get(2).getItemBase().getPercentRequired() * 3));
|
||||
else
|
||||
guard.atrHandOne = baseAtr;
|
||||
}
|
||||
|
||||
public static void setMaxHealthForGuard(Mob guard){
|
||||
//values derived fom reading memory address for health on client when selecting player guards
|
||||
switch(guard.getRank()){
|
||||
default:
|
||||
guard.healthMax = 750; //rank 1
|
||||
break;
|
||||
case 2:
|
||||
guard.healthMax = 2082;
|
||||
break;
|
||||
case 3:
|
||||
guard.healthMax = 2740;
|
||||
break;
|
||||
case 4:
|
||||
guard.healthMax = 3414;
|
||||
break;
|
||||
case 5:
|
||||
guard.healthMax = 4080;
|
||||
break;
|
||||
case 6:
|
||||
guard.healthMax = 4746;
|
||||
break;
|
||||
case 7:
|
||||
guard.healthMax = 5412;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyMobbaseEffects(Mob mob) {
|
||||
EffectsBase effectsBase;
|
||||
for (MobBaseEffects mbe : mob.mobBase.effectsList) {
|
||||
|
||||
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
||||
|
||||
if (effectsBase == null) {
|
||||
Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to upgrade effects if needed.
|
||||
if (mob.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) mob.level)
|
||||
continue;
|
||||
|
||||
Effect eff = mob.effects.get(Integer.toString(effectsBase.getUUID()));
|
||||
|
||||
if (eff == null)
|
||||
continue;
|
||||
|
||||
//Current effect is a higher rank, dont apply.
|
||||
if (eff.getTrains() > mbe.getRank())
|
||||
continue;
|
||||
|
||||
//new effect is of a higher rank. remove old effect and apply new one.
|
||||
eff.cancelJob();
|
||||
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) mob.level)
|
||||
continue;
|
||||
|
||||
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEquipmentResists(Mob mob){
|
||||
if(mob.equip != null){
|
||||
for(MobEquipment equipped : mob.equip.values()){
|
||||
ItemBase itemBase = equipped.getItemBase();
|
||||
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
|
||||
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush,0) + itemBase.getCrushResist());
|
||||
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash,0) + itemBase.getCrushResist());
|
||||
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce,0) + itemBase.getCrushResist());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyMobbaseSkill(Mob mob) {
|
||||
SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill());
|
||||
if(baseSkill != null)
|
||||
mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount()));
|
||||
}
|
||||
|
||||
public static void applyRuneSkills(Mob mob, int runeID){
|
||||
//load mob skill adjustments from mobbase rune
|
||||
if(PowersManager._allRuneSkillAdjusts.containsKey(runeID))
|
||||
for(RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(runeID)) {
|
||||
if(SkillsBase.getFromCache(entry.skill_type) == null)
|
||||
SkillsBase.putInCache(DbManager.SkillsBaseQueries.GET_BASE_BY_NAME(entry.skill_type));
|
||||
SkillsBase skillBase = SkillsBase.getFromCache(entry.skill_type);
|
||||
if(skillBase == null)
|
||||
continue;
|
||||
if (entry.level <= mob.level)
|
||||
if (mob.skills.containsKey(entry.name) == false)
|
||||
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank));
|
||||
else
|
||||
mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank + mob.skills.get(entry.skill_type).getNumTrains()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyRunesForNPC(NPC npc){
|
||||
npc.runes = new ArrayList<>();
|
||||
RuneBase shopkeeperBase = RuneBase.getRuneBase(252620);
|
||||
CharacterRune shopkeeper = new CharacterRune(shopkeeperBase,npc.getObjectUUID());
|
||||
npc.runes.add(shopkeeper);
|
||||
if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) {
|
||||
for (int runeID : _runeSetMap.get(npc.runeSetID)) {
|
||||
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||
if(rb != null) {
|
||||
CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID());
|
||||
npc.runes.add(toApply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.*;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class NavigationManager {
|
||||
|
||||
private static final int cellGap = 1;
|
||||
private static final int stepHeight = 2;
|
||||
|
||||
public static void pathfind(AbstractCharacter character, Vector3fImmutable goal) {
|
||||
if(!pathBlocked(character.loc,goal)){
|
||||
character.destination = goal;
|
||||
MobAI.directMove((Mob)character,character.combatTarget != null);
|
||||
}
|
||||
try {
|
||||
ArrayList<Vector3fImmutable> path = getPath(character.loc, goal);//getOptimizedPath(getPath(character.loc, goal), getPath(goal, character.loc));
|
||||
if (path.isEmpty()) {
|
||||
MobAI.directMove((Mob)character,character.combatTarget != null);
|
||||
return; //no points to walk to
|
||||
}
|
||||
//character.navPath = path;
|
||||
|
||||
} catch (Exception e) {
|
||||
//something failed
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Vector3fImmutable> getOptimizedPath(ArrayList<Vector3fImmutable> startToGoal, ArrayList<Vector3fImmutable> goalToStart) {
|
||||
ArrayList<Vector3fImmutable> optimalPath = new ArrayList<>();
|
||||
optimalPath.add(startToGoal.get(0));
|
||||
for (Vector3fImmutable point : startToGoal) {
|
||||
if (goalToStart.contains(point) && !optimalPath.contains(point)) {
|
||||
optimalPath.add(point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//optimize the path to its smallest possible amount of points
|
||||
|
||||
|
||||
return optimalPath;
|
||||
}
|
||||
|
||||
private static ArrayList<Vector3fImmutable> getPath(Vector3fImmutable start, Vector3fImmutable goal) {
|
||||
ArrayList<Vector3fImmutable> path = new ArrayList<>();
|
||||
path.add(start);
|
||||
Vector3fImmutable current = start;
|
||||
boolean obstructed = false;
|
||||
int count = 0;
|
||||
while (current.distanceSquared(goal) > 9 && count < 250) {
|
||||
//gather the 8 cells around the player
|
||||
ArrayList<Vector3fImmutable> surroundingCells = new ArrayList<>();
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, 0)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, cellGap)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(0, 0, cellGap)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, 0)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, -cellGap)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(0, 0, -cellGap)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(-cellGap, 0, cellGap)));
|
||||
surroundingCells.add(current.add(new Vector3fImmutable(cellGap, 0, -cellGap)));
|
||||
Vector3fImmutable cheapest = new Vector3fImmutable(Vector3fImmutable.ZERO);
|
||||
for (Vector3fImmutable point : surroundingCells) {
|
||||
count++;
|
||||
|
||||
if (path.contains(point))
|
||||
continue;
|
||||
|
||||
if (pointIsBlocked(point)) {
|
||||
obstructed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getCost(cheapest, current, goal) > getCost(point, current, goal))
|
||||
cheapest = point;
|
||||
}
|
||||
current = cheapest;
|
||||
path.add(cheapest);
|
||||
}
|
||||
if (obstructed) {
|
||||
return path;
|
||||
} else {
|
||||
ArrayList<Vector3fImmutable> goalPath = new ArrayList<>();
|
||||
goalPath.add(start);
|
||||
goalPath.add(start.moveTowards(goal,32));
|
||||
goalPath.add(goal);
|
||||
return goalPath; //if the path isn't obstructed we can walk directly from start to the goal
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static float getCost(Vector3fImmutable point, Vector3fImmutable start, Vector3fImmutable goal) {
|
||||
float gCost = start.distanceSquared(point);
|
||||
float hCost = goal.distanceSquared(point);
|
||||
return gCost + hCost;
|
||||
}
|
||||
|
||||
public static boolean pathBlocked(Vector3fImmutable start, Vector3fImmutable end){
|
||||
Zone zone = ZoneManager.findSmallestZone(start);
|
||||
if(zone != null) {
|
||||
for (Path2D.Float obstacle : zone.navObstacles)
|
||||
if(obstacle.intersects(start.x,start.z,end.x,end.z))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean pointIsBlocked(Vector3fImmutable point) {
|
||||
Zone zone = ZoneManager.findSmallestZone(point);
|
||||
if(zone != null){
|
||||
for(Path2D.Float obstacle : zone.navObstacles)
|
||||
if (obstacle.contains(point.x,point.z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//Building building = BuildingManager.getBuildingAtLocation(point);
|
||||
//if(building != null) {
|
||||
//for (Path2D.Float mesh : building.meshes) {
|
||||
//if (mesh.contains(point.x,point.z)) {
|
||||
//return true;
|
||||
//}
|
||||
//}
|
||||
//for (Regions region : building.getBounds().getRegions()) {
|
||||
//if (region.isPointInPolygon(point))
|
||||
//if (Math.abs(region.lerpY(point) - point.y) > stepHeight) // get the height distance between current height and target location height
|
||||
//return true;
|
||||
//}
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.handlers.dbEffectsBaseHandler;
|
||||
import engine.db.handlers.dbPowerHandler;
|
||||
@@ -53,13 +53,10 @@ public enum PowersManager {
|
||||
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
||||
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
||||
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> AllMobPowers;
|
||||
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
||||
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
||||
private static JobScheduler js;
|
||||
|
||||
private PowersManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void initPowersManager(boolean fullPowersLoad) {
|
||||
|
||||
if (fullPowersLoad)
|
||||
@@ -103,6 +100,16 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<RunePowerEntry> getPowersForRune(int rune_id) {
|
||||
|
||||
ArrayList<RunePowerEntry> powerEntries = PowersManager._allRunePowers.get(rune_id);
|
||||
|
||||
if (powerEntries == null)
|
||||
powerEntries = new ArrayList<>();
|
||||
|
||||
return powerEntries;
|
||||
}
|
||||
|
||||
// This pre-loads all powers and effects
|
||||
public static void InitializePowers() {
|
||||
|
||||
@@ -839,8 +846,6 @@ public enum PowersManager {
|
||||
return;
|
||||
}
|
||||
|
||||
playerCharacter.setHateValue(pb.getHateValue(trains));
|
||||
|
||||
//Send Cast Message.
|
||||
// PerformActionMsg castMsg = new PerformActionMsg(msg);
|
||||
// castMsg.setNumTrains(9999);
|
||||
@@ -891,8 +896,6 @@ public enum PowersManager {
|
||||
//Power is aiding a target, handle aggro if combat target is a Mob.
|
||||
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
PlayerCharacter pcTarget = (PlayerCharacter) target;
|
||||
if (!pb.isHarmful())
|
||||
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
|
||||
}
|
||||
|
||||
// update target of used power timer
|
||||
@@ -1769,7 +1772,7 @@ public enum PowersManager {
|
||||
} else {
|
||||
targetLoc = tl;
|
||||
try {
|
||||
targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground
|
||||
targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
targetLoc = tl;
|
||||
@@ -1971,7 +1974,7 @@ public enum PowersManager {
|
||||
} else {
|
||||
targetLoc = tl;
|
||||
try {
|
||||
targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground
|
||||
targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
@@ -9,18 +9,20 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.utilities.PathingUtilities;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.ZoneTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@@ -36,6 +38,8 @@ public enum ZoneManager {
|
||||
|
||||
ZONEMANAGER;
|
||||
|
||||
public static HashMap<Integer, ZoneTemplate> _zone_templates = new HashMap<>();
|
||||
|
||||
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||
@@ -45,9 +49,9 @@ public enum ZoneManager {
|
||||
public static Instant hotZoneLastUpdate;
|
||||
public static Zone hotZone = null;
|
||||
public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config.
|
||||
public static HashMap<Integer, Vector2f> _zone_size_data = new HashMap<>();
|
||||
|
||||
/* Instance variables */
|
||||
private static Zone seaFloor = null;
|
||||
public static Zone seaFloor = null;
|
||||
|
||||
// Find all zones coordinates fit into, starting with Sea Floor
|
||||
|
||||
@@ -60,8 +64,8 @@ public enum ZoneManager {
|
||||
|
||||
if (zone != null) {
|
||||
allIn.add(zone);
|
||||
while (zone.getParent() != null) {
|
||||
zone = zone.getParent();
|
||||
while (zone.parent != null) {
|
||||
zone = zone.parent;
|
||||
allIn.add(zone);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public enum ZoneManager {
|
||||
|
||||
// Find smallest zone coordinates fit into.
|
||||
|
||||
public static final Zone findSmallestZone(final Vector3fImmutable loc) {
|
||||
public static Zone findSmallestZone(final Vector3fImmutable loc) {
|
||||
|
||||
Zone zone = ZoneManager.seaFloor;
|
||||
|
||||
@@ -83,13 +87,13 @@ public enum ZoneManager {
|
||||
|
||||
childFound = false;
|
||||
|
||||
ArrayList<Zone> nodes = zone.getNodes();
|
||||
ArrayList<Zone> nodes = zone.nodes;
|
||||
|
||||
// Logger.info("soze", "" + nodes.size());
|
||||
if (nodes != null)
|
||||
for (Zone child : nodes) {
|
||||
|
||||
if (Bounds.collide(loc, child.getBounds()) == true) {
|
||||
if (Bounds.collide(loc, child.bounds)) {
|
||||
zone = child;
|
||||
childFound = true;
|
||||
break;
|
||||
@@ -99,16 +103,6 @@ public enum ZoneManager {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public static void addZone(final int zoneID, final Zone zone) {
|
||||
|
||||
ZoneManager.zonesByID.put(zoneID, zone);
|
||||
|
||||
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
||||
|
||||
ZoneManager.zonesByName.put(zone.getName().toLowerCase(), zone);
|
||||
|
||||
}
|
||||
|
||||
// Returns the number of available hotZones
|
||||
// remaining in this cycle (1am)
|
||||
|
||||
@@ -129,8 +123,8 @@ public enum ZoneManager {
|
||||
public static void resetHotZones() {
|
||||
|
||||
for (Zone zone : ZoneManager.macroZones)
|
||||
if (zone.hasBeenHotzone)
|
||||
zone.hasBeenHotzone = false;
|
||||
if (zone.wasHotzonw)
|
||||
zone.wasHotzonw = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -147,18 +141,18 @@ public enum ZoneManager {
|
||||
return ZoneManager.zonesByName.get(zoneName);
|
||||
}
|
||||
|
||||
public static final Collection<Zone> getAllZones() {
|
||||
public static Collection<Zone> getAllZones() {
|
||||
return ZoneManager.zonesByUUID.values();
|
||||
}
|
||||
|
||||
public static final void setHotZone(final Zone zone) {
|
||||
public static void setHotZone(final Zone zone) {
|
||||
|
||||
if (!zone.isMacroZone())
|
||||
return;
|
||||
|
||||
ZoneManager.hotZone = zone;
|
||||
ZoneManager.hotZoneCycle = 1; // Used with HOTZONE_DURATION from config.
|
||||
zone.hasBeenHotzone = true;
|
||||
zone.wasHotzonw = true;
|
||||
ZoneManager.hotZoneLastUpdate = LocalDateTime.now().withMinute(0).withSecond(0).atZone(ZoneId.systemDefault()).toInstant();
|
||||
|
||||
}
|
||||
@@ -168,37 +162,32 @@ public enum ZoneManager {
|
||||
if (ZoneManager.hotZone == null)
|
||||
return false;
|
||||
|
||||
return (Bounds.collide(loc, ZoneManager.hotZone.getBounds()) == true);
|
||||
return (Bounds.collide(loc, ZoneManager.hotZone.bounds));
|
||||
}
|
||||
|
||||
public static Zone getSeaFloor() {
|
||||
return ZoneManager.seaFloor;
|
||||
}
|
||||
|
||||
public static void setSeaFloor(final Zone value) {
|
||||
ZoneManager.seaFloor = value;
|
||||
}
|
||||
|
||||
public static final void populateWorldZones(final Zone zone) {
|
||||
|
||||
int loadNum = zone.getLoadNum();
|
||||
public static void populateZoneCollections(final Zone zone) {
|
||||
|
||||
// Zones are added to separate
|
||||
// collections for quick access
|
||||
// based upon their type.
|
||||
|
||||
ZoneManager.zonesByID.put(zone.templateID, zone);
|
||||
|
||||
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
||||
|
||||
ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone);
|
||||
|
||||
if (zone.isMacroZone()) {
|
||||
addMacroZone(zone);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (zone.isPlayerCity()) {
|
||||
addPlayerCityZone(zone);
|
||||
if (zone.guild_zone) {
|
||||
ZoneManager.playerCityZones.add(zone);
|
||||
return;
|
||||
}
|
||||
|
||||
if (zone.isNPCCity())
|
||||
if (zone.isNPCCity)
|
||||
addNPCCityZone(zone);
|
||||
|
||||
}
|
||||
@@ -208,15 +197,10 @@ public enum ZoneManager {
|
||||
}
|
||||
|
||||
private static void addNPCCityZone(final Zone zone) {
|
||||
zone.setNPCCity(true);
|
||||
zone.isNPCCity = true;
|
||||
ZoneManager.npcCityZones.add(zone);
|
||||
}
|
||||
|
||||
public static final void addPlayerCityZone(final Zone zone) {
|
||||
zone.setPlayerCity(true);
|
||||
ZoneManager.playerCityZones.add(zone);
|
||||
}
|
||||
|
||||
public static final void generateAndSetRandomHotzone() {
|
||||
|
||||
Zone hotZone;
|
||||
@@ -249,23 +233,23 @@ public enum ZoneManager {
|
||||
|
||||
public static final boolean validHotZone(Zone zone) {
|
||||
|
||||
if (zone.getSafeZone() == (byte) 1)
|
||||
if (zone.peace_zone == (byte) 1)
|
||||
return false; // no safe zone hotzones// if (this.hotzone == null)
|
||||
|
||||
if (zone.getNodes().isEmpty())
|
||||
return false;
|
||||
|
||||
if (zone.equals(ZoneManager.seaFloor))
|
||||
return false;
|
||||
|
||||
if (zone.nodes.isEmpty())
|
||||
return false;
|
||||
|
||||
//no duplicate hotZones
|
||||
|
||||
if (zone.hasBeenHotzone == true)
|
||||
if (zone.wasHotzonw == true)
|
||||
return false;
|
||||
|
||||
// Enforce min level
|
||||
|
||||
if (zone.minLvl < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue()))
|
||||
if (zone.min_level < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue()))
|
||||
return false;
|
||||
|
||||
if (ZoneManager.hotZone != null)
|
||||
@@ -277,55 +261,50 @@ public enum ZoneManager {
|
||||
// Converts world coordinates to coordinates local to a given zone.
|
||||
|
||||
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
||||
Zone serverZone) {
|
||||
Zone zone) {
|
||||
|
||||
Vector3fImmutable localCoords;
|
||||
|
||||
localCoords = new Vector3fImmutable(worldVector.x - serverZone.absX,
|
||||
worldVector.y - serverZone.absY, worldVector.z
|
||||
- serverZone.absZ);
|
||||
localCoords = new Vector3fImmutable(worldVector.x - zone.absX,
|
||||
worldVector.y - zone.absY, worldVector.z
|
||||
- zone.absZ);
|
||||
|
||||
return localCoords;
|
||||
}
|
||||
|
||||
public static Vector2f worldToZoneSpace(Vector3fImmutable worldVector,
|
||||
Zone serverZone) {
|
||||
public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc,
|
||||
Zone zone) {
|
||||
|
||||
Vector2f zoneLoc;
|
||||
|
||||
zoneLoc = new Vector2f(worldLoc.x, worldLoc.z).subtract(zone.getLoc().x, zone.getLoc().z);
|
||||
zoneLoc.y *= -1;
|
||||
|
||||
return zoneLoc;
|
||||
|
||||
}
|
||||
|
||||
public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc,
|
||||
Zone zone) {
|
||||
|
||||
Vector2f localCoords;
|
||||
Vector2f zoneOrigin;
|
||||
|
||||
// Top left corner of zone is calculated in world space by the center and it's extents.
|
||||
|
||||
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
||||
zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.getBounds().getHalfExtents().x, serverZone.getBounds().getHalfExtents().y));
|
||||
zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z);
|
||||
zoneOrigin = zoneOrigin.subtract(new Vector2f(zone.bounds.getHalfExtents().x, zone.bounds.getHalfExtents().y));
|
||||
|
||||
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
||||
|
||||
localCoords = new Vector2f(worldVector.x, worldVector.z);
|
||||
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
||||
localCoords = localCoords.subtract(zoneOrigin);
|
||||
|
||||
localCoords.setY((serverZone.getBounds().getHalfExtents().y * 2) - localCoords.y);
|
||||
|
||||
|
||||
// TODO : Make sure this value does not go outside the zone's bounds.
|
||||
|
||||
return localCoords;
|
||||
}
|
||||
|
||||
// Converts local zone coordinates to world coordinates
|
||||
|
||||
public static Vector3fImmutable localToWorld(Vector3fImmutable worldVector,
|
||||
Zone serverZone) {
|
||||
|
||||
Vector3fImmutable worldCoords;
|
||||
|
||||
worldCoords = new Vector3fImmutable(worldVector.x + serverZone.absX,
|
||||
worldVector.y + serverZone.absY, worldVector.z
|
||||
+ serverZone.absZ);
|
||||
|
||||
return worldCoords;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts from local (relative to this building) to world.
|
||||
@@ -341,9 +320,10 @@ public enum ZoneManager {
|
||||
if (building.getBounds().getQuaternion() == null)
|
||||
return building.getLoc();
|
||||
|
||||
// handle building rotation
|
||||
|
||||
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
|
||||
|
||||
// handle building rotation
|
||||
// handle building translation
|
||||
|
||||
return building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z);
|
||||
@@ -353,12 +333,10 @@ public enum ZoneManager {
|
||||
//used for regions, Building bounds not set yet.
|
||||
public static Vector3f convertLocalToWorld(Building building, Vector3f localPos, Bounds bounds) {
|
||||
|
||||
// convert from SB rotation value to radians
|
||||
|
||||
// handle building rotation
|
||||
|
||||
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
|
||||
|
||||
// handle building rotation
|
||||
// handle building translation
|
||||
|
||||
return new Vector3f(building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z));
|
||||
@@ -381,13 +359,11 @@ public enum ZoneManager {
|
||||
public static City getCityAtLocation(Vector3fImmutable worldLoc) {
|
||||
|
||||
Zone currentZone;
|
||||
ArrayList<Zone> zoneList;
|
||||
City city;
|
||||
|
||||
currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||
|
||||
if (currentZone.isPlayerCity())
|
||||
return City.getCity(currentZone.getPlayerCityUUID());
|
||||
if (currentZone.guild_zone)
|
||||
return City.getCity(currentZone.playerCityUUID);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -410,16 +386,16 @@ public enum ZoneManager {
|
||||
|
||||
|
||||
treeBounds = Bounds.borrow();
|
||||
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.extents, Enum.CityBoundsType.PLACEMENT.extents), 0.0f);
|
||||
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f);
|
||||
|
||||
zoneList = currentZone.getNodes();
|
||||
zoneList = currentZone.nodes;
|
||||
|
||||
for (Zone zone : zoneList) {
|
||||
|
||||
if (zone.isContinent())
|
||||
continue;
|
||||
|
||||
if (Bounds.collide(treeBounds, zone.getBounds(), 0.0f))
|
||||
if (Bounds.collide(treeBounds, zone.bounds, 0.0f))
|
||||
validLocation = false;
|
||||
}
|
||||
|
||||
@@ -427,30 +403,36 @@ public enum ZoneManager {
|
||||
return validLocation;
|
||||
}
|
||||
|
||||
public static void loadCities(Zone zone) {
|
||||
public static float calculateGlobalZoneHeight(Zone zone) {
|
||||
|
||||
ArrayList<City> cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID());
|
||||
float worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
|
||||
for (City city : cities) {
|
||||
// Seafloor
|
||||
|
||||
city.setParent(zone);
|
||||
city.setObjectTypeMask(MBServerStatics.MASK_CITY);
|
||||
city.setLoc(city.getLoc()); // huh?
|
||||
if (ZoneManager.seaFloor.equals(zone))
|
||||
return worldAltitude;
|
||||
|
||||
//not player city, must be npc city..
|
||||
// Children of seafloor
|
||||
|
||||
if (!zone.isPlayerCity())
|
||||
zone.setNPCCity(true);
|
||||
if (ZoneManager.seaFloor.equals(zone.parent))
|
||||
return worldAltitude + zone.yOffset;
|
||||
|
||||
if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) {
|
||||
// return height from heightmap engine at zone location
|
||||
|
||||
city.setHash();
|
||||
worldAltitude = Terrain.getWorldHeight(zone.parent, zone.getLoc());
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
}
|
||||
// Add zone offset to value
|
||||
|
||||
worldAltitude += zone.yOffset;
|
||||
|
||||
return worldAltitude;
|
||||
}
|
||||
|
||||
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
|
||||
|
||||
float localAltitude = Terrain.getWorldHeight(currentLoc);
|
||||
Zone zone = findSmallestZone(currentLoc);
|
||||
|
||||
return localAltitude < zone.sea_level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EndFearJob extends AbstractEffectJob {
|
||||
if (this.target == null || (!(this.target instanceof Mob)))
|
||||
return;
|
||||
|
||||
((Mob) this.target).setFearedObject(null);
|
||||
((Mob) this.target).fearedObject = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob {
|
||||
if (this.target == null || (!(this.target instanceof Mob)))
|
||||
return;
|
||||
|
||||
((Mob) this.target).setFearedObject(null);
|
||||
((Mob) this.target).fearedObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,6 @@ public class FinishSummonsJob extends AbstractScheduleJob {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.source.region != null)
|
||||
this.target.setRegion(this.source.region);
|
||||
//teleport target to source
|
||||
target.teleport(source.getLoc());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package engine.jobs;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.objects.Building;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -39,7 +40,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
|
||||
// SetCurrentRank also changes the mesh and maxhp
|
||||
// accordingly for buildings with blueprints
|
||||
|
||||
rankingBuilding.setRank(rankingBuilding.getRank() + 1);
|
||||
BuildingManager.setRank(rankingBuilding, rankingBuilding.getRank() + 1);
|
||||
|
||||
// Reload the object
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Bounds {
|
||||
private boolean flipExtents;
|
||||
|
||||
private ArrayList<Regions> regions = new ArrayList<>();
|
||||
private ArrayList<Colliders> colliders = new ArrayList<>();
|
||||
public ArrayList<Colliders> colliders = new ArrayList<>();
|
||||
|
||||
// Default constructor
|
||||
|
||||
@@ -422,7 +422,7 @@ public class Bounds {
|
||||
this.origin.set(building.getLoc().x, building.getLoc().z);
|
||||
|
||||
|
||||
// Magicbane uses half halfExtents
|
||||
// Magicbane uses halfExtents
|
||||
|
||||
if (meshBounds == null) {
|
||||
halfExtentX = 1;
|
||||
@@ -438,8 +438,10 @@ public class Bounds {
|
||||
// The rotation is reset after the new aabb is calculated.
|
||||
|
||||
this.rotation = building.getRot().y;
|
||||
|
||||
// Caclculate and set the new half halfExtents for the rotated bounding box
|
||||
// and reset the rotation to 0 for this bounds.
|
||||
|
||||
this.halfExtents.set(halfExtentX, (halfExtentY));
|
||||
this.rotation = 0;
|
||||
|
||||
@@ -453,7 +455,6 @@ public class Bounds {
|
||||
this.halfExtents.set(blueprint.getExtents());
|
||||
this.flipExtents = Bounds.calculateFlipExtents(this);
|
||||
|
||||
|
||||
this.setRegions(building);
|
||||
this.setColliders(building);
|
||||
|
||||
|
||||
+333
-317
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.mobileAI.Threads;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
/**
|
||||
* Thread blocks until MagicBane dispatch messages are
|
||||
* enqueued then processes them in FIFO order. The collection
|
||||
* is thread safe.
|
||||
* <p>
|
||||
* Any large messages not time sensitive such as load object
|
||||
* sent to more than a single individual should be spawned
|
||||
* individually on a DispatchMessageThread.
|
||||
*/
|
||||
|
||||
public class MobRespawnThread implements Runnable {
|
||||
|
||||
|
||||
public MobRespawnThread() {
|
||||
Logger.info(" MobRespawnThread thread has started!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
|
||||
try {
|
||||
for (Zone zone : ZoneManager.getAllZones()) {
|
||||
|
||||
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
|
||||
|
||||
Mob respawner = zone.respawnQue.iterator().next();
|
||||
|
||||
if (respawner == null)
|
||||
continue;
|
||||
|
||||
respawner.respawn();
|
||||
zone.respawnQue.remove(respawner);
|
||||
zone.lastRespawn = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void startRespawnThread() {
|
||||
Thread respawnThread;
|
||||
respawnThread = new Thread(new MobRespawnThread());
|
||||
respawnThread.setName("respawnThread");
|
||||
respawnThread.start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.mobileAI.Threads;
|
||||
import engine.objects.Mob;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
|
||||
public enum Respawner implements Runnable {
|
||||
RESPAWNER;
|
||||
public static BlockingQueue<Mob> respawnQueue = new DelayQueue();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
|
||||
try {
|
||||
Mob mobile = respawnQueue.take();
|
||||
mobile.respawn();
|
||||
} catch (InterruptedException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
Thread respawnThread;
|
||||
respawnThread = new Thread(RESPAWNER);
|
||||
respawnThread.setName("respawnThread");
|
||||
respawnThread.start();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class CombatUtilities {
|
||||
}
|
||||
|
||||
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
|
||||
return entity1.getLoc().distance2D(entity2.getLoc()) < range;
|
||||
return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range;
|
||||
}
|
||||
|
||||
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {
|
||||
@@ -264,19 +264,9 @@ public class CombatUtilities {
|
||||
swingIsBlock(agent, target, passiveAnim);
|
||||
return;
|
||||
}
|
||||
if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
|
||||
//mob is duel wielding and should conduct an attack for each hand
|
||||
ItemBase weapon1 = agent.getEquip().get(1).getItemBase();
|
||||
double range1 = getMaxDmg(weapon1.getMinDamage(), agent, weapon1) - getMinDmg(weapon1.getMinDamage(), agent, weapon1);
|
||||
double damage1 = getMinDmg(weapon1.getMinDamage(), agent, weapon1) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
|
||||
swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true));
|
||||
ItemBase weapon2 = agent.getEquip().get(2).getItemBase();
|
||||
double range2 = getMaxDmg(weapon2.getMinDamage(), agent, weapon2) - getMinDmg(weapon2.getMinDamage(), agent, weapon2);
|
||||
double damage2 = getMinDmg(weapon2.getMinDamage(), agent, weapon2) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
|
||||
swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false));
|
||||
} else {
|
||||
|
||||
swingIsDamage(agent, target, determineDamage(agent), anim);
|
||||
}
|
||||
|
||||
|
||||
if (agent.getWeaponPower() != null)
|
||||
agent.getWeaponPower().attack(target, MBServerStatics.ONE_MINUTE);
|
||||
@@ -319,19 +309,10 @@ public class CombatUtilities {
|
||||
if (target == null)
|
||||
return 0;
|
||||
|
||||
float damage = 0;
|
||||
int damage = 0;
|
||||
|
||||
DamageType dt = getDamageType(agent);
|
||||
if ((agent.agentType.equals(AIAgentType.PET)) == true || agent.isPet() == true || agent.isNecroPet() == true) {
|
||||
damage = calculatePetDamage(agent);
|
||||
} else if (agent.isPlayerGuard() == true) {
|
||||
//damage = calculateGuardDamage(agent);
|
||||
damage = calculateMobDamage(agent);
|
||||
} else if (agent.getLevel() > 80) {
|
||||
damage = calculateEpicDamage(agent);
|
||||
} else {
|
||||
damage = calculateMobDamage(agent);
|
||||
}
|
||||
damage = ThreadLocalRandom.current().nextInt((int)getMinDmg(agent), (int)getMaxDmg(agent) + 1);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
if (((AbstractCharacter) target).isSit()) {
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
@@ -357,158 +338,16 @@ public class CombatUtilities {
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static int calculatePetDamage(Mob agent) {
|
||||
//damage calc for pet
|
||||
float range;
|
||||
float damage;
|
||||
float min = 40;
|
||||
float max = 60;
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
double minDmg = getMinDmg(min, agent, null);
|
||||
double maxDmg = getMaxDmg(max, agent, null);
|
||||
dmgMultiplier += agent.getLevel() * 0.1f;
|
||||
range = (float) (maxDmg - minDmg);
|
||||
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
return (int) (damage * dmgMultiplier);
|
||||
public static double getMinDmg(Mob agent) {
|
||||
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield())
|
||||
return agent.minDamageHandTwo;
|
||||
else return agent.minDamageHandOne;
|
||||
}
|
||||
|
||||
public static int calculateGuardDamage(Mob agent) {
|
||||
//damage calc for guard
|
||||
ItemBase weapon = agent.getEquip().get(1).getItemBase();
|
||||
AbstractWorldObject target = agent.getCombatTarget();
|
||||
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
|
||||
double minDmg = weapon.getMinDamage();
|
||||
double maxDmg = weapon.getMaxDamage();
|
||||
double min = getMinDmg(minDmg, agent, weapon);
|
||||
double max = getMaxDmg(maxDmg, agent, weapon);
|
||||
|
||||
DamageType dt = weapon.getDamageType();
|
||||
|
||||
double range = max - min;
|
||||
double damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
if (((AbstractCharacter) target).isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int calculateEpicDamage(Mob agent) {
|
||||
//handle r8 mob damage
|
||||
DamageType dt = DamageType.Crush;
|
||||
AbstractWorldObject target = agent.getCombatTarget();
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
double min = agent.getMinDamageHandOne();
|
||||
double max = agent.getMaxDamageHandOne();
|
||||
if (agent.getEquip().get(1) != null) {
|
||||
if (agent.getEquip().get(1).getItemBase() != null) {
|
||||
dt = agent.getEquip().get(1).getItemBase().getDamageType();
|
||||
min = agent.getMinDamageHandOne();
|
||||
max = agent.getMaxDamageHandOne();
|
||||
} else if (agent.getEquip().get(2).getItemBase() != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
|
||||
dt = agent.getEquip().get(2).getItemBase().getDamageType();
|
||||
min = agent.getMinDamageHandTwo();
|
||||
max = agent.getMaxDamageHandTwo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double range = max - min;
|
||||
double damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
|
||||
}
|
||||
|
||||
public static int calculateMobDamage(Mob agent) {
|
||||
ItemBase weapon = null;
|
||||
double minDmg;
|
||||
double maxDmg;
|
||||
DamageType dt;
|
||||
|
||||
//main hand or offhand damage
|
||||
|
||||
if (agent.getEquip().get(1) != null)
|
||||
weapon = agent.getEquip().get(1).getItemBase();
|
||||
else if (agent.getEquip().get(2) != null)
|
||||
weapon = agent.getEquip().get(2).getItemBase();
|
||||
|
||||
if (weapon != null) {
|
||||
minDmg = getMinDmg(weapon.getMinDamage(), agent, weapon);
|
||||
maxDmg = getMaxDmg(weapon.getMaxDamage(), agent, weapon);
|
||||
dt = weapon.getDamageType();
|
||||
} else {
|
||||
minDmg = agent.getMobBase().getDamageMin();
|
||||
maxDmg = agent.getMobBase().getDamageMax();
|
||||
dt = DamageType.Crush;
|
||||
}
|
||||
|
||||
AbstractWorldObject target = agent.getCombatTarget();
|
||||
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
double range = maxDmg - minDmg;
|
||||
double damage = minDmg + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
if (((AbstractCharacter) target).isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getMinDmg(double min, Mob agent, ItemBase weapon) {
|
||||
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
int focusLevel = 0;
|
||||
int masteryLevel = 0;
|
||||
|
||||
if (weapon != null) {
|
||||
if (weapon.isStrBased() == true) {
|
||||
primary = agent.getStatStrCurrent();
|
||||
secondary = agent.getStatDexCurrent();
|
||||
} else {
|
||||
primary = agent.getStatDexCurrent();
|
||||
secondary = agent.getStatStrCurrent();
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired())) {
|
||||
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
|
||||
}
|
||||
if (agent.getSkills().containsKey(weapon.getMastery())) {
|
||||
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
|
||||
}
|
||||
|
||||
public static double getMaxDmg(double max, Mob agent, ItemBase weapon) {
|
||||
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
int focusLevel = 0;
|
||||
int masteryLevel = 0;
|
||||
|
||||
if (weapon != null) {
|
||||
|
||||
if (weapon.isStrBased() == true) {
|
||||
primary = agent.getStatStrCurrent();
|
||||
secondary = agent.getStatDexCurrent();
|
||||
} else {
|
||||
primary = agent.getStatDexCurrent();
|
||||
secondary = agent.getStatStrCurrent();
|
||||
}
|
||||
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
|
||||
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
|
||||
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
|
||||
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
|
||||
|
||||
}
|
||||
return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel));
|
||||
public static double getMaxDmg(Mob agent) {
|
||||
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield())
|
||||
return agent.maxDamageHandTwo;
|
||||
else return agent.maxDamageHandOne;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.mobileAI.utilities;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ModType;
|
||||
import engine.Enum.SourceType;
|
||||
import engine.mobileAI.Threads.MobAIThread;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
import static engine.math.FastMath.sqrt;
|
||||
|
||||
public class MovementUtilities {
|
||||
|
||||
|
||||
public static boolean inRangeOfBindLocation(Mob agent) {
|
||||
|
||||
|
||||
if (agent.isPlayerGuard()) {
|
||||
|
||||
Mob guardCaptain = null;
|
||||
if (agent.getContract() != null)
|
||||
guardCaptain = agent;
|
||||
else
|
||||
guardCaptain = (Mob) agent.npcOwner;
|
||||
|
||||
if (guardCaptain != null) {
|
||||
Building barracks = guardCaptain.building;
|
||||
|
||||
if (barracks != null) {
|
||||
City city = barracks.getCity();
|
||||
|
||||
if (city != null) {
|
||||
Building tol = city.getTOL();
|
||||
|
||||
//Guards recall distance = 814.
|
||||
if (tol != null) {
|
||||
return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.extents));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector3fImmutable sl = new Vector3fImmutable(agent.getLoc().getX(), 0, agent.getLoc().getZ());
|
||||
Vector3fImmutable tl = new Vector3fImmutable(agent.getTrueBindLoc().x, 0, agent.getTrueBindLoc().z);
|
||||
|
||||
float distanceSquaredToTarget = sl.distanceSquared2D(tl); //distance to center of target
|
||||
float zoneRange = 250;
|
||||
|
||||
if (agent.getParentZone() != null) {
|
||||
if (agent.getParentZone().getBounds() != null)
|
||||
zoneRange = agent.getParentZone().getBounds().getHalfExtents().x * 2;
|
||||
}
|
||||
|
||||
if (zoneRange > 300)
|
||||
zoneRange = 300;
|
||||
|
||||
if (agent.getSpawnRadius() > zoneRange)
|
||||
zoneRange = agent.getSpawnRadius();
|
||||
|
||||
|
||||
return distanceSquaredToTarget < sqr(MobAIThread.AI_DROP_AGGRO_RANGE + zoneRange);
|
||||
|
||||
}
|
||||
|
||||
public static boolean inRangeToAggro(Mob agent, PlayerCharacter target) {
|
||||
|
||||
Vector3fImmutable sl = agent.getLoc();
|
||||
Vector3fImmutable tl = target.getLoc();
|
||||
|
||||
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||
float range = MobAIThread.AI_BASE_AGGRO_RANGE;
|
||||
|
||||
if (agent.isPlayerGuard())
|
||||
range = 150;
|
||||
|
||||
return distanceSquaredToTarget < sqr(range);
|
||||
|
||||
}
|
||||
|
||||
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) {
|
||||
|
||||
Vector3fImmutable sl = agent.getLoc();
|
||||
Vector3fImmutable tl = target.getLoc();
|
||||
|
||||
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||
|
||||
float range = agent.getRange() + 150;
|
||||
|
||||
if (range > 200)
|
||||
range = 200;
|
||||
|
||||
|
||||
return distanceSquaredToTarget < sqr(range);
|
||||
|
||||
}
|
||||
|
||||
public static Vector3fImmutable GetMoveLocation(Mob aiAgent, AbstractCharacter aggroTarget) {
|
||||
|
||||
// Player isnt moving and neither is mob. Just return
|
||||
// the mobile's current location. Ain't goin nowhere!
|
||||
// *** Refactor: Check to ensure methods calling us
|
||||
// all don't sent move messages when not moving.
|
||||
|
||||
if ((aggroTarget.isMoving() == false))
|
||||
return aggroTarget.getLoc();
|
||||
|
||||
if (aggroTarget.getEndLoc().x != 0) {
|
||||
|
||||
float aggroTargetDistanceSquared = aggroTarget.getLoc().distanceSquared2D(aggroTarget.getEndLoc());
|
||||
float aiAgentDistanceSquared = aiAgent.getLoc().distanceSquared2D(aggroTarget.getEndLoc());
|
||||
|
||||
if (aiAgentDistanceSquared >= aggroTargetDistanceSquared)
|
||||
return aggroTarget.getEndLoc();
|
||||
else {
|
||||
float distanceToMove = sqrt(aggroTargetDistanceSquared + aiAgentDistanceSquared) * .5f;
|
||||
|
||||
return aggroTarget.getFaceDir().scaleAdd(distanceToMove, aggroTarget.getLoc());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// One of us is moving so let's calculate our destination loc for this
|
||||
// simulation frame. We will simply project our position onto the
|
||||
// character's movement vector and return the closest point.
|
||||
|
||||
return aiAgent.getLoc().ClosestPointOnLine(aggroTarget.getLoc(), aggroTarget.getEndLoc());
|
||||
}
|
||||
|
||||
public static void moveToLocation(Mob agent, Vector3fImmutable newLocation, float offset) {
|
||||
try {
|
||||
|
||||
//don't move farther than 30 units from player.
|
||||
if (offset > 30)
|
||||
offset = 30;
|
||||
Vector3fImmutable newLoc = Vector3fImmutable.getRandomPointInCircle(newLocation, offset);
|
||||
|
||||
|
||||
agent.setFaceDir(newLoc.subtract2D(agent.getLoc()).normalize());
|
||||
|
||||
aiMove(agent, newLoc, false);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean canMove(Mob agent) {
|
||||
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
|
||||
return false;
|
||||
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
}
|
||||
|
||||
public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) {
|
||||
|
||||
//Determing where I want to move.
|
||||
return new Vector3fImmutable((center.x - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius),
|
||||
center.y,
|
||||
(center.z - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius));
|
||||
}
|
||||
|
||||
public static Long estimateMovementTime(Mob agent) {
|
||||
if (agent.getEndLoc().x == 0 && agent.getEndLoc().y == 0)
|
||||
return 0L;
|
||||
|
||||
return (long) ((agent.getLoc().distance2D(agent.getEndLoc()) * 1000) / agent.getSpeed());
|
||||
}
|
||||
|
||||
public static void aiMove(Mob agent, Vector3fImmutable vect, boolean isWalking) {
|
||||
|
||||
//update our walk/run state.
|
||||
if (isWalking && !agent.isWalk()) {
|
||||
agent.setWalkMode(true);
|
||||
MovementManager.sendRWSSMsg(agent);
|
||||
} else if (!isWalking && agent.isWalk()) {
|
||||
agent.setWalkMode(false);
|
||||
MovementManager.sendRWSSMsg(agent);
|
||||
}
|
||||
|
||||
MoveToPointMsg msg = new MoveToPointMsg();
|
||||
|
||||
|
||||
// Regions currentRegion = Mob.InsideBuildingRegion(agent);
|
||||
//
|
||||
// if (currentRegion != null){
|
||||
//
|
||||
//
|
||||
// if (currentRegion.isGroundLevel()){
|
||||
// agent.setInBuilding(0);
|
||||
// agent.setInFloorID(-1);
|
||||
// }else{
|
||||
// agent.setInBuilding(currentRegion.getLevel());
|
||||
// agent.setInFloorID(currentRegion.getRoom());
|
||||
// }
|
||||
// }else{
|
||||
// agent.setInBuilding(-1);
|
||||
// agent.setInFloorID(-1);
|
||||
// agent.setInBuildingID(0);
|
||||
// }
|
||||
// agent.setLastRegion(currentRegion);
|
||||
|
||||
|
||||
Vector3fImmutable startLoc = null;
|
||||
Vector3fImmutable endLoc = null;
|
||||
|
||||
// if (agent.getLastRegion() != null){
|
||||
// Building inBuilding = Building.getBuildingFromCache(agent.getInBuildingID());
|
||||
// if (inBuilding != null){
|
||||
// startLoc = ZoneManager.convertWorldToLocal(inBuilding, agent.getLoc());
|
||||
// endLoc = ZoneManager.convertWorldToLocal(inBuilding, vect);
|
||||
// }
|
||||
// }else{
|
||||
// agent.setBuildingID(0);
|
||||
// agent.setInBuildingID(0);
|
||||
// startLoc = agent.getLoc();
|
||||
// endLoc = vect;
|
||||
// }
|
||||
|
||||
startLoc = agent.getLoc();
|
||||
endLoc = vect;
|
||||
|
||||
msg.setSourceType(GameObjectType.Mob.ordinal());
|
||||
msg.setSourceID(agent.getObjectUUID());
|
||||
msg.setStartCoord(startLoc);
|
||||
msg.setEndCoord(endLoc);
|
||||
msg.setUnknown01(-1);
|
||||
msg.setInBuilding(-1);
|
||||
msg.setTargetType(0);
|
||||
msg.setTargetID(0);
|
||||
|
||||
|
||||
try {
|
||||
MovementManager.movement(msg, agent);
|
||||
} catch (MsgSendException e) {
|
||||
// TODO Figure out how we want to handle the msg send exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3fImmutable GetDestinationToCharacter(Mob aiAgent, AbstractCharacter character) {
|
||||
|
||||
if (!character.isMoving())
|
||||
return character.getLoc();
|
||||
|
||||
|
||||
float agentDistanceEndLoc = aiAgent.getLoc().distanceSquared2D(character.getEndLoc());
|
||||
float characterDistanceEndLoc = character.getLoc().distanceSquared2D(character.getEndLoc());
|
||||
|
||||
if (agentDistanceEndLoc > characterDistanceEndLoc)
|
||||
return character.getEndLoc();
|
||||
|
||||
return character.getLoc();
|
||||
}
|
||||
|
||||
public static boolean updateMovementToCharacter(Mob aiAgent, AbstractCharacter aggroTarget) {
|
||||
|
||||
if (aiAgent.destination.equals(Vector3fImmutable.ZERO))
|
||||
return true;
|
||||
|
||||
if (!aiAgent.isMoving())
|
||||
return true;
|
||||
|
||||
|
||||
if (aggroTarget.isMoving()) {
|
||||
return !aiAgent.destination.equals(aggroTarget.getEndLoc()) && !aiAgent.destination.equals(aggroTarget.getLoc());
|
||||
} else {
|
||||
if (aiAgent.destination.equals(aggroTarget.getLoc()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package engine.mobileAI.utilities;
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Regions;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PathingUtilities {
|
||||
public static class Node {
|
||||
public Vector2f location;
|
||||
public ArrayList<Node> neighbors;
|
||||
public Regions region;
|
||||
public Building parentBuilding;
|
||||
|
||||
public Node(Vector2f loc, Regions reg, Building parent){
|
||||
this.location = loc;
|
||||
this.region = reg;
|
||||
this.parentBuilding = parent;
|
||||
this.neighbors = new ArrayList<>();
|
||||
}
|
||||
public Node(Node clone){
|
||||
this.location = clone.location;
|
||||
this.region = clone.region;
|
||||
this.parentBuilding = clone.parentBuilding;
|
||||
this.neighbors = (ArrayList<Node>) clone.neighbors.clone();
|
||||
}
|
||||
public ArrayList<Node> getNeighbors(){
|
||||
if(neighbors.size() == 0){
|
||||
Zone zone = ZoneManager.findSmallestZone(new Vector3fImmutable(this.location.x,0,this.location.y));
|
||||
if(zone == null)
|
||||
return null;
|
||||
|
||||
for(Node potentialNeighbor : zone.navNodes){
|
||||
for (Path2D.Float obstacle : zone.navObstacles) {
|
||||
if (!this.equals(potentialNeighbor) && !obstacle.intersects(this.location.x, this.location.y, potentialNeighbor.location.x, potentialNeighbor.location.y) && this.location.distance(potentialNeighbor.location) < 65) {
|
||||
this.neighbors.add(potentialNeighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.neighbors;
|
||||
}
|
||||
}
|
||||
|
||||
public static Node getClosestNode(Vector3fImmutable loc){
|
||||
Zone zone = ZoneManager.findSmallestZone(loc);
|
||||
Regions region = Regions.getRegionAtLocation(loc);
|
||||
if(region != null){
|
||||
for(Node node : zone.navNodes){
|
||||
if(node.location == new Vector2f(region.center.x,region.center.z))
|
||||
return node;
|
||||
}
|
||||
}
|
||||
float disSq = 10000000;
|
||||
Node closest = null;
|
||||
for(Node node : zone.navNodes){
|
||||
if(node.location.distanceSquared(new Vector2f(loc.x,loc.z)) < disSq)
|
||||
closest = node;
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
public static ArrayList<Node> getPath(AbstractCharacter mover, Vector3fImmutable goal){
|
||||
ArrayList<Node> path = new ArrayList<>();
|
||||
Node startNode = getClosestNode(mover.loc);
|
||||
Node goalNode = getClosestNode(goal);
|
||||
if(goalNode == null)
|
||||
move(mover,goal);
|
||||
Node currentNode = new Node(startNode);
|
||||
path.add(startNode);
|
||||
int attempts = 0;
|
||||
while(!currentNode.equals(goalNode) && attempts < 250){
|
||||
attempts ++;
|
||||
currentNode = getCheapestNeighbor(currentNode,new Vector2f(goal.x,goal.z));
|
||||
path.add(currentNode);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
public static Node getCheapestNeighbor(Node node, Vector2f goal){
|
||||
Node cheapest = null;
|
||||
for(Node neighbor : node.getNeighbors()){
|
||||
if(cheapest == null) {
|
||||
cheapest = neighbor;
|
||||
continue;
|
||||
}
|
||||
if(getCost(cheapest.location,node.location,goal) > getCost(neighbor.location,node.location,goal)){
|
||||
cheapest = neighbor;
|
||||
}
|
||||
}
|
||||
return cheapest;
|
||||
}
|
||||
public static float getCost(Vector2f point, Vector2f start, Vector2f goal) {
|
||||
float gCost = start.distanceSquared(point);
|
||||
float hCost = goal.distanceSquared(point);
|
||||
return gCost + hCost;
|
||||
}
|
||||
public static void followPath(AbstractCharacter character, ArrayList<Node> path){
|
||||
character.isPathing = true;
|
||||
while(new Vector2f(character.loc.x,character.loc.z).distanceSquared(path.get(path.size() - 1).location) > 9 && path.size() > 0){
|
||||
if( character.isMoving())
|
||||
continue;
|
||||
if(character.combatTarget != null){
|
||||
//need ot adjust new path for a moving combat target
|
||||
if(character.combatTarget.loc.distanceSquared2D(new Vector3fImmutable(path.get(path.size() - 1).location.x,0,path.get(path.size() - 1).location.y)) > 625){
|
||||
character.isPathing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
move(character,new Vector3fImmutable(path.get(0).location.x,0,path.get(0).location.y));
|
||||
path.remove(0);
|
||||
}
|
||||
character.isPathing = false;
|
||||
}
|
||||
public static void move(AbstractCharacter mob, Vector3fImmutable goal) {
|
||||
mob.destination = goal;
|
||||
if (mob.getObjectType().equals(Enum.GameObjectType.Mob)) {
|
||||
mob.setWalkMode(!(mob.combatTarget == null));
|
||||
MovementManager.sendRWSSMsg(mob);
|
||||
}
|
||||
mob.endLoc = goal;
|
||||
|
||||
MoveToPointMsg msg = new MoveToPointMsg();
|
||||
|
||||
msg.setSourceType(Enum.GameObjectType.Mob.ordinal());
|
||||
msg.setSourceID(mob.getObjectUUID());
|
||||
msg.setStartCoord(mob.loc);
|
||||
msg.setEndCoord(goal);
|
||||
Regions region = Regions.getRegionAtLocation(goal);
|
||||
if (region != null) {
|
||||
msg.setInBuildingFloor(region.room);
|
||||
msg.setInBuilding(region.level);
|
||||
msg.setStartLocType(0);
|
||||
msg.setInBuildingUUID(region.parentBuildingID);
|
||||
} else {
|
||||
msg.setInBuildingFloor(-1);
|
||||
msg.setInBuilding(-1);
|
||||
msg.setStartLocType(0);
|
||||
msg.setInBuildingUUID(0);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
MovementManager.movement(msg, mob);
|
||||
} catch (MsgSendException e) {
|
||||
// TODO Figure out how we want to handle the msg send exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import static engine.net.MessageDispatcher.maxRecipients;
|
||||
|
||||
/*
|
||||
* Dispatch Message is the main interface to Magicbane's threaded
|
||||
* asynch message delivery system.
|
||||
* async message delivery system.
|
||||
*/
|
||||
|
||||
public class DispatchMessage {
|
||||
|
||||
@@ -643,7 +643,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
moveMsg.setStartCoord(sourcePlayer.getLoc());
|
||||
moveMsg.setEndCoord(sourcePlayer.getLoc());
|
||||
moveMsg.setInBuilding(-1);
|
||||
moveMsg.setUnknown01(-1);
|
||||
moveMsg.setInBuildingFloor(-1);
|
||||
|
||||
dispatch = Dispatch.borrow(sourcePlayer, moveMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
@@ -1196,7 +1196,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
|
||||
if (npc.getCharItemManager().getInventoryCount() > 150) {
|
||||
if (npc.getParentZone() != null && npc.getParentZone().getPlayerCityUUID() == 0) {
|
||||
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID == 0) {
|
||||
ArrayList<Item> inv = npc.getInventory();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
try {
|
||||
@@ -1229,7 +1229,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
if (npc.getParentZone() != null && npc.getParentZone().getPlayerCityUUID() != 0)
|
||||
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0)
|
||||
if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) {
|
||||
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
@@ -1280,7 +1280,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
if (building != null && building.getProtectionState().equals(ProtectionState.NPC))
|
||||
building = null;
|
||||
if (npc.getParentZone().getPlayerCityUUID() == 0)
|
||||
if (npc.getParentZone().playerCityUUID == 0)
|
||||
building = null;
|
||||
|
||||
//make sure npc can afford item
|
||||
@@ -1892,9 +1892,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
case POWER:
|
||||
PowersManager.usePower((PerformActionMsg) msg, origin, false);
|
||||
break;
|
||||
case REQUESTMELEEATTACK:
|
||||
CombatManager.setAttackTarget((AttackCmdMsg) msg, origin);
|
||||
break;
|
||||
case READYTOENTER:
|
||||
break;
|
||||
case OPENVAULT:
|
||||
|
||||
@@ -173,7 +173,7 @@ public enum Protocol {
|
||||
REPAIROBJECT(0x782219CE, RepairMsg.class, null), //Repair Window Req/Ack, RepairObject item Req/Ack
|
||||
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, null), // MoveObjectToContainer Window Request
|
||||
REQUESTGUILDLIST(0x85DCC6D7, ReqGuildListMsg.class, RequestGuildListHandler.class),
|
||||
REQUESTMELEEATTACK(0x98C71545, AttackCmdMsg.class, null), // Attack
|
||||
REQUESTMELEEATTACK(0x98C71545, AttackCmdMsg.class, AttackCmdMsgHandler.class), // Attack
|
||||
REQUESTMEMBERLIST(0x3235E5EA, GuildControlMsg.class, GuildControlHandler.class), // Part of Promote/Demote, Also Player History
|
||||
REQUESTTOOPENBANK(0xF26E453F, null, null), // RequestToOpenBankMsg
|
||||
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, null), // Trade Request
|
||||
|
||||
@@ -151,7 +151,7 @@ public class AbandonAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
if (cityZone.guild_zone == false)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity() == null)
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AssetSupportMsgHandler extends AbstractClientMsgHandler {
|
||||
if (serverZone == null)
|
||||
return;
|
||||
|
||||
serverCity = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
serverCity = City.GetCityFromCache(serverZone.playerCityUUID);
|
||||
|
||||
if (serverCity == null)
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.AttackCmdMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
import engine.objects.*;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
* @Summary: Processes application protocol message which keeps
|
||||
* client's tcp connection open.
|
||||
*/
|
||||
|
||||
public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AttackCmdMsgHandler() {
|
||||
super(AttackCmdMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
AttackCmdMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AttackCmdMsg) baseMsg;
|
||||
|
||||
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70)
|
||||
return true;
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
AbstractWorldObject target = null;
|
||||
Enum.GameObjectType targetType;
|
||||
|
||||
targetType = Enum.GameObjectType.values()[msg.getTargetType()];
|
||||
|
||||
switch(targetType){
|
||||
case Mob:
|
||||
target = Mob.getMob(msg.getTargetID());
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
|
||||
break;
|
||||
case Building:
|
||||
target = BuildingManager.getBuilding(msg.getTargetID());
|
||||
break;
|
||||
case NPC:
|
||||
target = NPC.getNPC(msg.getTargetID());
|
||||
break;
|
||||
}
|
||||
if(target == null) {
|
||||
playerCharacter.setCombatTarget(null);
|
||||
return true; // cannot attack a null target
|
||||
}
|
||||
//set sources target
|
||||
|
||||
playerCharacter.setCombatTarget(target);
|
||||
|
||||
//put in combat if not already
|
||||
|
||||
if (!playerCharacter.isCombat())
|
||||
CombatManager.toggleCombat(true, origin);
|
||||
|
||||
//make character stand if sitting
|
||||
|
||||
if (playerCharacter.isSit())
|
||||
CombatManager.toggleSit(false, origin);
|
||||
|
||||
CombatManager.AttackTarget(playerCharacter, target);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
float startAlt = 0;
|
||||
Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
|
||||
if (upRegion != null)
|
||||
startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y;
|
||||
startAlt = upRegion.lerpY(pc.loc) - regionBuilding.getLoc().y;
|
||||
float rounded = startAlt * .10f;
|
||||
|
||||
rounded = ((int) rounded) * 10;
|
||||
@@ -143,7 +143,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
float landingAltitude = 0;
|
||||
Building building = Regions.GetBuildingForRegion(region);
|
||||
if (building != null)
|
||||
landingAltitude = region.lerpY(pc) - building.getLoc().y;
|
||||
landingAltitude = region.lerpY(pc.loc) - building.getLoc().y;
|
||||
|
||||
if (landingAltitude >= targetAlt) {
|
||||
pc.landingRegion = region;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ChannelMuteMsgHandler extends AbstractClientMsgHandler {
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
if (cityZone.guild_zone == false)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity().hasBeenTransfered == true) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
|
||||
playerZone = building.getParentZone();
|
||||
|
||||
if (playerZone != null)
|
||||
playerCity = City.getCity(playerZone.getPlayerCityUUID());
|
||||
playerCity = City.getCity(playerZone.playerCityUUID);
|
||||
|
||||
// Oops! *** Refactor: Log error
|
||||
switch (msg.getMessageType()) {
|
||||
@@ -117,7 +117,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
|
||||
dispatch = Dispatch.borrow(sourcePlayer, gtsm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
CityZoneMsg czm = new CityZoneMsg(2, playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(), playerZone, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents);
|
||||
CityZoneMsg czm = new CityZoneMsg(2, playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(), playerZone, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
|
||||
break;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler {
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
|
||||
building.setRank(-1);
|
||||
BuildingManager.setRank(building, -1);
|
||||
WorldGrid.RemoveWorldObject(building);
|
||||
WorldGrid.removeObject(building);
|
||||
building.getParentZone().zoneBuildingSet.remove(building);
|
||||
|
||||
@@ -75,12 +75,12 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(player.getLoc());
|
||||
|
||||
if (!zone.isPlayerCity()) {
|
||||
if (!zone.guild_zone) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
City city = City.GetCityFromCache(zone.getPlayerCityUUID());
|
||||
City city = City.GetCityFromCache(zone.playerCityUUID);
|
||||
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
@@ -254,7 +254,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (baneZone == null)
|
||||
return true;
|
||||
|
||||
City banedCity = City.getCity(baneZone.getPlayerCityUUID());
|
||||
City banedCity = City.getCity(baneZone.playerCityUUID);
|
||||
|
||||
if (banedCity == null)
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
@@ -16,9 +15,6 @@ import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
* @Summary: Processes application protocol message which
|
||||
@@ -27,8 +23,6 @@ import java.util.HashMap;
|
||||
|
||||
public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> _minionsByCaptain = null;
|
||||
|
||||
public MinionTrainingMsgHandler() {
|
||||
super(MinionTrainingMessage.class);
|
||||
}
|
||||
@@ -38,9 +32,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
MinionTrainingMessage minionMsg = (MinionTrainingMessage) baseMsg;
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
|
||||
@@ -50,23 +44,24 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
Building building = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
|
||||
if (b == null)
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
//clear minion
|
||||
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
if (!npc.minions.contains(toRemove.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
npc.getSiegeMinionMap().remove(toRemove);
|
||||
npc.minions.remove(Integer.valueOf(toRemove.getObjectUUID()));
|
||||
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
|
||||
@@ -74,33 +69,35 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
|
||||
toRemove.guardCaptain = null;
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(playerCharacter, building);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
@@ -115,7 +112,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
if (npc.getContractID() == 842)
|
||||
maxSlots = 1;
|
||||
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
if (npc.minions.size() == maxSlots)
|
||||
return true;
|
||||
|
||||
int mobBase;
|
||||
@@ -146,47 +143,15 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
if (mobBase == 0)
|
||||
return true;
|
||||
|
||||
Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
|
||||
Mob siegeMob = Mob.createSiegeMinion(npc, mobBase);
|
||||
|
||||
if (siegeMob == null)
|
||||
return true;
|
||||
|
||||
if (siegeMob != null) {
|
||||
|
||||
siegeMob.setSpawnTime(60 * 15);
|
||||
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
|
||||
|
||||
siegeMob.building = building;
|
||||
siegeMob.parentZone = zone;
|
||||
|
||||
// Slot siege minion
|
||||
// Can be either corner tower or bulwark.
|
||||
|
||||
int slot;
|
||||
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
|
||||
slot = 2;
|
||||
else
|
||||
slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
|
||||
|
||||
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
|
||||
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
|
||||
|
||||
// Rotate slot position by the building rotation
|
||||
|
||||
siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY);
|
||||
|
||||
siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc);
|
||||
siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc);
|
||||
|
||||
zone.zoneMobSet.add(siegeMob);
|
||||
siegeMob.setLoc(siegeMob.bindLoc);
|
||||
}
|
||||
}
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} finally {
|
||||
@@ -214,13 +179,13 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
if (!npc.minions.contains(toRemove.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.getMobBaseID(), npc.getSiegeMinionMap().get(toRemove)))
|
||||
if (!DbManager.MobQueries.REMOVE_GUARD_MINION(npc.getObjectUUID(), toRemove.firstName))
|
||||
return true;
|
||||
|
||||
npc.getSiegeMinionMap().remove(toRemove);
|
||||
npc.minions.remove(Integer.valueOf(toRemove.getObjectUUID()));
|
||||
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
|
||||
@@ -228,17 +193,22 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
if (toRemove.agentType.equals(Enum.AIAgentType.SIEGEENGINE)) {
|
||||
|
||||
PlayerCharacter trebOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
|
||||
if (trebOwner != null) {
|
||||
trebOwner.setPet(null);
|
||||
|
||||
toRemove.guardCaptain = null;
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
Dispatch dispatch = Dispatch.borrow(trebOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, building);
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(playerCharacter, building);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
@@ -248,11 +218,11 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
@@ -288,7 +258,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
break;
|
||||
}
|
||||
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
if (npc.minions.size() == maxSlots)
|
||||
return true;
|
||||
|
||||
int mobBase = npc.getMobBaseID();
|
||||
@@ -298,14 +268,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
String pirateName = NPCManager.getPirateName(mobBase);
|
||||
|
||||
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
|
||||
return true;
|
||||
|
||||
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
|
||||
Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName);
|
||||
|
||||
if (toCreate == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.MobQueries.ADD_GUARD_MINION(npc.getObjectUUID(), pirateName))
|
||||
return true;
|
||||
|
||||
if (toCreate != null) {
|
||||
toCreate.setDeathTime(System.currentTimeMillis());
|
||||
toCreate.parentZone.zoneMobSet.add(toCreate);
|
||||
@@ -314,7 +284,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.*;
|
||||
|
||||
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@@ -26,13 +28,11 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
MoveToPointMsg msg = (MoveToPointMsg) baseMsg;
|
||||
|
||||
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null;
|
||||
if (pc == null)
|
||||
return false;
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
if(pc == null)
|
||||
return true;
|
||||
|
||||
MovementManager.movement(msg, pc);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
realm.claimRealmForCity(city, charterUUID);
|
||||
|
||||
tol.setRank(8);
|
||||
BuildingManager.setRank(tol, 8);
|
||||
WorldGrid.updateObject(tol);
|
||||
|
||||
for (Building building : city.getParent().zoneBuildingSet) {
|
||||
@@ -334,7 +334,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
||||
Zone zone = ZoneManager.findSmallestZone(player.getLoc());
|
||||
|
||||
if (zone != null) {
|
||||
if (zone.isPlayerCity()) {
|
||||
if (zone.guild_zone) {
|
||||
loc = zone.getLoc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
if (removeCondemn == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.getParent(), removeCondemn.getPlayerUID(), removeCondemn.getGuildUID(), removeCondemn.getFriendType()))
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.buildingUUID, removeCondemn.playerUID, removeCondemn.guildUID, removeCondemn.friendType))
|
||||
return true;
|
||||
|
||||
sourceBuilding.getCondemned().remove(msg.getRemoveFriendID());
|
||||
@@ -175,7 +175,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
|
||||
condemn.setActive(msg.isReverseKOS());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.isActive());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.active);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
@@ -354,7 +354,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
if (friend == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.getPlayerUID(), friend.getGuildUID(), friend.getFriendType())) {
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.playerUID, friend.guildUID, friend.friendType)) {
|
||||
Logger.debug("Failed to remove Friend: " + msg.getRemoveFriendID() + " from Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import engine.Enum.ProfitType;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.FastMath;
|
||||
import engine.math.Vector3fImmutable;
|
||||
@@ -37,7 +36,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
super(OrderNPCMsg.class);
|
||||
}
|
||||
|
||||
public static void processRedeedMob(Mob mob, Building building, ClientConnection origin) {
|
||||
public static void processRedeedHireling(AbstractCharacter hireling, Building building, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter player;
|
||||
Contract contract;
|
||||
@@ -48,33 +47,28 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
itemMan = player.getCharItemManager();
|
||||
|
||||
contract = mob.getContract();
|
||||
contract = hireling.contract;
|
||||
|
||||
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!building.getHirelings().containsKey(mob))
|
||||
if (!building.getHirelings().containsKey(hireling))
|
||||
return;
|
||||
|
||||
if (!NPCManager.removeMobileFromBuilding(mob, building)) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return;
|
||||
}
|
||||
|
||||
building.getHirelings().remove(mob);
|
||||
BuildingManager.removeHireling(building, hireling);
|
||||
|
||||
itemBase = ItemBase.getItemBase(contract.getContractID());
|
||||
|
||||
if (itemBase == null) {
|
||||
Logger.error("Could not find Contract for npc: " + mob.getObjectUUID());
|
||||
Logger.error("Could not find Contract for npc: " + hireling.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
boolean itemWorked = false;
|
||||
|
||||
item = new Item(itemBase, player.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) ((byte) mob.getRank() - 1), (byte) ((byte) mob.getRank() - 1), (short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), "");
|
||||
item = new Item(itemBase, player.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) ((byte) hireling.getRank() - 1), (byte) ((byte) hireling.getRank() - 1), (short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), "");
|
||||
item.setNumOfItems(1);
|
||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
|
||||
@@ -212,10 +206,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AbstractCharacter guard : building.getHirelings().keySet()) {
|
||||
if (guard.getObjectType() == GameObjectType.Mob)
|
||||
((Mob) guard).setPatrolPointIndex(0);
|
||||
}
|
||||
} else if (building.getPatrolPoints() != null)
|
||||
ClearPatrolPoints(building.getObjectUUID());
|
||||
|
||||
@@ -223,10 +213,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints());
|
||||
} else if (building.getSentryPoints() != null)
|
||||
ClearSentryPoints(building.getObjectUUID());
|
||||
|
||||
// Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
|
||||
private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) {
|
||||
@@ -290,28 +276,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void processRedeedNPC(AbstractCharacter abstractCharacter, Building building, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
switch (abstractCharacter.getObjectType()) {
|
||||
case NPC:
|
||||
NPC npc = (NPC) abstractCharacter;
|
||||
|
||||
Building cityBuilding = npc.getBuilding();
|
||||
|
||||
if (cityBuilding == null)
|
||||
return;
|
||||
|
||||
BuildingManager.processRedeedNPC(npc, npc.building, origin);
|
||||
break;
|
||||
case Mob:
|
||||
Mob mob = (Mob) abstractCharacter;
|
||||
processRedeedMob(mob, mob.building, origin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean AddPatrolPoints(int buildingID, ArrayList<Vector3fImmutable> patrolPoints) {
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(buildingID);
|
||||
@@ -324,7 +288,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (zone == null)
|
||||
return false;
|
||||
|
||||
if (zone.getPlayerCityUUID() == 0)
|
||||
if (zone.playerCityUUID == 0)
|
||||
return false;
|
||||
|
||||
City city = building.getCity();
|
||||
@@ -502,7 +466,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
||||
return true;
|
||||
|
||||
processRedeedNPC(npc, building, origin);
|
||||
processRedeedHireling(npc, building, origin);
|
||||
return true;
|
||||
//MB TODO HANDLE all profits.
|
||||
case 7:
|
||||
@@ -541,7 +505,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
|
||||
|
||||
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
|
||||
mob = Mob.getMob(orderNPCMsg.getNpcUUID());
|
||||
|
||||
if (mob == null)
|
||||
return true;
|
||||
@@ -570,10 +534,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building.getHirelings().containsKey(mob) == false)
|
||||
return true;
|
||||
|
||||
if (NPCManager.removeMobileFromBuilding(mob, building) == false) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
BuildingManager.removeHireling(building, mob);
|
||||
|
||||
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
|
||||
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
|
||||
@@ -608,7 +569,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
||||
return true;
|
||||
|
||||
processRedeedNPC(mob, building, origin);
|
||||
processRedeedHireling(mob, building, origin);
|
||||
return true;
|
||||
//MB TODO HANDLE all profits.
|
||||
case 7:
|
||||
|
||||
@@ -2,7 +2,6 @@ package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.RealmMap;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
@@ -112,7 +111,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Cannot place a tree underwater
|
||||
|
||||
if (HeightMap.isLocUnderwater(placementInfo.getLoc())) {
|
||||
if (ZoneManager.isLocUnderwater(placementInfo.getLoc())) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater
|
||||
return false;
|
||||
}
|
||||
@@ -138,7 +137,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) {
|
||||
|
||||
if (serverZone.isPlayerCity() == false) {
|
||||
if (serverZone.guild_zone == false) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName());
|
||||
return false;
|
||||
}
|
||||
@@ -157,7 +156,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Retrieve the building details we're placing
|
||||
|
||||
if (serverZone.isNPCCity() == true) {
|
||||
if (serverZone.isNPCCity == true) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 15, ""); // Cannot place in a peace zone
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +177,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Cannot place a building underwater
|
||||
|
||||
if (HeightMap.isLocUnderwater(placementInfo.getLoc())) {
|
||||
if (ZoneManager.isLocUnderwater(placementInfo.getLoc())) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater
|
||||
return false;
|
||||
}
|
||||
@@ -186,7 +185,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
// Players cannot place buildings in mob zones.
|
||||
|
||||
if ((serverZone.isMacroZone() == true)
|
||||
|| (serverZone.getParent().isMacroZone() == true)) {
|
||||
|| (serverZone.parent.isMacroZone() == true)) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName()); // No building may be placed within this territory
|
||||
return false;
|
||||
}
|
||||
@@ -202,8 +201,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Cannot place assets on a dead tree
|
||||
|
||||
if ((serverZone.isPlayerCity())
|
||||
&& (City.getCity(serverZone.getPlayerCityUUID()).getTOL().getRank() == -1)) {
|
||||
if ((serverZone.guild_zone)
|
||||
&& (City.getCity(serverZone.playerCityUUID).getTOL().getRank() == -1)) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot place asset on dead tree until world heals");
|
||||
return false;
|
||||
}
|
||||
@@ -262,14 +261,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Must be a player city
|
||||
|
||||
if (serverZone.isPlayerCity() == false) {
|
||||
if (serverZone.guild_zone == false) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 41, player.getName()); // Cannot place outside a guild zone
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test zone has a city object
|
||||
|
||||
City city = City.getCity(serverZone.getPlayerCityUUID());
|
||||
City city = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
if (city == null) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); //"no city to associate asset with"
|
||||
@@ -513,7 +512,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (serverZone == null)
|
||||
return false;
|
||||
|
||||
cityObject = City.getCity(serverZone.getPlayerCityUUID());
|
||||
cityObject = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
// Early exit if something went horribly wrong
|
||||
|
||||
@@ -572,7 +571,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// No valid player city found
|
||||
|
||||
if (serverCity == null || serverCity.getParent().isPlayerCity() == false) {
|
||||
if (serverCity == null || serverCity.getParent().guild_zone == false) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); // Cannot place outisde a guild zone
|
||||
return false;
|
||||
}
|
||||
@@ -661,7 +660,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (!building.getBlueprint().isSiegeEquip())
|
||||
continue;
|
||||
|
||||
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.extents))
|
||||
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.halfExtents))
|
||||
continue;
|
||||
|
||||
if (building.getGuild() == null)
|
||||
@@ -745,15 +744,16 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
Vector3fImmutable plantLoc = new Vector3fImmutable(treeInfo.getLoc().x,
|
||||
HeightMap.getWorldHeight(treeInfo.getLoc()),
|
||||
0,
|
||||
treeInfo.getLoc().z);
|
||||
|
||||
cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(),
|
||||
serverRealm.getRealmID(),
|
||||
plantLoc.x - serverZone.getAbsX(), plantLoc.y,
|
||||
plantLoc.z - serverZone.getAbsZ(), treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now());
|
||||
plantLoc.x - serverZone.absX, plantLoc.y,
|
||||
plantLoc.z - serverZone.absZ, treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now());
|
||||
|
||||
// Uh oh!
|
||||
|
||||
if (cityObjects == null || cityObjects.isEmpty()) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return false;
|
||||
@@ -767,7 +767,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
||||
treeObject.runAfterLoad();
|
||||
;
|
||||
|
||||
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
||||
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
||||
|
||||
@@ -780,44 +780,26 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
playerNation = playerCharacter.getGuild();
|
||||
playerNation.setGuildState(GuildState.Sovereign);
|
||||
|
||||
// Link the zone with the city and then add
|
||||
// to the appropriate hash tables and cache
|
||||
|
||||
zoneObject.setPlayerCity(true);
|
||||
|
||||
if (zoneObject.getParent() != null)
|
||||
zoneObject.getParent().addNode(zoneObject); //add as child to parent
|
||||
|
||||
ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject);
|
||||
ZoneManager.addPlayerCityZone(zoneObject);
|
||||
serverZone.addNode(zoneObject);
|
||||
|
||||
zoneObject.generateWorldAltitude();
|
||||
|
||||
cityObject.setParent(zoneObject);
|
||||
cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already
|
||||
//Link the tree of life with the new zone
|
||||
|
||||
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
treeObject.setParentZone(zoneObject);
|
||||
MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7));
|
||||
|
||||
// Update guild binds and tags
|
||||
//load the new city on the clients
|
||||
|
||||
CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
|
||||
GuildManager.updateAllGuildBinds(playerNation, cityObject);
|
||||
GuildManager.updateAllGuildTags(playerNation);
|
||||
|
||||
//load the new city on the clients
|
||||
|
||||
CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
|
||||
// Set maintenance date
|
||||
|
||||
MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7));
|
||||
|
||||
// Send all the cities to the clients?
|
||||
// *** Refactor : figure out how to send like, one?
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
treeObject.setLoc(treeObject.getLoc());
|
||||
InterestManager.setObjectDirty(treeObject);
|
||||
// WorldGrid.addObject(treeObject, playerCharacter);
|
||||
|
||||
serverRealm.addCity(cityObject.getObjectUUID());
|
||||
playerNation.setCityUUID(cityObject.getObjectUUID());
|
||||
@@ -857,7 +839,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (serverZone == null)
|
||||
return false;
|
||||
|
||||
cityObject = City.getCity(serverZone.getPlayerCityUUID());
|
||||
cityObject = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
if (cityObject == null)
|
||||
return false;
|
||||
@@ -915,6 +897,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Early exit if something went horribly wrong
|
||||
// with locating the current realm and/or zone
|
||||
|
||||
if (serverZone == null)
|
||||
return false;
|
||||
|
||||
@@ -930,7 +913,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
int shrineCount = 0;
|
||||
|
||||
cityObject = City.getCity(serverZone.getPlayerCityUUID());
|
||||
cityObject = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
// Cannot place shrine in abandoned city. Shrines must be owned
|
||||
// by the tol owner not the person placing them.
|
||||
@@ -977,7 +960,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
City cityObject;
|
||||
PlacementInfo buildingList;
|
||||
|
||||
// Setup working variables we'll need
|
||||
// Setup working variables
|
||||
|
||||
buildingList = msg.getFirstPlacementInfo();
|
||||
|
||||
serverZone = ZoneManager.findSmallestZone(buildingList.getLoc());
|
||||
@@ -999,7 +983,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
int barracksCount = 0;
|
||||
|
||||
cityObject = City.getCity(serverZone.getPlayerCityUUID());
|
||||
cityObject = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
// Cannot place barracks in abandoned city.
|
||||
|
||||
@@ -1059,7 +1043,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (validateCityBuildingPlacement(serverZone, msg, origin, player, msg.getFirstPlacementInfo()) == false)
|
||||
return false;
|
||||
|
||||
cityObject = City.getCity(serverZone.getPlayerCityUUID());
|
||||
cityObject = City.getCity(serverZone.playerCityUUID);
|
||||
|
||||
// We need to be able to access how much gold a character is carrying
|
||||
|
||||
@@ -1090,7 +1074,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
placementCost = 0; // reset placement cost for fix bug with wall pieces somethings not taking gold out if forced an error.
|
||||
|
||||
|
||||
// Overlap check and wall deed verifications
|
||||
for (PlacementInfo wall : walls) {
|
||||
|
||||
@@ -1109,7 +1092,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
for (Building building : serverZone.zoneBuildingSet) {
|
||||
|
||||
|
||||
//TODO Clean up collision with placementInfo. don't need to create the same placementinfo bounds for collision checks on each building.
|
||||
if ((building.getBlueprintUUID() != 0) && (Bounds.collide(wall, building) == true)) {
|
||||
|
||||
@@ -1117,7 +1099,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
building.removeFromCache();
|
||||
WorldGrid.RemoveWorldObject(building);
|
||||
WorldGrid.removeObject(building);
|
||||
building.getParentZone().getParent().zoneBuildingSet.remove(building);
|
||||
building.getParentZone().parent.zoneBuildingSet.remove(building);
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)) {
|
||||
building.RemoveFromBarracksList();
|
||||
}
|
||||
@@ -1129,12 +1111,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
placementCost = PlaceAssetMsg.getWallCost(wall.getBlueprintUUID());
|
||||
|
||||
if (!itemMan.modifyInventoryGold(-placementCost)) {
|
||||
ChatManager.chatSystemInfo(player, player.getFirstName() + " can't has free moneys! no for real.. Thor.. seriously... I didnt fix it because you getting laid isnt important enough for me.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to place wall piece
|
||||
|
||||
wallPiece = createStructure(player, wall, serverZone);
|
||||
@@ -1145,14 +1129,12 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
// walls are auto protected
|
||||
|
||||
wallPiece.setProtectionState(ProtectionState.PROTECTED);
|
||||
PlaceAssetMsg.sendPlaceAssetConfirmWall(origin, serverZone);
|
||||
|
||||
}
|
||||
|
||||
// Deduct gold from character's inventory
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1172,6 +1154,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
// All siege buildings build in 15 minutes
|
||||
|
||||
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
||||
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
|
||||
completionDate = DateTime.now().plusMinutes(15);
|
||||
@@ -1191,6 +1174,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
||||
|
||||
// Make sure we have a valid mesh
|
||||
|
||||
if (newMesh == null) {
|
||||
Logger.error("CreateStructure: DB returned null object.");
|
||||
return null;
|
||||
@@ -1227,7 +1211,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
shrineType = Shrine.getShrineTypeByBlueprintUUID(blueprint.getBlueprintUUID());
|
||||
|
||||
city = City.getCity(currentZone.getPlayerCityUUID());
|
||||
city = City.getCity(currentZone.playerCityUUID);
|
||||
|
||||
if (city == null)
|
||||
return false;
|
||||
@@ -1292,7 +1276,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
city = City.getCity(currentZone.getPlayerCityUUID());
|
||||
city = City.getCity(currentZone.playerCityUUID);
|
||||
|
||||
if (city == null)
|
||||
return false;
|
||||
@@ -1362,15 +1346,16 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
newMesh = (Building) ago;
|
||||
newMesh.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
MaintenanceManager.setMaintDateTime(newMesh, LocalDateTime.now().plusDays(7));
|
||||
// WorldGrid.addObject(newMesh, player);
|
||||
newMesh.setLoc(newMesh.getLoc());
|
||||
InterestManager.setObjectDirty(newMesh);
|
||||
newMesh.runAfterLoad();
|
||||
} else if (ago.getObjectType() == GameObjectType.Warehouse) {
|
||||
Warehouse warehouse = (Warehouse) ago;
|
||||
City city = City.getCity(currentZone.getPlayerCityUUID());
|
||||
City city = City.getCity(currentZone.playerCityUUID);
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
city.setWarehouseBuildingID(newMesh.getObjectUUID());
|
||||
Warehouse.warehouseByBuildingUUID.put(newMesh.getObjectUUID(), warehouse);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ public class RepairBuildingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
serverZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
|
||||
if (serverZone.getPlayerCityUUID() == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE)
|
||||
if (serverZone.playerCityUUID == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE)
|
||||
return;
|
||||
|
||||
|
||||
City city = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
City city = City.GetCityFromCache(serverZone.playerCityUUID);
|
||||
|
||||
if (city != null) {
|
||||
if (city.getBane() != null && city.protectionEnforced == false)
|
||||
|
||||
@@ -110,7 +110,6 @@ public class RequestEnterWorldHandler extends AbstractClientMsgHandler {
|
||||
player.stopMovement(player.getBindLoc());
|
||||
player.setSafeMode();
|
||||
player.updateLocation();
|
||||
player.setRegion(AbstractWorldObject.GetRegionByWorldObject(player));
|
||||
}
|
||||
|
||||
player.setTimeStamp("logout", 0);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CityAssetMsg extends ClientNetMsg {
|
||||
return;
|
||||
}
|
||||
|
||||
city = City.getCity(zone.getPlayerCityUUID());
|
||||
city = City.getCity(zone.playerCityUUID);
|
||||
|
||||
if (city == null) {
|
||||
Logger.debug("Failed to load city data for Tree of life.");
|
||||
|
||||
@@ -117,8 +117,8 @@ public class GuildTreeStatusMsg extends ClientNetMsg {
|
||||
city = null;
|
||||
|
||||
if (cityZone != null)
|
||||
if (cityZone.isPlayerCity())
|
||||
city = City.GetCityFromCache(cityZone.getPlayerCityUUID());
|
||||
if (cityZone.guild_zone)
|
||||
city = City.GetCityFromCache(cityZone.playerCityUUID);
|
||||
else if (this.treeOfLife != null && this.treeOfLife.getGuild() != null)
|
||||
city = this.treeOfLife.getGuild().getOwnedCity();
|
||||
|
||||
|
||||
@@ -299,8 +299,8 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
Set<Building> buildings = ZoneManager.findSmallestZone(assetManager.getLoc()).zoneBuildingSet;
|
||||
|
||||
Building tol = null;
|
||||
if (playerZone.getPlayerCityUUID() != 0)
|
||||
city = City.GetCityFromCache(playerZone.getPlayerCityUUID());
|
||||
if (playerZone.playerCityUUID != 0)
|
||||
city = City.GetCityFromCache(playerZone.playerCityUUID);
|
||||
|
||||
if (city != null)
|
||||
tol = city.getTOL();
|
||||
@@ -368,7 +368,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
if (zone == null)
|
||||
return;
|
||||
|
||||
City banedCity = City.getCity(zone.getPlayerCityUUID());
|
||||
City banedCity = City.getCity(zone.playerCityUUID);
|
||||
|
||||
if (banedCity == null)
|
||||
return;
|
||||
@@ -479,7 +479,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
if (zone == null)
|
||||
writer.putString("Forlord");
|
||||
else
|
||||
writer.putString(zone.getName());
|
||||
writer.putString(zone.zoneName);
|
||||
|
||||
writer.putString(building.getGuild().getName());
|
||||
|
||||
@@ -621,9 +621,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
} else {
|
||||
writer.putInt(1); //kos on/off?
|
||||
writer.putInt(3); // was 3
|
||||
if (zone.getPlayerCityUUID() != 0 && asset.assetIsProtected()) {
|
||||
if (zone.playerCityUUID != 0 && asset.assetIsProtected()) {
|
||||
writer.putInt(GameObjectType.Building.ordinal());
|
||||
writer.putInt(City.getCity(zone.getPlayerCityUUID()).getTOL().getObjectUUID());
|
||||
writer.putInt(City.getCity(zone.playerCityUUID).getTOL().getObjectUUID());
|
||||
} else {
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
@@ -727,9 +727,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
|
||||
if (!npcHire.isAlive()) {
|
||||
writer.put((byte) 1); // 1 SHOWs respawning
|
||||
int respawnRemaining = (int) (((Mob) npcHire).deathTime + ((Mob) npcHire).spawnTime * 1000 - System.currentTimeMillis()) / 1000;
|
||||
int respawnRemaining = (int) (((Mob) npcHire).deathTime + ((Mob) npcHire).spawnDelay * 1000 - System.currentTimeMillis()) / 1000;
|
||||
writer.putInt(respawnRemaining); // Seconds in respawn remaining.
|
||||
writer.putInt(((Mob) npcHire).spawnTime); // max seconds for respawn
|
||||
writer.putInt(((Mob) npcHire).spawnDelay); // max seconds for respawn
|
||||
} else
|
||||
writer.put((byte) 0);
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.pmw.tinylog.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -96,7 +95,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putString("A weapon suited to laying siege");
|
||||
}
|
||||
|
||||
private static void serializeGuardList(ByteBufferWriter writer, int minion) {
|
||||
private static void serializeGuardList(ByteBufferWriter writer, int minion, Mob captain) {
|
||||
|
||||
writer.putInt(1);
|
||||
|
||||
@@ -106,7 +105,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(minion);
|
||||
writer.putInt(1);
|
||||
writer.putInt(minion);
|
||||
writer.putInt(1);
|
||||
writer.putInt(captain.getRank());//minion rank
|
||||
writer.put((byte) 0);
|
||||
|
||||
writer.putInt(600); //roll time
|
||||
@@ -343,14 +342,17 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(0); //runemaster list
|
||||
|
||||
//artillery captain list
|
||||
ConcurrentHashMap<Mob, Integer> siegeMinions = npc.getSiegeMinionMap();
|
||||
writer.putInt(1 + siegeMinions.size());
|
||||
|
||||
writer.putInt(1 + npc.minions.size());
|
||||
serializeBulwarkList(writer, 1); //Trebuchet
|
||||
//serializeBulwarkList(writer, 2); //Ballista
|
||||
|
||||
if (siegeMinions != null && siegeMinions.size() > 0)
|
||||
if (npc.minions != null && npc.minions.size() > 0)
|
||||
|
||||
for (Integer minionUUID : npc.minions) {
|
||||
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
|
||||
for (Mob mob : siegeMinions.keySet()) {
|
||||
this.unknown83 = mob.getObjectUUID();
|
||||
writer.putInt(2);
|
||||
writer.putInt(mob.getObjectType().ordinal());
|
||||
@@ -362,14 +364,14 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(1);
|
||||
|
||||
long curTime = System.currentTimeMillis() / 1000;
|
||||
long upgradeTime = (mob.deathTime + (mob.spawnTime * 1000)) / 1000;
|
||||
long upgradeTime = (mob.deathTime + (mob.spawnDelay * 1000)) / 1000;
|
||||
long timeLife = upgradeTime - curTime;
|
||||
|
||||
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
||||
if (mob.npcOwner.isAlive()) {
|
||||
if (mob.guardCaptain.isAlive()) {
|
||||
writer.put((byte) 0);//shows respawning timer
|
||||
writer.putInt(mob.spawnTime);
|
||||
writer.putInt(mob.spawnTime);
|
||||
writer.putInt(mob.spawnDelay);
|
||||
writer.putInt(mob.spawnDelay);
|
||||
writer.putInt((int) timeLife); //time remaining for mob that is dead
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
@@ -557,7 +559,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
|
||||
} else if (this.targetType == GameObjectType.Mob.ordinal()) {
|
||||
|
||||
mobA = Mob.getFromCacheDBID(this.targetID);
|
||||
mobA = Mob.getMob(this.targetID);
|
||||
|
||||
if (mobA == null) {
|
||||
Logger.error("Missing Mob of ID " + this.targetID);
|
||||
@@ -666,14 +668,15 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(0); //runemaster list
|
||||
|
||||
//artillery captain list
|
||||
ConcurrentHashMap<Mob, Integer> siegeMinions = mobA.getSiegeMinionMap();
|
||||
|
||||
writer.putInt(siegeMinions.size() + 1);
|
||||
serializeGuardList(writer, mobA.getContract().getContractID()); //Guard
|
||||
writer.putInt(mobA.minions.size() + 1);
|
||||
|
||||
if (siegeMinions != null && siegeMinions.size() > 0)
|
||||
serializeGuardList(writer, mobA.getContract().getContractID(), mobA); //Guard
|
||||
|
||||
for (Mob mob : siegeMinions.keySet()) {
|
||||
if (mobA.minions != null && mobA.minions.size() > 0)
|
||||
|
||||
for (Integer minionUUID : mobA.minions) {
|
||||
Mob mob = Mob.getMob(minionUUID);
|
||||
this.unknown83 = mob.getObjectUUID();
|
||||
writer.putInt(2);
|
||||
writer.putInt(mob.getObjectType().ordinal());
|
||||
@@ -685,14 +688,14 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(1);
|
||||
|
||||
long curTime = System.currentTimeMillis() / 1000;
|
||||
long upgradeTime = (mob.deathTime + (mob.spawnTime * 1000)) / 1000;
|
||||
long upgradeTime = (mob.deathTime + (mob.spawnDelay * 1000)) / 1000;
|
||||
long timeLife = upgradeTime - curTime;
|
||||
|
||||
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
||||
if (mob.npcOwner.isAlive()) {
|
||||
if (mob.guardCaptain.isAlive()) {
|
||||
writer.put((byte) 0);//shows respawning timer
|
||||
writer.putInt(mob.spawnTime);
|
||||
writer.putInt(mob.spawnTime);
|
||||
writer.putInt(mob.spawnDelay);
|
||||
writer.putInt(mob.spawnDelay);
|
||||
writer.putInt((int) timeLife); //time remaining for mob that is dead
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.AbstractConnection;
|
||||
@@ -21,19 +22,19 @@ import engine.objects.Building;
|
||||
|
||||
public class MoveToPointMsg extends ClientNetMsg {
|
||||
|
||||
private int sourceType;
|
||||
private int sourceID;
|
||||
private float startLat;
|
||||
private float startLon;
|
||||
private float startAlt;
|
||||
private float endLat;
|
||||
private float endLon;
|
||||
private float endAlt;
|
||||
private int targetType;
|
||||
private int targetID;
|
||||
private int inBuilding; // 0=true, -1=false 0/1/2 = floor you are on
|
||||
private int unknown01;
|
||||
private byte unknown02;
|
||||
private int sourceType; //ordinal of the character type that sent this message 54=PlayerCharacter
|
||||
private int sourceID; // uuid of the source character of this message
|
||||
private float startLat; //start loc of move message (offset if inside a building not world loc)
|
||||
private float startLon; //start loc of move message (offset if inside a building not world loc)
|
||||
private float startAlt; //start loc of move message (offset if inside a building not world loc)
|
||||
private float endLat; //end loc of move message (offset if inside a building not world loc)
|
||||
private float endLon; //end loc of move message (offset if inside a building not world loc)
|
||||
private float endAlt; //end loc of move message (offset if inside a building not world loc)
|
||||
private int startLocType; // enum ordinal of the object player is inside 0=nothing 8=building
|
||||
private int inBuildingUUID; // uuid of the building character is currently inside
|
||||
private int inBuilding; // is inside a building 0=true -1=false
|
||||
private int inBuildingFloor; // floor of building character is currently in -1=not inside building 0/1/2/3 = floor number
|
||||
private byte initiatedByAttack; // move message sent as a result of move to target to attack 0=false 1=true
|
||||
private byte unknown03;
|
||||
|
||||
/**
|
||||
@@ -54,11 +55,11 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.endLat = msg.endLat;
|
||||
this.endLon = msg.endLon;
|
||||
this.endAlt = msg.endAlt;
|
||||
this.targetType = msg.targetType;
|
||||
this.targetID = msg.targetID;
|
||||
this.startLocType = msg.startLocType;
|
||||
this.inBuildingUUID = msg.inBuildingUUID;
|
||||
this.inBuilding = msg.inBuilding;
|
||||
this.unknown01 = msg.unknown01;
|
||||
this.unknown02 = msg.unknown02;
|
||||
this.inBuildingFloor = msg.inBuildingFloor;
|
||||
this.initiatedByAttack = msg.initiatedByAttack;
|
||||
this.unknown03 = msg.unknown03;
|
||||
}
|
||||
|
||||
@@ -73,11 +74,11 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.endLat = building.getLoc().x;
|
||||
this.endLon = building.getLoc().z;
|
||||
this.endAlt = building.getLoc().y;
|
||||
this.targetType = 0;
|
||||
this.targetID = 0;
|
||||
this.startLocType = 0;
|
||||
this.inBuildingUUID = 0;
|
||||
this.inBuilding = -1;
|
||||
this.unknown01 = -1;
|
||||
this.unknown02 = 0;
|
||||
this.inBuildingFloor = -1;
|
||||
this.initiatedByAttack = 0;
|
||||
this.unknown03 = 0;
|
||||
}
|
||||
|
||||
@@ -108,11 +109,11 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
writer.putFloat(this.endAlt);
|
||||
writer.putFloat(this.endLon);
|
||||
|
||||
writer.putInt(this.targetType);
|
||||
writer.putInt(this.targetID);
|
||||
writer.putInt(this.startLocType);
|
||||
writer.putInt(this.inBuildingUUID);
|
||||
|
||||
writer.putInt(this.inBuilding);
|
||||
writer.putInt(this.unknown01);
|
||||
writer.putInt(this.inBuildingFloor);
|
||||
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
@@ -135,13 +136,13 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.endAlt = reader.getFloat();
|
||||
this.endLon = reader.getFloat();
|
||||
|
||||
this.targetType = reader.getInt();
|
||||
this.targetID = reader.getInt();
|
||||
this.startLocType = reader.getInt();
|
||||
this.inBuildingUUID = reader.getInt();
|
||||
|
||||
this.inBuilding = reader.getInt();
|
||||
this.unknown01 = reader.getInt();
|
||||
this.inBuildingFloor = reader.getInt();
|
||||
|
||||
this.unknown02 = reader.get();
|
||||
this.initiatedByAttack = reader.get();
|
||||
this.unknown03 = reader.get();
|
||||
}
|
||||
|
||||
@@ -209,20 +210,20 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.endAlt = value;
|
||||
}
|
||||
|
||||
public int getTargetType() {
|
||||
return this.targetType;
|
||||
public int getStartLocType() {
|
||||
return this.startLocType;
|
||||
}
|
||||
|
||||
public void setTargetType(int value) {
|
||||
this.targetType = value;
|
||||
public void setStartLocType(int value) {
|
||||
this.startLocType = value;
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return this.targetID;
|
||||
public int getInBuildingUUID() {
|
||||
return this.inBuildingUUID;
|
||||
}
|
||||
|
||||
public void setTargetID(int value) {
|
||||
this.targetID = value;
|
||||
public void setInBuildingUUID(int value) {
|
||||
this.inBuildingUUID = value;
|
||||
}
|
||||
|
||||
public int getInBuilding() {
|
||||
@@ -233,12 +234,8 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.inBuilding = value;
|
||||
}
|
||||
|
||||
public int getUnknown01() {
|
||||
return this.unknown01;
|
||||
}
|
||||
|
||||
public void setUnknown01(int value) {
|
||||
this.unknown01 = value;
|
||||
public void setInBuildingFloor(int value) {
|
||||
this.inBuildingFloor = value;
|
||||
}
|
||||
|
||||
public void setStartCoord(Vector3fImmutable value) {
|
||||
@@ -254,8 +251,8 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
}
|
||||
|
||||
public void clearTarget() {
|
||||
this.targetType = 0;
|
||||
this.targetID = 0;
|
||||
this.startLocType = 0;
|
||||
this.inBuildingUUID = 0;
|
||||
}
|
||||
|
||||
public void setPlayer(AbstractCharacter ac) {
|
||||
@@ -263,10 +260,10 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
this.sourceID = ac.getObjectUUID();
|
||||
this.setStartCoord(ac.getLoc());
|
||||
this.setEndCoord(ac.getEndLoc());
|
||||
this.targetType = 0;
|
||||
this.targetID = 0;
|
||||
this.startLocType = 0;
|
||||
this.inBuildingUUID = 0;
|
||||
this.inBuilding = ac.getInBuilding();
|
||||
this.unknown01 = ac.getInFloorID();
|
||||
this.inBuildingFloor = ac.getInFloorID();
|
||||
|
||||
}
|
||||
|
||||
@@ -274,10 +271,10 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
if (target == null) {
|
||||
this.setStartCoord(ac.getLoc());
|
||||
this.setEndCoord(ac.getEndLoc());
|
||||
this.targetType = 0;
|
||||
this.targetID = 0;
|
||||
this.startLocType = 0;
|
||||
this.inBuildingUUID = 0;
|
||||
this.inBuilding = -1;
|
||||
this.unknown01 = -1;
|
||||
this.inBuildingFloor = -1;
|
||||
} else {
|
||||
Vector3fImmutable convertLocStart = ZoneManager.convertWorldToLocal(target, ac.getLoc());
|
||||
Vector3fImmutable convertLocEnd = convertLocStart;
|
||||
@@ -286,10 +283,10 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
|
||||
this.setStartCoord(convertLocStart);
|
||||
this.setEndCoord(convertLocEnd);
|
||||
this.targetType = GameObjectType.Building.ordinal();
|
||||
this.targetID = target.getObjectUUID();
|
||||
this.startLocType = GameObjectType.Building.ordinal();
|
||||
this.inBuildingUUID = target.getObjectUUID();
|
||||
this.inBuilding = ac.getInBuilding();
|
||||
this.unknown01 = ac.getInFloorID();
|
||||
this.inBuildingFloor = ac.getInFloorID();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -298,7 +295,11 @@ public class MoveToPointMsg extends ClientNetMsg {
|
||||
return unknown03;
|
||||
}
|
||||
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
public int getInitiatedFromAttack() {
|
||||
return initiatedByAttack;
|
||||
}
|
||||
|
||||
public int getInBuildingFloor() {
|
||||
return this.inBuildingFloor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,17 +513,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
|
||||
writer.put((byte) 1);
|
||||
|
||||
switch (condemned.getFriendType()) {
|
||||
switch (condemned.friendType) {
|
||||
case 2:
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.getPlayerUID());
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.playerUID);
|
||||
|
||||
|
||||
guild = playerCharacter.getGuild();
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(condemned.getPlayerUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.playerUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(condemned.getPlayerUID());
|
||||
writer.putInt(condemned.playerUID);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
@@ -531,9 +531,9 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
writer.putInt(guild.getObjectUUID());
|
||||
else
|
||||
writer.putInt(0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
|
||||
if (playerCharacter != null)
|
||||
writer.putString(playerCharacter.getFirstName());
|
||||
@@ -547,16 +547,16 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
guild = Guild.getGuild(condemned.getGuildUID());
|
||||
guild = Guild.getGuild(condemned.guildUID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putLong(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putLong(0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
writer.put((byte) 0);
|
||||
if (guild != null)
|
||||
writer.putString(guild.getName());
|
||||
@@ -570,17 +570,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
GuildTag._serializeForDisplay(GuildTag.ERRANT, writer);
|
||||
break;
|
||||
case 5:
|
||||
guild = Guild.getGuild(condemned.getGuildUID());
|
||||
guild = Guild.getGuild(condemned.guildUID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putLong(0);
|
||||
writer.putLong(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
if (guild != null)
|
||||
writer.putString(guild.getName());
|
||||
else
|
||||
@@ -619,22 +619,22 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
writer.putInt(listSize);
|
||||
|
||||
for (BuildingFriends friend : this.friends.values()) {
|
||||
pc = PlayerCharacter.getFromCache(friend.getPlayerUID());
|
||||
guild = Guild.getGuild(friend.getGuildUID());
|
||||
if (friend.getFriendType() == 7) {
|
||||
pc = PlayerCharacter.getFromCache(friend.playerUID);
|
||||
guild = Guild.getGuild(friend.guildUID);
|
||||
if (friend.friendType == 7) {
|
||||
if (pc != null)
|
||||
name = pc.getCombinedName();
|
||||
} else if (guild != null)
|
||||
name = guild.getName();
|
||||
writer.put((byte) 1);
|
||||
if (friend.getFriendType() == 7) {
|
||||
if (friend.friendType == 7) {
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(friend.getPlayerUID());
|
||||
writer.putInt(friend.playerUID);
|
||||
} else {
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(friend.getGuildUID());
|
||||
writer.putInt(friend.guildUID);
|
||||
}
|
||||
writer.putInt(friend.getFriendType());
|
||||
writer.putInt(friend.friendType);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SyncMessage extends ClientNetMsg {
|
||||
|
||||
private int type;
|
||||
private int size;
|
||||
private int pad = 0;
|
||||
private int objectType;
|
||||
private int objectUUID;
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public SyncMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.CITYASSET, origin, reader);
|
||||
}
|
||||
|
||||
public SyncMessage() {
|
||||
super(Protocol.CITYASSET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
//none yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
//lets do returns before writing so we don't send improper structures to the client
|
||||
|
||||
Building tol = BuildingManager.getBuilding(this.objectUUID);
|
||||
|
||||
if (tol == null) {
|
||||
Logger.debug("TOL is null");
|
||||
return;
|
||||
}
|
||||
Zone zone = ZoneManager.findSmallestZone(tol.getLoc());
|
||||
if (zone == null) {
|
||||
Logger.debug("Zone is null");
|
||||
return;
|
||||
}
|
||||
ArrayList<Building> allCityAssets = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
|
||||
|
||||
// *** Refactor: collection created but never used?
|
||||
|
||||
ArrayList<Building> canProtectAssets = new ArrayList<>();
|
||||
|
||||
for (Building b : allCityAssets) {
|
||||
if (b.getBlueprintUUID() != 0)
|
||||
canProtectAssets.add(b);
|
||||
}
|
||||
|
||||
// *** Refactor : Not sure what this synch message does
|
||||
// Get the feeling it should be looping over upgradable
|
||||
// assets.
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.objectType);
|
||||
writer.putInt(this.objectUUID);
|
||||
writer.putInt(allCityAssets.size());
|
||||
for (Building b : allCityAssets) {
|
||||
String name = b.getName();
|
||||
// if (name.equals(""))
|
||||
// name = b.getBuildingSet().getName();
|
||||
writer.putInt(b.getObjectType().ordinal());
|
||||
writer.putInt(b.getObjectUUID());
|
||||
|
||||
writer.putString(b.getName()); // Blueprint name?
|
||||
writer.putString(b.getGuild().getName());
|
||||
writer.putInt(20);// \/ Temp \/
|
||||
writer.putInt(b.getRank());
|
||||
writer.putInt(1); // symbol
|
||||
writer.putInt(7); //TODO identify these Guild tags??
|
||||
writer.putInt(17);
|
||||
writer.putInt(14);
|
||||
writer.putInt(14);
|
||||
writer.putInt(98);// /\ Temp /\
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public void setObjectType(int value) {
|
||||
this.objectType = value;
|
||||
}
|
||||
|
||||
public int getUUID() {
|
||||
return objectUUID;
|
||||
|
||||
}
|
||||
|
||||
public int getPad() {
|
||||
return pad;
|
||||
}
|
||||
|
||||
public void setPad(int value) {
|
||||
this.pad = value;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class ViewResourcesMessage extends ClientNetMsg {
|
||||
if (this.warehouseBuilding.getParentZone() == null)
|
||||
return false;
|
||||
|
||||
this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().getPlayerCityUUID());
|
||||
this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().playerCityUUID);
|
||||
|
||||
if (this.city == null)
|
||||
return false;
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.AbstractNetMsg;
|
||||
@@ -44,14 +46,9 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
super(Protocol.NEWWORLD, origin, reader);
|
||||
}
|
||||
|
||||
private static int getTotalMapSize(Zone root) {
|
||||
if (root.getNodes().isEmpty())
|
||||
return 0;
|
||||
private static int getTotalMapSize() {
|
||||
|
||||
int size = root.getNodes().size();
|
||||
for (Zone child : root.getNodes())
|
||||
size += getTotalMapSize(child);
|
||||
return size;
|
||||
return DbManager.getList(Enum.GameObjectType.Zone).size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +70,7 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
|
||||
// TODO replace this return with SerializationException
|
||||
|
||||
Zone root = ZoneManager.getSeaFloor();
|
||||
Zone root = ZoneManager.seaFloor;
|
||||
if (root == null) {
|
||||
Logger.error("Failed to find Sea Floor!");
|
||||
return;
|
||||
@@ -86,11 +83,10 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
writer.putInt(WorldServer.worldMapID);
|
||||
writer.putInt(0x00000000);
|
||||
|
||||
writer.putInt(getTotalMapSize(root) + 1);
|
||||
writer.putInt(getTotalMapSize());
|
||||
Zone.serializeForClientMsg(root, writer);
|
||||
|
||||
Zone hotzone = ZoneManager.hotZone;
|
||||
;
|
||||
|
||||
if (hotzone == null)
|
||||
writer.putLong(0L);
|
||||
@@ -99,7 +95,6 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
writer.putInt(hotzone.getObjectUUID());
|
||||
}
|
||||
|
||||
|
||||
writer.putFloat(0);
|
||||
writer.putFloat(1);
|
||||
writer.putFloat(0);
|
||||
|
||||
@@ -12,12 +12,10 @@ package engine.objects;
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.job.AbstractJob;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
@@ -27,8 +25,10 @@ import engine.jobs.TrackJob;
|
||||
import engine.math.AtomicFloat;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.utilities.PathingUtilities;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -39,6 +39,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -52,8 +53,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
public int contractUUID;
|
||||
public Contract contract;
|
||||
|
||||
protected String firstName;
|
||||
protected String lastName;
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
protected short statStrCurrent;
|
||||
protected short statDexCurrent;
|
||||
protected short statConCurrent;
|
||||
@@ -71,7 +72,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
public Guild guild;
|
||||
protected byte runningTrains;
|
||||
protected ConcurrentHashMap<Integer, CharacterPower> powers;
|
||||
protected ConcurrentHashMap<String, CharacterSkill> skills;
|
||||
public ConcurrentHashMap<String, CharacterSkill> skills;
|
||||
// Variables NOT to be stored in db
|
||||
protected boolean sit = false;
|
||||
protected boolean walkMode;
|
||||
@@ -88,20 +89,20 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
protected AtomicFloat mana = new AtomicFloat();
|
||||
protected float manaMax; // Health/Mana/Stamina
|
||||
protected AtomicBoolean isAlive = new AtomicBoolean(true);
|
||||
protected Resists resists = new Resists("Genric");
|
||||
public Resists resists = new Resists("Genric");
|
||||
protected ConcurrentHashMap<String, JobContainer> timers;
|
||||
protected ConcurrentHashMap<String, Long> timestamps;
|
||||
protected int atrHandOne;
|
||||
protected int atrHandTwo;
|
||||
protected int minDamageHandOne;
|
||||
protected int maxDamageHandOne;
|
||||
protected int minDamageHandTwo;
|
||||
protected int maxDamageHandTwo;
|
||||
protected float rangeHandOne;
|
||||
protected float rangeHandTwo;
|
||||
protected float speedHandOne;
|
||||
protected float speedHandTwo;
|
||||
protected int defenseRating;
|
||||
public int atrHandOne;
|
||||
public int atrHandTwo;
|
||||
public int minDamageHandOne;
|
||||
public int maxDamageHandOne;
|
||||
public int minDamageHandTwo;
|
||||
public int maxDamageHandTwo;
|
||||
public float rangeHandOne;
|
||||
public float rangeHandTwo;
|
||||
public float speedHandOne;
|
||||
public float speedHandTwo;
|
||||
public int defenseRating;
|
||||
protected boolean isActive; // <-Do not use this for deleting character!
|
||||
protected float altitude = 0; // 0=on terrain, 1=tier 1, 2=tier 2, etc.
|
||||
protected ConcurrentHashMap<Integer, JobContainer> recycleTimers;
|
||||
@@ -117,16 +118,42 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
protected boolean movingUp = false;
|
||||
private float desiredAltitude = 0;
|
||||
private long takeOffTime = 0;
|
||||
private float hateValue = 0;
|
||||
private long lastHateUpdate = 0;
|
||||
private boolean collided = false;
|
||||
private byte aoecntr = 0;
|
||||
|
||||
public Vector3fImmutable destination = Vector3fImmutable.ZERO;
|
||||
|
||||
public int hidden = 0; // current rank of hide/sneak/invis
|
||||
public CopyOnWriteArrayList<Integer> minions = new CopyOnWriteArrayList();
|
||||
|
||||
public ArrayList<CharacterRune> runes;
|
||||
|
||||
public ArrayList<PathingUtilities.Node> navPath = new ArrayList<>();
|
||||
public boolean isPathing = false;
|
||||
|
||||
public AbstractCharacter() {
|
||||
super();
|
||||
this.firstName = "";
|
||||
this.lastName = "";
|
||||
|
||||
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.statStrCurrent = (short) 0;
|
||||
this.statDexCurrent = (short) 0;
|
||||
this.statConCurrent = (short) 0;
|
||||
this.statIntCurrent = (short) 0;
|
||||
this.statSpiCurrent = (short) 0;
|
||||
|
||||
this.unusedStatPoints = (short) 0;
|
||||
|
||||
this.level = (short) 0; // TODO get this from MobsBase later
|
||||
this.exp = 1;
|
||||
this.walkMode = true;
|
||||
this.bindLoc = Vector3fImmutable.ZERO;
|
||||
this.faceDir = Vector3fImmutable.ZERO;
|
||||
|
||||
this.runningTrains = (byte) 0;
|
||||
|
||||
this.skills = new ConcurrentHashMap<>();
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
this.initializeCharacter();
|
||||
|
||||
}
|
||||
@@ -214,8 +241,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +283,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,8 +314,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,9 +363,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
public static int getBankCapacity() {
|
||||
@@ -504,10 +522,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public static void teleport(AbstractCharacter worldObject, final Vector3fImmutable targetLoc) {
|
||||
Regions targetRegion = Regions.GetRegionForTeleport(targetLoc);
|
||||
worldObject.locationLock.writeLock().lock();
|
||||
try {
|
||||
MovementManager.translocate(worldObject, targetLoc, targetRegion);
|
||||
MovementManager.translocate(worldObject, targetLoc);
|
||||
if (worldObject.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) worldObject);
|
||||
} catch (Exception e) {
|
||||
@@ -823,6 +840,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
if (this.isCasting && this.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
return false;
|
||||
|
||||
if(this.getObjectType().equals(GameObjectType.Mob)){
|
||||
if(this.destination.equals(Vector3fImmutable.ZERO))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -975,8 +996,27 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
|
||||
@Override
|
||||
public final void setLoc(final Vector3fImmutable value) {
|
||||
super.setLoc(value); // set the location in the world
|
||||
|
||||
Regions region = Regions.getRegionAtLocation(value);
|
||||
float regionHeightOffset = 0;
|
||||
if(region != null){
|
||||
this.region = region;
|
||||
regionHeightOffset = region.lerpY(this.loc);
|
||||
this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc
|
||||
this.inBuildingID = region.parentBuildingID;
|
||||
this.inFloorID = region.room;
|
||||
} else {
|
||||
this.region = null;
|
||||
this.inBuilding = -1;
|
||||
this.inBuildingID = 0;
|
||||
this.inFloorID = -1;
|
||||
}
|
||||
|
||||
float terrainHeight = Terrain.getWorldHeight(value);
|
||||
Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z);
|
||||
super.setLoc(finalLocation); // set the location in the world
|
||||
this.resetLastSetLocUpdate();
|
||||
|
||||
}
|
||||
|
||||
public Vector3fImmutable getMovementLoc() {
|
||||
@@ -1096,6 +1136,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public final void setCombatTarget(final AbstractWorldObject value) {
|
||||
|
||||
if(this.getObjectTypeMask() == 2050) {//MOB?
|
||||
if (value == null) {
|
||||
if (this.isCombat()) {
|
||||
@@ -1113,7 +1154,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.combatTarget = value;
|
||||
|
||||
}
|
||||
|
||||
public final ConcurrentHashMap<String, JobContainer> getTimers() {
|
||||
@@ -1230,11 +1273,29 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
CombatManager.handleRetaliate(this, attacker);
|
||||
}
|
||||
|
||||
if(this.getObjectType().equals(GameObjectType.Mob)){
|
||||
//handle hate value addition
|
||||
Mob target = (Mob)this;
|
||||
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value);
|
||||
if (target.isPlayerGuard()){
|
||||
if(target.guardedCity != null && target.guardedCity.cityOutlaws.contains(attacker.getObjectUUID()) == false)
|
||||
target.guardedCity.cityOutlaws.add(attacker.getObjectUUID());
|
||||
}
|
||||
}
|
||||
} else if(this.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
City playerCity = ZoneManager.getCityAtLocation(this.loc);
|
||||
if(playerCity != null){
|
||||
if(!attacker.getGuild().getNation().equals(playerCity.getGuild().getNation()))
|
||||
if(!playerCity.getGuild().getNation().getAllyList().contains(attacker.getGuild().getNation()))
|
||||
if(!playerCity.cityOutlaws.contains(attacker.getObjectUUID()))
|
||||
playerCity.cityOutlaws.add(attacker.getObjectUUID());
|
||||
}
|
||||
}
|
||||
return newHealth - oldHealth;
|
||||
} finally {
|
||||
this.healthLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -1420,10 +1481,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public void teleport(final Vector3fImmutable targetLoc) {
|
||||
Regions targetRegion = Regions.GetRegionForTeleport(targetLoc);
|
||||
locationLock.writeLock().lock();
|
||||
try {
|
||||
MovementManager.translocate(this, targetLoc, targetRegion);
|
||||
MovementManager.translocate(this, targetLoc);
|
||||
MovementManager.sendRWSSMsg(this);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
@@ -1758,29 +1818,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.inBuildingID = inBuildingID;
|
||||
}
|
||||
|
||||
public float getHateValue() {
|
||||
if (this.hateValue <= 0) {
|
||||
this.hateValue = 0;
|
||||
return hateValue;
|
||||
}
|
||||
|
||||
if (this.lastHateUpdate == 0) {
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
return this.hateValue;
|
||||
}
|
||||
long duration = System.currentTimeMillis() - this.lastHateUpdate;
|
||||
//convert duration to seconds and multiply Hate Delimiter.
|
||||
float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER;
|
||||
this.hateValue -= modAmount;
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
return this.hateValue;
|
||||
}
|
||||
|
||||
public void setHateValue(float hateValue) {
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
this.hateValue = hateValue;
|
||||
}
|
||||
|
||||
public int getInFloorID() {
|
||||
return inFloorID;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import ch.claude_martin.enumbitset.EnumBitSet;
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ModType;
|
||||
@@ -32,6 +33,19 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
public boolean assist = false;
|
||||
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
|
||||
|
||||
public AbstractCharacter guardCaptain;
|
||||
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
;
|
||||
public Enum.MobBehaviourType behaviourType;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||
public int lastPatrolPointIndex = 0;
|
||||
public long stopPatrolTime = 0;
|
||||
public City guardedCity;
|
||||
|
||||
public AbstractIntelligenceAgent() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
@@ -87,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
this.agentType = Enum.AIAgentType.CHARMED;
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob)) {
|
||||
((Mob) this).setOwner(owner);
|
||||
|
||||
((Mob) this).guardCaptain = owner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,20 +125,12 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public PlayerCharacter getOwner() {
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob))
|
||||
return this.getOwner();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean getSafeZone() {
|
||||
|
||||
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
|
||||
|
||||
for (Zone zone : allIn)
|
||||
if (zone.getSafeZone() == (byte) 1)
|
||||
if (zone.peace_zone == (byte) 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -156,9 +163,11 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
this.setCombatTarget(null);
|
||||
}
|
||||
|
||||
//clear owner
|
||||
// clear owner and set not alive
|
||||
|
||||
PlayerCharacter owner = this.getOwner();
|
||||
this.isAlive.set(false);
|
||||
|
||||
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
|
||||
|
||||
//close pet window
|
||||
|
||||
@@ -174,7 +183,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
owner.setPet(null);
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob))
|
||||
((Mob) this).setOwner(null);
|
||||
this.guardCaptain = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import engine.Enum.DispatchChannel;
|
||||
import engine.Enum.EffectSourceType;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.GridObjectType;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.job.JobContainer;
|
||||
@@ -179,7 +179,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
if (region.center.y == region.highLerp.y)
|
||||
worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude());
|
||||
else
|
||||
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject) + worldObject.getAltitude());
|
||||
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject.loc) + worldObject.getAltitude());
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
Mob mob = (Mob) this;
|
||||
if (mob.isSiege()) {
|
||||
if (mob.isPet()) {
|
||||
PlayerCharacter petOwner = mob.getOwner();
|
||||
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain;
|
||||
if (petOwner != null && source.equals(EffectSourceType.Effect)) {
|
||||
petOwner.dismissPet();
|
||||
return;
|
||||
@@ -500,7 +502,13 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
return;
|
||||
this.lastLoc = new Vector3fImmutable(this.loc);
|
||||
this.loc = loc;
|
||||
this.loc = this.loc.setY(HeightMap.getWorldHeight(this) + this.getAltitude());
|
||||
|
||||
if(this instanceof AbstractCharacter && this.region != null){
|
||||
this.loc = this.loc.setY(this.region.lerpY(this.loc) + this.getAltitude());
|
||||
} else{
|
||||
this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||
}
|
||||
|
||||
|
||||
//lets not add mob to world grid if he is currently despawned.
|
||||
if (this.getObjectType().equals(GameObjectType.Mob) && ((Mob) this).despawned)
|
||||
@@ -608,9 +616,6 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
this.movingUp = movingUp;
|
||||
}
|
||||
|
||||
public void setRegion(Regions region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
//used for interestmanager loading and unloading objects to client.
|
||||
// if not in grid, unload from player.
|
||||
|
||||
@@ -13,7 +13,6 @@ import engine.Enum;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.Enum.SiegePhase;
|
||||
import engine.Enum.SiegeResult;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.archive.BaneRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
@@ -135,7 +134,7 @@ public final class Bane {
|
||||
|
||||
// Cannot place banestone underwater;
|
||||
|
||||
if (HeightMap.isLocUnderwater(player.getLoc())) {
|
||||
if (ZoneManager.isLocUnderwater(player.getLoc())) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater
|
||||
return false;
|
||||
}
|
||||
@@ -163,8 +162,8 @@ public final class Bane {
|
||||
|
||||
// Cannot place assets on a dead tree
|
||||
|
||||
if ((cityZone.isPlayerCity()) &&
|
||||
(City.getCity(cityZone.getPlayerCityUUID()).getTOL().getRank() == -1)) {
|
||||
if ((cityZone.guild_zone) &&
|
||||
(City.getCity(cityZone.playerCityUUID).getTOL().getRank() == -1)) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot bane a dead tree!");
|
||||
return false;
|
||||
}
|
||||
|
||||
+122
-297
@@ -11,8 +11,8 @@ package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.RealmMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
@@ -34,6 +34,8 @@ import engine.net.client.msg.UpdateObjectMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -55,6 +57,7 @@ public class Building extends AbstractWorldObject {
|
||||
private final HashMap<Integer, DoorCloseJob> doorJobs = new HashMap<>();
|
||||
public int meshUUID;
|
||||
public Zone parentZone;
|
||||
public int parentZoneUUID;
|
||||
public boolean reverseKOS;
|
||||
public int reserve = 0;
|
||||
public float statLat;
|
||||
@@ -62,7 +65,6 @@ public class Building extends AbstractWorldObject {
|
||||
public float statAlt;
|
||||
public LocalDateTime upgradeDateTime = null;
|
||||
public LocalDateTime taxDateTime = null;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>();
|
||||
public ArrayList<Vector3fImmutable> sentryPoints = new ArrayList<>();
|
||||
public TaxType taxType = TaxType.NONE;
|
||||
public int taxAmount;
|
||||
@@ -75,11 +77,14 @@ public class Building extends AbstractWorldObject {
|
||||
public int level;
|
||||
public AtomicBoolean isDeranking = new AtomicBoolean(false);
|
||||
public LocalDateTime maintDateTime;
|
||||
protected Resists resists;
|
||||
/* The Blueprint class has methods able to derive
|
||||
* all defining characteristics of this building,
|
||||
*/
|
||||
private int blueprintUUID = 0;
|
||||
public int blueprintUUID = 0;
|
||||
public int rank;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||
public ProtectionState protectionState = ProtectionState.NONE;
|
||||
protected Resists resists;
|
||||
private float w = 1.0f;
|
||||
private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
private int doorState = 0;
|
||||
@@ -88,16 +93,16 @@ public class Building extends AbstractWorldObject {
|
||||
private int maxGold;
|
||||
private int effectFlags = 0;
|
||||
private String name = "";
|
||||
private int rank;
|
||||
private boolean ownerIsNPC = true;
|
||||
private boolean spireIsActive = false;
|
||||
private ConcurrentHashMap<String, JobContainer> timers = null;
|
||||
private ConcurrentHashMap<String, Long> timestamps = null;
|
||||
private ConcurrentHashMap<Integer, BuildingFriends> friends = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<Integer, Condemned> condemned = new ConcurrentHashMap<>();
|
||||
private ProtectionState protectionState = ProtectionState.NONE;
|
||||
private ConcurrentHashMap<Integer, BuildingFriends> friends;
|
||||
private ConcurrentHashMap<Integer, Condemned> condemned;
|
||||
private ArrayList<Building> children = null;
|
||||
|
||||
public ArrayList<Path2D.Float> meshes;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -106,27 +111,23 @@ public class Building extends AbstractWorldObject {
|
||||
super(rs);
|
||||
|
||||
float scale;
|
||||
Blueprint blueprint = null;
|
||||
|
||||
try {
|
||||
this.meshUUID = rs.getInt("meshUUID");
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
this.blueprintUUID = rs.getInt("blueprintUUID");
|
||||
this.gridObjectType = GridObjectType.STATIC;
|
||||
this.parentZone = DbManager.ZoneQueries.GET_BY_UID(rs.getLong("parent"));
|
||||
this.parentZoneUUID = rs.getInt("parent");
|
||||
this.name = rs.getString("name");
|
||||
this.ownerUUID = rs.getInt("ownerUUID");
|
||||
|
||||
// Orphaned Object Sanity Check
|
||||
//This was causing ABANDONED Tols.
|
||||
// if (objectType == DbObjectType.INVALID)
|
||||
// this.ownerUUID = 0;
|
||||
|
||||
this.doorState = rs.getInt("doorState");
|
||||
this.setHealth(rs.getInt("currentHP"));
|
||||
this.w = rs.getFloat("w");
|
||||
this.setRot(new Vector3f(0f, rs.getFloat("rotY"), 0f));
|
||||
this.reverseKOS = rs.getByte("reverseKOS") == 1 ? true : false;
|
||||
this.reverseKOS = rs.getByte("reverseKOS") == 1;
|
||||
this.statLat = rs.getFloat("locationX");
|
||||
this.statAlt = rs.getFloat("locationY");
|
||||
this.statLon = rs.getFloat("locationZ");
|
||||
|
||||
scale = rs.getFloat("scale");
|
||||
this.meshScale = new Vector3f(scale, scale, scale);
|
||||
@@ -143,79 +144,10 @@ public class Building extends AbstractWorldObject {
|
||||
this.level = rs.getInt("level");
|
||||
this.isFurniture = (rs.getBoolean("isFurniture"));
|
||||
|
||||
// Lookup building blueprint
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
blueprint = Blueprint._meshLookup.get(meshUUID);
|
||||
else
|
||||
blueprint = this.getBlueprint();
|
||||
|
||||
// Log error if something went horrible wrong
|
||||
|
||||
if ((this.blueprintUUID != 0) && (blueprint == null))
|
||||
Logger.error("Invalid blueprint for object: " + this.getObjectUUID());
|
||||
|
||||
// Note: We handle R8 tree edge case for mesh and health
|
||||
// after city is loaded to avoid recursive result set call
|
||||
// in City resulting in a stack ovreflow.
|
||||
|
||||
if (blueprint != null) {
|
||||
|
||||
// Only switch mesh for player dropped structures
|
||||
|
||||
if (this.blueprintUUID != 0)
|
||||
this.meshUUID = blueprint.getMeshForRank(rank);
|
||||
|
||||
this.healthMax = blueprint.getMaxHealth(this.rank);
|
||||
|
||||
// If this object has no blueprint but is a blueprint
|
||||
// mesh then set it's current health to max health
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
this.setHealth(healthMax);
|
||||
|
||||
if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK))
|
||||
this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this);
|
||||
|
||||
} else {
|
||||
this.healthMax = 100000; // Structures with no blueprint mesh
|
||||
this.setHealth(healthMax);
|
||||
}
|
||||
|
||||
// Null out blueprint if not needed (npc building)
|
||||
|
||||
if (blueprintUUID == 0)
|
||||
blueprint = null;
|
||||
|
||||
resists = new Resists("Building");
|
||||
this.statLat = rs.getFloat("locationX");
|
||||
this.statAlt = rs.getFloat("locationY");
|
||||
this.statLon = rs.getFloat("locationZ");
|
||||
|
||||
if (this.parentZone != null) {
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
if (parentBuilding != null) {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon));
|
||||
} else {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ));
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
// Altitude of this building is derived from the heightmap engine.
|
||||
|
||||
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ);
|
||||
tempLoc = new Vector3fImmutable(tempLoc.x, HeightMap.getWorldHeight(tempLoc), tempLoc.z);
|
||||
this.setLoc(tempLoc);
|
||||
}
|
||||
}
|
||||
|
||||
this._strongboxValue = rs.getInt("currentGold");
|
||||
this.maxGold = 15000000; // *** Refactor to blueprint method
|
||||
this.reserve = rs.getInt("reserve");
|
||||
|
||||
// Does building have a protection contract?
|
||||
this.taxType = TaxType.valueOf(rs.getString("taxType"));
|
||||
this.taxAmount = rs.getInt("taxAmount");
|
||||
this.protectionState = ProtectionState.valueOf(rs.getString("protectionState"));
|
||||
@@ -236,8 +168,7 @@ public class Building extends AbstractWorldObject {
|
||||
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString());
|
||||
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,86 +281,6 @@ public class Building extends AbstractWorldObject {
|
||||
return rank;
|
||||
}
|
||||
|
||||
public final void setRank(int newRank) {
|
||||
|
||||
int newMeshUUID;
|
||||
boolean success;
|
||||
|
||||
|
||||
// If this building has no blueprint then set rank and exit immediatly.
|
||||
|
||||
if (this.blueprintUUID == 0 || this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) {
|
||||
this.rank = newRank;
|
||||
DbManager.BuildingQueries.CHANGE_RANK(this.getObjectUUID(), newRank);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete any upgrade jobs before doing anything else. It won't quite work
|
||||
// if in a few lines we happen to delete this building.
|
||||
|
||||
JobContainer jc = this.getTimers().get("UPGRADE");
|
||||
|
||||
if (jc != null) {
|
||||
if (!JobScheduler.getInstance().cancelScheduledJob(jc))
|
||||
Logger.error("failed to cancel existing upgrade job.");
|
||||
}
|
||||
|
||||
// Attempt write to database, or delete the building
|
||||
// if we are destroying it.
|
||||
|
||||
if (newRank == -1)
|
||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(this);
|
||||
else
|
||||
success = DbManager.BuildingQueries.updateBuildingRank(this, newRank);
|
||||
|
||||
if (success == false) {
|
||||
Logger.error("Error writing to database UUID: " + this.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
this.isDeranking.compareAndSet(false, true);
|
||||
|
||||
// Change the building's rank
|
||||
|
||||
this.rank = newRank;
|
||||
|
||||
// New rank means new mesh
|
||||
|
||||
newMeshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
this.meshUUID = newMeshUUID;
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
||||
this.setCurrentHitPoints(this.healthMax);
|
||||
|
||||
if (this.getUpgradeDateTime() != null)
|
||||
BuildingManager.setUpgradeDateTime(this, null, 0);
|
||||
|
||||
// If we destroyed this building make sure to turn off
|
||||
// protection
|
||||
|
||||
if (this.rank == -1)
|
||||
this.protectionState = ProtectionState.NONE;
|
||||
|
||||
if ((this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
&& (this.rank == 8))
|
||||
this.meshUUID = Realm.getRealmMesh(this.getCity());
|
||||
;
|
||||
|
||||
// update object to clients
|
||||
|
||||
this.refresh(true);
|
||||
if (this.getBounds() != null)
|
||||
this.getBounds().setBounds(this);
|
||||
|
||||
// Cleanup hirelings resulting from rank change
|
||||
|
||||
BuildingManager.cleanupHirelings(this);
|
||||
|
||||
this.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
|
||||
public final int getOwnerUUID() {
|
||||
return ownerUUID;
|
||||
}
|
||||
@@ -446,24 +297,24 @@ public class Building extends AbstractWorldObject {
|
||||
if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)) {
|
||||
if (this.getGuild() != null) {
|
||||
if (this.getGuild().getOwnedCity() != null) {
|
||||
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.extents))
|
||||
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
||||
return this.getGuild().getOwnedCity();
|
||||
} else {
|
||||
Bane bane = Bane.getBaneByAttackerGuild(this.getGuild());
|
||||
|
||||
if (bane != null) {
|
||||
if (bane.getCity() != null) {
|
||||
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.extents))
|
||||
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
||||
return bane.getCity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.parentZone.isPlayerCity() == false)
|
||||
if (this.parentZone.guild_zone == false)
|
||||
return null;
|
||||
|
||||
return City.getCity(this.parentZone.getPlayerCityUUID());
|
||||
return City.getCity(this.parentZone.playerCityUUID);
|
||||
|
||||
}
|
||||
|
||||
@@ -537,6 +388,18 @@ public class Building extends AbstractWorldObject {
|
||||
if (value < 0)
|
||||
Mine.SendMineAttackMessage(this);
|
||||
|
||||
City playerCity = ZoneManager.getCityAtLocation(this.loc);
|
||||
if (playerCity != null) {
|
||||
if (this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())) {
|
||||
//friendly building has been attacked, add attacker to city outlaw list
|
||||
if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
playerCity.cityOutlaws.add(attacker.getObjectUUID());
|
||||
for (Mob guard : playerCity.getParent().zoneMobSet)
|
||||
if (guard.combatTarget == null)
|
||||
guard.setCombatTarget(attacker);
|
||||
}
|
||||
}
|
||||
|
||||
return newHealth - oldHealth;
|
||||
|
||||
|
||||
@@ -589,7 +452,7 @@ public class Building extends AbstractWorldObject {
|
||||
MineRecord mineRecord = MineRecord.borrow(mine, attacker, RecordEventType.DESTROY);
|
||||
DataWarehouse.pushToWarehouse(mineRecord);
|
||||
|
||||
this.setRank(-1);
|
||||
BuildingManager.setRank(this, -1);
|
||||
this.setCurrentHitPoints((float) 1);
|
||||
this.healthMax = (float) 1;
|
||||
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
@@ -612,9 +475,9 @@ public class Building extends AbstractWorldObject {
|
||||
// Time to either derank or destroy the building.
|
||||
|
||||
if ((this.rank - 1) < 1)
|
||||
this.setRank(-1);
|
||||
BuildingManager.setRank(this, -1);
|
||||
else
|
||||
this.setRank(this.rank - 1);
|
||||
BuildingManager.setRank(this, this.rank - 1);
|
||||
|
||||
}
|
||||
|
||||
@@ -672,7 +535,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
if (spireBuilding != null) {
|
||||
spireBuilding.disableSpire(true);
|
||||
spireBuilding.setRank(-1);
|
||||
BuildingManager.setRank(spireBuilding, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,7 +546,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Delete a random shrine
|
||||
|
||||
if (shrineBuilding != null)
|
||||
shrineBuilding.setRank(-1);
|
||||
BuildingManager.setRank(shrineBuilding, -1);
|
||||
}
|
||||
|
||||
if (barracksBuildings.size() > this.rank - 1) {
|
||||
@@ -693,7 +556,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Delete a random barrack
|
||||
|
||||
if (barracksBuilding != null)
|
||||
barracksBuilding.setRank(-1);
|
||||
BuildingManager.setRank(barracksBuilding, -1);
|
||||
}
|
||||
|
||||
// If the tree is R8 and deranking, we need to update it's
|
||||
@@ -722,7 +585,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Let's do so and early exit
|
||||
|
||||
if (this.rank > 1) {
|
||||
this.setRank(rank - 1);
|
||||
BuildingManager.setRank(this, rank - 1);
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
@@ -840,10 +703,6 @@ public class Building extends AbstractWorldObject {
|
||||
return this.meshUUID;
|
||||
}
|
||||
|
||||
public final void setMeshUUID(int value) {
|
||||
this.meshUUID = value;
|
||||
}
|
||||
|
||||
public final Resists getResists() {
|
||||
return this.resists;
|
||||
}
|
||||
@@ -930,13 +789,8 @@ public class Building extends AbstractWorldObject {
|
||||
DispatchMessage.sendToAllInRange(this, applyBuildingEffectMsg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utils
|
||||
*/
|
||||
|
||||
public void removeEffectBit(int bit) {
|
||||
this.effectFlags &= (~bit);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -953,26 +807,18 @@ public class Building extends AbstractWorldObject {
|
||||
this.updateName();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Serializing
|
||||
*/
|
||||
|
||||
public final AbstractCharacter getOwner() {
|
||||
|
||||
if (this.ownerUUID == 0)
|
||||
return null;
|
||||
if (this.ownerIsNPC)
|
||||
return NPC.getFromCache(this.ownerUUID);
|
||||
|
||||
return PlayerCharacter.getFromCache(this.ownerUUID);
|
||||
if (this.ownerIsNPC)
|
||||
return NPC.getNPC(this.ownerUUID);
|
||||
|
||||
return PlayerCharacter.getPlayerCharacter(this.ownerUUID);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Database
|
||||
*/
|
||||
|
||||
public final String getOwnerName() {
|
||||
AbstractCharacter owner = this.getOwner();
|
||||
if (owner != null)
|
||||
@@ -1033,19 +879,6 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
// *** Refactor: Can't we just use setRank() for this?
|
||||
|
||||
public final void rebuildMine() {
|
||||
this.setRank(1);
|
||||
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
||||
this.setCurrentHitPoints(this.healthMax);
|
||||
this.getBounds().setBounds(this);
|
||||
}
|
||||
|
||||
public final void refreshGuild() {
|
||||
|
||||
UpdateObjectMsg uom = new UpdateObjectMsg(this, 5);
|
||||
@@ -1057,15 +890,78 @@ public class Building extends AbstractWorldObject {
|
||||
return maxGold;
|
||||
}
|
||||
|
||||
//This returns if a player is allowed access to control the building
|
||||
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
try {
|
||||
// Set Parent Zone
|
||||
|
||||
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID);
|
||||
this.parentZone.zoneBuildingSet.add(this);
|
||||
|
||||
// Lookup building blueprint
|
||||
|
||||
Blueprint blueprint;
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
blueprint = Blueprint._meshLookup.get(meshUUID);
|
||||
else
|
||||
blueprint = this.getBlueprint();
|
||||
|
||||
// Log error if something went horrible wrong
|
||||
|
||||
if ((this.blueprintUUID != 0) && (blueprint == null))
|
||||
Logger.error("Invalid blueprint for object: " + this.getObjectUUID());
|
||||
|
||||
// Note: We handle R8 tree edge case for mesh and health
|
||||
// after city is loaded to avoid recursive result set call
|
||||
// in City resulting in a stack ovreflow.
|
||||
|
||||
if (blueprint != null) {
|
||||
|
||||
// Only switch mesh for player dropped structures
|
||||
|
||||
if (this.blueprintUUID != 0)
|
||||
this.meshUUID = blueprint.getMeshForRank(rank);
|
||||
|
||||
this.healthMax = blueprint.getMaxHealth(this.rank);
|
||||
|
||||
// If this object has no blueprint but is a blueprint
|
||||
// mesh then set it's current health to max health
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
this.setHealth(healthMax);
|
||||
|
||||
this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>());
|
||||
|
||||
if (this.patrolPoints == null)
|
||||
Logger.error("Null patrol points");
|
||||
|
||||
} else {
|
||||
this.healthMax = 100000; // Structures with no blueprint mesh
|
||||
this.setHealth(healthMax);
|
||||
}
|
||||
|
||||
resists = new Resists("Building");
|
||||
|
||||
if (this.parentZone != null) {
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
if (parentBuilding != null) {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon));
|
||||
} else {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ));
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
// Altitude of this building is derived from the heightmap engine.
|
||||
|
||||
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ);
|
||||
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z);
|
||||
this.setLoc(tempLoc);
|
||||
}
|
||||
}
|
||||
|
||||
// Submit upgrade job if building is currently set to rank.
|
||||
|
||||
try {
|
||||
@@ -1076,52 +972,10 @@ public class Building extends AbstractWorldObject {
|
||||
Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
}
|
||||
|
||||
try {
|
||||
DbManager.BuildingQueries.LOAD_ALL_FRIENDS_FOR_BUILDING(this);
|
||||
DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this);
|
||||
} catch (Exception e) {
|
||||
Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage());
|
||||
}
|
||||
// Reference friend and condemn lists from BuildingManager
|
||||
|
||||
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
||||
|
||||
if (this.ownerIsNPC) {
|
||||
if (NPC.getNPC(this.ownerUUID) == null)
|
||||
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
|
||||
} else if (this.ownerUUID != 0) {
|
||||
if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) {
|
||||
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Apply health bonus and special mesh for realm if applicable
|
||||
if ((this.getCity() != null) && this.getCity().getTOL() != null && (this.getCity().getTOL().rank == 8)) {
|
||||
|
||||
// Update mesh accordingly
|
||||
if (this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
this.meshUUID = Realm.getRealmMesh(this.getCity());
|
||||
|
||||
// Apply realm capital health bonus.
|
||||
// Do not apply bonus to banestones or TOL's. *** Refactor:
|
||||
// Possibly only protected buildings? Needs some thought.
|
||||
|
||||
float missingHealth = 0;
|
||||
|
||||
if (this.health.get() != 0)
|
||||
missingHealth = this.healthMax - this.health.get();
|
||||
|
||||
if ((this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() != BuildingGroup.TOL)
|
||||
&& (this.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)) {
|
||||
this.healthMax += (this.healthMax * Realm.getRealmHealthMod(this.getCity()));
|
||||
|
||||
if (this.health.get() != 0)
|
||||
this.health.set(this.healthMax - missingHealth);
|
||||
|
||||
if (this.health.get() > this.healthMax)
|
||||
this.health.set(this.healthMax);
|
||||
}
|
||||
}
|
||||
this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>());
|
||||
this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>());
|
||||
|
||||
// Set bounds for this building
|
||||
|
||||
@@ -1136,7 +990,7 @@ public class Building extends AbstractWorldObject {
|
||||
this.children = new ArrayList<>();
|
||||
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parent = BuildingManager.getBuildingFromCache(this.parentBuildingID);
|
||||
Building parent = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
|
||||
if (parent != null) {
|
||||
parent.children.add(this);
|
||||
@@ -1144,6 +998,7 @@ public class Building extends AbstractWorldObject {
|
||||
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
||||
|
||||
Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z);
|
||||
|
||||
if (region != null)
|
||||
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region);
|
||||
}
|
||||
@@ -1153,9 +1008,7 @@ public class Building extends AbstractWorldObject {
|
||||
if (this.upgradeDateTime != null)
|
||||
BuildingManager.submitUpgradeJob(this);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BuildingManager.bakeNavMesh(this); // update the navmesh of the parent zone
|
||||
}
|
||||
|
||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||
@@ -1181,7 +1034,6 @@ public class Building extends AbstractWorldObject {
|
||||
this.ownerIsNPC = (newOwner.getObjectType() == GameObjectType.NPC);
|
||||
}
|
||||
|
||||
|
||||
// Set new guild for hirelings and refresh all clients
|
||||
|
||||
this.refreshGuild();
|
||||
@@ -1301,7 +1153,7 @@ public class Building extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
// Save to database ?
|
||||
if (updateRecord == true)
|
||||
if (updateRecord)
|
||||
return DbManager.BuildingQueries.UPDATE_DOOR_LOCK(this.getObjectUUID(), this.doorState);
|
||||
else
|
||||
return true;
|
||||
@@ -1337,7 +1189,6 @@ public class Building extends AbstractWorldObject {
|
||||
this.spireIsActive = true;
|
||||
this.updateEffects();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final void disableSpire(boolean refreshEffect) {
|
||||
@@ -1390,7 +1241,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Buildings on an npc citygrid are never vulnerable
|
||||
|
||||
if (this.getCity() != null) {
|
||||
if (this.getCity().getParent().isNPCCity() == true)
|
||||
if (this.getCity().getParent().isNPCCity == true)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1546,10 +1397,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
public boolean assetIsProtected() {
|
||||
|
||||
boolean outValue = false;
|
||||
|
||||
if (protectionState.equals(ProtectionState.PROTECTED))
|
||||
outValue = true;
|
||||
boolean outValue = protectionState.equals(ProtectionState.PROTECTED);
|
||||
|
||||
if (protectionState.equals(ProtectionState.CONTRACT))
|
||||
outValue = true;
|
||||
@@ -1626,18 +1474,10 @@ public class Building extends AbstractWorldObject {
|
||||
return patrolPoints;
|
||||
}
|
||||
|
||||
public void setPatrolPoints(ArrayList<Vector3fImmutable> patrolPoints) {
|
||||
this.patrolPoints = patrolPoints;
|
||||
}
|
||||
|
||||
public ArrayList<Vector3fImmutable> getSentryPoints() {
|
||||
return sentryPoints;
|
||||
}
|
||||
|
||||
public void setSentryPoints(ArrayList<Vector3fImmutable> sentryPoints) {
|
||||
this.sentryPoints = sentryPoints;
|
||||
}
|
||||
|
||||
public synchronized boolean addProtectionTax(Building building, PlayerCharacter pc, final TaxType taxType, int amount, boolean enforceKOS) {
|
||||
if (building == null)
|
||||
return false;
|
||||
@@ -1662,14 +1502,6 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
public synchronized boolean declineTaxOffer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean acceptTaxOffer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean acceptTaxes() {
|
||||
|
||||
if (!DbManager.BuildingQueries.acceptTaxes(this))
|
||||
@@ -1694,14 +1526,6 @@ public class Building extends AbstractWorldObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isTaxed() {
|
||||
if (this.taxType == TaxType.NONE)
|
||||
return false;
|
||||
if (this.taxAmount == 0)
|
||||
return false;
|
||||
return this.taxDateTime != null;
|
||||
}
|
||||
|
||||
public void AddToBarracksList() {
|
||||
City playerCity = ZoneManager.getCityAtLocation(this.loc);
|
||||
if (playerCity != null) {
|
||||
@@ -1712,4 +1536,5 @@ public class Building extends AbstractWorldObject {
|
||||
public void RemoveFromBarracksList() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ import java.sql.SQLException;
|
||||
|
||||
public class BuildingFriends {
|
||||
|
||||
private int playerUID;
|
||||
private int buildingUID;
|
||||
private int guildUID;
|
||||
private int friendType;
|
||||
public int playerUID;
|
||||
public int buildingUID;
|
||||
public int guildUID;
|
||||
public int friendType;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
@@ -38,16 +38,4 @@ public class BuildingFriends {
|
||||
this.friendType = friendType;
|
||||
}
|
||||
|
||||
public int getPlayerUID() {
|
||||
return playerUID;
|
||||
}
|
||||
|
||||
public int getGuildUID() {
|
||||
return guildUID;
|
||||
}
|
||||
|
||||
public int getFriendType() {
|
||||
return friendType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.numTrains.set(0);
|
||||
this.ownerUID = pc.getObjectUUID();
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.ownerUID = pc.getObjectUUID();
|
||||
this.trained = true;
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
|
||||
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.numTrains.set(rs.getShort("trains"));
|
||||
this.ownerUID = pc.getObjectUUID();
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
|
||||
}
|
||||
|
||||
@@ -264,8 +264,9 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.numTrains.set(trains);
|
||||
this.ownerUID = mob.getObjectUUID();
|
||||
this.isMobOwner = true;
|
||||
calculateMobBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
boolean isGuard = mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN) || mob.agentType.equals(Enum.AIAgentType.GUARDMINION);
|
||||
calculateMobBaseAmount(isGuard);
|
||||
calculateModifiedAmount(isGuard);
|
||||
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.ownerUID = rs.getInt("CharacterID");
|
||||
// this.owner = DbManager.PlayerCharacterQueries.GET_PLAYER_CHARACTER(rs.getInt("CharacterID"));
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
|
||||
}
|
||||
|
||||
@@ -370,7 +371,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
String name = it.next();
|
||||
CharacterSkill cs = skills.get(name);
|
||||
if (cs != null)
|
||||
cs.calculateModifiedAmount();
|
||||
cs.calculateModifiedAmount(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -756,7 +757,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
|
||||
//recalculate this skill
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
|
||||
//see if any new skills or powers granted
|
||||
pc.calculateSkills();
|
||||
@@ -848,7 +849,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
if (recalculate) {
|
||||
//recalculate this skill
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
|
||||
//see if any skills or powers removed
|
||||
pc.calculateSkills();
|
||||
@@ -887,7 +888,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
if (recalculate) {
|
||||
//recalculate this skill
|
||||
calculateBaseAmount();
|
||||
calculateModifiedAmount();
|
||||
calculateModifiedAmount(false);
|
||||
|
||||
//see if any skills or powers removed
|
||||
pc.calculateSkills();
|
||||
@@ -1016,7 +1017,8 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.modifiedAmountBeforeMods = Math.round(this.baseAmountBeforeMods + calculateAmountAfterTrains());
|
||||
}
|
||||
|
||||
public void calculateMobBaseAmount() {
|
||||
public void calculateMobBaseAmount(boolean isGuard) {
|
||||
if(!isGuard) {
|
||||
if (CharacterSkill.GetOwner(this) == null) {
|
||||
Logger.error("owner not found for owner uuid : " + this.ownerUID);
|
||||
this.baseAmount = 1;
|
||||
@@ -1030,19 +1032,19 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.modifiedAmount = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
//Get any rune bonus
|
||||
float bonus = 0f;
|
||||
//TODO SKILLS RUNES
|
||||
|
||||
if (CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
//Get bonuses from runes
|
||||
bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType);
|
||||
}
|
||||
|
||||
//Get Base skill for unmodified stats
|
||||
float base = 7f;
|
||||
float statMod = 0.5f;
|
||||
if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
//Get bonuses from runes
|
||||
bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType);
|
||||
|
||||
//Get Base skill for unmodified stats
|
||||
|
||||
|
||||
if (this.skillsBase.getStrMod() > 0)
|
||||
statMod += (float) this.skillsBase.getStrMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseStr() / 100f;
|
||||
if (this.skillsBase.getDexMod() > 0)
|
||||
@@ -1057,6 +1059,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
statMod = 1f;
|
||||
else if (statMod > 600)
|
||||
statMod = 600f;
|
||||
}
|
||||
base += CharacterSkill.baseSkillValues[(int) statMod];
|
||||
|
||||
if (base + bonus < 1f)
|
||||
@@ -1066,25 +1069,27 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
this.modifiedAmountBeforeMods = (int) (this.baseAmountBeforeMods + calculateAmountAfterTrains());
|
||||
}
|
||||
|
||||
public void calculateModifiedAmount() {
|
||||
public void calculateModifiedAmount(boolean isGuard) {
|
||||
if(!isGuard) {
|
||||
if (CharacterSkill.GetOwner(this) == null || this.skillsBase == null) {
|
||||
Logger.error("owner or SkillsBase not found for skill " + this.getObjectUUID());
|
||||
this.baseAmount = 1;
|
||||
this.modifiedAmount = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
//Get any rune bonus
|
||||
float bonus = 0f;
|
||||
if (CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
float base = 7f;
|
||||
float statMod = 0.5f;
|
||||
if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
//Get bonuses from runes
|
||||
bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType);
|
||||
}
|
||||
|
||||
|
||||
//Get Base skill for modified stats
|
||||
//TODO this fomula needs verified
|
||||
float base = 7f;
|
||||
float statMod = 0.5f;
|
||||
|
||||
if (this.skillsBase.getStrMod() > 0)
|
||||
statMod += (float) this.skillsBase.getStrMod() * (float) CharacterSkill.GetOwner(this).getStatStrCurrent() / 100f;
|
||||
if (this.skillsBase.getDexMod() > 0)
|
||||
@@ -1099,12 +1104,13 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
statMod = 1f;
|
||||
else if (statMod > 600)
|
||||
statMod = 600f;
|
||||
}
|
||||
base += CharacterSkill.baseSkillValues[(int) statMod];
|
||||
SourceType sourceType = SourceType.GetSourceType(this.skillsBase.getNameNoSpace());
|
||||
|
||||
//Get any rune, effect and item bonus
|
||||
|
||||
if (CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
//add bonuses from effects/items and runes
|
||||
base += bonus + CharacterSkill.GetOwner(this).getBonuses().getFloat(ModType.Skill, sourceType);
|
||||
}
|
||||
@@ -1116,7 +1122,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
|
||||
float modAmount = this.baseAmount + calculateAmountAfterTrains();
|
||||
|
||||
if (CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) {
|
||||
//Multiply any percent bonuses
|
||||
modAmount *= (1 + CharacterSkill.GetOwner(this).getBonuses().getFloatPercentAll(ModType.Skill, sourceType));
|
||||
}
|
||||
|
||||
+157
-210
@@ -11,7 +11,6 @@ package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.RealmMap;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.archive.CityRecord;
|
||||
@@ -49,6 +48,8 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
public static long lastCityUpdate = 0;
|
||||
public final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
private final boolean isOpen = false;
|
||||
private final boolean reverseKOS = false;
|
||||
public java.time.LocalDateTime established;
|
||||
public boolean hasBeenTransfered = false;
|
||||
public LocalDateTime realmTaxDate;
|
||||
@@ -56,7 +57,8 @@ public class City extends AbstractWorldObject {
|
||||
public volatile boolean protectionEnforced = true;
|
||||
public ArrayList<Building> cityBarracks;
|
||||
public ArrayList<Integer> cityOutlaws = new ArrayList<>();
|
||||
protected Zone parentZone;
|
||||
public Zone parentZone;
|
||||
public int parentZoneUUID;
|
||||
private String cityName;
|
||||
private String motto;
|
||||
private String description;
|
||||
@@ -66,9 +68,6 @@ public class City extends AbstractWorldObject {
|
||||
private int realmID;
|
||||
private int radiusType;
|
||||
private float bindRadius;
|
||||
private float statLat;
|
||||
private float statAlt;
|
||||
private float statLon;
|
||||
private float bindX;
|
||||
private float bindZ;
|
||||
private byte isNpc; //aka Safehold
|
||||
@@ -77,15 +76,12 @@ public class City extends AbstractWorldObject {
|
||||
private boolean forceRename = false;
|
||||
private boolean noTeleport = false; //used by npc cities
|
||||
private boolean noRepledge = false; //used by npc cities
|
||||
private boolean isOpen = false;
|
||||
private int treeOfLifeID;
|
||||
private Vector3fImmutable location = Vector3fImmutable.ZERO;
|
||||
|
||||
// Players who have entered the city (used for adding and removing affects)
|
||||
private Vector3fImmutable bindLoc;
|
||||
private int warehouseBuildingID = 0;
|
||||
private boolean open = false;
|
||||
private boolean reverseKOS = false;
|
||||
private String hash;
|
||||
|
||||
/**
|
||||
@@ -95,6 +91,7 @@ public class City extends AbstractWorldObject {
|
||||
public City(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
try {
|
||||
this.parentZoneUUID = rs.getInt("parent");
|
||||
this.cityName = rs.getString("name");
|
||||
this.motto = rs.getString("motto");
|
||||
this.isNpc = rs.getByte("isNpc");
|
||||
@@ -113,10 +110,7 @@ public class City extends AbstractWorldObject {
|
||||
if (establishedTimeStamp != null)
|
||||
this.established = java.time.LocalDateTime.ofInstant(establishedTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
this.location = new Vector3fImmutable(rs.getFloat("xCoord"), rs.getFloat("yCoord"), rs.getFloat("zCoord"));
|
||||
this.statLat = rs.getFloat("xCoord");
|
||||
this.statAlt = rs.getFloat("yCoord");
|
||||
this.statLon = rs.getFloat("zCoord");
|
||||
this.location = Vector3fImmutable.ZERO;
|
||||
|
||||
java.sql.Timestamp realmTaxTimeStamp = rs.getTimestamp("realmTaxDate");
|
||||
|
||||
@@ -133,7 +127,9 @@ public class City extends AbstractWorldObject {
|
||||
this.location.getY(),
|
||||
this.location.getZ() + this.bindZ);
|
||||
this.radiusType = rs.getInt("radiusType");
|
||||
|
||||
float bindradiustemp = rs.getFloat("bindRadius");
|
||||
|
||||
if (bindradiustemp > 2)
|
||||
bindradiustemp -= 2;
|
||||
|
||||
@@ -142,47 +138,14 @@ public class City extends AbstractWorldObject {
|
||||
this.forceRename = rs.getInt("forceRename") == 1;
|
||||
this.open = rs.getInt("open") == 1;
|
||||
|
||||
if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) {
|
||||
this.noTeleport = true;
|
||||
this.noRepledge = true;
|
||||
} else {
|
||||
this.noTeleport = false;
|
||||
this.noRepledge = false;
|
||||
}
|
||||
|
||||
this.hash = rs.getString("hash");
|
||||
|
||||
if (this.motto.isEmpty()) {
|
||||
Guild guild = this.getGuild();
|
||||
|
||||
if (guild != null && guild.isEmptyGuild() == false)
|
||||
this.motto = guild.getMotto();
|
||||
}
|
||||
|
||||
|
||||
//Disabled till i finish.
|
||||
// this.reverseKOS = rs.getInt("kos") == 1;
|
||||
|
||||
|
||||
Zone zone = ZoneManager.getZoneByUUID(rs.getInt("parent"));
|
||||
|
||||
if (zone != null)
|
||||
setParent(zone);
|
||||
|
||||
//npc cities without heightmaps except swampstone are specials.
|
||||
|
||||
|
||||
this.realmID = rs.getInt("realmID");
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
// *** Refactor: Is this working? Intended to supress
|
||||
// login server errors from attempting to
|
||||
// load cities/realms along with players
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -208,7 +171,6 @@ public class City extends AbstractWorldObject {
|
||||
Logger.error("NULL TOL FOR " + city.cityName);
|
||||
}
|
||||
|
||||
|
||||
// Assign city owner
|
||||
|
||||
if (city.getTOL() != null)
|
||||
@@ -226,7 +188,8 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
rulingNation = rulingGuild.getNation();
|
||||
|
||||
// Begin Serialzing soverign guild data
|
||||
// Begin Serializing sovereign guild data
|
||||
|
||||
writer.putInt(city.getObjectType().ordinal());
|
||||
writer.putInt(city.getObjectUUID());
|
||||
writer.putString(city.cityName);
|
||||
@@ -281,7 +244,6 @@ public class City extends AbstractWorldObject {
|
||||
writer.putInt(rulingNation.getObjectUUID());
|
||||
}
|
||||
|
||||
|
||||
// Serialize nation name
|
||||
|
||||
if (rulingNation.isEmptyGuild())
|
||||
@@ -303,16 +265,8 @@ public class City extends AbstractWorldObject {
|
||||
else
|
||||
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName());
|
||||
|
||||
|
||||
writer.putLocalDateTime(city.established);
|
||||
|
||||
// writer.put((byte) city.established.getDayOfMonth());
|
||||
// writer.put((byte) city.established.minusMonths(1).getMonth().getValue());
|
||||
// writer.putInt((int) years);
|
||||
// writer.put((byte) hours);
|
||||
// writer.put((byte) minutes);
|
||||
// writer.put((byte) seconds);
|
||||
|
||||
writer.putFloat(city.location.x);
|
||||
writer.putFloat(city.location.y);
|
||||
writer.putFloat(city.location.z);
|
||||
@@ -351,6 +305,7 @@ public class City extends AbstractWorldObject {
|
||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
||||
|
||||
//add npc cities
|
||||
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
|
||||
if (ago.getObjectType().equals(GameObjectType.City)) {
|
||||
@@ -359,7 +314,7 @@ public class City extends AbstractWorldObject {
|
||||
if (city.noTeleport)
|
||||
continue;
|
||||
|
||||
if (city.parentZone != null && city.parentZone.isPlayerCity()) {
|
||||
if (city.parentZone != null && city.parentZone.guild_zone) {
|
||||
|
||||
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
|
||||
cities.add(city);
|
||||
@@ -367,6 +322,7 @@ public class City extends AbstractWorldObject {
|
||||
//list Player cities
|
||||
|
||||
//open city, just list
|
||||
|
||||
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
||||
|
||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
|
||||
@@ -376,7 +332,9 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
|
||||
} else if (city.isNpc == 1) {
|
||||
|
||||
//list NPC cities
|
||||
|
||||
Guild g = city.getGuild();
|
||||
if (g == null) {
|
||||
if (city.isNpc == 1)
|
||||
@@ -386,13 +344,9 @@ public class City extends AbstractWorldObject {
|
||||
} else if (pc.getLevel() > 9)
|
||||
cities.add(city);
|
||||
|
||||
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) {
|
||||
|
||||
|
||||
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax())
|
||||
cities.add(city);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -400,30 +354,37 @@ public class City extends AbstractWorldObject {
|
||||
return cities;
|
||||
}
|
||||
|
||||
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter pc) {
|
||||
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter playerCharacter) {
|
||||
|
||||
ArrayList<City> cities = new ArrayList<>();
|
||||
if (pc == null)
|
||||
|
||||
if (playerCharacter == null)
|
||||
return cities;
|
||||
Guild pcG = pc.getGuild();
|
||||
|
||||
Guild pcG = playerCharacter.getGuild();
|
||||
|
||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
||||
|
||||
//add npc cities
|
||||
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
if (ago.getObjectType().equals(GameObjectType.City)) {
|
||||
|
||||
City city = (City) ago;
|
||||
|
||||
if (city.noRepledge)
|
||||
continue;
|
||||
|
||||
if (city.parentZone != null && city.parentZone.isPlayerCity()) {
|
||||
if (city.parentZone != null && city.parentZone.guild_zone) {
|
||||
|
||||
//list Player cities
|
||||
//open city, just list
|
||||
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
|
||||
|
||||
if (playerCharacter.getAccount().status.equals(AccountStatus.ADMIN)) {
|
||||
cities.add(city);
|
||||
} else if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
||||
|
||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
|
||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), playerCharacter))
|
||||
cities.add(city); //verify nation or guild is same
|
||||
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG))
|
||||
cities.add(city);
|
||||
@@ -431,15 +392,16 @@ public class City extends AbstractWorldObject {
|
||||
} else if (city.isNpc == 1) {
|
||||
//list NPC cities
|
||||
|
||||
Guild g = city.getGuild();
|
||||
if (g == null) {
|
||||
Guild guild = city.getGuild();
|
||||
|
||||
if (guild == null) {
|
||||
if (city.isNpc == 1)
|
||||
if (city.isNoobIsle == 1) {
|
||||
if (pc.getLevel() < 21)
|
||||
if (playerCharacter.getLevel() < 21)
|
||||
cities.add(city);
|
||||
} else if (pc.getLevel() > 9)
|
||||
} else if (playerCharacter.getLevel() > 9)
|
||||
cities.add(city);
|
||||
} else if (pc.getLevel() >= g.getRepledgeMin() && pc.getLevel() <= g.getRepledgeMax()) {
|
||||
} else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) {
|
||||
|
||||
cities.add(city);
|
||||
}
|
||||
@@ -455,6 +417,7 @@ public class City extends AbstractWorldObject {
|
||||
return null;
|
||||
|
||||
City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId);
|
||||
|
||||
if (city != null)
|
||||
return city;
|
||||
|
||||
@@ -471,8 +434,10 @@ public class City extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean renameCity(String cityName) {
|
||||
|
||||
if (!DbManager.CityQueries.renameCity(this, cityName))
|
||||
return false;
|
||||
|
||||
if (!DbManager.CityQueries.updateforceRename(this, false))
|
||||
return false;
|
||||
|
||||
@@ -482,17 +447,22 @@ public class City extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean updateTOL(Building tol) {
|
||||
|
||||
if (tol == null)
|
||||
return false;
|
||||
|
||||
if (!DbManager.CityQueries.updateTOL(this, tol.getObjectUUID()))
|
||||
return false;
|
||||
|
||||
this.treeOfLifeID = tol.getObjectUUID();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean renameCityForNewPlant(String cityName) {
|
||||
|
||||
if (!DbManager.CityQueries.renameCity(this, cityName))
|
||||
return false;
|
||||
|
||||
if (!DbManager.CityQueries.updateforceRename(this, true))
|
||||
return false;
|
||||
|
||||
@@ -515,19 +485,11 @@ public class City extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public Building getTOL() {
|
||||
|
||||
if (this.treeOfLifeID == 0)
|
||||
return null;
|
||||
|
||||
return BuildingManager.getBuildingFromCache(this.treeOfLifeID);
|
||||
|
||||
}
|
||||
|
||||
public int getIsNoobIsle() {
|
||||
return isNoobIsle;
|
||||
}
|
||||
|
||||
public int getPopulation() {
|
||||
return population;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -557,14 +519,6 @@ public class City extends AbstractWorldObject {
|
||||
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
|
||||
}
|
||||
|
||||
public float getLatitude() {
|
||||
return this.location.x;
|
||||
}
|
||||
|
||||
public float getLongitude() {
|
||||
return this.location.z;
|
||||
}
|
||||
|
||||
public float getAltitude() {
|
||||
return this.location.y;
|
||||
}
|
||||
@@ -574,34 +528,10 @@ public class City extends AbstractWorldObject {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public byte getIsNpcOwned() {
|
||||
return isNpc;
|
||||
}
|
||||
|
||||
public byte getIsSafeHold() {
|
||||
return this.isSafeHold;
|
||||
}
|
||||
|
||||
public boolean isSafeHold() {
|
||||
return (this.isSafeHold == (byte) 1);
|
||||
}
|
||||
|
||||
public byte getIsCapital() {
|
||||
return isCapital;
|
||||
}
|
||||
|
||||
public void setIsCapital(boolean state) {
|
||||
this.isCapital = (state) ? (byte) 1 : (byte) 0;
|
||||
}
|
||||
|
||||
public int getRadiusType() {
|
||||
return this.radiusType;
|
||||
}
|
||||
|
||||
public float getBindRadius() {
|
||||
return this.bindRadius;
|
||||
}
|
||||
|
||||
public int getRank() {
|
||||
return (this.getTOL() == null) ? 0 : this.getTOL().getRank();
|
||||
}
|
||||
@@ -618,43 +548,6 @@ public class City extends AbstractWorldObject {
|
||||
return this.parentZone;
|
||||
}
|
||||
|
||||
public void setParent(Zone zone) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
this.parentZone = zone;
|
||||
this.location = new Vector3fImmutable(zone.absX + statLat, zone.absY + statAlt, zone.absZ + statLon);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||
this.location.y,
|
||||
this.location.z + this.bindZ);
|
||||
|
||||
// set city bounds
|
||||
|
||||
Bounds cityBounds = Bounds.borrow();
|
||||
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
|
||||
new Vector2f(Enum.CityBoundsType.GRID.extents, Enum.CityBoundsType.GRID.extents),
|
||||
0.0f);
|
||||
this.setBounds(cityBounds);
|
||||
|
||||
if (zone.getHeightMap() == null && this.isNpc == 1 && this.getObjectUUID() != 1213) {
|
||||
HeightMap.GenerateCustomHeightMap(zone);
|
||||
Logger.info(zone.getName() + " created custom heightmap");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCityZone(Zone zone) {
|
||||
|
||||
if (zone == null || this.parentZone == null)
|
||||
return false;
|
||||
|
||||
return zone.getObjectUUID() == this.parentZone.getObjectUUID();
|
||||
|
||||
}
|
||||
|
||||
public AbstractCharacter getOwner() {
|
||||
|
||||
if (this.getTOL() == null)
|
||||
@@ -676,13 +569,13 @@ public class City extends AbstractWorldObject {
|
||||
if (this.getTOL() == null)
|
||||
return null;
|
||||
|
||||
|
||||
if (this.isNpc == 1) {
|
||||
|
||||
if (this.getTOL().getOwner() == null)
|
||||
return null;
|
||||
return this.getTOL().getOwner().getGuild();
|
||||
} else {
|
||||
|
||||
if (this.getTOL().getOwner() == null)
|
||||
return null;
|
||||
return this.getTOL().getOwner().getGuild();
|
||||
@@ -690,13 +583,16 @@ public class City extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean openCity(boolean open) {
|
||||
|
||||
if (!DbManager.CityQueries.updateOpenCity(this, open))
|
||||
return false;
|
||||
|
||||
this.open = open;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3fImmutable getBindLoc() {
|
||||
|
||||
Vector3fImmutable treeLoc = null;
|
||||
|
||||
if (this.getTOL() != null && this.getTOL().getRank() == 8)
|
||||
@@ -706,7 +602,9 @@ public class City extends AbstractWorldObject {
|
||||
return treeLoc;
|
||||
|
||||
if (this.radiusType == 1 && this.bindRadius > 0f) {
|
||||
|
||||
//square radius
|
||||
|
||||
float x = this.bindLoc.getX();
|
||||
float z = this.bindLoc.getZ();
|
||||
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * this.bindRadius;
|
||||
@@ -779,11 +677,33 @@ public class City extends AbstractWorldObject {
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
// Set city bounds
|
||||
// *** Note: Moved to SetParent()
|
||||
// for some undocumented reason
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_CITY);
|
||||
|
||||
// Set city motto to current guild motto
|
||||
// Set parent
|
||||
|
||||
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID);
|
||||
|
||||
// If it's not a player city then must be an NPC city
|
||||
|
||||
if (!parentZone.guild_zone)
|
||||
parentZone.isNPCCity = true;
|
||||
|
||||
// Set location for this city
|
||||
|
||||
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||
this.location.y,
|
||||
this.location.z + this.bindZ);
|
||||
|
||||
// set city bounds
|
||||
|
||||
Bounds cityBounds = Bounds.borrow();
|
||||
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
|
||||
new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents),
|
||||
0.0f);
|
||||
this.setBounds(cityBounds);
|
||||
|
||||
// Sanity check; no tol
|
||||
|
||||
if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
|
||||
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
|
||||
@@ -799,6 +719,8 @@ public class City extends AbstractWorldObject {
|
||||
Logger.error("Unable to find realm of ID " + realmID + " for city " + this.getObjectUUID());
|
||||
}
|
||||
|
||||
// Set city motto to current guild motto
|
||||
|
||||
if (this.getGuild() != null) {
|
||||
this.motto = this.getGuild().getMotto();
|
||||
|
||||
@@ -808,8 +730,10 @@ public class City extends AbstractWorldObject {
|
||||
for (Guild sub : this.getGuild().getSubGuildList()) {
|
||||
|
||||
if ((sub.getGuildState() == GuildState.Protectorate) ||
|
||||
(sub.getGuildState() == GuildState.Province))
|
||||
(sub.getGuildState() == GuildState.Province)) {
|
||||
this.isCapital = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> guildList = Guild.GuildRoster(this.getGuild());
|
||||
@@ -817,6 +741,61 @@ public class City extends AbstractWorldObject {
|
||||
this.population = guildList.size();
|
||||
}
|
||||
|
||||
if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) {
|
||||
this.noTeleport = true;
|
||||
this.noRepledge = true;
|
||||
} else {
|
||||
this.noTeleport = false;
|
||||
this.noRepledge = false;
|
||||
}
|
||||
|
||||
// Add city entry to data warehouse if newly created
|
||||
|
||||
if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (this.getHash() == null)) {
|
||||
|
||||
this.setHash();
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, this.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(this, Enum.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply health bonus and special mesh for realm if applicable
|
||||
|
||||
if (this.getTOL().rank == 8) {
|
||||
|
||||
// Update mesh accordingly
|
||||
|
||||
this.getTOL().meshUUID = Realm.getRealmMesh(this);
|
||||
|
||||
// Apply realm capital health bonus.
|
||||
// Do not apply bonus to banestones or TOL's. *** Refactor:
|
||||
// Possibly only protected buildings? Needs some thought.
|
||||
|
||||
float missingHealth = 0;
|
||||
|
||||
if (this.health.get() != 0)
|
||||
missingHealth = this.healthMax - this.health.get();
|
||||
|
||||
for (Building building : this.parentZone.zoneBuildingSet) {
|
||||
|
||||
if (building.getBlueprint() != null &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
|
||||
|
||||
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
|
||||
|
||||
if (this.health.get() != 0)
|
||||
this.health.set(this.healthMax - missingHealth);
|
||||
|
||||
if (this.health.get() > this.healthMax)
|
||||
this.health.set(this.healthMax);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Banes are loaded for this city from the database at this point
|
||||
|
||||
if (this.getBane() == null)
|
||||
@@ -824,13 +803,12 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// if this city is baned, add the siege effect
|
||||
|
||||
try {
|
||||
this.getTOL().addEffectBit((1 << 16));
|
||||
this.getBane().getStone().addEffectBit((1 << 19));
|
||||
;
|
||||
} catch (Exception e) {
|
||||
Logger.info("Failed ao add bane effects on city." + e.getMessage());
|
||||
}
|
||||
|
||||
// Spawn city
|
||||
|
||||
this.setLoc(this.getLoc());
|
||||
}
|
||||
|
||||
public void addCityEffect(EffectsBase effectBase, int rank) {
|
||||
@@ -846,12 +824,13 @@ public class City extends AbstractWorldObject {
|
||||
// Any players currently in the zone will not be processed by the heartbeat
|
||||
// if it's not the first effect toggled so we do it here manually
|
||||
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, this.parentZone.getBounds().getHalfExtents().x * 1.2f, MBServerStatics.MASK_PLAYER);
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, this.parentZone.bounds.getHalfExtents().x * 1.2f, MBServerStatics.MASK_PLAYER);
|
||||
|
||||
for (AbstractWorldObject playerObject : currentPlayers) {
|
||||
|
||||
if (playerObject == null)
|
||||
continue;
|
||||
|
||||
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc()))
|
||||
continue;
|
||||
|
||||
@@ -868,7 +847,6 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// Remove the city effect from the ago's internal collection
|
||||
|
||||
if (this.getEffects().containsKey(Integer.toString(effectBase.getUUID())))
|
||||
this.getEffects().remove(Integer.toString(effectBase.getUUID()));
|
||||
|
||||
// Any players currently in the zone will not be processed by the heartbeat
|
||||
@@ -878,6 +856,7 @@ public class City extends AbstractWorldObject {
|
||||
for (Integer playerID : this._playerMemory) {
|
||||
|
||||
player = PlayerCharacter.getFromCache(playerID);
|
||||
|
||||
if (player == null)
|
||||
continue;
|
||||
|
||||
@@ -889,12 +868,13 @@ public class City extends AbstractWorldObject {
|
||||
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Warehouse getWarehouse() {
|
||||
|
||||
if (this.warehouseBuildingID == 0)
|
||||
return null;
|
||||
|
||||
return Warehouse.warehouseByBuildingUUID.get(this.warehouseBuildingID);
|
||||
}
|
||||
|
||||
@@ -913,20 +893,14 @@ public class City extends AbstractWorldObject {
|
||||
return collided;
|
||||
}
|
||||
|
||||
public boolean isLocationOnCityGrid(Bounds newBounds) {
|
||||
|
||||
boolean collided = Bounds.collide(this.getBounds(), newBounds, 0);
|
||||
return collided;
|
||||
}
|
||||
|
||||
public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) {
|
||||
|
||||
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.extents);
|
||||
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.halfExtents);
|
||||
|
||||
}
|
||||
|
||||
public boolean isLocationOnCityZone(Vector3fImmutable insideLoc) {
|
||||
return Bounds.collide(insideLoc, this.parentZone.getBounds());
|
||||
return Bounds.collide(insideLoc, this.parentZone.bounds);
|
||||
}
|
||||
|
||||
private void applyAllCityEffects(PlayerCharacter player) {
|
||||
@@ -986,7 +960,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// Gather current list of players within the zone bounds
|
||||
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER);
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.halfExtents, MBServerStatics.MASK_PLAYER);
|
||||
currentMemory = new HashSet<>();
|
||||
|
||||
for (AbstractWorldObject playerObject : currentPlayers) {
|
||||
@@ -1066,7 +1040,6 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
_playerMemory.removeAll(toRemove);
|
||||
for (Integer removalUUID : toRemove) {
|
||||
if (this.cityOutlaws.contains(removalUUID))
|
||||
this.cityOutlaws.remove(removalUUID);
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1056,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
Thread destroyCityThread = new Thread(new DestroyCityThread(this));
|
||||
|
||||
destroyCityThread.setName("deestroyCity:" + this.getName());
|
||||
destroyCityThread.setName("destroyCity:" + this.getName());
|
||||
destroyCityThread.start();
|
||||
}
|
||||
|
||||
@@ -1168,6 +1141,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// All protection contracts are void upon transfer of a city
|
||||
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
||||
|
||||
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip()
|
||||
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
|
||||
cityBuilding.setProtectionState(ProtectionState.NONE);
|
||||
@@ -1199,7 +1173,6 @@ public class City extends AbstractWorldObject {
|
||||
Zone cityZone;
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
|
||||
|
||||
if (sourceGuild == null)
|
||||
return false;
|
||||
|
||||
@@ -1255,14 +1228,6 @@ public class City extends AbstractWorldObject {
|
||||
this.forceRename = forceRename;
|
||||
}
|
||||
|
||||
public boolean isReverseKOS() {
|
||||
return reverseKOS;
|
||||
}
|
||||
|
||||
public void setReverseKOS(boolean reverseKOS) {
|
||||
this.reverseKOS = reverseKOS;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
@@ -1290,26 +1255,6 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
//TODO use this for taxing later.
|
||||
// public boolean isAfterTaxPeriod(LocalDateTime dateTime,PlayerCharacter player){
|
||||
// if (dateTime.isBefore(realmTaxDate)){
|
||||
// String wait = "";
|
||||
// float hours = 1000*60*60;
|
||||
// float seconds = 1000;
|
||||
// float hoursUntil = realmTaxDate.minus(dateTime.get).getMillis() /hours;
|
||||
// int secondsUntil = (int) (realmTaxDate.minus(dateTime.getMillis()).getMillis() /seconds);
|
||||
// if (hoursUntil < 1)
|
||||
// wait = "You must wait " + secondsUntil + " seconds before taxing this city again!";
|
||||
// else
|
||||
// wait = "You must wait " + hoursUntil + " hours before taxing this city again!";
|
||||
// ErrorPopupMsg.sendErrorMsg(player, wait);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
public synchronized boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) {
|
||||
|
||||
// Member variable declaration
|
||||
@@ -1322,12 +1267,12 @@ public class City extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
City city = building.getCity();
|
||||
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (playerGuild == null || playerGuild.isEmptyGuild()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!");
|
||||
return true;
|
||||
@@ -1352,6 +1297,7 @@ public class City extends AbstractWorldObject {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Realm targetRealm = RealmMap.getRealmForCity(city);
|
||||
|
||||
if (targetRealm == null) {
|
||||
@@ -1380,31 +1326,32 @@ public class City extends AbstractWorldObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (this.realmTaxDate.isAfter(LocalDateTime.now()))
|
||||
return true;
|
||||
|
||||
if (msg.getResources().size() == 0)
|
||||
return true;
|
||||
|
||||
if (city.getWarehouse() == null)
|
||||
return true;
|
||||
|
||||
Warehouse ruledWarehouse = playerGuild.getOwnedCity().getWarehouse();
|
||||
|
||||
if (ruledWarehouse == null)
|
||||
return true;
|
||||
|
||||
|
||||
ItemBase.getItemHashIDMap();
|
||||
|
||||
ArrayList<Integer> resources = new ArrayList<>();
|
||||
|
||||
float taxPercent = msg.getTaxPercent();
|
||||
|
||||
if (taxPercent > 20)
|
||||
taxPercent = .20f;
|
||||
|
||||
for (int resourceHash : msg.getResources().keySet()) {
|
||||
if (ItemBase.getItemHashIDMap().get(resourceHash) != null)
|
||||
resources.add(ItemBase.getItemHashIDMap().get(resourceHash));
|
||||
|
||||
}
|
||||
|
||||
for (Integer itemBaseID : resources) {
|
||||
@@ -1422,6 +1369,7 @@ public class City extends AbstractWorldObject {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Failed to Update next Tax Date due to internal Error. City was not charged taxes this time.");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse);
|
||||
} catch (Exception e) {
|
||||
@@ -1439,6 +1387,5 @@ public class City extends AbstractWorldObject {
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,72 +14,45 @@ import engine.gameManager.DbManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public class Condemned {
|
||||
|
||||
public static final int INDIVIDUAL = 2;
|
||||
public static final int GUILD = 4;
|
||||
public static final int NATION = 5;
|
||||
private int ID;
|
||||
private int playerUID;
|
||||
private int parent;
|
||||
private int guildUID;
|
||||
private int friendType;
|
||||
private boolean active;
|
||||
|
||||
public int playerUID;
|
||||
public int buildingUUID;
|
||||
public int guildUID;
|
||||
public int friendType;
|
||||
public boolean active;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public Condemned(ResultSet rs) throws SQLException {
|
||||
this.playerUID = rs.getInt("playerUID");
|
||||
this.parent = rs.getInt("buildingUID");
|
||||
this.buildingUUID = rs.getInt("buildingUID");
|
||||
this.guildUID = rs.getInt("guildUID");
|
||||
this.friendType = rs.getInt("friendType");
|
||||
this.active = rs.getBoolean("active");
|
||||
}
|
||||
|
||||
|
||||
public Condemned(int playerUID, int parent, int guildUID, int friendType) {
|
||||
public Condemned(int playerUID, int buildingUUID, int guildUID, int friendType) {
|
||||
super();
|
||||
this.playerUID = playerUID;
|
||||
this.parent = parent;
|
||||
this.buildingUUID = buildingUUID;
|
||||
this.guildUID = guildUID;
|
||||
this.friendType = friendType;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
|
||||
public int getPlayerUID() {
|
||||
return playerUID;
|
||||
}
|
||||
|
||||
|
||||
public int getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
public int getGuildUID() {
|
||||
return guildUID;
|
||||
}
|
||||
|
||||
|
||||
public int getFriendType() {
|
||||
return friendType;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
|
||||
public boolean setActive(boolean active) {
|
||||
|
||||
if (!DbManager.BuildingQueries.updateActiveCondemn(this, active))
|
||||
return false;
|
||||
|
||||
this.active = active;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user