Browse Source

Contracted Mob/Npc rotation derived from slot position.

master
MagicBot 2 years ago
parent
commit
ce516f24c0
  1. 9
      src/engine/gameManager/BuildingManager.java
  2. 10
      src/engine/objects/BuildingLocation.java
  3. 10
      src/engine/objects/Mob.java
  4. 9
      src/engine/objects/NPC.java

9
src/engine/gameManager/BuildingManager.java

@ -56,19 +56,20 @@ public enum BuildingManager {
return -1; return -1;
} }
public static Vector3fImmutable getSlotLocation(Building building, int slot) { public static BuildingLocation getSlotLocation(Building building, int slot) {
BuildingLocation buildingLocation = new BuildingLocation();
if (slot == -1) if (slot == -1)
return Vector3fImmutable.ZERO; return buildingLocation;
BuildingLocation buildingLocation;
buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index
if (buildingLocation == null) { if (buildingLocation == null) {
Logger.error("Invalid slot for building: " + building.getObjectUUID()); Logger.error("Invalid slot for building: " + building.getObjectUUID());
} }
return buildingLocation.getLocation(); return buildingLocation;
} }
public static Quaternion getSlotRotation(Building building, int slot) { public static Quaternion getSlotRotation(Building building, int slot) {

10
src/engine/objects/BuildingLocation.java

@ -30,6 +30,16 @@ public class BuildingLocation extends AbstractGameObject {
private final Quaternion rotation; private final Quaternion rotation;
public BuildingLocation() {
this.buildingUUID = 0;
this.type = 0;
this.slot = 0;
this.unknown = 0;
this.location = Vector3fImmutable.ZERO;
this.rotation = new Quaternion();
}
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */

10
src/engine/objects/Mob.java

@ -20,6 +20,8 @@ import engine.jobs.DeferredPowerJob;
import engine.jobs.UpgradeNPCJob; import engine.jobs.UpgradeNPCJob;
import engine.loot.LootManager; import engine.loot.LootManager;
import engine.math.Bounds; import engine.math.Bounds;
import engine.math.Quaternion;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.Dispatch; import engine.net.Dispatch;
@ -863,6 +865,7 @@ public class Mob extends AbstractIntelligenceAgent {
int slot; int slot;
Vector3fImmutable slotLocation; Vector3fImmutable slotLocation;
Quaternion slotRotation;
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return; return;
@ -907,10 +910,15 @@ public class Mob extends AbstractIntelligenceAgent {
// Override bind and location for this contracted Mobile // Override bind and location for this contracted Mobile
// derived from BuildingManager slot location data. // derived from BuildingManager slot location data.
slotLocation = BuildingManager.getSlotLocation(building, slot); slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation();
this.bindLoc = building.getLoc().add(slotLocation); this.bindLoc = building.getLoc().add(slotLocation);
// Rotate MOB by slot rotation
slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation();
this.setRot(new Vector3f(0, slotRotation.y, 0));
} }
// Rotate slot position by the building rotation // Rotate slot position by the building rotation

9
src/engine/objects/NPC.java

@ -18,6 +18,7 @@ import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.UpgradeNPCJob; import engine.jobs.UpgradeNPCJob;
import engine.math.Bounds; import engine.math.Bounds;
import engine.math.Quaternion;
import engine.math.Vector3f; import engine.math.Vector3f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
@ -319,6 +320,7 @@ public class NPC extends AbstractCharacter {
int slot; int slot;
Vector3fImmutable slotLocation; Vector3fImmutable slotLocation;
Quaternion slotRotation;
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return; return;
@ -358,7 +360,7 @@ public class NPC extends AbstractCharacter {
// Override bind and location for this npc derived // Override bind and location for this npc derived
// from BuildingManager slot location data. // from BuildingManager slot location data.
slotLocation = BuildingManager.getSlotLocation(building, slot); slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation();
this.bindLoc = building.getLoc().add(slotLocation); this.bindLoc = building.getLoc().add(slotLocation);
@ -368,6 +370,11 @@ public class NPC extends AbstractCharacter {
this.loc = new Vector3fImmutable(bindLoc); this.loc = new Vector3fImmutable(bindLoc);
// Rotate NPC by slot rotation
slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation();
this.setRot(new Vector3f(0, slotRotation.y, 0));
// Configure region and floor/level for this NPC // Configure region and floor/level for this NPC
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);

Loading…
Cancel
Save