diff --git a/Server/src/main/content/global/skill/construction/BuildHotspot.java b/Server/src/main/content/global/skill/construction/BuildHotspot.java index c5ca6c8e7..365d6331a 100644 --- a/Server/src/main/content/global/skill/construction/BuildHotspot.java +++ b/Server/src/main/content/global/skill/construction/BuildHotspot.java @@ -65,8 +65,10 @@ public enum BuildHotspot { * Low-level Work shop hotspots. */ REPAIR(15448, BuildHotspotType.INDIVIDUAL, BuildingUtils.BUILD_MID_ANIM, Decoration.REPAIR_BENCH, Decoration.WHETSTONE, Decoration.ARMOUR_STAND), - WORKBENCH(15439, BuildHotspotType.INDIVIDUAL, BuildingUtils.BUILD_MID_ANIM, Decoration.WORKBENCH_WOODEN, Decoration.WORKBENCH_OAK,Decoration.WORKBENCH_STEEL_FRAME, Decoration.WORKBENCH_WITH_VICE,Decoration.WORKBENCH_WITH_LATHE), - CRAFTING(15441, BuildHotspotType.INDIVIDUAL, BuildingUtils.BUILD_MID_ANIM, Decoration.CRAFTING_TABLE_1, Decoration.CRAFTING_TABLE_2,Decoration.CRAFTING_TABLE_3, Decoration.CRAFTING_TABLE_4), + WORKBENCH(15439, BuildHotspotType.LINKED, BuildingUtils.BUILD_MID_ANIM, Decoration.WORKBENCH_WOODEN, Decoration.WORKBENCH_OAK,Decoration.WORKBENCH_STEEL_FRAME, Decoration.WORKBENCH_WITH_VICE,Decoration.WORKBENCH_WITH_LATHE), + WORKBENCH_STOOL(15540, BuildHotspotType.LINKED, BuildingUtils.BUILD_MID_ANIM, Decoration.WORKSHOP_STOOL, Decoration.WORKSHOP_STOOL,Decoration.WORKSHOP_STOOL_OAK, Decoration.WORKSHOP_STOOL_OAK,Decoration.WORKSHOP_STOOL_OAK), + CRAFTING(15441, BuildHotspotType.LINKED, BuildingUtils.BUILD_MID_ANIM, Decoration.CRAFTING_TABLE_1, Decoration.CRAFTING_TABLE_2,Decoration.CRAFTING_TABLE_3, Decoration.CRAFTING_TABLE_4), + CRAFTING_STOOL(15542, BuildHotspotType.LINKED, BuildingUtils.BUILD_MID_ANIM, Decoration.WORKSHOP_STOOL, Decoration.WORKSHOP_STOOL,Decoration.WORKSHOP_STOOL, Decoration.WORKSHOP_STOOL), TOOL1(15443, BuildHotspotType.RECURSIVE, BuildingUtils.BUILD_HIGH_ANIM, Decoration.TOOL_STORE_1, Decoration.TOOL_STORE_2, Decoration.TOOL_STORE_3, Decoration.TOOL_STORE_4, Decoration.TOOL_STORE_5), TOOL2(15444, BuildHotspotType.RECURSIVE, BuildingUtils.BUILD_HIGH_ANIM, Decoration.TOOL_STORE_1, Decoration.TOOL_STORE_2,Decoration.TOOL_STORE_3, Decoration.TOOL_STORE_4,Decoration.TOOL_STORE_5), TOOL3(15445, BuildHotspotType.RECURSIVE, BuildingUtils.BUILD_HIGH_ANIM, Decoration.TOOL_STORE_1, Decoration.TOOL_STORE_2,Decoration.TOOL_STORE_3, Decoration.TOOL_STORE_4,Decoration.TOOL_STORE_5), @@ -386,6 +388,8 @@ public enum BuildHotspot { linkedHotspots.add(new BuildHotspot[] { DUNGEON_DOOR_LEFT2, DUNGEON_DOOR_RIGHT2 }); linkedHotspots.add(new BuildHotspot[] { SMALL_PLANT_1, SMALL_PLANT1 }); linkedHotspots.add(new BuildHotspot[] { SHELVES, SHELVES_2 }); + linkedHotspots.add(new BuildHotspot[] { WORKBENCH, WORKBENCH_STOOL }); + linkedHotspots.add(new BuildHotspot[] { CRAFTING, CRAFTING_STOOL }); } /** diff --git a/Server/src/main/content/global/skill/construction/ConstructionInterface.kt b/Server/src/main/content/global/skill/construction/ConstructionInterface.kt index 2106c04a1..5745e09d4 100644 --- a/Server/src/main/content/global/skill/construction/ConstructionInterface.kt +++ b/Server/src/main/content/global/skill/construction/ConstructionInterface.kt @@ -9,7 +9,7 @@ import core.game.node.scenery.Scenery import core.tools.Log /** - * Handles the creating of a decoration object. + * Handles the creation of a decoration object. * @author Emperor * @author Bishop */ @@ -17,13 +17,13 @@ import core.tools.Log class ConstructionInterface : InterfaceListener { companion object { - const val DECO_INTERFACE = 396 - const val POH_MENU = 398 - const val ROOM_INTERFACE = 402 + const val decorationInterface = 396 + const val pohMenuInterface = 398 + const val roomInterface = 402 } override fun defineInterfaceListeners() { - on(DECO_INTERFACE) { player, _, _, buttonID, slot, _ -> + on(decorationInterface) { player, _, _, buttonID, slot, _ -> when (buttonID) { 132 -> { closeInterface(player) @@ -76,8 +76,8 @@ class ConstructionInterface : InterfaceListener { return@on true } } - if (flatpackMode && WorkbenchListeners.getMaxLevel(getAttribute(player, WorkbenchListeners.attributeWorkbenchId, 0)) < deco.level) { - sendMessage(player, "You need a better workbench to make this flatpack.") // placeholder + if (flatpackMode && WorkbenchListeners.getBenchLevel(getAttribute(player, WorkbenchListeners.attributeWorkbenchId, 0)) < deco.level) { + sendDialogue(player, "You need a better workbench to make this flatpack.") // TODO: find authentic dialogue return@on true } } @@ -92,7 +92,7 @@ class ConstructionInterface : InterfaceListener { } } - on(POH_MENU) { player, _, _, buttonID, _, _ -> + on(pohMenuInterface) { player, _, _, buttonID, _, _ -> when (buttonID) { 14 -> { player.houseManager.toggleBuildingMode(player, true) @@ -108,7 +108,7 @@ class ConstructionInterface : InterfaceListener { } 13 -> { if (!player.houseManager.isInHouse(player)) { - player.sendMessage("You can't do this outside of your house.") + sendMessage(player, "You can't do this outside of your house.") return@on true } HouseManager.leave(player) @@ -118,11 +118,11 @@ class ConstructionInterface : InterfaceListener { } } - on(ROOM_INTERFACE) { player, _, _, buttonID, _, _ -> + on(roomInterface) { player, _, _, buttonID, _, _ -> val index = buttonID - 160 log(this.javaClass, Log.FINE, "BuildRoom Interface Index: $index") if (index > -1 && index < RoomProperties.values().size) { - player.dialogueInterpreter.open("con:room", RoomProperties.values()[index]) + openDialogue(player, "con:room", RoomProperties.values()[index]) } return@on true } diff --git a/Server/src/main/content/global/skill/construction/RoomProperties.java b/Server/src/main/content/global/skill/construction/RoomProperties.java index 80bc6e6ed..0f4cb7791 100644 --- a/Server/src/main/content/global/skill/construction/RoomProperties.java +++ b/Server/src/main/content/global/skill/construction/RoomProperties.java @@ -130,7 +130,9 @@ public enum RoomProperties { new Hotspot(BuildHotspot.REPAIR, 7, 3, 7, 4), new Hotspot(BuildHotspot.HERALDRY, 7, 6, 7, 7), new Hotspot(BuildHotspot.CRAFTING, 0, 3, 0, 4), + new Hotspot(BuildHotspot.CRAFTING_STOOL, 1, 3), new Hotspot(BuildHotspot.WORKBENCH, 3, 4), + new Hotspot(BuildHotspot.WORKBENCH_STOOL, 3, 3), new Hotspot(BuildHotspot.TOOL4, 7, 1), new Hotspot(BuildHotspot.TOOL2, 6, 0), new Hotspot(BuildHotspot.TOOL1, 1, 0), diff --git a/Server/src/main/content/global/skill/construction/decoration/workshop/WorkbenchListeners.kt b/Server/src/main/content/global/skill/construction/decoration/workshop/WorkbenchListeners.kt index 2bfb15772..0173a7239 100644 --- a/Server/src/main/content/global/skill/construction/decoration/workshop/WorkbenchListeners.kt +++ b/Server/src/main/content/global/skill/construction/decoration/workshop/WorkbenchListeners.kt @@ -8,9 +8,13 @@ import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener import core.game.interaction.InterfaceListener +import core.game.interaction.QueueStrength import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills import core.game.node.item.Item +import core.game.node.scenery.SceneryBuilder +import core.game.world.map.Direction +import core.game.world.map.RegionManager import org.rs09.consts.Items import org.rs09.consts.Scenery @@ -22,20 +26,32 @@ import org.rs09.consts.Scenery class WorkbenchListeners : InteractionListener, InterfaceListener { companion object { - const val WORKBENCH_INTERFACE = 397 + const val workbenchInterface = 397 + const val attributeWorkbenchId = "con:workbench" const val attributeFlatpackMode = "con:flatpack" const val attributeSelection = "con:flatpack-hotspot" + const val attributeCrafting = "con:crafting" + const val attributeStandUp = "con:stand-up" - val WORKBENCHES = intArrayOf( - Scenery.WORKBENCH_13704, // wooden - Scenery.WORKBENCH_13705, // oak - Scenery.WORKBENCH_13706, // steel framed - Scenery.WORKBENCH_13707, // with vice - Scenery.WORKBENCH_13708, // with lathe + const val animationSitDown = 4103 + const val animationStandUp = 4105 + const val animationSit = 4107 + const val animationSitOak = 4108 + const val animationCraft = 4109 + const val animationCraftOak = 4110 + + const val `nothing` = 15440 + + private val workbenches = intArrayOf( + Scenery.WORKBENCH_13704, // lv20, wooden + Scenery.WORKBENCH_13705, // lv40, oak + Scenery.WORKBENCH_13706, // lv60, steel framed + Scenery.WORKBENCH_13707, // lv80, with vice + Scenery.WORKBENCH_13708, // lv99, with lathe ) - val FLATPACK_CATEGORIES = arrayOf( + private val decoCategories = arrayOf( BuildHotspot.CHAIRS_1, // 111 BuildHotspot.BOOKCASE, // 112 BuildHotspot.BARRELS, // 113 @@ -54,50 +70,114 @@ class WorkbenchListeners : InteractionListener, InterfaceListener { BuildHotspot.TOY_BOX, // 126 ) - fun getMaxLevel(workbenchId: Int): Int { - return (WORKBENCHES.indexOf(workbenchId) + 1) * 20 + fun getBenchLevel(workbenchId: Int): Int { + return (workbenches.indexOf(workbenchId) + 1) * 20 } fun produceFlatpack(player: Player, deco: Decoration) { val reward = deco.flatpackItemID if (reward == -1) return if (removeItem(player, deco.items) || player.isAdmin) { - animate(player, 1) // find fiddling animation + setAttribute(player, attributeCrafting, true) rewardXP(player, Skills.CONSTRUCTION, deco.experience.toDouble()) addItemOrDrop(player, reward) } } + + private fun sitDown(player: Player) { + val chunk = RegionManager.getRegionChunk(player.location) + for (x in 3..4) { + for (y in 3..4) { + val obj = chunk.objects[x][y] + if (obj != null && obj.id == BuildHotspot.WORKBENCH_STOOL.objectId) { + val finalDir = when ((x * 10) + y) { // I just think this is fun, okay? Don't laugh! + 33 -> Direction.EAST + 34 -> Direction.SOUTH + 43 -> Direction.NORTH + else -> Direction.WEST + } + val sittingAnim = if (obj.id == Scenery.STOOL_13719) animationSit else animationSitOak + val craftingAnim = if (obj.id == Scenery.STOOL_13719) animationCraft else animationCraftOak + animate(player, animationSitDown) + queueScript(player, 1, QueueStrength.NORMAL) { stage -> + when (stage) { + 0 -> { + SceneryBuilder.replace(obj, obj.transform(`nothing`)) + animate(player, sittingAnim) + forceMove(player, player.location, player.location.transform(finalDir, -1), 0, 1000) + return@queueScript delayScript(player, 1) + } + else -> { + if (!getAttribute(player, attributeStandUp, false)) { + if (getAttribute(player, attributeCrafting, false)) { + removeAttribute(player, attributeCrafting) + animate(player, craftingAnim) + } else { + animate(player, sittingAnim) + } + return@queueScript delayScript(player, 2) + } else { + removeAttribute(player, attributeStandUp) + SceneryBuilder.replace(chunk.objects[x][y], obj.transform(BuildHotspot.WORKBENCH_STOOL.objectId)) + animate(player, animationStandUp) + forceMove(player, player.location, player.location.transform(finalDir, 1), 0, 1000) + return@queueScript stopExecuting(player) + } + } + } + } + return + } + } + } + } + + private fun standUp(player: Player) { + setAttribute(player, attributeStandUp, true) + } } override fun defineListeners() { - on(WORKBENCHES, IntType.SCENERY, "work-at") { player, node -> + on(workbenches, IntType.SCENERY, "work-at") { player, node -> + sitDown(player) setAttribute(player, attributeWorkbenchId, node.id) - openInterface(player, WORKBENCH_INTERFACE) + openInterface(player, workbenchInterface) return@on true } - on(WORKBENCHES, IntType.SCENERY, "upgrade") { player, node -> + on(workbenches, IntType.SCENERY, "upgrade") { player, node -> if (!inInventory(player, Items.OAK_PLANK_8778, 2) || !inInventory(player, Items.STEEL_BAR_2353)) { + sendDialogue(player, "You need two oak planks and a steel bar to upgrade this workbench.") // TODO: find authentic dialogue return@on false } if (removeItem(player, Item(Items.OAK_PLANK_8778, 2)) && removeItem(player, Items.STEEL_BAR_2353)) { - + // TODO: upgrading } return@on true } } override fun defineInterfaceListeners() { - on(WORKBENCH_INTERFACE) { player, _, _, buttonID, _, _ -> + on(workbenchInterface) { player, _, _, buttonID, _, _ -> val index = buttonID - 111 - if (index < 0 || index >= FLATPACK_CATEGORIES.size) return@on false - val hotspot = FLATPACK_CATEGORIES[index] + if (index < 0 || index >= decoCategories.size) return@on false + val hotspot = decoCategories[index] setAttribute(player, attributeSelection, hotspot) setAttribute(player, attributeFlatpackMode, true) BuildingUtils.openBuildInterface(player, hotspot) return@on true } - onClose(ConstructionInterface.DECO_INTERFACE) { player, _ -> + onClose(workbenchInterface) { player, _ -> + if (!getAttribute(player, attributeFlatpackMode, false)) { + standUp(player) + removeAttribute(player, attributeSelection) + removeAttribute(player, attributeFlatpackMode) + } + return@onClose true + } + + onClose(ConstructionInterface.decorationInterface) { player, _ -> + standUp(player) removeAttribute(player, attributeSelection) removeAttribute(player, attributeFlatpackMode) return@onClose true