diff --git a/src/main/java/com/projectswg/holocore/resources/support/objects/swg/ServerAttribute.java b/src/main/java/com/projectswg/holocore/resources/support/objects/swg/ServerAttribute.java index 6109f23ad..9d1765563 100644 --- a/src/main/java/com/projectswg/holocore/resources/support/objects/swg/ServerAttribute.java +++ b/src/main/java/com/projectswg/holocore/resources/support/objects/swg/ServerAttribute.java @@ -34,6 +34,7 @@ public enum ServerAttribute { PCD_PET_TEMPLATE ("pcd.pet.template", PredefinedDataType.STRING), + PCD_PET_CONDITION_DAMAGE("pcd.pet.condition_damage", PredefinedDataType.INT), EGG_SPAWNER ("egg.spawner", Spawner.class, s -> null, s -> null), GALACTIC_RESOURCE_ID("resources.galactic_resource_id", PredefinedDataType.LONG), SURVEY_TOOL_RANGE ("survey_tool.range", PredefinedDataType.INT), diff --git a/src/main/java/com/projectswg/holocore/services/gameplay/world/travel/PlayerMountService.kt b/src/main/java/com/projectswg/holocore/services/gameplay/world/travel/PlayerMountService.kt index 6db639bc8..f7170c235 100644 --- a/src/main/java/com/projectswg/holocore/services/gameplay/world/travel/PlayerMountService.kt +++ b/src/main/java/com/projectswg/holocore/services/gameplay/world/travel/PlayerMountService.kt @@ -235,6 +235,7 @@ class PlayerMountService : Service() { mount.addOptionFlags(OptionFlag.MOUNT) // The mount won't appear properly if this isn't set mount.faction = player.faction mount.ownerId = player.objectId // Client crash if this isn't set before making anyone aware + mount.conditionDamage = mountControlDevice.getServerAttribute(ServerAttribute.PCD_PET_CONDITION_DAMAGE) as Int? ?: 0 // TODO after combat there's a delay // TODO update faction status on mount if necessary @@ -396,6 +397,7 @@ class PlayerMountService : Service() { vehicleDecayJobs[mount]?.cancel() // Destroy the mount + mountControlDevice.setServerAttribute(ServerAttribute.PCD_PET_CONDITION_DAMAGE, mount.conditionDamage) mountControlDevice.count = IntangibleObject.COUNT_PCD_STORED player.broadcast(DestroyObjectIntent(mount)) StandardLog.onPlayerTrace(this, player, "stored mount %s at %s %s", mount, mount.terrain, mount.location.position) diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/world/travel/TestPlayerMountService.kt b/src/test/java/com/projectswg/holocore/services/gameplay/world/travel/TestPlayerMountService.kt index 37a425e11..bb93d17ce 100644 --- a/src/test/java/com/projectswg/holocore/services/gameplay/world/travel/TestPlayerMountService.kt +++ b/src/test/java/com/projectswg/holocore/services/gameplay/world/travel/TestPlayerMountService.kt @@ -90,6 +90,22 @@ class TestPlayerMountService : TestRunnerSimulatedWorld() { assertCorrectStored(creature, vehicle, friend) } + @Test + fun testConditionSurvivesStoring() { + val creature: CreatureObject = createCreature() + ObjectCreatedIntent(creature).broadcast() + val deed = ObjectCreator.createObjectFromTemplate(getUniqueId(), DEED) + broadcastAndWait(VehicleDeedGenerateIntent(creature, deed)) + updateAwareness() + val pcd = creature.findAware(PCD) as IntangibleObject + (creature.findAware(SWOOP) as CreatureObject).conditionDamage = 500 + broadcastAndWait(PetDeviceStoreIntent(creature, pcd)) + broadcastAndWait(PetDeviceCallIntent(creature, pcd)) + updateAwareness() + + Assertions.assertEquals(500, (creature.findAware(SWOOP) as CreatureObject).conditionDamage) + } + @Test fun testMountDismount() { val friend = createNPC()