This commit is contained in:
Bishop 2026-07-21 20:34:18 -05:00
parent 528a0da11d
commit 3722762b70
5 changed files with 31 additions and 20 deletions

View file

@ -66,15 +66,15 @@ public enum BuildHotspot {
*/
REPAIR(15448, BuildHotspotType.INDIVIDUAL, BuildingUtils.BUILD_MID_ANIM, Decoration.REPAIR_BENCH, Decoration.WHETSTONE, Decoration.ARMOUR_STAND),
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),
TOOL4(15446, 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),
TOOL5(15447, 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),
HERALDRY(15450, BuildHotspotType.INDIVIDUAL, BuildingUtils.BUILD_MID_ANIM, Decoration.PLUMING_STAND, Decoration.SHIELD_EASEL,Decoration.BANNER_EASEL),
WORKBENCH_STOOL(15440, 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_STOOL(15442, BuildHotspotType.LINKED, BuildingUtils.BUILD_MID_ANIM, Decoration.WORKSHOP_STOOL, Decoration.WORKSHOP_STOOL,Decoration.WORKSHOP_STOOL, Decoration.WORKSHOP_STOOL),
/**
* Bedroom hotspots.

View file

@ -439,7 +439,7 @@ public final class BuildingUtils {
for (int y = 0; y < 8; y++) {
for (BuildHotspot bh : linkedHotspots) {
Hotspot h = room.getHotspot(bh, x, y);
if (h != null) {
if (h != null && h.getDecorationIndex() >= 0) {
int objectId = bh.getDecorations()[h.getDecorationIndex()].getObjectId(style);
Scenery o = chunk.get(x, y, chunk.getIndex(x, y, objectId));
h.setDecorationIndex(-1);

View file

@ -26,11 +26,11 @@ class ConstructionInterface : InterfaceListener {
on(decorationInterface) { player, _, _, buttonID, slot, _ ->
when (buttonID) {
132 -> {
closeInterface(player)
val hotspot = getAttribute<Hotspot?>(player, "con:hotspot", null)
val `object` = getAttribute<Scenery?>(player, "con:hsobject", null)
val flatpackMode = getAttribute(player, WorkbenchListeners.attributeFlatpackMode, false)
if (hotspot == null || `object` == null && !flatpackMode) {
if ((hotspot == null || `object` == null) && !flatpackMode) {
closeInterface(player)
log(this.javaClass, Log.ERR, "Failed building decoration $hotspot : $`object`")
return@on false
}
@ -38,8 +38,9 @@ class ConstructionInterface : InterfaceListener {
val buildHotspot = if (flatpackMode) {
getAttribute<BuildHotspot?>(player, WorkbenchListeners.attributeSelection, null)?: return@on false
} else {
hotspot.hotspot
hotspot!!.hotspot
}
closeInterface(player)
if (slot >= buildHotspot.decorations.size) {
log(this.javaClass, Log.ERR, "Failed building decoration " + slot + "/" + buildHotspot.decorations.size)
return@on false
@ -122,7 +123,8 @@ class ConstructionInterface : InterfaceListener {
val index = buttonID - 160
log(this.javaClass, Log.FINE, "BuildRoom Interface Index: $index")
if (index > -1 && index < RoomProperties.values().size) {
openDialogue(player, "con:room", RoomProperties.values()[index])
// ContentAPI impl won't work for this
player.dialogueInterpreter.open("con:room", RoomProperties.values()[index])
}
return@on true
}

View file

@ -130,14 +130,14 @@ 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),
new Hotspot(BuildHotspot.TOOL3, 0, 1),
new Hotspot(BuildHotspot.TOOL5, 0, 6)),
new Hotspot(BuildHotspot.TOOL5, 0, 6),
new Hotspot(BuildHotspot.CRAFTING_STOOL, 1, 3),
new Hotspot(BuildHotspot.WORKBENCH_STOOL, 3, 3)),
/**
* Bedroom.

View file

@ -51,6 +51,11 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
Scenery.WORKBENCH_13708, // lv99, with lathe
)
private val stools = intArrayOf(
Scenery.STOOL_13719, // wooden
Scenery.STOOL_13720, // oak
)
private val decoCategories = arrayOf(
BuildHotspot.CHAIRS_1, // 111
BuildHotspot.BOOKCASE, // 112
@ -77,7 +82,7 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
fun produceFlatpack(player: Player, deco: Decoration) {
val reward = deco.flatpackItemID
if (reward == -1) return
if (removeItem(player, deco.items) || player.isAdmin) {
if (removeItemsIfPlayerHasEnough(player, *deco.items) || player.isAdmin) {
setAttribute(player, attributeCrafting, true)
rewardXP(player, Skills.CONSTRUCTION, deco.experience.toDouble())
addItemOrDrop(player, reward)
@ -89,15 +94,17 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
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
if (obj != null && obj.id in stools) {
val oakStool = obj.id == Scenery.STOOL_13720
val stoolId = obj.id
val finalDir = when (Pair(x,y)) {
Pair(3,3) -> Direction.EAST
Pair(3,4) -> Direction.SOUTH
Pair(4,3) -> 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
val sittingAnim = if (oakStool) animationSitOak else animationSit
val craftingAnim = if (oakStool) animationCraftOak else animationCraft
animate(player, animationSitDown)
queueScript(player, 1, QueueStrength.NORMAL) { stage ->
when (stage) {
@ -117,8 +124,9 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
}
return@queueScript delayScript(player, 2)
} else {
// Clean up and put the player back to normal
removeAttribute(player, attributeStandUp)
SceneryBuilder.replace(chunk.objects[x][y], obj.transform(BuildHotspot.WORKBENCH_STOOL.objectId))
SceneryBuilder.replace(chunk.objects[x][y], obj.transform(stoolId))
animate(player, animationStandUp)
forceMove(player, player.location, player.location.transform(finalDir, 1), 0, 1000)
return@queueScript stopExecuting(player)
@ -139,6 +147,7 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
override fun defineListeners() {
on(workbenches, IntType.SCENERY, "work-at") { player, node ->
face(player, node)
sitDown(player)
setAttribute(player, attributeWorkbenchId, node.id)
openInterface(player, workbenchInterface)