From 82aeba3a05fecd13bfa796625bcf613607cf26ba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 13:51:31 -0400 Subject: [PATCH] NPC rotations inherit building rotation. --- src/engine/objects/Mob.java | 2 +- src/engine/objects/NPC.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5cf420fb..d7fb700e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -929,7 +929,7 @@ public class Mob extends AbstractIntelligenceAgent { this.loc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); - // Rotate mobile's rotation by the building's rotation + // Rotate mobile rotation by the building's rotation slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index cdd5e166..c0b5169d 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -38,6 +38,7 @@ import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static engine.math.FastMath.acos; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; import static engine.objects.MobBase.loadEquipmentSet; @@ -375,6 +376,12 @@ public class NPC extends AbstractCharacter { slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation(); this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Rotate NPC rotation by the building's rotation + + slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); + slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); + this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Configure region and floor/level for this NPC this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);