Compare commits
571 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fe4f32302 | |||
| d6ad0ecbd3 | |||
| efdf19f22e | |||
| 76a71b5984 | |||
| cf09f447bd | |||
| 8dc6a0627c | |||
| 8b095976ef | |||
| 83606046ba | |||
| adcf3fd9b6 | |||
| e983a32b5d | |||
| 9d8f800c2a | |||
| 05e90d495f | |||
| 18f70b6d5c | |||
| 86c8e985be | |||
| b6b5db41bd | |||
| d573534f6d | |||
| 06df109a18 | |||
| f077370034 | |||
| 94e16bdf3d | |||
| a52f0941b7 | |||
| 840dc83987 | |||
| 5b9d1dd6eb | |||
| 6215e15e82 | |||
| e8a39e596e | |||
| 90b516bbb9 | |||
| 561170eb44 | |||
| 68920f150d | |||
| a54e8c2176 | |||
| c77f38dec1 | |||
| 5a57677013 | |||
| 306c64d236 | |||
| 0b05e661c7 | |||
| a94a400102 | |||
| 4bff36d7bb | |||
| 969b36e6fd | |||
| 688553e6c6 | |||
| 4f057ee851 | |||
| fd47c90f4f | |||
| 253ca2344e | |||
| 95f09a255e | |||
| 31ea74f98c | |||
| 67c474dbdf | |||
| c65a713bae | |||
| e3641872d0 | |||
| c25fdf3823 | |||
| 7c28efb47c | |||
| c92316f03e | |||
| e330f190fe | |||
| ae52735131 | |||
| 59025c2585 | |||
| 6354eb2893 | |||
| 3ad97a7ce3 | |||
| f8cbeb4cc6 | |||
| f1e41e47cf | |||
| 78a0416b19 | |||
| eb5bc14974 | |||
| 7e99e8c7a4 | |||
| 9b0f4d5aef | |||
| b58049968f | |||
| 9bf0d3f7d1 | |||
| 8300c47e4a | |||
| c73fcc19f2 | |||
| f93573177a | |||
| fe9c6437d8 | |||
| c110ffc4b1 | |||
| 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 |
@@ -0,0 +1,27 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
import engine.objects.Building;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CollisionManager {
|
||||
public static HashMap<Integer, ArrayList<MeshData>> structure_meshes;
|
||||
public static HashMap<Integer,ArrayList<Triangle>> mesh_triangles;
|
||||
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){
|
||||
|
||||
if(building.buildingRect != null)
|
||||
if(!travelLine.intersects(building.buildingRect) && !building.buildingRect.contains(travelLine.getP1()) && !building.buildingRect.contains(travelLine.getP2()))
|
||||
return false;
|
||||
|
||||
for(Mesh mesh : building.buildingMeshes)
|
||||
if(mesh.collides(travelLine))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.Building;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Mesh {
|
||||
public ArrayList<Triangle> triangles;
|
||||
public Vector3f mesh_end_point;
|
||||
public Vector3f mesh_ref_point;
|
||||
public Vector3f mesh_location;
|
||||
public float mesh_max_y;
|
||||
public float mesh_min_y;
|
||||
public Vector3f mesh_scale;
|
||||
public int mesh_id;
|
||||
public int parent_prop_id;
|
||||
public int parent_structure_id;
|
||||
public int parentUUID;
|
||||
public Rectangle2D.Float mesh_bounds;
|
||||
public MeshData meshData;
|
||||
|
||||
public void update(){
|
||||
this.BakeTriangles();
|
||||
}
|
||||
public Vector3f getLocation(){
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID);
|
||||
int degrees = (int)Math.toDegrees(parentBuilding.getBounds().getQuaternion().angleY);
|
||||
Vector3f parentLoc = new Vector3f(parentBuilding.loc.x,parentBuilding.loc.y,parentBuilding.loc.z);
|
||||
Vector3f offsetLoc = parentLoc.add(this.meshData.loc);
|
||||
Vector3f rotatedPoint = Vector3f.rotateAroundPoint(offsetLoc,parentLoc,degrees);
|
||||
return rotatedPoint;
|
||||
}
|
||||
|
||||
public void BakeTriangles(){
|
||||
|
||||
if(CollisionManager.mesh_triangles.containsKey(this.meshData.meshID) == false){
|
||||
Logger.error("Failed To Bake Triangles For Mesh: " + this.meshData.meshID);
|
||||
return;
|
||||
}
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID);
|
||||
int degrees = (int)Math.toDegrees(parentBuilding.getBounds().getQuaternion().angleY);
|
||||
Vector3f parentLoc = new Vector3f(parentBuilding.loc.x,parentBuilding.loc.y,parentBuilding.loc.z);
|
||||
Vector3f offsetLoc = parentLoc.add(this.meshData.loc);
|
||||
|
||||
for(Triangle tri : CollisionManager.mesh_triangles.get(this.meshData.meshID)) {
|
||||
|
||||
Triangle newTri = new Triangle();
|
||||
|
||||
Vector3f Point1 = offsetLoc.add(new Vector3f(tri.point1.x,offsetLoc.y,tri.point1.y));
|
||||
Vector3f Point2 = offsetLoc.add(new Vector3f(tri.point2.x,offsetLoc.y,tri.point2.y));
|
||||
Vector3f Point3 = offsetLoc.add(new Vector3f(tri.point3.x,offsetLoc.y,tri.point3.y));
|
||||
|
||||
Vector3f rotatedPoint1 = Vector3f.rotateAroundPoint(Point1,offsetLoc,degrees);
|
||||
Vector3f rotatedPoint2 = Vector3f.rotateAroundPoint(Point2,offsetLoc,degrees);
|
||||
Vector3f rotatedPoint3 = Vector3f.rotateAroundPoint(Point3,offsetLoc,degrees);
|
||||
|
||||
newTri.point1 = new Point2D.Float(rotatedPoint1.x,rotatedPoint1.z);
|
||||
newTri.point2 = new Point2D.Float(rotatedPoint2.x,rotatedPoint2.z);
|
||||
newTri.point3 = new Point2D.Float(rotatedPoint3.x,rotatedPoint3.z);
|
||||
|
||||
newTri.sides = new ArrayList<>();
|
||||
newTri.sides.add(new Line2D.Float(newTri.point1,newTri.point2));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point2,newTri.point3));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point3,newTri.point1));
|
||||
|
||||
this.triangles.add(newTri);
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean collides(Line2D line){
|
||||
for(Triangle tri : this.triangles)
|
||||
if(tri.collides(line))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class MeshData {
|
||||
public int propID;
|
||||
public int meshID;
|
||||
public Vector3f loc;
|
||||
public Vector3f scale;
|
||||
public Vector3f refPoint;
|
||||
public Vector3f endPoint;
|
||||
public float maxY;
|
||||
public float minY;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Triangle {
|
||||
public Point2D.Float point1;
|
||||
public Point2D.Float point2;
|
||||
public Point2D.Float point3;
|
||||
public ArrayList<Line2D> sides;
|
||||
public boolean collides(Line2D line)
|
||||
{
|
||||
for(Line2D side : sides)
|
||||
if(side.intersectsLine(line))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+14
-44
@@ -139,8 +139,8 @@ public class Enum {
|
||||
HALFGIANTMALE(2010, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.MALE, 1.15f),
|
||||
HUMANMALE(2011, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.MALE, 1),
|
||||
HUMANFEMALE(2012, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
|
||||
IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.MALE, 1.1f),
|
||||
IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.FEMALE, 1.1f),
|
||||
IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.MALE, 1.1f),
|
||||
IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f),
|
||||
SHADEMALE(2015, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.MALE, 1),
|
||||
SHADEFEMALE(2016, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
|
||||
MINOMALE(2017, MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE, 1.3f),
|
||||
@@ -152,9 +152,7 @@ public class Enum {
|
||||
NEPHFEMALE(2026, MonsterType.Nephilim, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f),
|
||||
HALFGIANTFEMALE(2027, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.15f),
|
||||
VAMPMALE(2028, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.MALE, 1),
|
||||
VAMPFEMALE(2029, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
|
||||
SAETOR(1999, MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE, 0.80000001f),
|
||||
LIZARDMAN(1998, MonsterType.Reptile, RunSpeed.STANDARD, CharacterSex.MALE, 1.05f);
|
||||
VAMPFEMALE(2029, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.FEMALE, 1);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static HashMap<Integer, RaceType> _raceTypeByID = new HashMap<>();
|
||||
@@ -210,7 +208,6 @@ public class Enum {
|
||||
SENTINEL(0, 0, 0, 0, 0, 0, 0),
|
||||
STANDARD(6.1900001f, 13.97f, 4.2199998f, 13.97f, 6.3299999f, 18.379999f, 6.5f),
|
||||
CENTAUR(6.1900001f, 16.940001f, 5.5500002f, 16.940001f, 6.3299999f, 18.379999f, 6.5f),
|
||||
IREKEI(6.35f, 15.25f, 4.2199998f, 14.5f, 6.3299999f, 18.379999f, 6.5f),
|
||||
MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f);
|
||||
|
||||
private float walkStandard;
|
||||
@@ -472,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()
|
||||
@@ -963,17 +960,7 @@ public class Enum {
|
||||
SourceType returnMod;
|
||||
if (modName.isEmpty())
|
||||
return SourceType.None;
|
||||
switch(modName) {
|
||||
case "Piercing":
|
||||
modName = "Pierce";
|
||||
break;
|
||||
case "Crushing":
|
||||
modName = "Crush";
|
||||
break;
|
||||
case "Slashing":
|
||||
modName = "Slash";
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
returnMod = SourceType.valueOf(modName.replace(",", ""));
|
||||
} catch (Exception e) {
|
||||
@@ -1665,24 +1652,6 @@ public class Enum {
|
||||
return extents;
|
||||
}
|
||||
|
||||
public boolean isTrainerBuilding(){
|
||||
switch(this){
|
||||
case AMAZONHALL:
|
||||
case CATHEDRAL:
|
||||
case GREATHALL:
|
||||
case KEEP:
|
||||
case THIEFHALL:
|
||||
case TEMPLEHALL:
|
||||
case WIZARDHALL:
|
||||
case ELVENHALL:
|
||||
case ELVENSANCTUM:
|
||||
case IREKEIHALL:
|
||||
case FORESTHALL:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum UpdateType {
|
||||
@@ -2338,13 +2307,13 @@ public class Enum {
|
||||
public enum CityBoundsType {
|
||||
|
||||
GRID(640),
|
||||
ZONE(680),
|
||||
PLACEMENT(681);
|
||||
ZONE(875),
|
||||
PLACEMENT(876);
|
||||
|
||||
public final float extents;
|
||||
public final float halfExtents;
|
||||
|
||||
CityBoundsType(float extents) {
|
||||
this.extents = extents;
|
||||
CityBoundsType(float halfExtents) {
|
||||
this.halfExtents = halfExtents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2908,10 +2877,11 @@ public class Enum {
|
||||
|
||||
public enum AIAgentType {
|
||||
MOBILE,
|
||||
GUARDCAPTAIN,
|
||||
GUARDMINION,
|
||||
GUARDWALLARCHER,
|
||||
PET,
|
||||
CHARMED,
|
||||
|
||||
SIEGEENGINE,
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.net.client.msg.UnloadObjectsMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.BoxTracker;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -110,7 +109,7 @@ public enum InterestManager implements Runnable {
|
||||
origin.sendMsg(moveMsg);
|
||||
}
|
||||
|
||||
public static void reloadCharacter(AbstractCharacter absChar, boolean sendToSelf) {
|
||||
public static void reloadCharacter(AbstractCharacter absChar) {
|
||||
|
||||
UnloadObjectsMsg uom = new UnloadObjectsMsg();
|
||||
uom.addObject(absChar);
|
||||
@@ -141,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)) {
|
||||
@@ -211,7 +210,7 @@ public enum InterestManager implements Runnable {
|
||||
if (origin == null)
|
||||
continue;
|
||||
|
||||
if (!playerCharacter.enteredWorld)
|
||||
if (!playerCharacter.isEnteredWorld())
|
||||
continue;
|
||||
|
||||
if (playerCharacter.getTeleportLock().readLock().tryLock()) {
|
||||
@@ -341,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())
|
||||
@@ -373,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);
|
||||
@@ -438,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());
|
||||
@@ -525,7 +524,6 @@ public enum InterestManager implements Runnable {
|
||||
player.setDirtyLoad(true);
|
||||
updateStaticList(player, origin);
|
||||
updateMobileList(player, origin);
|
||||
BoxTracker.addPlayer(origin.machineID,player);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -73,14 +73,6 @@ public class dbBlueprintHandler extends dbHandlerBase {
|
||||
Blueprint._meshLookup.putIfAbsent(thisBlueprint.getMeshForRank(3), thisBlueprint);
|
||||
Blueprint._meshLookup.putIfAbsent(thisBlueprint.getMeshForRank(7), thisBlueprint);
|
||||
|
||||
if(thisBlueprint.getName().contains("Vampire Shrine")){
|
||||
Blueprint saetorShrine = new Blueprint(rs);
|
||||
saetorShrine.setBlueprintUUID(1720000);
|
||||
saetorShrine.rank1UUID = 1720000;
|
||||
saetorShrine.rank3UUID = 1720000;
|
||||
saetorShrine.rank7UUID = 1720000;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -9,16 +9,25 @@
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.CollisionEngine.CollisionManager;
|
||||
import engine.CollisionEngine.MeshData;
|
||||
import engine.CollisionEngine.Triangle;
|
||||
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.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,7 +35,9 @@ import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
@@ -88,14 +99,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 +434,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 +466,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 +498,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) {
|
||||
@@ -722,10 +728,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);
|
||||
|
||||
@@ -852,4 +858,167 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LOAD_MESH_DATA(){
|
||||
CollisionManager.structure_meshes = new HashMap<>();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_structure_meshes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
MeshData md = new MeshData();
|
||||
md.propID = rs.getInt("propID");
|
||||
md.meshID = rs.getInt("meshID");
|
||||
md.loc = new Vector3f(rs.getFloat("locX"), rs.getFloat("locY"),rs.getFloat("locz"));
|
||||
md.scale = new Vector3f(rs.getFloat("scaleX"), rs.getFloat("scaleY"),rs.getFloat("scaleZ"));
|
||||
md.refPoint = new Vector3f(rs.getFloat("refX"), rs.getFloat("refY"),rs.getFloat("refZ"));
|
||||
md.endPoint = new Vector3f(rs.getFloat("endX"), rs.getFloat("endY"),rs.getFloat("endZ"));
|
||||
md.minY = rs.getFloat("minY");
|
||||
md.maxY = rs.getFloat("maxY");
|
||||
if(CollisionManager.structure_meshes.containsKey(rs.getInt("propID"))){
|
||||
CollisionManager.structure_meshes.get(rs.getInt("propID")).add(md);
|
||||
} else{
|
||||
ArrayList<MeshData> meshData = new ArrayList<>();
|
||||
meshData.add(md);
|
||||
CollisionManager.structure_meshes.put(rs.getInt("propID"),meshData);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
public void LOAD_MESH_TRIANGLE_DATA(){
|
||||
CollisionManager.mesh_triangles = new HashMap<>();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_mesh_triangles`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
Triangle tri = new Triangle();
|
||||
tri.point1 = new Point2D.Float(rs.getFloat("P1X"),rs.getFloat("P1Z"));
|
||||
tri.point2 = new Point2D.Float(rs.getFloat("P2X"),rs.getFloat("P2Z"));
|
||||
tri.point3 = new Point2D.Float(rs.getFloat("P3X"),rs.getFloat("P3Z"));
|
||||
if(CollisionManager.mesh_triangles.containsKey(rs.getInt("meshID"))){
|
||||
CollisionManager.mesh_triangles.get(rs.getInt("meshID")).add(tri);
|
||||
} else{
|
||||
ArrayList<Triangle> triData = new ArrayList<>();
|
||||
triData.add(tri);
|
||||
CollisionManager.mesh_triangles.put(rs.getInt("meshID"),triData);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
public void LOAD_PROP_MESHES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_meshes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.prop_meshes = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
if(BuildingManager.prop_meshes.containsKey(rs.getInt("propID")) == false){
|
||||
ArrayList<Integer> meshList = new ArrayList<>();
|
||||
meshList.add(rs.getInt("meshID"));
|
||||
BuildingManager.prop_meshes.put(rs.getInt("propID"),meshList);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList<Integer> meshes = BuildingManager.prop_meshes.get(rs.getInt("propID"));
|
||||
meshes.add(rs.getInt("meshID"));
|
||||
//BuildingManager.prop_meshes.get(rs.getInt("propID")).add(rs.getInt("meshID"));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_MESH_DATA_OLD() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_triangles`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_triangle_points = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
|
||||
ArrayList<Float> floatPoints = new ArrayList<>();
|
||||
for(String f : rs.getString("vertices").split(";"))
|
||||
{
|
||||
floatPoints.add(Float.parseFloat(f));
|
||||
}
|
||||
ArrayList<Vector3f> triPoints = new ArrayList<>();
|
||||
for(int i = 0; i < floatPoints.size(); i += 3){
|
||||
triPoints.add(new Vector3f(floatPoints.get(i),floatPoints.get(i+1),floatPoints.get(i+2)));
|
||||
}
|
||||
|
||||
if(BuildingManager.mesh_triangle_points.containsKey(rs.getInt("meshID")) == false){
|
||||
ArrayList<ArrayList<Vector3f>> newPoints = new ArrayList<>();
|
||||
newPoints.add(triPoints);
|
||||
BuildingManager.mesh_triangle_points.put(rs.getInt("meshID"),newPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildingManager.mesh_triangle_points.get(rs.getInt("meshID")).add(triPoints);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_heights`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_heights = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
|
||||
if(BuildingManager.mesh_heights.containsKey(rs.getInt("meshID")) == false){
|
||||
Vector2f heights = new Vector2f(rs.getFloat("maxY"),rs.getFloat("minY"));
|
||||
BuildingManager.mesh_heights.put(rs.getInt("meshID"),heights);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_MESH_BOUNDING_BOXES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_bounding_boxes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_bounding_boxes = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
int meshID = rs.getInt("meshId");
|
||||
if(BuildingManager.mesh_bounding_boxes.containsKey(meshID) == false){
|
||||
float endX = Float.parseFloat(rs.getString("mesh_end_point").split(";")[0]);
|
||||
float endZ = Float.parseFloat(rs.getString("mesh_end_point").split(";")[1]);
|
||||
float refX = Float.parseFloat(rs.getString("mesh_ref_point").split(";")[0]);
|
||||
float refZ = Float.parseFloat(rs.getString("mesh_ref_point").split(";")[1]);
|
||||
|
||||
|
||||
Vector2f topLeft = new Vector2f(refX,refZ);
|
||||
float width = Math.abs(Math.abs(endX)-Math.abs(refX));
|
||||
float height = Math.abs(Math.abs(endZ)-Math.abs(refZ));
|
||||
Rectangle2D boundRect = new Rectangle2D.Float();
|
||||
boundRect.setRect(topLeft.x,topLeft.y,width,height);
|
||||
BuildingManager.mesh_bounding_boxes.put(meshID,boundRect);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import engine.gameManager.DbManager;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.CharacterSkill;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.SkillsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
|
||||
@@ -34,16 +34,19 @@ public class dbCityHandler extends dbHandlerBase {
|
||||
case "zone":
|
||||
Zone zone = new Zone(rs);
|
||||
DbManager.addToCache(zone);
|
||||
zone.runAfterLoad();
|
||||
list.add(zone);
|
||||
break;
|
||||
case "building":
|
||||
Building building = new Building(rs);
|
||||
DbManager.addToCache(building);
|
||||
building.runAfterLoad();
|
||||
list.add(building);
|
||||
break;
|
||||
case "city":
|
||||
City city = new City(rs);
|
||||
DbManager.addToCache(city);
|
||||
city.runAfterLoad();
|
||||
list.add(city);
|
||||
break;
|
||||
}
|
||||
@@ -96,14 +99,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);
|
||||
|
||||
@@ -63,9 +63,6 @@ public abstract class dbHandlerBase {
|
||||
} else {
|
||||
AbstractGameObject toAdd = localClass.getConstructor(ResultSet.class).newInstance(rs);
|
||||
DbManager.addToCache(toAdd);
|
||||
if(toAdd.getObjectType().equals(GameObjectType.Zone) && rs.getInt("canLoad") == 0){
|
||||
continue;
|
||||
}
|
||||
objectList.add((T) toAdd);
|
||||
|
||||
if (toAdd != null && toAdd instanceof AbstractWorldObject)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,67 +28,10 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
|
||||
public void LOAD_BAKEDINSTATS(ItemBase itemBase) {
|
||||
|
||||
int itemBaseID = itemBase.getUUID();
|
||||
switch(itemBaseID){
|
||||
case 27550://bow
|
||||
case 27560://dagger
|
||||
case 27570://hammer
|
||||
case 27580://axe
|
||||
case 27590://sword
|
||||
//return new String[]{"PRE-010","SUF-260"};
|
||||
itemBaseID = 8000000;
|
||||
break;
|
||||
case 27600://staff
|
||||
//return new String[]{"PRE-334","PRE-315"};
|
||||
itemBaseID = 8000010;
|
||||
break;
|
||||
|
||||
case 188500://HA chest
|
||||
case 188510://HA arms
|
||||
case 188520://HA legs
|
||||
case 188530://HA gloves
|
||||
case 188550://HA helm
|
||||
case 188720://CC hood
|
||||
case 188900://MA chest
|
||||
case 188910://MA Sleeves
|
||||
case 188920://MA Legs
|
||||
case 188930://MA gloves
|
||||
case 188950://MA helm
|
||||
case 189100://la chest
|
||||
case 189110://la arms
|
||||
case 189120://la legs
|
||||
case 189130://la gloves
|
||||
case 189150://la helm
|
||||
case 189550://CC gloves
|
||||
//return new String[]{"PRE-130", "PRE-232", "PRE-212", "PRE-222", "SUF-007"};
|
||||
itemBaseID = 8000020;
|
||||
break;
|
||||
|
||||
case 188540://HA boots
|
||||
case 188940://MA boots
|
||||
case 189140://LA boots
|
||||
case 189560://CC boots
|
||||
//return new String[]{"PRE-133", "PRE-230", "PRE-210", "PRE-220", "SUF-003","SUF-150"};
|
||||
itemBaseID = 8000030;
|
||||
break;
|
||||
|
||||
case 188700://CC robe
|
||||
//return new String[]{"PRE-130", "PRE-232", "PRE-212", "PRE-222","SUF-317","SUF-317","SUF-317"};
|
||||
itemBaseID = 8000040;
|
||||
break;
|
||||
|
||||
case 189500://MA shield
|
||||
case 189510://HA shield
|
||||
//return new String[]{"PRE-125","PRE-125","PRE-125", "PRE-230", "PRE-210", "PRE-220"};
|
||||
itemBaseID = 8000050;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBaseID);
|
||||
preparedStatement.setInt(1, itemBase.getUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
@@ -144,19 +87,12 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
recordsRead++;
|
||||
itemBase = new ItemBase(rs);
|
||||
ItemBase.addToCache(itemBase);
|
||||
|
||||
//copy the vampire shrine for saetor and change uuid and name
|
||||
if(itemBase.getName().contains("Vampire Shrine")){
|
||||
ItemBase saetorShrine = new ItemBase(rs);
|
||||
saetorShrine.setUUID(1035);
|
||||
saetorShrine.setName(saetorShrine.getName().replace("Vampire","Saetor"));
|
||||
ItemBase.addToCache(saetorShrine);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +135,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (rs.next())
|
||||
try {
|
||||
worked = rs.getBoolean("result");
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
worked = rs.getBoolean("result");
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
@@ -354,11 +350,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (rs.next())
|
||||
try {
|
||||
worked = rs.getBoolean("result");
|
||||
} catch(Exception e){
|
||||
worked = true;
|
||||
}
|
||||
worked = rs.getBoolean("result");
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
@@ -504,18 +496,4 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean UPDATE_NUM_ITEMS(final Item item, int newValue) {
|
||||
if (item.getItemBase().getType().equals(ItemType.GOLD))
|
||||
return false;
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
||||
preparedStatement.setInt(1, newValue);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.MineProduction;
|
||||
import engine.objects.Resource;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -34,24 +32,8 @@ public class dbMineHandler extends dbHandlerBase {
|
||||
|
||||
if (id == 0)
|
||||
return null;
|
||||
|
||||
Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id);
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM obj_mine;")) {
|
||||
|
||||
//preparedStatement.setInt(1, id);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
while(rs.next()){
|
||||
if(rs.getInt("UID") == id){
|
||||
int towerUID = rs.getInt("mine_buildingUID");
|
||||
mine = Mine.getMineFromTower(towerUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
if (mine != null)
|
||||
return mine;
|
||||
@@ -74,27 +56,13 @@ public class dbMineHandler extends dbHandlerBase {
|
||||
|
||||
ArrayList<Mine> mines = new ArrayList<>();
|
||||
|
||||
//try (Connection connection = DbManager.getConnection();
|
||||
// PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mine`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mine` ON `obj_mine`.`UID` = `object`.`UID`")) {
|
||||
|
||||
// ResultSet rs = preparedStatement.executeQuery();
|
||||
// mines = getObjectsFromRs(rs, 1000);
|
||||
|
||||
// } catch (SQLException e) {
|
||||
// Logger.error(e);
|
||||
//}
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM obj_mine;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mine`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mine` ON `obj_mine`.`UID` = `object`.`UID`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
while(rs.next()){
|
||||
if(BuildingManager.getBuildingFromCache(rs.getInt("mine_buildingUID")) == null)
|
||||
continue;
|
||||
mines = getObjectsFromRs(rs, 1000);
|
||||
|
||||
mines.add(new Mine(rs));
|
||||
}
|
||||
|
||||
} catch (SQLException | UnknownHostException e) {
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return mines;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class dbMobBaseHandler extends dbHandlerBase {
|
||||
|
||||
@@ -113,25 +112,6 @@ public class dbMobBaseHandler extends dbHandlerBase {
|
||||
return mobBaseStats;
|
||||
}
|
||||
|
||||
public void LOAD_ALL_MOBBASE_RACES() {
|
||||
MobBase.mobbase_race_types = new HashMap<>();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase`;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
int id = rs.getInt("loadID");
|
||||
if(MobBase.mobbase_race_types.containsKey(id) == false){
|
||||
MobBase.mobbase_race_types.put(id,rs.getString("raceType"));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_ALL_MOBBASE_SPEEDS(MobBase mobBase) {
|
||||
|
||||
if (mobBase.getLoadID() == 0)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
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.parentZoneUUID);
|
||||
preparedStatement.setInt(2, toAdd.loadID);
|
||||
@@ -43,11 +42,12 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
preparedStatement.setFloat(6, toAdd.bindLoc.z);
|
||||
preparedStatement.setInt(7, 0);
|
||||
preparedStatement.setFloat(8, toAdd.spawnRadius);
|
||||
preparedStatement.setInt(9, toAdd.spawnTime);
|
||||
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();
|
||||
|
||||
@@ -64,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();
|
||||
@@ -110,7 +127,7 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String minionName = rs.getString("name");
|
||||
String minionName = rs.getString("minionName");
|
||||
Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
|
||||
|
||||
if (toCreate == null)
|
||||
@@ -126,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);
|
||||
|
||||
@@ -144,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);
|
||||
|
||||
@@ -161,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,25 +23,7 @@ public class dbResistHandler extends dbHandlerBase {
|
||||
public dbResistHandler() {
|
||||
|
||||
}
|
||||
public void LOAD_RESISTS_FOR_MOBS() {
|
||||
|
||||
Resists resists = null;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mob_resists`;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while(rs.next()){
|
||||
resists = new Resists(rs);
|
||||
if(!Resists.mobResists.containsKey(rs.getInt("ID")))
|
||||
Resists.mobResists.put(rs.getInt("ID"),resists);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
public Resists GET_RESISTS_FOR_MOB(int resistID) {
|
||||
|
||||
Resists resists = null;
|
||||
|
||||
@@ -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();
|
||||
@@ -59,43 +139,6 @@ public class dbRuneBaseHandler extends dbHandlerBase {
|
||||
rb.setLevelRequired(rs.getInt("requiredRuneID"));
|
||||
break;
|
||||
}
|
||||
int id = rs.getInt("runeID");
|
||||
switch(id) {
|
||||
case 3001:
|
||||
case 3002:
|
||||
case 3003:
|
||||
case 3004:
|
||||
case 3007:
|
||||
case 3008:
|
||||
case 3009:
|
||||
case 3013:
|
||||
case 3014:
|
||||
case 3016:
|
||||
case 3017:
|
||||
case 3018:
|
||||
case 3019:
|
||||
case 3020:
|
||||
case 3021:
|
||||
case 3026:
|
||||
case 3030:
|
||||
case 3031:
|
||||
case 3033:
|
||||
case 3037:
|
||||
case 3040:
|
||||
case 3045:
|
||||
case 3046:
|
||||
case 3047:
|
||||
case 3048:
|
||||
case 2514:
|
||||
rb.getRace().put(1999, true);
|
||||
break;
|
||||
case 3035:
|
||||
rb.getBaseClass().put(2501,true);
|
||||
break;
|
||||
case 3049:
|
||||
rb.getRace().clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -143,13 +143,6 @@ public class dbSkillBaseHandler extends dbHandlerBase {
|
||||
|
||||
SkillsBase.runeSkillsCache.get(runeID).put(token, amount);
|
||||
}
|
||||
//add saetor skills
|
||||
HashMap<Integer, Integer> skills = new HashMap<>();
|
||||
skills.put(71438003,15); // staff
|
||||
skills.put(-61022283,10); // staff mastery
|
||||
skills.put(95961104,10); // parry
|
||||
SkillsBase.runeSkillsCache.put(1999,skills);
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
|
||||
@@ -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, zone, null, null, "", 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, zone, null, null, "", 1);
|
||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
if (mob != null) {
|
||||
mob.updateDatabase();
|
||||
ChatManager.chatSayInfo(pc,
|
||||
|
||||
@@ -13,7 +13,6 @@ import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -71,30 +70,28 @@ public class AddNPCCmd extends AbstractDevCmd {
|
||||
throwbackError(pc, "Failed to find zone to place npc in.");
|
||||
return;
|
||||
}
|
||||
Building building = null;
|
||||
|
||||
if (target != null)
|
||||
if (target.getObjectType() == GameObjectType.Building) {
|
||||
building = (Building)target;
|
||||
Building parentBuilding = (Building) target;
|
||||
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
|
||||
return;
|
||||
}
|
||||
NPC created;
|
||||
Guild guild = null;
|
||||
Vector3fImmutable loc;
|
||||
if(building != null){
|
||||
guild = building.getGuild();
|
||||
loc = building.loc;
|
||||
} else{
|
||||
loc = pc.loc;
|
||||
|
||||
NPC npc = NPC.createNPC(name, contractID,
|
||||
pc.getLoc(), null, zone, (short) level, null);
|
||||
|
||||
if (npc != null) {
|
||||
WorldGrid.addObject(npc, pc);
|
||||
ChatManager.chatSayInfo(pc,
|
||||
"NPC with ID " + npc.getDBID() + " added");
|
||||
this.setResult(String.valueOf(npc.getDBID()));
|
||||
} else {
|
||||
throwbackError(pc, "Failed to create npc of contract type "
|
||||
+ contractID);
|
||||
Logger.error(
|
||||
"Failed to create npc of contract type " + contractID);
|
||||
}
|
||||
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building);
|
||||
created.bindLoc = loc;
|
||||
if(building != null) {
|
||||
created.buildingUUID = building.getObjectUUID();
|
||||
created.building = building;
|
||||
NPCManager.slotCharacterInBuilding(created);
|
||||
}
|
||||
created.setLoc(created.bindLoc);
|
||||
created.updateDatabase();
|
||||
throwbackInfo(pc, "Created NPC with UUID: " + created.getObjectUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
public class ColliderCmd extends AbstractDevCmd {
|
||||
|
||||
public ColliderCmd() {
|
||||
super("collider");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output;
|
||||
if(target.getObjectType().equals(Enum.GameObjectType.Building) == false){
|
||||
throwbackInfo(pc,"Please Select A Building To Show Collider Data");
|
||||
}
|
||||
Building building = (Building)target;
|
||||
output = "Collision Info:" + newline;
|
||||
output += "Total Meshes: " + building.buildingMeshes.size() + newline;
|
||||
for(Mesh mesh : building.buildingMeshes){
|
||||
output += "-----------------------------" + newline;
|
||||
output += "Mesh ID: " + mesh.mesh_id + newline;
|
||||
output += "Mesh Location: " + mesh.mesh_location + newline;
|
||||
output += "Mesh Scale: " + mesh.mesh_scale + newline;
|
||||
output += "Mesh Min/Max: " + mesh.mesh_min_y + "/" + mesh.mesh_max_y + newline;
|
||||
output += "Mesh Triangle Count: " + mesh.triangles.size() + newline;
|
||||
output += "Mesh Rect: " + mesh.mesh_bounds + newline;
|
||||
output += "-----------------------------" + newline;
|
||||
}
|
||||
|
||||
throwbackInfo(pc,output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Displays Information About Colliders";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /collider displays collision info when selected on a building";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
|
||||
public class EnchantCmd extends AbstractDevCmd {
|
||||
|
||||
@@ -56,9 +55,21 @@ public class EnchantCmd extends AbstractDevCmd {
|
||||
this.setResult(String.valueOf(item.getObjectUUID()));
|
||||
} else {
|
||||
int cnt = words.length;
|
||||
String enchant = words[1];
|
||||
enchant = EffectsBase.getItemEffectsByName(enchant.toLowerCase());
|
||||
item.addPermanentEnchantmentForDev(enchant, 0);
|
||||
for (int i = 1; i < cnt; i++) {
|
||||
String enchant = words[i];
|
||||
boolean valid = true;
|
||||
for (Effect eff : item.getEffects().values()) {
|
||||
if (eff.getEffectsBase().getIDString().equals(enchant)) {
|
||||
throwbackError(pc, "This item already has that enchantment");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (valid) {
|
||||
item.addPermanentEnchantmentForDev(enchant, rank);
|
||||
this.setResult(String.valueOf(item.getObjectUUID()));
|
||||
} else
|
||||
throwbackError(pc, "Invalid Enchantment. Enchantment must consist of SUF-001 to SUF-328 or PRE-001 to PRE-334. Sent " + enchant + '.');
|
||||
}
|
||||
cim.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class FlashMsgCmd extends AbstractDevCmd {
|
||||
this.sendUsage(pcSender);
|
||||
return;
|
||||
}
|
||||
ChatManager.chatSystemFlash(String.join(" ", args));
|
||||
ChatManager.chatSystemFlash(args[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
@@ -244,7 +245,6 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
for (Regions regions : targetBuilding.getBounds().getRegions()) {
|
||||
//TODO ADD REGION INFO
|
||||
}
|
||||
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
output += newline;
|
||||
@@ -280,7 +280,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "Inventory Weight:" + (targetPC.getCharItemManager().getInventoryWeight() + targetPC.getCharItemManager().getEquipWeight());
|
||||
output += newline;
|
||||
output += "Max Inventory Weight:" + targetPC.getInventoryCapacity();
|
||||
output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3);
|
||||
output += newline;
|
||||
output += "ALTITUDE :" + targetPC.getAltitude();
|
||||
output += newline;
|
||||
@@ -336,9 +336,8 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
|
||||
output += "Swimming : " + targetPC.isSwimming();
|
||||
output += newline;
|
||||
output += "isMoving : " + targetPC.isMoving() + newline;
|
||||
output += "Zerg Multiplier: " + targetPC.ZergMultiplier + newline;
|
||||
output += "isBoxed: " + targetPC.isBoxed + newline;
|
||||
output += "isMoving : " + targetPC.isMoving();
|
||||
|
||||
break;
|
||||
|
||||
case NPC:
|
||||
@@ -388,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;
|
||||
|
||||
}
|
||||
|
||||
@@ -474,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
|
||||
}
|
||||
@@ -526,7 +525,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
ConcurrentHashMap<String, Effect> effects = item.getEffects();
|
||||
for (String name : effects.keySet()) {
|
||||
Effect eff = effects.get(name);
|
||||
output += eff.getEffectsBase().getIDString() + " Static:" + eff.isStatic();
|
||||
output += eff.getEffectsBase().getIDString();
|
||||
output += newline;
|
||||
// output += eff.getEffectToken() + (eff.bakedInStat() ? " (baked in)" : "") + newline;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -65,10 +65,6 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
|
||||
if (item == null || !worked) {
|
||||
throwbackError(pc, "DB error 2: Unable to create item.");
|
||||
if(item == null)
|
||||
throwbackError(pc, "Item Null");
|
||||
else
|
||||
throwbackError(pc, "Worked = false");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,10 +222,6 @@ public class MakeItemCmd extends AbstractDevCmd {
|
||||
|
||||
if (item == null || !worked) {
|
||||
throwbackError(pc, "DB error 2: Unable to create item.");
|
||||
if(item == null)
|
||||
throwbackError(pc, "Item Null");
|
||||
else
|
||||
throwbackError(pc, "Worked = false");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.workthreads.HourlyJobThread;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -40,10 +41,10 @@ public class MineActiveCmd extends AbstractDevCmd {
|
||||
String trigger = args[0];
|
||||
switch (trigger) {
|
||||
case "true":
|
||||
Mine.mineWindowOpen(mine);
|
||||
HourlyJobThread.mineWindowOpen(mine);
|
||||
break;
|
||||
case "false":
|
||||
Mine.mineWindowClose(mine);
|
||||
HourlyJobThread.mineWindowClose(mine);
|
||||
break;
|
||||
default:
|
||||
this.sendUsage(pcSender);
|
||||
|
||||
@@ -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'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,9 +39,6 @@ public class PrintResistsCmd extends AbstractDevCmd {
|
||||
if (mb != null)
|
||||
name = mb.getFirstName();
|
||||
type = "Mob";
|
||||
throwbackInfo(pc, "Server resists for " + type + ' ' + name);
|
||||
tar.getResists().printResistsToClient(pc);
|
||||
return;
|
||||
} else if (tar instanceof NPC) {
|
||||
NPC npc = (NPC) tar;
|
||||
Contract contract = npc.getContract();
|
||||
|
||||
@@ -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'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
@@ -56,7 +55,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) {
|
||||
tar.calculateMaxHealthManaStamina();
|
||||
String newline = "\r\n ";
|
||||
String out = "Server stats for Player " + tar.getFirstName() + newline;
|
||||
out += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
|
||||
@@ -74,11 +72,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + newline;
|
||||
out += "Off Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + newline;
|
||||
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
||||
out += "Health Regen: " + tar.getRegenModifier(Enum.ModType.HealthRecoverRate) + newline;
|
||||
out += "Stamina Regen: " + tar.getRegenModifier(Enum.ModType.StaminaRecoverRate) + newline;
|
||||
out += "Mana Regen: " + tar.getRegenModifier(Enum.ModType.ManaRecoverRate) + newline;
|
||||
out += "Zerg Multiplier: " + tar.ZergMultiplier + newline;
|
||||
|
||||
throwbackInfo(pc, out);
|
||||
}
|
||||
|
||||
@@ -110,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.siegeMinionMap.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.siegeMinionMap.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,11 +9,12 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
public class RegionCmd extends AbstractDevCmd {
|
||||
|
||||
@@ -25,43 +26,27 @@ 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) {
|
||||
Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
|
||||
if(building == null){
|
||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||
}
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
if (region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
result.trim();
|
||||
result += (newLine);
|
||||
if(region != null) {
|
||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "is Outside: " + region.isOutside();
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
result += ("}");
|
||||
|
||||
this.throwbackInfo(pc, result.toString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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.siegeMinionMap.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.siegeMinionMap.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);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SetAdminRuneCmd extends AbstractDevCmd {
|
||||
if (worked) {
|
||||
ChatManager.chatSayInfo(pcSender,
|
||||
"rune of ID " + runeID + " removed");
|
||||
InterestManager.reloadCharacter(pcSender,false);
|
||||
InterestManager.reloadCharacter(pcSender);
|
||||
} else
|
||||
throwbackError(pcSender, "Failed to remove the rune of type "
|
||||
+ runeID);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SetBaseClassCmd extends AbstractDevCmd {
|
||||
this.setTarget(pc); //for logging
|
||||
ChatManager.chatSayInfo(pc,
|
||||
"BaseClass changed to " + classID);
|
||||
InterestManager.reloadCharacter(pc,false);
|
||||
InterestManager.reloadCharacter(pc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -14,7 +14,6 @@ import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
public class SetLevelCmd extends AbstractDevCmd {
|
||||
|
||||
@@ -47,7 +46,7 @@ public class SetLevelCmd extends AbstractDevCmd {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
if (level < 1 || level > MBServerStatics.LEVELCAP) {
|
||||
if (level < 1 || level > 75) {
|
||||
this.sendHelp(pc);
|
||||
return;
|
||||
}
|
||||
@@ -58,12 +57,12 @@ public class SetLevelCmd extends AbstractDevCmd {
|
||||
tar.setLevel((short) level);
|
||||
this.setTarget(tar); //for logging
|
||||
ChatManager.chatSayInfo(pc, tar.getFirstName() + " level changed to " + level);
|
||||
InterestManager.reloadCharacter(tar,false);
|
||||
InterestManager.reloadCharacter(tar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets your character's level to 'amount'. 'amount' must be between 1-" + MBServerStatics.LEVELCAP;
|
||||
return "Sets your character's level to 'amount'. 'amount' must be between 1-75";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SetPromotionClassCmd extends AbstractDevCmd {
|
||||
pc.setPromotionClass(classID);
|
||||
ChatManager.chatSayInfo(pc,
|
||||
"PromotionClass changed to " + classID);
|
||||
InterestManager.reloadCharacter(pc,false);
|
||||
InterestManager.reloadCharacter(pc);
|
||||
this.setTarget(pc); //for logging
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SetRuneCmd extends AbstractDevCmd {
|
||||
if (worked) {
|
||||
ChatManager.chatSayInfo(pcSender,
|
||||
"rune of ID " + runeID + " removed");
|
||||
InterestManager.reloadCharacter(pcSender,false);
|
||||
InterestManager.reloadCharacter(pcSender);
|
||||
} else
|
||||
throwbackError(pcSender, "Failed to remove the rune of type "
|
||||
+ runeID);
|
||||
|
||||
@@ -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,12 +1,10 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.LootManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.loot.BootySetEntry;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -28,9 +26,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
String output;
|
||||
|
||||
output = "Booty Simulation:" + newline;
|
||||
if(target.getObjectType().equals(Enum.GameObjectType.Mob) == false){
|
||||
return;//ugh what?
|
||||
}
|
||||
|
||||
Mob mob = (Mob) target;
|
||||
output += "Name: " + mob.getName() + newline;
|
||||
output += "Special Loot:" + newline;
|
||||
@@ -55,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
int failures = 0;
|
||||
int goldAmount = 0;
|
||||
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
|
||||
try {
|
||||
mob.loadInventory();
|
||||
@@ -83,19 +79,12 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
goldAmount += lootItem.getNumOfItems();
|
||||
break;
|
||||
default:
|
||||
if(Warehouse.maxResources.containsKey(lootItem.getItemBaseID())){
|
||||
Resources.add(lootItem);
|
||||
} else {
|
||||
OtherDrops.add(lootItem);
|
||||
}
|
||||
OtherDrops.add(lootItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
failures++;
|
||||
//throwbackError(playerCharacter,ex.getLocalizedMessage());
|
||||
//Logger.error(ex.fillInStackTrace());
|
||||
//return;
|
||||
}
|
||||
if (mob.getEquip() != null) {
|
||||
for (MobEquipment me : mob.getEquip().values()) {
|
||||
@@ -142,17 +131,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
output += "GLASS DROPS: " + GlassItems.size() + newline;
|
||||
for(Item glass : GlassItems){
|
||||
output += " " + glass.getName() + newline;
|
||||
}
|
||||
output += "RUNE DROPS: " + Runes.size() + newline;
|
||||
for(Item rune : Runes){
|
||||
output += " " + rune.getName() + newline;
|
||||
}
|
||||
output += "CONTRACTS DROPS: " + Contracts.size() + newline;
|
||||
for(Item contract : Contracts){
|
||||
output += " " + contract.getName() + newline;
|
||||
}
|
||||
output += "RESOURCE DROPS: " + Resources.size() + newline;
|
||||
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
|
||||
output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SlotTestCmd extends AbstractDevCmd {
|
||||
outString += "Hirelings List:";
|
||||
|
||||
for (AbstractCharacter hireling : building.getHirelings().keySet())
|
||||
outString += "\r\n" + hireling.getName() + "(" + hireling.getObjectUUID() + ") slot : " + building.getHirelings().get(hireling);
|
||||
outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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, serverZone, null, null, "", 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,14 +9,17 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.MobBase;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.powers.RunePowerEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -58,6 +61,27 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
Mob mob = (Mob) target;
|
||||
output = "Mob AI Information:" + newline;
|
||||
output += mob.getName() + 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) {
|
||||
@@ -88,17 +112,46 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
|
||||
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;
|
||||
|
||||
for (int token : mob.mobPowers.keySet())
|
||||
output += PowersManager.getPowerByToken(token).getName() + 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 += "Race type: " + MobBase.mobbase_race_types.get(mob.getMobBaseID());
|
||||
throwbackInfo(playerCharacter, output);
|
||||
|
||||
throwbackInfo(playerCharacter, "Race Types: " + MobBase.mobbase_race_types.size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.*;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class setProfit extends AbstractDevCmd {
|
||||
|
||||
public setProfit() {
|
||||
super("setprofit");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
if (words.length < 2) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
float updateValue;
|
||||
try {
|
||||
updateValue = Float.parseFloat(words[1]);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
throwbackError(pc,
|
||||
"Failed to parse supplied contractID or level to an Integer.");
|
||||
return; // NaN
|
||||
}
|
||||
if(target.getObjectType().equals(GameObjectType.NPC) == false){
|
||||
|
||||
return;
|
||||
}
|
||||
NPC npc = (NPC)target;
|
||||
if(words[0].toLowerCase().equals("buy")){
|
||||
npc.buyPercent = updateValue;
|
||||
npc.updateDatabase();
|
||||
return;
|
||||
}
|
||||
if(words[0].toLowerCase().equals("sell")){
|
||||
npc.sellPercent = updateValue;
|
||||
npc.updateDatabase();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets profit margin of targeted NPC";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /setprofit buy/sell VALUE(1.0)'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,15 +9,21 @@
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.CollisionEngine.CollisionManager;
|
||||
import engine.CollisionEngine.MeshData;
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.CollisionEngine.Triangle;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
@@ -27,19 +33,32 @@ import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
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>> prop_meshes = new HashMap<>();
|
||||
public static HashMap<Integer, Vector2f> mesh_heights = new HashMap<>();
|
||||
public static HashMap<Integer,ArrayList<ArrayList<Vector3f>>> mesh_triangle_points = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, Rectangle2D> mesh_bounding_boxes = 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 +123,6 @@ public enum BuildingManager {
|
||||
if (building == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
@@ -112,26 +130,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 +325,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 +403,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 +511,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 +530,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
|
||||
}
|
||||
@@ -520,10 +579,9 @@ public enum BuildingManager {
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return false;
|
||||
|
||||
if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) {
|
||||
Logger.error("failed at addHireling with contract: " + contract.getContractID());
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
|
||||
return false;
|
||||
}
|
||||
|
||||
String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
|
||||
|
||||
if (item.getChargesRemaining() > 0)
|
||||
@@ -531,41 +589,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(), zone, building, contract, 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(), zone, building, contract, 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(), zone, building, contract, 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;
|
||||
}
|
||||
@@ -788,4 +868,156 @@ 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);
|
||||
|
||||
//rebake colliders for change in rank
|
||||
//BuildingManager.BakeBuildingMeshes(building);
|
||||
BuildingManager.BakeBuildingColliders(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 BakeBuildingColliders(Building building){
|
||||
|
||||
if(CollisionManager.structure_meshes.containsKey(building.meshUUID) == false) {
|
||||
Logger.error("No Meshes Found For Structure: " + building.meshUUID);
|
||||
return;
|
||||
}
|
||||
|
||||
//create the empty array of meshes
|
||||
building.buildingMeshes = new ArrayList<>();
|
||||
|
||||
//create the actual meshes from the stored mesh data
|
||||
for(MeshData meshData : CollisionManager.structure_meshes.get(building.meshUUID)){
|
||||
if(meshData.meshID == 0)
|
||||
continue;
|
||||
|
||||
int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY);
|
||||
|
||||
Mesh generatedMesh = new Mesh();
|
||||
|
||||
generatedMesh.meshData = meshData;
|
||||
|
||||
Vector3f buildingLoc = new Vector3f(building.loc.x,building.loc.y,building.loc.z);
|
||||
|
||||
Vector3f offset_mesh_loc = buildingLoc.add(meshData.loc);
|
||||
Vector3f offset_mesh_end = buildingLoc.add(meshData.endPoint);
|
||||
Vector3f offset_mesh_ref = buildingLoc.add(meshData.refPoint);
|
||||
|
||||
generatedMesh.mesh_location = Vector3f.rotateAroundPoint(offset_mesh_loc,buildingLoc,degrees);
|
||||
generatedMesh.mesh_end_point = Vector3f.rotateAroundPoint(offset_mesh_end,buildingLoc,degrees);
|
||||
generatedMesh.mesh_ref_point = Vector3f.rotateAroundPoint(offset_mesh_ref,buildingLoc,degrees);
|
||||
|
||||
generatedMesh.mesh_max_y = building.loc.y + meshData.maxY;
|
||||
generatedMesh.mesh_min_y = building.loc.y + meshData.minY;
|
||||
generatedMesh.mesh_scale = meshData.scale;
|
||||
generatedMesh.mesh_id = meshData.meshID;
|
||||
generatedMesh.parent_prop_id = meshData.propID;
|
||||
generatedMesh.parent_structure_id = building.meshUUID;
|
||||
generatedMesh.parentUUID = building.getObjectUUID();
|
||||
generatedMesh.update();
|
||||
building.buildingMeshes.add(generatedMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,28 +459,28 @@ 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;
|
||||
int errorTrack = 0;
|
||||
int subTrack = 0;
|
||||
|
||||
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,74 +540,46 @@ 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;
|
||||
|
||||
//Get hit chance
|
||||
float constant = (atr+defense)*0.315f;
|
||||
float atrChance = atr - constant;
|
||||
float defChance = defense - constant + atrChance;
|
||||
float smallChance = atrChance/defChance;
|
||||
int chance = (int)(smallChance * 100);
|
||||
|
||||
int chance;
|
||||
float dif = atr - defense;
|
||||
|
||||
if (dif > 100)
|
||||
chance = 94;
|
||||
else if (dif < -100)
|
||||
chance = 4;
|
||||
else
|
||||
chance = (int) ((0.45 * dif) + 49);
|
||||
|
||||
errorTrack = 5;
|
||||
|
||||
if(chance < 5){
|
||||
chance = 5;
|
||||
}
|
||||
if(chance > 95){
|
||||
chance = 95;
|
||||
}
|
||||
|
||||
//calculate hit/miss
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(1,101);
|
||||
int roll = ThreadLocalRandom.current().nextInt(100);
|
||||
DeferredPowerJob dpj = null;
|
||||
|
||||
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;
|
||||
@@ -686,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);
|
||||
@@ -725,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;
|
||||
}
|
||||
|
||||
@@ -753,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;
|
||||
}
|
||||
}
|
||||
@@ -774,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
|
||||
|
||||
@@ -782,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;
|
||||
@@ -801,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;
|
||||
}
|
||||
|
||||
@@ -811,7 +719,11 @@ public enum CombatManager {
|
||||
|
||||
float damage;
|
||||
|
||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
if (wb != null)
|
||||
damage = calculateDamage(attacker, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
else
|
||||
damage = calculateDamage(attacker, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
|
||||
float d = 0f;
|
||||
|
||||
errorTrack = 12;
|
||||
@@ -819,58 +731,39 @@ public enum CombatManager {
|
||||
//Subtract Damage from target's health
|
||||
|
||||
if (tarAc != null) {
|
||||
if (tarAc.isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
|
||||
if (tarAc.isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
|
||||
subTrack = 1;
|
||||
if (tarAc.getHealth() > 0)
|
||||
d = tarAc.modifyHealth(-damage, attacker, false);
|
||||
|
||||
if (tarAc.getObjectType() == GameObjectType.Mob) {
|
||||
Mob mobTarget = (Mob) tarAc;
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
subTrack = 2;
|
||||
if (mobTarget.playerAgroMap.containsKey(ac.getObjectUUID())) {
|
||||
subTrack = 3;
|
||||
float hateValue = damage + mobTarget.playerAgroMap.get(ac.getObjectUUID());
|
||||
mobTarget.playerAgroMap.put(ac.getObjectUUID(), hateValue);
|
||||
} else {
|
||||
mobTarget.playerAgroMap.put(ac.getObjectUUID(), damage);
|
||||
}
|
||||
subTrack = 4;
|
||||
}
|
||||
mobTarget.handleDirectAggro(ac);
|
||||
}
|
||||
if (tarAc.getHealth() > 0)
|
||||
d = tarAc.modifyHealth(-damage, ac, false);
|
||||
subTrack = 5;
|
||||
} else if (target.getObjectType().equals(GameObjectType.Building)) {
|
||||
subTrack = 6;
|
||||
|
||||
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||
ac.setCombatTarget(null);
|
||||
subTrack = 7;
|
||||
attacker.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
subTrack = 8;
|
||||
|
||||
if (target.getHealth() > 0)
|
||||
d = ((Building) target).modifyHealth(-damage, ac);
|
||||
subTrack = 9;
|
||||
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;
|
||||
|
||||
@@ -897,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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -909,53 +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: " + errorTrack + " ErrorSubTrack = " + subTrack + e);
|
||||
Logger.error(e.getMessage());
|
||||
Logger.error(attacker.getName() + ' ' + errorTrack + ' ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1034,9 +926,7 @@ public enum CombatManager {
|
||||
damage += minDamage;
|
||||
|
||||
//calculate resists in if any
|
||||
if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
damage *= ((PlayerCharacter)source).ZergMultiplier;
|
||||
}
|
||||
|
||||
if (resists != null)
|
||||
return resists.getResistedDamage(source, target, damageType, damage, 0);
|
||||
else
|
||||
@@ -1235,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);
|
||||
|
||||
@@ -1252,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);
|
||||
|
||||
@@ -1275,13 +1165,6 @@ public enum CombatManager {
|
||||
|
||||
range += (calcHitBox(ac) + calcHitBox(target));
|
||||
|
||||
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
range += ((PlayerCharacter)ac).getCharacterHeight() * 0.5f;
|
||||
if(ac.isMoving()){
|
||||
range += ((PlayerCharacter) ac).getCharacterHeight();
|
||||
}
|
||||
}
|
||||
|
||||
float magnitudeSquared = tl.distanceSquared(sl);
|
||||
|
||||
return magnitudeSquared > range * range;
|
||||
@@ -1289,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();
|
||||
|
||||
@@ -11,8 +11,6 @@ package engine.gameManager;
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.devcmd.cmds.*;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Account;
|
||||
import engine.objects.PlayerCharacter;
|
||||
@@ -48,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());
|
||||
@@ -121,7 +121,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new PurgeObjectsCmd());
|
||||
DevCmdManager.registerDevCmd(new SplatMobCmd());
|
||||
DevCmdManager.registerDevCmd(new SlotNpcCmd());
|
||||
DevCmdManager.registerDevCmd(new setProfit());
|
||||
DevCmdManager.registerDevCmd(new GateInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new ShowOffsetCmd());
|
||||
DevCmdManager.registerDevCmd(new RealmInfoCmd());
|
||||
@@ -131,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());
|
||||
@@ -142,11 +140,11 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new BoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new RegionCmd());
|
||||
DevCmdManager.registerDevCmd(new ColliderCmd());
|
||||
DevCmdManager.registerDevCmd(new SetMaintCmd());
|
||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||
DevCmdManager.registerDevCmd(new SlotTestCmd());
|
||||
|
||||
}
|
||||
|
||||
private static void registerDevCmd(AbstractDevCmd cmd) {
|
||||
@@ -182,17 +180,8 @@ public enum DevCmdManager {
|
||||
|
||||
//kill any commands not available to everyone on production server
|
||||
//only admin level can run dev commands on production
|
||||
if((cmd.toLowerCase().equals("printstats") || cmd.toLowerCase().equals("printresists")) && target.equals(pcSender)){
|
||||
// execute command;
|
||||
try {
|
||||
adc.doCmd(pcSender, argString, target);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a.status.equals(Enum.AccountStatus.ADMIN) == false && a.getUname().toLowerCase().equals("fatboy") == false) {
|
||||
if (a.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||
Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
|
||||
return false;
|
||||
}
|
||||
@@ -216,11 +205,6 @@ public enum DevCmdManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, pcName + " from account: " + accName + " has used Dev Command: " + cmd);
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,9 @@ import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -36,11 +34,6 @@ public enum LootManager {
|
||||
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>();
|
||||
|
||||
public static ArrayList<Integer> vorg_ha_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510}));
|
||||
public static ArrayList<Integer> vorg_ma_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27570,188900,188910,188920,188930,188940,188950,189500}));
|
||||
public static ArrayList<Integer> vorg_la_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27550,27560,189100,189110,189120,189130,189140,189150}));
|
||||
public static ArrayList<Integer> vorg_cloth_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27600,188700,188720,189550,189560}));
|
||||
|
||||
// Drop Rates
|
||||
|
||||
public static float NORMAL_DROP_RATE;
|
||||
@@ -75,13 +68,16 @@ public enum LootManager {
|
||||
|
||||
public static void GenerateMobLoot(Mob mob) {
|
||||
|
||||
//determine if mob is in hotzone
|
||||
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
|
||||
|
||||
//iterate the booty sets
|
||||
|
||||
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true)
|
||||
RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob);
|
||||
RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone);
|
||||
|
||||
if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true)
|
||||
RunBootySet(_bootySetMap.get(mob.bootySet), mob);
|
||||
RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone);
|
||||
|
||||
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
||||
for (Item it : mob.getInventory()) {
|
||||
@@ -89,8 +85,8 @@ public enum LootManager {
|
||||
ItemBase ib = it.getItemBase();
|
||||
if(ib == null)
|
||||
break;
|
||||
if (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?");
|
||||
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
|
||||
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);
|
||||
@@ -99,105 +95,54 @@ public enum LootManager {
|
||||
|
||||
}
|
||||
|
||||
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob) {
|
||||
mob.runeCounter++;
|
||||
mob.contractCounter++;
|
||||
float dropRate = NORMAL_DROP_RATE;
|
||||
//roll the geenric world drop table
|
||||
if(mob.parentZone.getSafeZone() == 0) {
|
||||
GenerateLootDrop(mob, 1300);
|
||||
if(ThreadLocalRandom.current().nextInt(1, 10000) == 5000) {
|
||||
MobLoot extraLoot = rollForGlass(mob);
|
||||
if (extraLoot != null) {
|
||||
mob.getCharItemManager().addItemToInventory(extraLoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) {
|
||||
|
||||
boolean hotzoneWasRan = false;
|
||||
float dropRate = 1.0f;
|
||||
|
||||
// Iterate all entries in this bootySet and process accordingly
|
||||
|
||||
for (BootySetEntry bse : entries) {
|
||||
switch (bse.bootyType) {
|
||||
case "GOLD":
|
||||
GenerateGoldDrop(mob, bse);
|
||||
GenerateGoldDrop(mob, bse, inHotzone);
|
||||
break;
|
||||
case "LOOT":
|
||||
if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate))
|
||||
GenerateLootDrop(mob, bse.genTable); //generate normal loot drop
|
||||
if(ThreadLocalRandom.current().nextInt(1,100) == 50){
|
||||
MobLoot extraLoot = rollForContract(bse.genTable, mob);
|
||||
if (extraLoot != null) {
|
||||
mob.getCharItemManager().addItemToInventory(extraLoot);
|
||||
|
||||
if (mob.getSafeZone() == false)
|
||||
dropRate = LootManager.NORMAL_DROP_RATE;
|
||||
|
||||
if (inHotzone == true)
|
||||
dropRate = LootManager.HOTZONE_DROP_RATE;
|
||||
|
||||
if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate))
|
||||
GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop
|
||||
|
||||
// Generate hotzone loot if in hotzone
|
||||
// Only one bite at the hotzone apple per bootyset.
|
||||
|
||||
if (inHotzone == true && hotzoneWasRan == false)
|
||||
if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) {
|
||||
GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table
|
||||
hotzoneWasRan = true;
|
||||
}
|
||||
}
|
||||
if(ThreadLocalRandom.current().nextInt(1,100) == 50){
|
||||
MobLoot extraLoot = rollForRune(bse.genTable, mob);
|
||||
if (extraLoot != null) {
|
||||
mob.getCharItemManager().addItemToInventory(extraLoot);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "ITEM":
|
||||
GenerateInventoryDrop(mob, bse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MobLoot specialDrop = null;
|
||||
switch(mob.getObjectUUID()) {
|
||||
case 22595://elf 1
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252134),true);
|
||||
mob.setFirstName("Melandrach The Blood-Mage");
|
||||
break;
|
||||
case 22432: //elf 2
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252135),true);
|
||||
mob.setFirstName("Kyrtaar The Blood-Mage");
|
||||
break;
|
||||
case 22537: //elf 3
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252136),true);
|
||||
mob.setFirstName("Vamir The Blood-Mage");
|
||||
break;
|
||||
case 16387: //human 4 DONE
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252129),true);
|
||||
mob.setFirstName("Alatar The Blood-Mage");
|
||||
break;
|
||||
case 32724:// human 5 GOOD
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252130),true);
|
||||
mob.setFirstName("Elphaba The Blood-Mage");
|
||||
break;
|
||||
case 23379: //human 1 GOOD
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252131),true);
|
||||
mob.setFirstName("Bavmorda The Blood-Mage");
|
||||
break;
|
||||
case 10826: //human 2 REDO
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252132),true);
|
||||
mob.setFirstName("Draco The Blood-Mage");
|
||||
break;
|
||||
case 15929: //human 3 GOOD
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(252133),true);
|
||||
mob.setFirstName("Atlantes The Blood-Mage");
|
||||
break;
|
||||
}
|
||||
if(specialDrop != null) {
|
||||
mob.setLevel((short) 65);
|
||||
mob.setSpawnTime(10800);
|
||||
mob.healthMax = (7500);
|
||||
mob.setHealth(7500);
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + specialDrop.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
mob.getCharItemManager().addItemToInventory(specialDrop);
|
||||
mob.setResists(new Resists("Dropper"));
|
||||
}
|
||||
}
|
||||
|
||||
public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob) {
|
||||
public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) {
|
||||
|
||||
if (mob == null || _genTables.containsKey(genTableID) == false)
|
||||
return null;
|
||||
|
||||
MobLoot outItem;
|
||||
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1,94 + 1);
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1);
|
||||
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
|
||||
|
||||
@@ -215,7 +160,7 @@ public enum LootManager {
|
||||
if(mob.getObjectType().ordinal() == 52) { //52 = player character
|
||||
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
itemTableRoll = TableRoll(mob.level);
|
||||
itemTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
|
||||
if (tableRow == null)
|
||||
@@ -227,10 +172,7 @@ public enum LootManager {
|
||||
return null;
|
||||
|
||||
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
|
||||
int chance = ThreadLocalRandom.current().nextInt(1,101);
|
||||
if(chance > 10)
|
||||
return null;
|
||||
int amount = ThreadLocalRandom.current().nextInt((int)(tableRow.minSpawn * 0.5f), (int)((tableRow.maxSpawn + 1) * 0.5f));
|
||||
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
|
||||
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
|
||||
}
|
||||
|
||||
@@ -240,7 +182,7 @@ public enum LootManager {
|
||||
|
||||
if(selectedRow.pModTable != 0){
|
||||
try {
|
||||
outItem = GeneratePrefix(mob, outItem, genTableID, genRoll);
|
||||
outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone);
|
||||
outItem.setIsID(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Failed to GeneratePrefix for item: " + outItem.getName());
|
||||
@@ -248,7 +190,7 @@ public enum LootManager {
|
||||
}
|
||||
if(selectedRow.sModTable != 0){
|
||||
try {
|
||||
outItem = GenerateSuffix(mob, outItem, genTableID, genRoll);
|
||||
outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone);
|
||||
outItem.setIsID(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
|
||||
@@ -257,7 +199,7 @@ public enum LootManager {
|
||||
return outItem;
|
||||
}
|
||||
|
||||
private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) {
|
||||
private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) {
|
||||
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
|
||||
|
||||
@@ -274,7 +216,7 @@ public enum LootManager {
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
prefixTableRoll = TableRoll(mob.level);
|
||||
prefixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
|
||||
|
||||
@@ -289,7 +231,7 @@ public enum LootManager {
|
||||
return inItem;
|
||||
}
|
||||
|
||||
private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) {
|
||||
private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) {
|
||||
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
|
||||
|
||||
@@ -306,7 +248,7 @@ public enum LootManager {
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
suffixTableRoll = TableRoll(mob.level);
|
||||
suffixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
|
||||
|
||||
@@ -321,7 +263,7 @@ public enum LootManager {
|
||||
return inItem;
|
||||
}
|
||||
|
||||
public static int TableRoll(int mobLevel) {
|
||||
public static int TableRoll(int mobLevel, Boolean inHotzone) {
|
||||
|
||||
if (mobLevel > 65)
|
||||
mobLevel = 65;
|
||||
@@ -336,12 +278,15 @@ public enum LootManager {
|
||||
if (min < 70)
|
||||
min = 70;
|
||||
|
||||
if (inHotzone)
|
||||
min += mobLevel;
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(min, max + 1);
|
||||
|
||||
return roll;
|
||||
}
|
||||
|
||||
public static void GenerateGoldDrop(Mob mob, BootySetEntry bse) {
|
||||
public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) {
|
||||
|
||||
int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
|
||||
@@ -352,9 +297,14 @@ public enum LootManager {
|
||||
|
||||
//determine and add gold to mob inventory
|
||||
|
||||
int high = (int)(bse.highGold * NORMAL_GOLD_RATE);
|
||||
int low = (int)(bse.lowGold * NORMAL_GOLD_RATE);
|
||||
int gold = ThreadLocalRandom.current().nextInt(low, high);
|
||||
int high = bse.highGold;
|
||||
int low = bse.lowGold;
|
||||
int gold = ThreadLocalRandom.current().nextInt(low, high + 1);
|
||||
|
||||
if (inHotzone == true)
|
||||
gold = (int) (gold * HOTZONE_GOLD_RATE);
|
||||
else
|
||||
gold = (int) (gold * NORMAL_GOLD_RATE);
|
||||
|
||||
if (gold > 0) {
|
||||
MobLoot goldAmount = new MobLoot(mob, gold);
|
||||
@@ -363,31 +313,25 @@ public enum LootManager {
|
||||
|
||||
}
|
||||
|
||||
public static void GenerateLootDrop(Mob mob, int tableID) {
|
||||
public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) {
|
||||
|
||||
try {
|
||||
if(mob.parentZone.getSafeZone() == 1) {
|
||||
return;
|
||||
}
|
||||
MobLoot toAdd = getGenTableItem(tableID, mob);
|
||||
if(toAdd.getItemBase().getType().equals(Enum.ItemType.CONTRACT) || toAdd.getItemBase().getType().equals(Enum.ItemType.RUNE))
|
||||
return;//block all contracts and runes that drop outside the confines of the new system
|
||||
|
||||
if (toAdd != null) {
|
||||
toAdd.setIsID(true);
|
||||
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
|
||||
|
||||
if (toAdd != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO chase down loot generation error, affects roughly 2% of drops
|
||||
int i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateEquipmentDrop(Mob mob) {
|
||||
|
||||
if(mob.parentZone.getSafeZone() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -398,64 +342,25 @@ public enum LootManager {
|
||||
|
||||
float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
float dropChance = me.getDropChance() * 100;
|
||||
|
||||
if (equipmentRoll > dropChance)
|
||||
continue;
|
||||
ItemBase genericIB = me.getItemBase();
|
||||
if(genericIB.isVorg()){
|
||||
if(genericIB.isClothArmor()){
|
||||
//get random cloth piece
|
||||
genericIB = getRandomVorgCloth();//ItemBase.getItemBase(vorg_cloth_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_cloth_uuids.size() - 1)));
|
||||
} else if(genericIB.isHeavyArmor()){
|
||||
//get random heavy armor piece
|
||||
genericIB = getRandomVorgHA();//ItemBase.getItemBase(vorg_ha_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ha_uuids.size() - 1)));
|
||||
} else if(genericIB.isMediumArmor()){
|
||||
//get random medium armor piece
|
||||
genericIB = getRandomVorgMA();//ItemBase.getItemBase(vorg_ma_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ma_uuids.size() - 1)));
|
||||
} else if(genericIB.isLightArmor()){
|
||||
//get random light armor piece
|
||||
genericIB = getRandomVorgLA();//ItemBase.getItemBase(vorg_la_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_la_uuids.size() - 1)));
|
||||
}
|
||||
mob.spawnTime = ThreadLocalRandom.current().nextInt(300,2700);
|
||||
}
|
||||
MobLoot ml = new MobLoot(mob, genericIB, false);
|
||||
|
||||
if (ml != null && dropCount < 1 && genericIB.isVorg() == false) {
|
||||
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
|
||||
|
||||
if (ml != null && dropCount < 1) {
|
||||
ml.setIsID(true);
|
||||
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||
mob.getCharItemManager().addItemToInventory(ml);
|
||||
dropCount = 1;
|
||||
//break; // Exit on first successful roll.
|
||||
}
|
||||
if(ml != null && genericIB.isVorg() && mob.getMobBaseID() != 14062){
|
||||
ml.setIsID(true);
|
||||
ml.setDurabilityCurrent(ml.getDurabilityMax());
|
||||
mob.getCharItemManager().addItemToInventory(ml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) {
|
||||
|
||||
if(ItemBase.getItemBase(bse.itemBase).isDiscRune()) {
|
||||
if(!Mob.disciplineDroppers.contains(mob))
|
||||
Mob.disciplineDroppers.add(mob);
|
||||
|
||||
mob.setResists(new Resists("Dropper"));
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ItemBase.getItemBase(bse.itemBase).getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
}
|
||||
|
||||
//if((bse.itemBase == 3040 || bse.itemBase == 3021) && mob.level < 80){
|
||||
// chance = 100;
|
||||
//}
|
||||
|
||||
if(mob.parentZone.getSafeZone() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int chanceRoll = ThreadLocalRandom.current().nextInt(1, 99);
|
||||
int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
|
||||
//early exit, failed to hit minimum chance roll
|
||||
|
||||
@@ -551,164 +456,4 @@ public enum LootManager {
|
||||
itemMan.addItemToInventory(playerWinnings);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
|
||||
public static MobLoot rollForContract(int table, Mob mob){
|
||||
|
||||
int roll = 99;
|
||||
if (table == 1900 || table == 1500)
|
||||
roll = 73;
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(table, roll, 1.0f);
|
||||
if (selectedRow == null)
|
||||
return null;
|
||||
|
||||
int itemTableId = selectedRow.itemTableID;
|
||||
|
||||
if (_itemTables.containsKey(itemTableId) == false)
|
||||
return null;
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(75,321));
|
||||
if (tableRow == null)
|
||||
return null;
|
||||
|
||||
int itemUUID = tableRow.cacheID;
|
||||
|
||||
if (itemUUID == 0)
|
||||
return null;
|
||||
|
||||
MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
|
||||
if(outItem != null) {
|
||||
mob.contractCounter = ThreadLocalRandom.current().nextInt(200);
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " looks like he found something special");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToInterestArea(mob,chatMsg, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE,false,false);
|
||||
return outItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static MobLoot rollForRune(int table, Mob mob){
|
||||
int roll = 97;
|
||||
if(table == 1900 || table == 1500){
|
||||
roll = 77;
|
||||
}
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(table, roll, 1.0f);
|
||||
if (selectedRow == null)
|
||||
return null;
|
||||
|
||||
int itemTableId = selectedRow.itemTableID;
|
||||
|
||||
if (_itemTables.containsKey(itemTableId) == false)
|
||||
return null;
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(75,321));
|
||||
if (tableRow == null)
|
||||
return null;
|
||||
|
||||
int itemUUID = tableRow.cacheID;
|
||||
|
||||
if (itemUUID == 0)
|
||||
return null;
|
||||
|
||||
MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
|
||||
if(outItem != null) {
|
||||
mob.runeCounter = ThreadLocalRandom.current().nextInt(200);
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " looks like he found something special");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToInterestArea(mob,chatMsg, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE,false,false);
|
||||
return outItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static MobLoot rollForGlass( Mob mob){
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(220,321));
|
||||
if (tableRow == null)
|
||||
return null;
|
||||
|
||||
int itemUUID = tableRow.cacheID;
|
||||
|
||||
if (itemUUID == 0)
|
||||
return null;
|
||||
|
||||
MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
|
||||
if(outItem != null)
|
||||
return outItem;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemBase getRandomVorgCloth(){
|
||||
int random = ThreadLocalRandom.current().nextInt(100);
|
||||
if(random < 20)
|
||||
return ItemBase.getItemBase(27600);
|
||||
if(random > 20 && random < 40)
|
||||
return ItemBase.getItemBase(188700);
|
||||
if(random > 40 && random < 60)
|
||||
return ItemBase.getItemBase(188720);
|
||||
if(random > 60 && random < 80)
|
||||
return ItemBase.getItemBase(189550);
|
||||
if(random > 80)
|
||||
return ItemBase.getItemBase(189560);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemBase getRandomVorgLA(){
|
||||
int random = ThreadLocalRandom.current().nextInt(160);
|
||||
if(random < 20)
|
||||
return ItemBase.getItemBase(27550);
|
||||
if(random > 20 && random < 40)
|
||||
return ItemBase.getItemBase(27560);
|
||||
if(random > 40 && random < 60)
|
||||
return ItemBase.getItemBase(189100);
|
||||
if(random > 60 && random < 80)
|
||||
return ItemBase.getItemBase(189110);
|
||||
if(random > 80 && random < 100)
|
||||
return ItemBase.getItemBase(189120);
|
||||
if(random > 100 && random < 120)
|
||||
return ItemBase.getItemBase(189130);
|
||||
if(random > 120 && random < 140)
|
||||
return ItemBase.getItemBase(189140);
|
||||
if(random > 140)
|
||||
return ItemBase.getItemBase(189150);
|
||||
return null;
|
||||
}
|
||||
public static ItemBase getRandomVorgMA(){
|
||||
int random = ThreadLocalRandom.current().nextInt(160);
|
||||
if(random < 20)
|
||||
return ItemBase.getItemBase(27570);
|
||||
if(random > 20 && random < 40)
|
||||
return ItemBase.getItemBase(188900);
|
||||
if(random > 40 && random < 60)
|
||||
return ItemBase.getItemBase(188910);
|
||||
if(random > 60 && random < 80)
|
||||
return ItemBase.getItemBase(188920);
|
||||
if(random > 80 && random < 100)
|
||||
return ItemBase.getItemBase(188930);
|
||||
if(random > 100 && random < 120)
|
||||
return ItemBase.getItemBase(188940);
|
||||
if(random > 120 && random < 140)
|
||||
return ItemBase.getItemBase(188950);
|
||||
if(random > 140)
|
||||
return ItemBase.getItemBase(189500);
|
||||
return null;
|
||||
}
|
||||
public static ItemBase getRandomVorgHA(){
|
||||
int random = ThreadLocalRandom.current().nextInt(180);
|
||||
if(random < 20)
|
||||
return ItemBase.getItemBase(27580);
|
||||
if(random > 20 && random < 40)
|
||||
return ItemBase.getItemBase(27590);
|
||||
if(random > 40 && random < 60)
|
||||
return ItemBase.getItemBase(188500);
|
||||
if(random > 60 && random < 80)
|
||||
return ItemBase.getItemBase(188510);
|
||||
if(random > 80 && random < 100)
|
||||
return ItemBase.getItemBase(188520);
|
||||
if(random > 100 && random < 120)
|
||||
return ItemBase.getItemBase(188530);
|
||||
if(random > 120 && random < 140)
|
||||
return ItemBase.getItemBase(188540);
|
||||
if(random > 140 && random < 160)
|
||||
return ItemBase.getItemBase(188550);
|
||||
if(random > 160)
|
||||
return ItemBase.getItemBase(189510);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,206 +5,320 @@
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
// Defines static methods which comprise the magicbane
|
||||
// building maintenance system.
|
||||
|
||||
import engine.Enum;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public enum MaintenanceManager {
|
||||
|
||||
MAINTENANCEMANAGER;
|
||||
|
||||
public static void setMaintDateTime(Building building, LocalDateTime maintDate) {
|
||||
|
||||
building.maintDateTime = maintDate;
|
||||
DbManager.BuildingQueries.updateMaintDate(building);
|
||||
|
||||
}
|
||||
|
||||
public static void processBuildingMaintenance() {
|
||||
|
||||
ArrayList<AbstractGameObject> buildingList;
|
||||
ArrayList<Building> maintList;
|
||||
ArrayList<Building> derankList = new ArrayList<>();
|
||||
|
||||
Logger.info("Starting Maintenance on Player Buildings");
|
||||
|
||||
// Build list of buildings to apply maintenance on.
|
||||
|
||||
buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.Building));
|
||||
maintList = buildMaintList(buildingList);
|
||||
|
||||
// Deduct upkeep and build list of buildings
|
||||
// which did not have funds available
|
||||
|
||||
for (Building building : maintList) {
|
||||
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
}
|
||||
// Reset maintenance dates for these buildings
|
||||
|
||||
for (Building building : maintList) {
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||
|
||||
}
|
||||
// Derak or destroy buildings that did not
|
||||
// have funds available.
|
||||
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
|
||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||
}
|
||||
|
||||
// Iterate over all buildings in game and apply exclusion rules
|
||||
// returning a list of building for which maintenance is due.
|
||||
|
||||
private static ArrayList<Building> buildMaintList(ArrayList<AbstractGameObject> buildingList) {
|
||||
|
||||
ArrayList<Building> maintList = new ArrayList<>();
|
||||
|
||||
for (AbstractGameObject gameObject : buildingList) {
|
||||
|
||||
Building building = (Building) gameObject;
|
||||
|
||||
// No maintenance on NPC owned buildings (Cache loaded)
|
||||
|
||||
if (building.getProtectionState() == Enum.ProtectionState.NPC)
|
||||
continue;
|
||||
|
||||
// No maintenance on constructing meshes
|
||||
|
||||
if (building.getRank() < 1)
|
||||
continue;
|
||||
|
||||
// No Maintenance on furniture
|
||||
|
||||
if (building.parentBuildingID != 0)
|
||||
continue;
|
||||
|
||||
// No Blueprint?
|
||||
|
||||
if (building.getBlueprint() == null) {
|
||||
Logger.error("Blueprint missing for uuid: " + building.getObjectUUID());
|
||||
continue;
|
||||
}
|
||||
|
||||
// No maintenance on banestones omfg
|
||||
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE))
|
||||
continue;
|
||||
|
||||
// no maintenance on Mines omfg
|
||||
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.MINE))
|
||||
continue;
|
||||
|
||||
// Null Maintenance date?
|
||||
|
||||
if (building.maintDateTime == null) {
|
||||
Logger.error("Null maint date for building UUID: " + building.getObjectUUID());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Maintenance date is in the future
|
||||
|
||||
if (building.maintDateTime.isAfter(LocalDateTime.now()))
|
||||
continue;
|
||||
|
||||
|
||||
//no maintenance if day of week doesnt match
|
||||
if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
|
||||
continue;
|
||||
}
|
||||
// Add building to maintenance queue
|
||||
|
||||
maintList.add(building);
|
||||
}
|
||||
|
||||
return maintList;
|
||||
}
|
||||
|
||||
// Method removes the appropriate amount of gold/resources from
|
||||
// a building according to it's maintenance schedule. True/False
|
||||
// is returned indicating if the building had enough funds to cover.
|
||||
|
||||
public static boolean chargeUpkeep(Building building) {
|
||||
|
||||
City city = null;
|
||||
Warehouse warehouse = null;
|
||||
int maintCost = 0;
|
||||
int overDraft = 0;
|
||||
boolean hasFunds = false;
|
||||
boolean hasResources = false;
|
||||
int resourceValue = 0;
|
||||
|
||||
city = building.getCity();
|
||||
|
||||
if (city != null)
|
||||
warehouse = city.getWarehouse();
|
||||
|
||||
// Cache maintenance cost value
|
||||
|
||||
maintCost = building.getMaintCost();
|
||||
|
||||
// Something went wrong. Missing buildinggroup from switch?
|
||||
|
||||
if (maintCost == 0) {
|
||||
Logger.error("chargeUpkeep", "Error retrieving rankcost for " + building.getName() + " uuid:" + building.getObjectUUID() + "buildinggroup:" + building.getBlueprint().getBuildingGroup().name());
|
||||
// check if there is enough gold on the building
|
||||
return true;
|
||||
}
|
||||
|
||||
if (building.getStrongboxValue() >= maintCost)
|
||||
hasFunds = true;
|
||||
|
||||
// If we cannot cover with just the strongbox
|
||||
// see if there is a warehouse that will cover
|
||||
// the overdraft for us.
|
||||
|
||||
|
||||
if (hasFunds == false && (building.assetIsProtected() || building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.WAREHOUSE)) {
|
||||
overDraft = maintCost - building.getStrongboxValue();
|
||||
}
|
||||
|
||||
if ((overDraft > 0))
|
||||
if ((building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SHRINE) == false) &&
|
||||
(warehouse != null) && building.assetIsProtected() == true &&
|
||||
(warehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) >= overDraft) {
|
||||
hasFunds = true;
|
||||
}
|
||||
|
||||
// If this is an R8 tree, validate that we can
|
||||
// cover the resources required
|
||||
|
||||
if (building.getRank() == 8) {
|
||||
|
||||
hasResources = true;
|
||||
|
||||
if (warehouse == null)
|
||||
hasResources = false;
|
||||
else {
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
|
||||
}
|
||||
}
|
||||
// Validation completed but has failed. We can derank
|
||||
// the target building and early exit
|
||||
|
||||
if ((hasFunds == false) ||
|
||||
((building.getRank() == 8) && !hasResources)) {
|
||||
|
||||
// Add cash back to strongbox for lost rank if the building isn't being destroyed
|
||||
// and it's not an R8 deranking
|
||||
|
||||
if ((building.getRank() > 1) && (building.getRank() < 8)) {
|
||||
building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7)));
|
||||
}
|
||||
|
||||
return false; // Early exit for having failed to meet maintenance
|
||||
}
|
||||
|
||||
// Remove cash and resources
|
||||
|
||||
// withdraw what we can from the building
|
||||
|
||||
building.setStrongboxValue(building.getStrongboxValue() - (maintCost - overDraft));
|
||||
|
||||
// withdraw overdraft from the whorehouse
|
||||
|
||||
if (overDraft > 0) {
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.goldIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateGold(warehouse, resourceValue - overDraft) == true) {
|
||||
warehouse.getResources().put(Warehouse.goldIB, resourceValue - overDraft);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GOLD, overDraft);
|
||||
} else {
|
||||
Logger.error("gold update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Early exit as we're done if we're not an R8 tree
|
||||
|
||||
if (building.getRank() < 8)
|
||||
return true;
|
||||
|
||||
// Now for the resources if it's an R8 tree
|
||||
|
||||
// Withdraw Stone
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.getResources().put(Warehouse.stoneIB, resourceValue - 1500);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
|
||||
} else {
|
||||
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Withdraw Lumber
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.getResources().put(Warehouse.lumberIB, resourceValue - 1500);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
|
||||
} else {
|
||||
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Withdraw Galvor
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.getResources().put(Warehouse.galvorIB, resourceValue - 5);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
|
||||
} else {
|
||||
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.getResources().put(Warehouse.wormwoodIB, resourceValue - 5);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
|
||||
} else {
|
||||
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void dailyMaintenance() {
|
||||
|
||||
Logger.info("Maintenance has started");
|
||||
|
||||
// Run maintenance on player buildings
|
||||
|
||||
if (ConfigManager.MB_WORLD_MAINTENANCE.getValue().equalsIgnoreCase("true"))
|
||||
processMaintenance();
|
||||
processBuildingMaintenance();
|
||||
else
|
||||
Logger.info("Maintenance Costings: DISABLED");
|
||||
|
||||
Logger.info("Maintenance has completed!");
|
||||
}
|
||||
public static void processMaintenance() {
|
||||
//create list of all cities
|
||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
||||
//loop all cities
|
||||
for (AbstractGameObject ago : worldCities.values()) {
|
||||
if (ago.getObjectType().equals(Enum.GameObjectType.City)) {
|
||||
City city = (City) ago;
|
||||
if(city == null || !city.getParent().isPlayerCity())
|
||||
continue;
|
||||
Building tol = city.getTOL();
|
||||
if(tol == null)
|
||||
continue;
|
||||
LocalDateTime maintenanceDueDate = tol.maintDateTime.withHour(1).withMinute(0).withSecond(0);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if(now.isAfter(maintenanceDueDate))
|
||||
processTolMaintenance(tol, city.getWarehouse());
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void processTolMaintenance(Building tol, Warehouse warehouse){
|
||||
if(tol == null)
|
||||
return;
|
||||
if(tol.getRank() == 8)
|
||||
handleR8(tol,warehouse);
|
||||
else
|
||||
handleNormal(tol,warehouse);
|
||||
}
|
||||
public static void handleNormal(Building tol, Warehouse warehouse){
|
||||
//handle r7 and lower ToL maintenance
|
||||
int goldDue = 3000000;
|
||||
//enough on strongbox alone to pay
|
||||
if (tol.getStrongboxValue() >= goldDue) {
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(7);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.setStrongboxValue(tol.getStrongboxValue() - goldDue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int newStrongboxValue = tol.getStrongboxValue();
|
||||
int newWarehouseGold = 0;
|
||||
if(warehouse != null && warehouse.getResources().get(ItemBase.getItemBase(7)) != null) {
|
||||
newWarehouseGold = warehouse.getResources().get(ItemBase.getItemBase(7));
|
||||
} else{
|
||||
//wasnt enough on strongbox and gold in warehouse is empty
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//some on strongbox to pay
|
||||
if (tol.getStrongboxValue() > 0) {
|
||||
newStrongboxValue = 0;
|
||||
goldDue -= tol.getStrongboxValue();
|
||||
}
|
||||
if(newWarehouseGold < goldDue){
|
||||
//not enough gold to pay, you miss maintenance
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
newWarehouseGold -= goldDue;
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(7);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol) && DbManager.WarehouseQueries.updateGold(warehouse,newWarehouseGold)) {
|
||||
warehouse.getResources().put(ItemBase.getItemBase(7), newWarehouseGold);
|
||||
tol.setStrongboxValue(newStrongboxValue);
|
||||
}
|
||||
}
|
||||
public static void handleR8(Building tol, Warehouse warehouse){
|
||||
//handle r8 ToL maintenance
|
||||
//cannot pay r8 maintenance without a warehouse
|
||||
if(warehouse == null && DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
return;
|
||||
}
|
||||
//handle resource processing
|
||||
int goldDue = 3000000;
|
||||
int galvorDue = 5;
|
||||
int wormwoodDue = 5;
|
||||
int stoneDue = 5000;
|
||||
int lumberDue = 5000;
|
||||
int goldStrongBox = tol.getStrongboxValue();
|
||||
int goldWarehouse = 0;
|
||||
int galvorWarehouse;
|
||||
int wormwoodWarehouse;
|
||||
int stoneWarehouse;
|
||||
int lumberWarehouse;
|
||||
if(warehouse.getResources().get(Warehouse.galvorIB) != null) {
|
||||
galvorWarehouse = warehouse.getResources().get(Warehouse.galvorIB);
|
||||
}else {
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(warehouse.getResources().get(Warehouse.stoneIB) != null) {
|
||||
stoneWarehouse = warehouse.getResources().get(Warehouse.stoneIB);
|
||||
}else {
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(warehouse.getResources().get(Warehouse.wormwoodIB) != null) {
|
||||
wormwoodWarehouse = warehouse.getResources().get(Warehouse.wormwoodIB);
|
||||
}else {
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(warehouse.getResources().get(Warehouse.lumberIB) != null) {
|
||||
lumberWarehouse = warehouse.getResources().get(Warehouse.lumberIB);
|
||||
}else {
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean canPay = true;
|
||||
if(goldStrongBox >= goldDue){
|
||||
goldStrongBox -= goldDue;
|
||||
goldDue = 0;
|
||||
}
|
||||
if (tol.getStrongboxValue() > 0) {
|
||||
goldStrongBox = 0;
|
||||
goldDue -= tol.getStrongboxValue();
|
||||
}
|
||||
if(warehouse.getResources().get(Warehouse.goldIB) != null) {
|
||||
goldWarehouse = warehouse.getResources().get(Warehouse.goldIB);
|
||||
}else if(goldDue > 0){
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(wormwoodDue > wormwoodWarehouse)
|
||||
canPay = false;
|
||||
if(galvorDue > galvorWarehouse)
|
||||
canPay = false;
|
||||
if(lumberDue > lumberWarehouse)
|
||||
canPay = false;
|
||||
if(stoneDue > stoneWarehouse)
|
||||
canPay = false;
|
||||
if(goldDue > goldWarehouse)
|
||||
canPay = false;
|
||||
if(!canPay){
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
tol.destroyOrDerank(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
tol.setStrongboxValue(goldStrongBox);
|
||||
if(DbManager.WarehouseQueries.updateGold(warehouse,goldWarehouse - goldDue)){
|
||||
if(DbManager.WarehouseQueries.updateStone(warehouse,stoneWarehouse - stoneDue)){
|
||||
if(DbManager.WarehouseQueries.updateLumber(warehouse,lumberWarehouse - lumberDue)){
|
||||
if(DbManager.WarehouseQueries.updateGalvor(warehouse,galvorWarehouse - galvorDue)){
|
||||
if(DbManager.WarehouseQueries.updateWormwood(warehouse,wormwoodWarehouse - wormwoodDue)){
|
||||
tol.maintDateTime = LocalDateTime.now().plusDays(1);
|
||||
if(DbManager.BuildingQueries.updateMaintDate(tol)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,9 @@ public enum MovementManager {
|
||||
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
if (((PlayerCharacter) toMove).isCasting())
|
||||
((PlayerCharacter) toMove).update();
|
||||
if(((PlayerCharacter) toMove).isFlying() && toMove.getEffects().containsKey("MoveBuff"))
|
||||
PlayerCharacter.GroundPlayer(((PlayerCharacter) toMove));
|
||||
}
|
||||
|
||||
|
||||
toMove.setIsCasting(false);
|
||||
toMove.setItemCasting(false);
|
||||
|
||||
@@ -117,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));
|
||||
@@ -129,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) {
|
||||
@@ -175,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 {
|
||||
@@ -186,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.
|
||||
@@ -234,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);
|
||||
|
||||
|
||||
@@ -268,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
|
||||
|
||||
@@ -465,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,84 +27,6 @@ public enum NPCManager {
|
||||
NPC_MANAGER;
|
||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||
|
||||
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);
|
||||
@@ -196,80 +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 = (PlayerCharacter) toRemove.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
|
||||
petOwner.setPet(null);
|
||||
|
||||
toRemove.guardCaptain = 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,7 +192,7 @@ public enum NPCManager {
|
||||
|
||||
if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) {
|
||||
Mob siegeMobile = (Mob) abstractCharacter;
|
||||
buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2;
|
||||
buildingSlot = siegeMobile.guardCaptain.minions.size() + 2;
|
||||
}
|
||||
|
||||
if (buildingSlot == -1)
|
||||
@@ -376,33 +228,6 @@ public enum NPCManager {
|
||||
return buildingSlot;
|
||||
}
|
||||
|
||||
public static int getMaxMinions(Mob guardCaptain) {
|
||||
|
||||
int maxSlots;
|
||||
|
||||
switch (guardCaptain.getRank()) {
|
||||
case 3:
|
||||
maxSlots = 2;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
maxSlots = 3;
|
||||
break;
|
||||
case 6:
|
||||
maxSlots = 4;
|
||||
break;
|
||||
case 7:
|
||||
maxSlots = 5;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
default:
|
||||
maxSlots = 1;
|
||||
|
||||
}
|
||||
return maxSlots;
|
||||
}
|
||||
|
||||
public static void AssignPatrolPoints(Mob mob) {
|
||||
mob.patrolPoints = new ArrayList<>();
|
||||
|
||||
@@ -419,9 +244,234 @@ public enum NPCManager {
|
||||
mob.patrolPoints.add(newPatrolPoint);
|
||||
|
||||
if (i == 1) {
|
||||
mob.loc = newPatrolPoint;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -27,7 +27,6 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import engine.powers.*;
|
||||
import engine.powers.effectmodifiers.SeeInvisibleEffectModifier;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import engine.powers.poweractions.TrackPowerAction;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -54,29 +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;
|
||||
|
||||
public static String[] siegeBuffs = new String[]{"ART-004A","ARM-112A"};
|
||||
public static String[] siegeDeBuffs = new String[]{"ACM-003A","WRT-003A"};
|
||||
|
||||
public static ArrayList<PowerQueObject> static_power_que = new ArrayList<>();
|
||||
|
||||
public static class PowerQueObject{
|
||||
public PowerQueObject(PerformActionMsg inmsg,ClientConnection inorigin,boolean insendCastToSelf){
|
||||
this.msg = inmsg;
|
||||
this.origin = inorigin;
|
||||
this.sendCastToSelf = insendCastToSelf;
|
||||
}
|
||||
public PerformActionMsg msg;
|
||||
public ClientConnection origin;
|
||||
public boolean sendCastToSelf;
|
||||
}
|
||||
|
||||
private PowersManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void initPowersManager(boolean fullPowersLoad) {
|
||||
|
||||
if (fullPowersLoad)
|
||||
@@ -120,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() {
|
||||
|
||||
@@ -182,9 +172,11 @@ public enum PowersManager {
|
||||
|
||||
if (usePowerA(msg, origin, sendCastToSelf)) {
|
||||
// Cast failed for some reason, reset timer
|
||||
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
|
||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
// Send Fail to cast message
|
||||
PlayerCharacter pc = SessionManager
|
||||
.getPlayerCharacter(origin);
|
||||
@@ -218,8 +210,6 @@ public enum PowersManager {
|
||||
if (playerCharacter == null)
|
||||
return false;
|
||||
|
||||
boolean skipCheck = false;
|
||||
|
||||
boolean CSRCast = false;
|
||||
|
||||
|
||||
@@ -232,67 +222,10 @@ public enum PowersManager {
|
||||
+ Integer.toHexString(msg.getPowerUsedID()) + " ("
|
||||
+ msg.getPowerUsedID() + ')');
|
||||
}
|
||||
Boolean earlyExit = false;
|
||||
|
||||
//Sending recycle message to player if died while casting.
|
||||
if (!playerCharacter.isAlive() && msg.getPowerUsedID() != 428589216) { //succor
|
||||
|
||||
earlyExit = true;
|
||||
}
|
||||
|
||||
if(msg.getPowerUsedID() == 430628895){ // group teleport
|
||||
|
||||
Boolean activeBane = false;
|
||||
|
||||
if(ZoneManager.getCityAtLocation(playerCharacter.loc) != null && ZoneManager.getCityAtLocation(playerCharacter.loc).getBane() != null)
|
||||
activeBane = ZoneManager.getCityAtLocation(playerCharacter.loc).getBane().getSiegePhase().equals(SiegePhase.WAR);
|
||||
|
||||
Zone currentZone = ZoneManager.findSmallestZone(playerCharacter.loc);
|
||||
if(currentZone == null)
|
||||
earlyExit = true;
|
||||
|
||||
if(currentZone.isPlayerCity() && !activeBane)
|
||||
earlyExit = true;
|
||||
|
||||
if(currentZone.getName().contains("Mine") == true && currentZone.isPlayerCity() == false) {
|
||||
for (Building building : currentZone.zoneBuildingSet) {
|
||||
if (Mine.getMineFromTower(building.getObjectUUID()) != null) {
|
||||
Mine currentMine = Mine.getMineFromTower(building.getObjectUUID());
|
||||
if (currentMine.isActive == false) {
|
||||
earlyExit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getTargetX(),msg.getTargetY(),msg.getTargetZ());
|
||||
currentZone = ZoneManager.findSmallestZone(endLoc);
|
||||
|
||||
if(currentZone == null)
|
||||
earlyExit = true;
|
||||
|
||||
if(currentZone.isPlayerCity() && !activeBane)
|
||||
earlyExit = true;
|
||||
|
||||
if(currentZone.getName().contains("Mine") == true && currentZone.isPlayerCity() == false) {
|
||||
for (Building building : currentZone.zoneBuildingSet) {
|
||||
if (Mine.getMineFromTower(building.getObjectUUID()) != null) {
|
||||
Mine currentMine = Mine.getMineFromTower(building.getObjectUUID());
|
||||
if (currentMine.isActive == false) {
|
||||
earlyExit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// get power
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
|
||||
|
||||
if(pb.description.equals("Personal Movement Buff") && playerCharacter.isFlying()) {
|
||||
ChatManager.chatSystemInfo(playerCharacter, "You cannot use movement speed buffs while flying");
|
||||
earlyExit = true;
|
||||
}
|
||||
|
||||
if (earlyExit) {
|
||||
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, recyclePowerMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
@@ -300,6 +233,7 @@ public enum PowersManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// if (!pc.getPowers().contains(msg.getPowerUsedID())) {
|
||||
// sendPowerMsg(pc, 10, msg);
|
||||
// return false;
|
||||
@@ -312,6 +246,8 @@ public enum PowersManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get power
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
|
||||
if (pb == null) {
|
||||
ChatManager.chatSayInfo(playerCharacter,
|
||||
"This power is not implemented yet.");
|
||||
@@ -322,18 +258,15 @@ public enum PowersManager {
|
||||
return true;
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (playerCharacter.getLastPower() != null)
|
||||
return true;
|
||||
|
||||
//Check if Power Target is allowed to cast.
|
||||
|
||||
|
||||
// Check powers for normal users
|
||||
|
||||
if(msg.getPowerUsedID() == 429399948)
|
||||
for(CharacterRune cr : playerCharacter.getRunes())
|
||||
if(cr.getRuneBaseID() == 3029)
|
||||
skipCheck = true;
|
||||
if (!skipCheck && (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID())))
|
||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
|
||||
if (!playerCharacter.isCSR()) {
|
||||
if (!MBServerStatics.POWERS_DEBUG) {
|
||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||
@@ -346,31 +279,18 @@ public enum PowersManager {
|
||||
|
||||
// get numTrains for power
|
||||
int trains = msg.getNumTrains();
|
||||
int token = pb.token;
|
||||
int overrideTrains = 0;
|
||||
int overrideRecycle = 0;
|
||||
if(token == 429420458){
|
||||
overrideTrains = 40;
|
||||
overrideRecycle = 300000;
|
||||
}
|
||||
|
||||
// can't go over the max trains for the power, unless CSR
|
||||
if (trains > pb.getMaxTrains() && !playerCharacter.isCSR()) {
|
||||
trains = pb.getMaxTrains();
|
||||
msg.setNumTrains(trains);
|
||||
}
|
||||
|
||||
// can't go over total trains by player
|
||||
if (playerCharacter.getPowers() != null && playerCharacter.getPowers().containsKey(msg.getPowerUsedID())) {
|
||||
CharacterPower cp = playerCharacter.getPowers().get(msg.getPowerUsedID());
|
||||
if (cp != null) {
|
||||
int tot = cp.getTotalTrains();
|
||||
switch(token){
|
||||
case 430596127:
|
||||
if(playerCharacter.getPromotionClass().getName().equals("Wizard"))
|
||||
tot = 40; //single teleport granted at 40 for wizard
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (tot == 0 && !playerCharacter.isCSR())
|
||||
return false;
|
||||
if (trains != tot && !playerCharacter.isCSR()) {
|
||||
@@ -379,19 +299,27 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(overrideTrains > 0)
|
||||
msg.setNumTrains(overrideTrains);
|
||||
|
||||
// get recycle time in ms
|
||||
int time = pb.getRecycleTime(trains);
|
||||
|
||||
if(overrideRecycle > 0)
|
||||
time = overrideRecycle;
|
||||
// verify player is in correct mode (combat/nonCombat)
|
||||
if (playerCharacter.isCombat()) {
|
||||
if (!pb.allowedInCombat())
|
||||
// ChatManager.chatPowerError(pc,
|
||||
// "This power is not allowed in combat mode.");
|
||||
return true;
|
||||
} else if (!pb.allowedOutOfCombat())
|
||||
// ChatManager.chatPowerError(pc,
|
||||
// "You must be in combat mode to use this power.");
|
||||
return true;
|
||||
|
||||
// verify player is not stunned or prohibited from casting
|
||||
PlayerBonuses bonus = playerCharacter.getBonuses();
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
Vector3fImmutable endLoc = playerCharacter.getEndLoc();
|
||||
|
||||
@@ -417,43 +345,35 @@ public enum PowersManager {
|
||||
if (pb.targetFromLastTarget() || pb.targetPet()) // use msg's target
|
||||
if (pb.isAOE()) {
|
||||
if (!pb.usePointBlank()) {
|
||||
AbstractWorldObject target;
|
||||
if(msg.getTargetType() == 37 && Mob.dynamic_pets.get(msg.getTargetID()) != null){
|
||||
Mob pet = Mob.dynamic_pets.get(msg.getTargetID());
|
||||
target = pet;
|
||||
}else{
|
||||
target = getTarget(msg);
|
||||
}
|
||||
AbstractWorldObject target = getTarget(msg);
|
||||
|
||||
|
||||
if (target != null && target.getObjectType() == GameObjectType.Building && !pb.targetBuilding()) {
|
||||
PowersManager.sendPowerMsg(playerCharacter, 9, new PerformActionMsg(msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
if (playerCharacter.getLoc().distanceSquared2D(msg.getTargetLoc()) > sqr(pb
|
||||
.getRange()))
|
||||
return true;
|
||||
} else if (verifyInvalidRange(playerCharacter, target, pb.getRange())) {
|
||||
} else if (verifyInvalidRange(playerCharacter, target, pb.getRange()))
|
||||
// pc.getLoc().distance(target.getLoc()) >
|
||||
// pb.getRange())
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
// get target
|
||||
AbstractWorldObject target;
|
||||
if(msg.getTargetType() == 37 && Mob.dynamic_pets.get(msg.getTargetID()) != null){
|
||||
Mob pet = Mob.dynamic_pets.get(msg.getTargetID());
|
||||
target = pet;
|
||||
}else{
|
||||
target = getTarget(msg);
|
||||
}
|
||||
if (target == null) {
|
||||
AbstractWorldObject target = getTarget(msg);
|
||||
|
||||
if (target == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!target.isAlive() && target.getObjectType().equals(GameObjectType.Building) == false && msg.getPowerUsedID() != 428589216)
|
||||
return true;
|
||||
|
||||
float range = pb.getRange();
|
||||
// verify target is in range
|
||||
|
||||
@@ -462,13 +382,16 @@ public enum PowersManager {
|
||||
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
|
||||
// TODO send message that target is out of range
|
||||
return true;
|
||||
|
||||
// verify target is valid type
|
||||
if (!validateTarget(target, playerCharacter, pb))
|
||||
return true;
|
||||
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
targetLiveCounter = ((AbstractCharacter) target).getLiveCounter();
|
||||
}
|
||||
|
||||
// verify regular player can cast spell, otherwise authenticate
|
||||
if (!pb.regularPlayerCanCast()) {
|
||||
Account a = SessionManager.getAccount(playerCharacter);
|
||||
@@ -478,6 +401,7 @@ public enum PowersManager {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// verify player has proper effects applied to use power
|
||||
if (pb.getEffectPrereqs().size() > 0 && playerCharacter.getEffects() != null) {
|
||||
|
||||
@@ -491,9 +415,11 @@ public enum PowersManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!passed)
|
||||
return true;
|
||||
}
|
||||
|
||||
//verify player has proper equipment to use power
|
||||
if (pb.getEquipPrereqs().size() > 0) {
|
||||
|
||||
@@ -612,13 +538,6 @@ public enum PowersManager {
|
||||
// get cast time in ms.
|
||||
time = pb.getCastTime(trains);
|
||||
|
||||
|
||||
if(pb.token == 430596127)
|
||||
time = 5000;
|
||||
|
||||
if(pb.name.equals("Summon") && playerCharacter.getRace().getName().contains("Vampire"))
|
||||
time = 60000;
|
||||
|
||||
// set player is casting for regens
|
||||
|
||||
|
||||
@@ -630,10 +549,6 @@ public enum PowersManager {
|
||||
|
||||
playerCharacter.setLastMovementState(playerCharacter.getMovementState());
|
||||
|
||||
if(msg.getPowerUsedID() == 429495514 && playerCharacter.getRace().getName().contains("Shade")){
|
||||
copyMsg.setPowerUsedID(429397210);//intercept shade using hide and cast sneak instead
|
||||
}
|
||||
|
||||
// run timer job to end cast
|
||||
if (time < 1) // run immediately
|
||||
finishUsePower(copyMsg, playerCharacter, casterLiveCounter, targetLiveCounter);
|
||||
@@ -699,13 +614,7 @@ public enum PowersManager {
|
||||
if (pb.targetFromLastTarget() || pb.targetPet()) // use msg's target
|
||||
if (pb.isAOE()) {
|
||||
if (!pb.usePointBlank()) {
|
||||
AbstractWorldObject target;
|
||||
if(msg.getTargetType() == 37 && Mob.dynamic_pets.get(msg.getTargetID()) != null){
|
||||
Mob pet = Mob.dynamic_pets.get(msg.getTargetID());
|
||||
target = pet;
|
||||
}else{
|
||||
target = getTarget(msg);
|
||||
}
|
||||
AbstractWorldObject target = getTarget(msg);
|
||||
|
||||
|
||||
if (target == null) {
|
||||
@@ -720,13 +629,7 @@ public enum PowersManager {
|
||||
}
|
||||
} else {
|
||||
// get target
|
||||
AbstractWorldObject target;
|
||||
if(msg.getTargetType() == 37 && Mob.dynamic_pets.get(msg.getTargetID()) != null){
|
||||
Mob pet = Mob.dynamic_pets.get(msg.getTargetID());
|
||||
target = pet;
|
||||
}else{
|
||||
target = getTarget(msg);
|
||||
}
|
||||
AbstractWorldObject target = getTarget(msg);
|
||||
|
||||
if (target == null)
|
||||
return true;
|
||||
@@ -1331,8 +1234,9 @@ public enum PowersManager {
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
PlayerCharacter target = SessionManager.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
if (target == null || target.equals(pc) || target.isCombat() || target.getGuild().getNation().equals(pc.getGuild().getNation()) == false) {
|
||||
PlayerCharacter target = SessionManager
|
||||
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
if (target == null || target.equals(pc) || target.isCombat()) {
|
||||
|
||||
if (target == null) // Player not found. Send not found message
|
||||
ChatManager.chatInfoError(pc,
|
||||
@@ -1341,10 +1245,7 @@ public enum PowersManager {
|
||||
ChatManager.chatInfoError(pc,
|
||||
"Cannot summon player in combat.");
|
||||
// else trying to summon self, just fail
|
||||
if(target != null && target.getGuild().getNation().equals(pc.getGuild().getNation()) == false){
|
||||
ChatManager.chatInfoError(pc,
|
||||
"Cannot summon outside of nation.");
|
||||
}
|
||||
|
||||
// recycle summon
|
||||
sendRecyclePower(msg.getPowerToken(), origin);
|
||||
|
||||
@@ -1376,7 +1277,7 @@ public enum PowersManager {
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
long tooLate = pc.getSummoner(source.getObjectUUID()) + 45000;
|
||||
long tooLate = pc.getSummoner(source.getObjectUUID());
|
||||
if (tooLate < System.currentTimeMillis()) {
|
||||
ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
||||
pc.removeSummoner(source.getObjectUUID());
|
||||
@@ -1438,15 +1339,7 @@ public enum PowersManager {
|
||||
duration = 15000; // Healer Summons, 15 seconds
|
||||
else
|
||||
duration = 45000; // Belgosh Summons, 45 seconds
|
||||
if(pc.inSafeZone() == false) {
|
||||
for (AbstractWorldObject absChar : WorldGrid.getObjectsInRangePartial(pc.loc, MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER)) {
|
||||
PlayerCharacter player = (PlayerCharacter) absChar;
|
||||
if (player.guild.getNation().equals(pc.guild.getNation()) == false) {
|
||||
duration += 60000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Teleport to summoners location
|
||||
FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
|
||||
@@ -1575,41 +1468,6 @@ public enum PowersManager {
|
||||
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
||||
allTargets, playerCharacter, maxTargets);
|
||||
|
||||
trackChars = new HashSet<>();
|
||||
HashSet<AbstractWorldObject> allInRange = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_PLAYER);
|
||||
//ArrayList<Guild> nationsInRange = new ArrayList<>();
|
||||
ArrayList<AbstractWorldObject> purgeList = new ArrayList<>();
|
||||
for(AbstractWorldObject trackChar : allInRange) {
|
||||
if(trackChar.equals(playerCharacter) || !trackChar.isAlive() || !((PlayerCharacter)trackChar).isActive())
|
||||
purgeList.add(trackChar);
|
||||
}
|
||||
|
||||
allInRange.removeAll(purgeList);
|
||||
|
||||
//first round to add players in range
|
||||
for(AbstractWorldObject trackChar : allInRange){
|
||||
if(trackChar.equals(playerCharacter) || !trackChar.isAlive() || !((PlayerCharacter)trackChar).isActive())
|
||||
continue;
|
||||
if(allInRange.contains(trackChar)) {
|
||||
trackChars.add((AbstractCharacter)trackChar);
|
||||
}
|
||||
}
|
||||
|
||||
//track full range for chaining nation members
|
||||
ArrayList<Guild> nationsInRange = new ArrayList<>();
|
||||
for(AbstractCharacter pc : trackChars){
|
||||
if(nationsInRange.contains(pc.guild.getNation()) == false)
|
||||
nationsInRange.add(pc.guild.getNation());
|
||||
}
|
||||
HashSet<AbstractWorldObject> fullRange = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,1024,MBServerStatics.MASK_PLAYER);
|
||||
for(AbstractWorldObject trackChar : fullRange) {
|
||||
if(trackChar.equals(playerCharacter) || !trackChar.isAlive() || !((PlayerCharacter)trackChar).isActive())
|
||||
continue;
|
||||
if(nationsInRange.contains(((PlayerCharacter) trackChar).guild.getNation()) && trackChars.contains(trackChar) == false)
|
||||
trackChars.add((AbstractCharacter)trackChar);
|
||||
}
|
||||
|
||||
|
||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
||||
|
||||
// send track window
|
||||
@@ -1785,8 +1643,7 @@ public enum PowersManager {
|
||||
ac.setItemCasting(false);
|
||||
if (ac == null || target == null || pb == null)
|
||||
return;
|
||||
if(pb.targetSelf)
|
||||
target = ac;
|
||||
|
||||
ac.clearTimer(Integer.toString(pb.getToken()));
|
||||
if (liveCounter == ac.getLiveCounter())
|
||||
finishApplyPowerA(ac, target, targetLoc, pb, trains, false);
|
||||
@@ -1915,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;
|
||||
@@ -2117,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);
|
||||
}
|
||||
@@ -2367,9 +2224,9 @@ public enum PowersManager {
|
||||
|
||||
int type = msg.getTargetType();
|
||||
int UUID = msg.getTargetID();
|
||||
if (type == -1 || type == 0 || UUID == -1 || UUID == 0) {
|
||||
|
||||
if (type == -1 || type == 0 || UUID == -1 || UUID == 0)
|
||||
return null;
|
||||
}
|
||||
|
||||
return (AbstractWorldObject) DbManager.getObject(GameObjectType.values()[type], UUID);
|
||||
}
|
||||
@@ -2392,11 +2249,17 @@ public enum PowersManager {
|
||||
ChatManager.chatSystemInfo(pc, smsg);
|
||||
}
|
||||
|
||||
float constant = (atr+defense)*0.315f;
|
||||
float atrChance = atr - constant;
|
||||
float defChance = defense - constant + atrChance;
|
||||
float smallChance = atrChance/defChance;
|
||||
int chance = (int)(smallChance * 100);
|
||||
int chance;
|
||||
|
||||
if (atr > defense || defense == 0)
|
||||
chance = 94;
|
||||
else {
|
||||
float dif = atr / defense;
|
||||
if (dif <= 0.8f)
|
||||
chance = 4;
|
||||
else
|
||||
chance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
}
|
||||
|
||||
// calculate hit/miss
|
||||
int roll = ThreadLocalRandom.current().nextInt(100);
|
||||
@@ -2604,11 +2467,11 @@ public enum PowersManager {
|
||||
ChatManager.chatSystemInfo(pc, outmsg);
|
||||
return false; // can't target player, stop here
|
||||
} // target is mob
|
||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0 && ((Mob)target).isPet() == false)
|
||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0)
|
||||
return pb.targetMob();
|
||||
|
||||
// target is pet
|
||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0 && ((Mob)target).isPet() == true)
|
||||
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_PET) != 0)
|
||||
return pb.targetPet();
|
||||
|
||||
// target is Building
|
||||
@@ -2687,7 +2550,7 @@ public enum PowersManager {
|
||||
|
||||
PowersBase power = getLastPower(ac);
|
||||
|
||||
if (power != null && power.cancelOnTakeDamage() && power.getName().equals("Translocate") == false)
|
||||
if (power != null && power.cancelOnTakeDamage())
|
||||
cancelPower(ac, true);
|
||||
cancelItems(ac, false, true);
|
||||
ac.cancelTimer("Stuck");
|
||||
@@ -2847,12 +2710,7 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void applyZergBuff(AbstractGameObject obj){
|
||||
|
||||
}
|
||||
public static void removeZergBuff(HashSet<Integer> playersIDs){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,12 +10,10 @@ package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.db.archive.MineRecord;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Runegate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -24,7 +22,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
|
||||
/*
|
||||
@@ -36,14 +33,13 @@ public enum SimulationManager {
|
||||
SERVERHEARTBEAT;
|
||||
|
||||
private static final long CITY_PULSE = 2000;
|
||||
private static final long RUNEGATE_PULSE = 500;
|
||||
private static final long RUNEGATE_PULSE = 3000;
|
||||
private static final long UPDATE_PULSE = 1000;
|
||||
private static final long FlIGHT_PULSE = 100;
|
||||
public static Duration executionTime = Duration.ofNanos(1);
|
||||
public static Duration executionMax = Duration.ofNanos(1);
|
||||
private static SimulationManager instance = null;
|
||||
private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
|
||||
private long _minePulseTime = System.currentTimeMillis() + CITY_PULSE;
|
||||
private long _runegatePulseTime = System.currentTimeMillis()
|
||||
+ RUNEGATE_PULSE;
|
||||
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
|
||||
@@ -73,8 +69,6 @@ public enum SimulationManager {
|
||||
return popString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Update the simulation. *** Important: Whatever you do in here, do it damn
|
||||
* quick!
|
||||
@@ -132,17 +126,7 @@ public enum SimulationManager {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
//try {
|
||||
// if ((_minePulseTime != 0)
|
||||
// && (System.currentTimeMillis() > _minePulseTime))
|
||||
// pulseMines();
|
||||
//} catch (Exception e) {
|
||||
// Logger.error(
|
||||
// "Fatal error in Mine Pulse: DISABLED. Error Message : "
|
||||
// + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
|
||||
//}
|
||||
SimulationManager.executionTime = Duration.between(startTime, Instant.now());
|
||||
|
||||
if (executionTime.compareTo(executionMax) > 0)
|
||||
@@ -219,6 +203,7 @@ public enum SimulationManager {
|
||||
city = (City) cityObject;
|
||||
city.onEnter();
|
||||
}
|
||||
|
||||
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.objects.Guild;
|
||||
|
||||
public class ZergManager {
|
||||
|
||||
public static int getBaneCap(Guild guild) {
|
||||
|
||||
if(guild.getOwnedCity() == null || guild.getOwnedCity().getTOL() == null)
|
||||
return 0;
|
||||
|
||||
int cityRank = guild.getOwnedCity().getTOL().getRank();
|
||||
return (cityRank == 8) ? 20 : ((guild.getNation().getSubGuildList().size() + 1 <= 4) ? 10 : 20);
|
||||
}
|
||||
|
||||
public static float getCurrentMultiplier(int count, int maxCount){
|
||||
switch(maxCount) {
|
||||
case 3:
|
||||
return getMultiplier3Man(count);
|
||||
case 5:
|
||||
return getMultiplier5Man(count);
|
||||
case 10:
|
||||
return getMultiplier10Man(count);
|
||||
case 20:
|
||||
return getMultiplier20Man(count);
|
||||
default:
|
||||
return getMultiplier40Man(count);
|
||||
}
|
||||
}
|
||||
public static float getMultiplier(int count, int maxCount, float[] thresholds) {
|
||||
if (count <= maxCount) return 1.0f;
|
||||
if (count > thresholds.length) return 0.0f;
|
||||
return 1.0f - thresholds[count - maxCount - 1];
|
||||
}
|
||||
|
||||
public static float getMultiplier3Man(int count) {
|
||||
float[] thresholds = {0.37f, 0.60f, 0.75f};
|
||||
return getMultiplier(count, 3, thresholds);
|
||||
}
|
||||
|
||||
public static float getMultiplier5Man(int count) {
|
||||
float[] thresholds = {0.25f, 0.43f, 0.56f, 0.67f, 0.75f};
|
||||
return getMultiplier(count, 5, thresholds);
|
||||
}
|
||||
|
||||
public static float getMultiplier10Man(int count) {
|
||||
float[] thresholds = {0.14f, 0.25f, 0.35f, 0.43f, 0.50f, 0.56f, 0.62f, 0.67f, 0.71f, 0.75f};
|
||||
return getMultiplier(count, 10, thresholds);
|
||||
}
|
||||
|
||||
public static float getMultiplier20Man(int count) {
|
||||
return getMultiplier10Man(count * 2);
|
||||
}
|
||||
|
||||
public static float getMultiplier40Man(int count) {
|
||||
return getMultiplier10Man(count * 4);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,7 @@
|
||||
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;
|
||||
@@ -18,6 +17,7 @@ import engine.math.Vector3fImmutable;
|
||||
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;
|
||||
|
||||
@@ -36,6 +36,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 +47,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 +62,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 +72,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 +85,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 +101,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 +121,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 +139,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 +160,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 +195,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 +231,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 +259,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 +318,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 +331,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 +357,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 +384,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 +401,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,9 @@ import engine.gameManager.DbManager;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.objects.Bane;
|
||||
import engine.objects.City;
|
||||
import engine.workthreads.ZergMechanicThread;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static engine.workthreads.ZergMechanicThread.startZergThreadBane;
|
||||
|
||||
public class ActivateBaneJob extends AbstractScheduleJob {
|
||||
|
||||
private final int cityUUID;
|
||||
@@ -71,10 +67,6 @@ public class ActivateBaneJob extends AbstractScheduleJob {
|
||||
msg.setChannel(ChatChannelType.SYSTEM.getChannelID());
|
||||
|
||||
DispatchMessage.dispatchMsgToAll(msg);
|
||||
|
||||
if(city.getBane() != null) {
|
||||
startZergThreadBane(city.getBane());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,11 +9,9 @@
|
||||
|
||||
package engine.jobs;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.job.AbstractJob;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class AttackJob extends AbstractJob {
|
||||
|
||||
@@ -31,9 +29,6 @@ public class AttackJob extends AbstractJob {
|
||||
@Override
|
||||
protected void doJob() {
|
||||
CombatManager.doCombat(this.source, slot);
|
||||
if(this.source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
if(((PlayerCharacter)this.source).getHidden() > 0)
|
||||
this.source.removeEffectBySource(Enum.EffectSourceType.Invisibility,41,true);
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -34,15 +34,10 @@ public class ModTableEntry {
|
||||
|
||||
itemTableEntryList = LootManager._modTables.get(modTablwe);
|
||||
|
||||
if(itemTableEntryList == null)
|
||||
return null;
|
||||
|
||||
for (ModTableEntry iteration : itemTableEntryList) {
|
||||
if (iteration == null)
|
||||
continue;
|
||||
for (ModTableEntry iteration : itemTableEntryList)
|
||||
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
|
||||
modTableEntry = iteration;
|
||||
}
|
||||
|
||||
return modTableEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class Bounds {
|
||||
//player is inside building region, skip collision check. we only do collision from the outside.
|
||||
if (player.region != null && player.region.parentBuildingID == building.getObjectUUID())
|
||||
continue;
|
||||
if (building.getBounds() == null || building.getBounds().colliders == null)
|
||||
if (building.getBounds().colliders == null)
|
||||
continue;
|
||||
|
||||
for (Colliders collider : building.getBounds().colliders) {
|
||||
@@ -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);
|
||||
|
||||
|
||||
+477
-284
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ public class MobAIThread implements Runnable{
|
||||
public static int AI_DROP_AGGRO_RANGE = 60;
|
||||
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
||||
public static int AI_PATROL_DIVISOR = 15;
|
||||
public static float AI_CAST_FREQUENCY = 1.0f;
|
||||
public static float AI_CAST_FREQUENCY;
|
||||
// Thread constructor
|
||||
|
||||
public MobAIThread() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -12,20 +12,13 @@ package engine.mobileAI.utilities;
|
||||
import engine.Enum.*;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.CombatManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mobileAI.MobAI;
|
||||
import engine.mobileAI.Threads.MobAIThread;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PerformActionMsg;
|
||||
import engine.net.client.msg.TargetedActionMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.ActionsBase;
|
||||
import engine.powers.PowersBase;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
@@ -271,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);
|
||||
}
|
||||
|
||||
swingIsDamage(agent, target, determineDamage(agent), anim);
|
||||
|
||||
|
||||
if (agent.getWeaponPower() != null)
|
||||
agent.getWeaponPower().attack(target, MBServerStatics.ONE_MINUTE);
|
||||
@@ -311,6 +294,7 @@ public class CombatUtilities {
|
||||
if (targetMob.isSiege())
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static float determineDamage(Mob agent) {
|
||||
@@ -325,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
|
||||
@@ -363,365 +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 double getMaxDmg(Mob agent) {
|
||||
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield())
|
||||
return agent.maxDamageHandTwo;
|
||||
else return agent.maxDamageHandOne;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
return agent.getMinDamageHandOne();
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
return agent.getMaxDamageHandOne();
|
||||
}
|
||||
|
||||
public static boolean MobCast(Mob mob) {
|
||||
|
||||
try {
|
||||
// Method picks a random spell from a mobile's list of powers
|
||||
// and casts it on the current target (or itself). Validation
|
||||
// (including empty lists) is done previously within canCast();
|
||||
|
||||
ArrayList<Integer> powerTokens;
|
||||
ArrayList<Integer> purgeTokens;
|
||||
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
|
||||
|
||||
if (mob.behaviourType.callsForHelp)
|
||||
MobAI.MobCallForHelp(mob);
|
||||
|
||||
// Generate a list of tokens from the mob powers for this mobile.
|
||||
|
||||
powerTokens = new ArrayList<>(mob.mobPowers.keySet());
|
||||
purgeTokens = new ArrayList<>();
|
||||
|
||||
// If player has this effect on them currently then remove
|
||||
// this token from our list.
|
||||
|
||||
for (int powerToken : powerTokens) {
|
||||
|
||||
PowersBase powerBase = PowersManager.getPowerByToken(powerToken);
|
||||
|
||||
for (ActionsBase actionBase : powerBase.getActions()) {
|
||||
|
||||
String stackType = actionBase.stackType;
|
||||
|
||||
if (target.getEffects() != null && target.getEffects().containsKey(stackType))
|
||||
purgeTokens.add(powerToken);
|
||||
}
|
||||
}
|
||||
|
||||
powerTokens.removeAll(purgeTokens);
|
||||
|
||||
// Sanity check
|
||||
|
||||
if (powerTokens.isEmpty())
|
||||
return false;
|
||||
|
||||
// Pick random spell from our list of powers
|
||||
|
||||
int powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size()));
|
||||
int powerRank = mob.mobPowers.get(powerToken);
|
||||
|
||||
PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
|
||||
|
||||
//check for hit-roll
|
||||
|
||||
if (mobPower.requiresHitRoll)
|
||||
if (triggerDefense(mob, mob.getCombatTarget()))
|
||||
return false;
|
||||
|
||||
// Cast the spell
|
||||
|
||||
if (inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) {
|
||||
|
||||
PerformActionMsg msg;
|
||||
|
||||
if (!mobPower.isHarmful() || mobPower.targetSelf) {
|
||||
PowersManager.useMobPower(mob, mob, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob);
|
||||
} else {
|
||||
PowersManager.useMobPower(mob, target, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target);
|
||||
}
|
||||
|
||||
msg.setUnknown04(2);
|
||||
|
||||
PowersManager.finishUseMobPower(msg, mob, 0, 0);
|
||||
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000L) * MobAIThread.AI_CAST_FREQUENCY);
|
||||
|
||||
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean GuardCast(Mob mob) {
|
||||
|
||||
try {
|
||||
// Method picks a random spell from a mobile's list of powers
|
||||
// and casts it on the current target (or itself). Validation
|
||||
// (including empty lists) is done previously within canCast();
|
||||
|
||||
ArrayList<Integer> powerTokens;
|
||||
ArrayList<Integer> purgeTokens;
|
||||
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
|
||||
|
||||
if (mob.behaviourType.callsForHelp)
|
||||
MobAI.MobCallForHelp(mob);
|
||||
|
||||
// Generate a list of tokens from the mob powers for this mobile.
|
||||
|
||||
powerTokens = new ArrayList<>(mob.mobPowers.keySet());
|
||||
purgeTokens = new ArrayList<>();
|
||||
|
||||
// If player has this effect on them currently then remove
|
||||
// this token from our list.
|
||||
|
||||
for (int powerToken : powerTokens) {
|
||||
|
||||
PowersBase powerBase = PowersManager.getPowerByToken(powerToken);
|
||||
|
||||
for (ActionsBase actionBase : powerBase.getActions()) {
|
||||
|
||||
String stackType = actionBase.stackType;
|
||||
|
||||
if (target.getEffects() != null && target.getEffects().containsKey(stackType))
|
||||
purgeTokens.add(powerToken);
|
||||
}
|
||||
}
|
||||
|
||||
powerTokens.removeAll(purgeTokens);
|
||||
|
||||
// Sanity check
|
||||
|
||||
if (powerTokens.isEmpty())
|
||||
return false;
|
||||
|
||||
int powerToken;
|
||||
int nukeRoll = ThreadLocalRandom.current().nextInt(1,100);
|
||||
|
||||
if (nukeRoll < 55) {
|
||||
|
||||
//use direct damage spell
|
||||
powerToken = powerTokens.get(powerTokens.size() - 1);
|
||||
|
||||
} else {
|
||||
//use random spell
|
||||
powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size()));
|
||||
}
|
||||
|
||||
int powerRank = 1;
|
||||
|
||||
switch(mob.getRank()){
|
||||
case 1:
|
||||
powerRank = 10;
|
||||
break;
|
||||
case 2:
|
||||
powerRank = 15;
|
||||
break;
|
||||
case 3:
|
||||
powerRank = 20;
|
||||
break;
|
||||
case 4:
|
||||
powerRank = 25;
|
||||
break;
|
||||
case 5:
|
||||
powerRank = 30;
|
||||
break;
|
||||
case 6:
|
||||
powerRank = 35;
|
||||
break;
|
||||
case 7:
|
||||
powerRank = 40;
|
||||
break;
|
||||
}
|
||||
|
||||
PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
|
||||
|
||||
//check for hit-roll
|
||||
|
||||
if (mobPower.requiresHitRoll)
|
||||
if (triggerDefense(mob, mob.getCombatTarget()))
|
||||
return false;
|
||||
|
||||
// Cast the spell
|
||||
|
||||
if (inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) {
|
||||
|
||||
PerformActionMsg msg;
|
||||
|
||||
if (!mobPower.isHarmful() || mobPower.targetSelf) {
|
||||
|
||||
if (mobPower.category.equals("DISPEL")) {
|
||||
PowersManager.useMobPower(mob, target, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target);
|
||||
} else {
|
||||
PowersManager.useMobPower(mob, mob, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob);
|
||||
}
|
||||
} else {
|
||||
PowersManager.useMobPower(mob, target, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target);
|
||||
}
|
||||
|
||||
msg.setUnknown04(2);
|
||||
|
||||
PowersManager.finishUseMobPower(msg, mob, 0, 0);
|
||||
|
||||
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000L) * MobAIThread.AI_CAST_FREQUENCY);
|
||||
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MovementUtilities {
|
||||
|
||||
//Guards recall distance = 814.
|
||||
if (tol != null) {
|
||||
return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.extents));
|
||||
return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.halfExtents));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,8 +68,8 @@ public class MovementUtilities {
|
||||
float zoneRange = 250;
|
||||
|
||||
if (agent.getParentZone() != null) {
|
||||
if (agent.getParentZone().getBounds() != null)
|
||||
zoneRange = agent.getParentZone().getBounds().getHalfExtents().x * 2;
|
||||
if (agent.getParentZone().bounds != null)
|
||||
zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2;
|
||||
}
|
||||
|
||||
if (zoneRange > 300)
|
||||
@@ -115,8 +115,39 @@ public class MovementUtilities {
|
||||
|
||||
}
|
||||
|
||||
public static void moveToLocation(Mob agent, Vector3fImmutable newLocation, float offset) {
|
||||
agent.resetLastSetLocUpdate();
|
||||
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, boolean isWalking) {
|
||||
try {
|
||||
|
||||
//don't move farther than 30 units from player.
|
||||
@@ -127,7 +158,7 @@ public class MovementUtilities {
|
||||
|
||||
agent.setFaceDir(newLoc.subtract2D(agent.getLoc()).normalize());
|
||||
|
||||
aiMove(agent, newLoc, false);
|
||||
aiMove(agent, newLoc, isWalking);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
@@ -141,8 +172,32 @@ public class MovementUtilities {
|
||||
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();
|
||||
|
||||
|
||||
@@ -189,10 +244,10 @@ public class MovementUtilities {
|
||||
msg.setSourceID(agent.getObjectUUID());
|
||||
msg.setStartCoord(startLoc);
|
||||
msg.setEndCoord(endLoc);
|
||||
msg.setUnknown01(-1);
|
||||
msg.setInBuildingFloor(-1);
|
||||
msg.setInBuilding(-1);
|
||||
msg.setTargetType(0);
|
||||
msg.setTargetID(0);
|
||||
msg.setStartLocType(0);
|
||||
msg.setInBuildingUUID(0);
|
||||
|
||||
|
||||
try {
|
||||
@@ -218,4 +273,23 @@ public class MovementUtilities {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -97,7 +97,7 @@ public class NetMsgFactory {
|
||||
// if (MBServerStatics.worldServerName.equals("Grief"))
|
||||
Logger.error("Invalid protocol msg for player " + player.getFirstName() + " : " + opcode + " lastopcode: " + origin.lastProtocol.name() + " Error Code : " + errorCode);
|
||||
} else
|
||||
Logger.error("PROTOCOL ERROR: Player: " + ((ClientConnection) origin).getPlayerCharacter().getName() + " Account: " + ((ClientConnection) origin).getPlayerCharacter().getAccount().getUname() + "Invalid protocol msg : " + opcode + " lastopcode: " + origin.lastProtocol.name() + " Error Code : " + errorCode);
|
||||
Logger.error("Invalid protocol msg : " + opcode + " lastopcode: " + origin.lastProtocol.name() + " Error Code : " + errorCode);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.net.client;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.MsgSendException;
|
||||
@@ -123,7 +122,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (pc.isSit()) {
|
||||
pc.setCombat(false);
|
||||
pc.cancelOnSit();
|
||||
pc.stopMovement(pc.loc);
|
||||
}
|
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||
@@ -224,11 +222,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(msg.getSlotNumber() == 11 && pc.getRaceID() == 1999){
|
||||
forceTransferFromEquipToInventory(msg, origin, "Saetor cannot wear shoes.");
|
||||
return;
|
||||
}
|
||||
|
||||
int uuid = msg.getUUID();
|
||||
int slot = msg.getSlotNumber();
|
||||
//System.out.println("loading to slot: " + slot);
|
||||
@@ -561,32 +554,18 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (i == null)
|
||||
return;
|
||||
|
||||
if(i.getItemBaseID() == 7)
|
||||
return; //cant delete gold
|
||||
|
||||
if (!itemManager.doesCharOwnThisItem(i.getObjectUUID()))
|
||||
return;
|
||||
|
||||
if (!itemManager.inventoryContains(i))
|
||||
return;
|
||||
|
||||
if(i.getItemBaseID() == 980066)
|
||||
return;
|
||||
|
||||
if (i.canDestroy) {
|
||||
int value = i.getItemBase().value;
|
||||
if(i.getItemBase().isRune())
|
||||
value = 500000;
|
||||
if(sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value > 10000000){
|
||||
return;
|
||||
}
|
||||
if (i.isCanDestroy())
|
||||
if (itemManager.delete(i) == true) {
|
||||
sourcePlayer.getCharItemManager().addGoldToInventory(value,false);
|
||||
sourcePlayer.getCharItemManager().updateInventory();
|
||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
|
||||
@@ -664,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);
|
||||
@@ -1217,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 {
|
||||
@@ -1250,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);
|
||||
@@ -1301,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
|
||||
@@ -1379,171 +1358,219 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
}
|
||||
|
||||
private static void buyFromNPC(BuyFromNPCMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return;
|
||||
|
||||
if (origin.buyLock.tryLock()) {
|
||||
|
||||
try {
|
||||
CharacterItemManager itemMan = sourcePlayer.getCharItemManager();
|
||||
if (itemMan == null) {
|
||||
|
||||
if (itemMan == null)
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
if (npc == null) {
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
}
|
||||
|
||||
Item gold = itemMan.getGoldInventory();
|
||||
if (gold == null) {
|
||||
|
||||
if (gold == null)
|
||||
return;
|
||||
}
|
||||
|
||||
Item buy = null;
|
||||
|
||||
if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) {
|
||||
ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory();
|
||||
if (sellInventory == null) {
|
||||
if (sellInventory == null)
|
||||
return;
|
||||
}
|
||||
for (MobEquipment me : sellInventory) {
|
||||
if (me.getObjectUUID() == msg.getItemID()) {
|
||||
ItemBase ib = me.getItemBase();
|
||||
if (ib == null) {
|
||||
if (ib == null)
|
||||
return;
|
||||
}
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight())) {
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
}
|
||||
int cost = me.magicValue;
|
||||
if(npc.getContractID() == 1201 && me.getItemBase().getName().equals("Prospector"))
|
||||
cost = 50;
|
||||
|
||||
int cost = me.getMagicValue();
|
||||
|
||||
float bargain = sourcePlayer.getBargain();
|
||||
|
||||
float profit = npc.getSellPercent(sourcePlayer) - bargain;
|
||||
if(me.getItemBase().getType().equals(ItemType.POTION))
|
||||
profit -= 1.0f;
|
||||
|
||||
if (profit < 1)
|
||||
profit = 1;
|
||||
if(npc.getContractID() == 900){
|
||||
cost = Warehouse.getCostForResource(ib.getUUID()) * Warehouse.getSellStackSize(ib.getUUID());
|
||||
}
|
||||
|
||||
|
||||
cost *= profit;
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
//dont' have enough goldItem exit!
|
||||
// chatMan.chatSystemInfo(pc, "" + "You dont have enough gold.");
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
int buildingDeposit = cost - me.getMagicValue();
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
// chatMan.chatSystemInfo(pc, "" + "You Failed to buy the item.");
|
||||
ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
|
||||
return;
|
||||
}
|
||||
if(me.getItemBase().getType().equals(ItemType.RESOURCE) && npc.getContractID() == 900){
|
||||
handleResourcePurchase(me,itemMan,npc,buy,sourcePlayer,ib);
|
||||
}else {
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib);
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
if(npc.contractUUID == 900 && buy.getItemBaseID() == 1705032){
|
||||
buy.setNumOfItems(10);
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(buy,buy.getNumOfItems());
|
||||
}
|
||||
//itemMan.updateInventory();
|
||||
}
|
||||
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib);
|
||||
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
//itemMan.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msg.getItemType() == GameObjectType.Item.ordinal()) {
|
||||
|
||||
CharacterItemManager npcCim = npc.getCharItemManager();
|
||||
|
||||
if (npcCim == null)
|
||||
return;
|
||||
|
||||
buy = Item.getFromCache(msg.getItemID());
|
||||
|
||||
if (buy == null)
|
||||
return;
|
||||
|
||||
ItemBase ib = buy.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
if (!npcCim.inventoryContains(buy))
|
||||
return;
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
|
||||
//TODO test cost and subtract goldItem
|
||||
|
||||
//TODO CHnage this if we ever put NPc city npcs in buildings.
|
||||
int cost = buy.getBaseValue();
|
||||
|
||||
if (buy.isID() || buy.isCustomValue())
|
||||
cost = buy.getMagicValue();
|
||||
|
||||
float bargain = sourcePlayer.getBargain();
|
||||
|
||||
float profit = npc.getSellPercent(sourcePlayer) - bargain;
|
||||
|
||||
if (profit < 1)
|
||||
profit = 1;
|
||||
|
||||
if (!buy.isCustomValue())
|
||||
cost *= profit;
|
||||
else
|
||||
cost = buy.getValue();
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 128); // Insufficient Gold
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null)
|
||||
if (b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
|
||||
int buildingDeposit = cost;
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 110);
|
||||
return;
|
||||
}
|
||||
|
||||
if (buy != null)
|
||||
itemMan.buyFromNPC(buy, npc);
|
||||
|
||||
} else if (msg.getItemType() == GameObjectType.MobLoot.ordinal()) {
|
||||
|
||||
CharacterItemManager npcCim = npc.getCharItemManager();
|
||||
|
||||
if (npcCim == null)
|
||||
return;
|
||||
|
||||
buy = MobLoot.getFromCache(msg.getItemID());
|
||||
|
||||
if (buy == null)
|
||||
return;
|
||||
|
||||
ItemBase ib = buy.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
if (!npcCim.inventoryContains(buy))
|
||||
return;
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
|
||||
//TODO test cost and subtract goldItem
|
||||
|
||||
//TODO CHnage this if we ever put NPc city npcs in buildings.
|
||||
|
||||
int cost = buy.getMagicValue();
|
||||
cost *= npc.getSellPercent(sourcePlayer);
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 128); // Insufficient Gold
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
int buildingDeposit = cost;
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit))
|
||||
return;
|
||||
|
||||
if (buy != null)
|
||||
itemMan.buyFromNPC(buy, npc);
|
||||
|
||||
} else
|
||||
return;
|
||||
|
||||
if (buy != null) {
|
||||
|
||||
msg.setItem(buy);
|
||||
//send the buy message back to update player
|
||||
// msg.setItemType(buy.getObjectType().ordinal());
|
||||
@@ -1552,44 +1579,16 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
|
||||
} finally {
|
||||
origin.buyLock.unlock();
|
||||
}
|
||||
} else {
|
||||
ErrorPopupMsg.sendErrorPopup(origin.getPlayerCharacter(), 12); // All production slots taken
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void handleResourcePurchase(MobEquipment me, CharacterItemManager itemMan, NPC npc, Item buy, PlayerCharacter sourcePlayer, ItemBase ib){
|
||||
boolean stacked = false;
|
||||
int buystack = Warehouse.getSellStackSize(me.getItemBase().getUUID());
|
||||
for(Item item : itemMan.getInventory()){
|
||||
int itemID = item.getItemBaseID();
|
||||
int meID = me.getItemBase().getUUID();
|
||||
if(itemID == meID){
|
||||
if(Warehouse.maxResources.isEmpty())
|
||||
Warehouse.getMaxResources();
|
||||
int maxStack = Warehouse.maxResources.get(itemID);
|
||||
if(maxStack > item.getNumOfItems() + buystack){
|
||||
item.setNumOfItems(item.getNumOfItems() + buystack);
|
||||
stacked = true;
|
||||
itemMan.updateInventory();
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(item,item.getNumOfItems());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!stacked){
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib);
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
buy.setNumOfItems(buystack);
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(buy,buy.getNumOfItems());
|
||||
}
|
||||
}
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
private static void Repair(RepairMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
@@ -1632,8 +1631,8 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (toRepair == null)
|
||||
return;
|
||||
|
||||
//if (toRepair.getItemBase().isGlass())
|
||||
// return;
|
||||
if (toRepair.getItemBase().isGlass())
|
||||
return;
|
||||
|
||||
//make sure item is in player's inventory or equipment
|
||||
if (!itemMan.inventoryContains(toRepair) && !itemMan.equippedContains(toRepair))
|
||||
@@ -1655,12 +1654,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
}
|
||||
//TODO get cost to repair
|
||||
int cost = (int) ((max - dur) * 80.1);
|
||||
|
||||
//glass costs 3x as much to repair
|
||||
if (toRepair.getItemBase().isGlass()){
|
||||
cost *= 3;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null)
|
||||
@@ -1895,25 +1888,9 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
break;
|
||||
case LEAVEREQUEST:
|
||||
origin.disconnect();
|
||||
ArrayList<PlayerCharacter> sameMachine = new ArrayList<>();
|
||||
for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) {
|
||||
if(origin.machineID.equals(pc.getClientConnection().machineID))
|
||||
sameMachine.add(pc);
|
||||
}
|
||||
if(sameMachine.isEmpty() == false){
|
||||
if(sameMachine.get(0) != null) {
|
||||
sameMachine.get(0).isBoxed = false;
|
||||
sameMachine.get(0).removeEffectBySource(EffectSourceType.DeathShroud,41,true);
|
||||
ChatManager.chatSystemInfo(sameMachine.get(0), "You Are No Longer Flagged 'Boxed'");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case POWER:
|
||||
PowersManager.usePower((PerformActionMsg) msg, origin, false);
|
||||
//PowersManager.static_power_que.add(new PowersManager.PowerQueObject((PerformActionMsg) msg, origin, false));
|
||||
break;
|
||||
case REQUESTMELEEATTACK:
|
||||
CombatManager.setAttackTarget((AttackCmdMsg) msg, origin);
|
||||
break;
|
||||
case READYTOENTER:
|
||||
break;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user