From 1169f440418353c6dfde134775b7a2f111ced35b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 5 Apr 2023 20:04:04 -0500 Subject: [PATCH 1/4] NPC and mob regions --- src/engine/net/client/msg/LoadCharacterMsg.java | 16 ++++++++++++++++ src/engine/objects/Mob.java | 2 ++ src/engine/objects/NPC.java | 1 + 3 files changed, 19 insertions(+) diff --git a/src/engine/net/client/msg/LoadCharacterMsg.java b/src/engine/net/client/msg/LoadCharacterMsg.java index 49464cf7..e88783ad 100644 --- a/src/engine/net/client/msg/LoadCharacterMsg.java +++ b/src/engine/net/client/msg/LoadCharacterMsg.java @@ -102,6 +102,22 @@ public class LoadCharacterMsg extends ClientNetMsg { writer.putInt(region.getRoom()); } } + else if (absChar.getObjectType().equals(GameObjectType.Mob)){ + Regions Mobregion = absChar.getRegion(); + + if (region == null){ + writer.putInt(-1); + writer.putInt(-1); + }else{ + Building regionBuilding = Regions.GetBuildingForRegion(Mobregion); + if (regionBuilding == null){ + writer.putInt(-1); + writer.putInt(-1); + }else{ + writer.putInt(region.getLevel()); + writer.putInt(region.getRoom()); + } + } //TODO below is Mob Region Serialization, not implemented. default to -1, which is ground. }else { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 4130be5d..5390903e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1152,11 +1152,13 @@ public class Mob extends AbstractIntelligenceAgent { if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); + this.region = AbstractWorldObject.GetRegionByWorldObject(this); return; //Next upda } setLoc(newLoc); + this.region = AbstractWorldObject.GetRegionByWorldObject(this); //Next update will be end Loc, lets stop him here. } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 7ee76473..7f925c49 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1222,6 +1222,7 @@ public class NPC extends AbstractCharacter { }catch (Exception e){ Logger.error( e.getMessage()); } + this.region = AbstractWorldObject.GetRegionByWorldObject(this); } public void removeFromZone() { From 07e993b0bac48559a98ec6761b499462ac2be2c2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 5 Apr 2023 20:06:28 -0500 Subject: [PATCH 2/4] NPC and mob regions for real this time --- src/engine/net/client/msg/LoadCharacterMsg.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/engine/net/client/msg/LoadCharacterMsg.java b/src/engine/net/client/msg/LoadCharacterMsg.java index e88783ad..abe292ad 100644 --- a/src/engine/net/client/msg/LoadCharacterMsg.java +++ b/src/engine/net/client/msg/LoadCharacterMsg.java @@ -86,30 +86,31 @@ public class LoadCharacterMsg extends ClientNetMsg { } else if (absChar != null) { - if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter)){ + if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter)) { Regions region = absChar.getRegion(); - - if (region == null){ + + if (region == null) { writer.putInt(-1); writer.putInt(-1); - }else{ + } else { Building regionBuilding = Regions.GetBuildingForRegion(region); - if (regionBuilding == null){ + if (regionBuilding == null) { writer.putInt(-1); writer.putInt(-1); - }else{ + } else { writer.putInt(region.getLevel()); writer.putInt(region.getRoom()); } } + } else if (absChar.getObjectType().equals(GameObjectType.Mob)){ - Regions Mobregion = absChar.getRegion(); + Regions region = absChar.getRegion(); if (region == null){ writer.putInt(-1); writer.putInt(-1); }else{ - Building regionBuilding = Regions.GetBuildingForRegion(Mobregion); + Building regionBuilding = Regions.GetBuildingForRegion(region); if (regionBuilding == null){ writer.putInt(-1); writer.putInt(-1); From 3f8d772f8fdc0374da2d79bfe7362adfe99def0e Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 5 Apr 2023 20:29:34 -0500 Subject: [PATCH 3/4] treb troubleshooting --- src/engine/objects/NPC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 7f925c49..c4b9203e 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1462,7 +1462,7 @@ public class NPC extends AbstractCharacter { mob.setSpawnTime(10); mob.setNpcOwner(this); mob.state = STATE.Awake; - + mob.region = AbstractWorldObject.GetRegionByWorldObject(mob); return mob; } From bfb6b0f5eb8f610d33ae675bf7ad8258d8957b4b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 6 Apr 2023 09:44:34 -0500 Subject: [PATCH 4/4] ./info now shows building information not just region --- src/engine/devcmd/cmds/InfoCmd.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 0b45ee99..8e0c3592 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -396,6 +396,10 @@ public class InfoCmd extends AbstractDevCmd { output += "BuildingID : " + targetNPC.getRegion().parentBuildingID; output += "building level : " + targetNPC.getRegion().level; output += "building room : " + targetNPC.getRegion().room; + }else if(targetNPC.getBuilding() != null) { + output += newline; + output += "Building : " + targetNPC.getBuilding(); + output += "In BuildingLoc : " + targetNPC.inBuildingLoc; }else{ output += newline; output += "No building found."; @@ -462,6 +466,19 @@ public class InfoCmd extends AbstractDevCmd { output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); output += newline; output += "isMoving : " + targetMob.isMoving(); + if (targetMob.getRegion() != null){ + output += newline; + output += "BuildingID : " + targetMob.getRegion().parentBuildingID; + output += "building level : " + targetMob.getRegion().level; + output += "building room : " + targetMob.getRegion().room; + }else if(targetMob.building != null) { + output += newline; + output += "BuildingID : " + targetMob.building; + output += "In BuildingLoc : " + targetMob.inBuildingLoc; + }else{ + output += newline; + output += "No building found."; + } break; case Item: //intentional passthrough case MobLoot: