This commit is contained in:
Bishop 2026-07-30 20:58:24 -05:00
parent e542861ca6
commit b54c8c7bb6
6 changed files with 52 additions and 62 deletions

View file

@ -49,7 +49,7 @@ public final class BuildOptionPlugin extends OptionHandler {
player.getDialogueInterpreter().open("con:removedec", object);
return true;
}
setAttribute(player, ConstructionInterface.attributeHotspotObj, node);
setAttribute(player, ConstructionInterface.ATTRIBUTE_HOTSPOT_OBJ, node);
if (BuildingUtils.isDoorHotspot(object)) {
int[] pos = BuildingUtils.roomExists(player, object);
if (pos != null) {
@ -82,8 +82,8 @@ public final class BuildOptionPlugin extends OptionHandler {
int dy = h.getCurrentY() - object.getLocation().getChunkOffsetY();
Scenery primaryObj = RegionManager.getObject(object.getLocation().transform(dx, dy, 0));
if (primaryObj != null) {
setAttribute(player, ConstructionInterface.attributeHotspotObj, primaryObj);
setAttribute(player, ConstructionInterface.attributeHotspot, h);
setAttribute(player, ConstructionInterface.ATTRIBUTE_HOTSPOT_OBJ, primaryObj);
setAttribute(player, ConstructionInterface.ATTRIBUTE_HOTSPOT, h);
BuildingUtils.openBuildInterface(player, linked[0]);
}
return true;
@ -92,7 +92,7 @@ public final class BuildOptionPlugin extends OptionHandler {
return true;
}
setAttribute(player, ConstructionInterface.attributeHotspot, hotspot);
setAttribute(player, ConstructionInterface.ATTRIBUTE_HOTSPOT, hotspot);
BuildingUtils.openBuildInterface(player, hotspot.getHotspot());
return true;
}

View file

@ -107,7 +107,7 @@ public final class BuildRoomDialogue extends DialoguePlugin {
stage = 2;
return true;
}
this.door = (Scenery) getAttribute(player, ConstructionInterface.attributeHotspotObj, null);
this.door = (Scenery) getAttribute(player, ConstructionInterface.ATTRIBUTE_HOTSPOT_OBJ, null);
int[] pos = BuildingUtils.getRoomPosition(player, door);
roomX = pos[0];
roomY = pos[1];

View file

@ -7,6 +7,7 @@ import core.game.interaction.InterfaceListener
import core.game.node.entity.skill.Skills
import core.game.node.scenery.Scenery
import core.tools.Log
import org.rs09.consts.Components
/**
* Handles three interfaces related to the Construction skill, namely those which allow a player to build decorations,
@ -17,12 +18,8 @@ import core.tools.Log
class ConstructionInterface : InterfaceListener {
companion object {
const val decorationInterface = 396
const val pohMenuInterface = 398
const val roomInterface = 402
const val attributeHotspot = "con:hotspot"
const val attributeHotspotObj = "con:hsobject"
const val ATTRIBUTE_HOTSPOT = "con:hotspot"
const val ATTRIBUTE_HOTSPOT_OBJ = "con:hsobject"
// Register furniture here when it is only obtainable by upgrading, to send the correct rejection message.
val upgradeOnly = arrayOf(
@ -35,12 +32,12 @@ class ConstructionInterface : InterfaceListener {
/**
* Handles the interface for selecting a decoration to build.
*/
on(decorationInterface) { player, _, _, buttonID, slot, _ ->
on(Components.POH_DECORATION_396) { player, _, _, buttonID, slot, _ ->
when (buttonID) {
132 -> {
val hotspot = getAttribute<Hotspot?>(player, attributeHotspot, null)
val hotspotObj = getAttribute<Scenery?>(player, attributeHotspotObj, null)
val flatpackMode = getAttribute(player, WorkbenchListeners.attributeFlatpackMode, false)
val hotspot = getAttribute<Hotspot?>(player, ATTRIBUTE_HOTSPOT, null)
val hotspotObj = getAttribute<Scenery?>(player, ATTRIBUTE_HOTSPOT_OBJ, null)
val flatpackMode = getAttribute(player, WorkbenchListeners.ATTRIBUTE_FLATPACK_MODE, false)
if (!flatpackMode) {
closeInterface(player)
}
@ -50,7 +47,7 @@ class ConstructionInterface : InterfaceListener {
}
val decoIndex = (if (slot % 2 != 0) 4 else 0) + (slot shr 1)
val buildHotspot = if (flatpackMode) {
getAttribute<BuildHotspot?>(player, WorkbenchListeners.attributeSelection, null)?: return@on false
getAttribute<BuildHotspot?>(player, WorkbenchListeners.ATTRIBUTE_WORKBENCH_SELECTION, null)?: return@on false
} else {
hotspot!!.hotspot
}
@ -98,7 +95,7 @@ class ConstructionInterface : InterfaceListener {
return@on true
}
}
if (flatpackMode && WorkbenchListeners.getBenchLevel(getAttribute(player, WorkbenchListeners.attributeWorkbenchId, 20)) < deco.level) {
if (flatpackMode && WorkbenchListeners.getBenchLevel(getAttribute(player, WorkbenchListeners.ATTRIBUTE_WORKBENCH_ID, 20)) < deco.level) {
closeInterface(player)
sendMessage(player, "You cannot make this with this workbench.") // Placeholder
return@on true
@ -118,7 +115,7 @@ class ConstructionInterface : InterfaceListener {
/**
* Handles the interface for managing building mode and POH guests.
*/
on(pohMenuInterface) { player, _, _, buttonID, _, _ ->
on(Components.POH_HOUSE_OPTIONS_398) { player, _, _, buttonID, _, _ ->
when (buttonID) {
14 -> {
player.houseManager.toggleBuildingMode(player, true)
@ -147,7 +144,7 @@ class ConstructionInterface : InterfaceListener {
/**
* Handles the interface for selecting a new room to add to a POH.
*/
on(roomInterface) { player, _, _, buttonID, _, _ ->
on(Components.POH_ROOMS_402) { player, _, _, buttonID, _, _ ->
val index = buttonID - 160
log(this.javaClass, Log.FINE, "BuildRoom Interface Index: $index")
if (index > -1 && index < RoomProperties.values().size) {

View file

@ -88,11 +88,11 @@ public final class HouseZone extends MapZone {
public boolean move(Entity e, Location from, Location to) {
if (e instanceof Player) {
Player p = (Player) e;
if (getAttribute(p, WorkbenchListeners.attributeSitting, false)) {
if (getAttribute(p, WorkbenchListeners.ATTRIBUTE_WORKBENCH_SEATED, false)) {
p.getPulseManager().clear();
p.getWalkingQueue().reset();
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext(p));
if (!getAttribute(p, WorkbenchListeners.attributeStandingUp, false)) {
if (!getAttribute(p, WorkbenchListeners.ATTRIBUTE_WORKBENCH_STANDING_UP, false)) {
WorkbenchListeners.standUpFromWorkbench(p);
}
return false;

View file

@ -1,12 +1,12 @@
package content.global.skill.construction.decoration
import content.global.skill.construction.decoration.workshop.WorkbenchListeners
import core.api.animate
import core.api.getScenery
import core.game.node.entity.Entity
import core.game.node.entity.player.Player
import core.game.system.timer.PersistTimer
import core.game.system.timer.RSTimer
import org.rs09.consts.Animations
import org.rs09.consts.Scenery
import kotlin.collections.get
@ -24,8 +24,8 @@ class StaySeated : PersistTimer(10 /*ticks*/, "con:sitting", isSoft = true) {
// Register new chairs and animations here
private val sittables = mapOf(
Scenery.STOOL_13719 to WorkbenchListeners.animationSit, // wooden workbench stool
Scenery.STOOL_13720 to WorkbenchListeners.animationSitOak, // oak workbench stool
Scenery.STOOL_13719 to Animations.HUMAN_SEATED_POH_STOOL_4107,
Scenery.STOOL_13720 to Animations.HUMAN_SEATED_POH_OAK_STOOL_4108,
)
override fun run(entity: Entity): Boolean {

View file

@ -12,6 +12,8 @@ import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.world.map.Direction
import core.tools.ticksToCycles
import org.rs09.consts.Animations
import org.rs09.consts.Components
import org.rs09.consts.Items
import org.rs09.consts.Scenery
@ -23,21 +25,12 @@ import org.rs09.consts.Scenery
class WorkbenchListeners : InteractionListener, InterfaceListener {
companion object {
const val workbenchInterface = 397
const val attributeWorkbenchId = "con:workbench:id"
const val attributeFlatpackMode = "con:workbench:active"
const val attributeDirections = "con:workbench:directions"
const val attributeSelection = "con:workbench:hotspot"
const val attributeSitting = "con:workbench:sitting"
const val attributeStandingUp = "con:workbench:standing"
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 ATTRIBUTE_FLATPACK_MODE = "con:workbench:active"
const val ATTRIBUTE_WORKBENCH_ID = "con:workbench:id"
const val ATTRIBUTE_WORKBENCH_SELECTION = "con:workbench:hotspot"
const val ATTRIBUTE_WORKBENCH_SEATED = "con:workbench:sitting"
const val ATTRIBUTE_WORKBENCH_STANDING_UP = "con:workbench:standing"
private const val ATTRIBUTE_DIRECTIONS = "con:workbench:directions"
private val workbenches = intArrayOf(
Scenery.WORKBENCH_13704, // lv20, wooden
@ -84,7 +77,7 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
*/
fun produceFlatpack(player: Player, deco: Decoration) {
val reward = deco.flatpackItemID
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { animationCraftOak } else { animationCraft }
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { Animations.HUMAN_CRAFT_POH_OAK_STOOL_4110 } else { Animations.HUMAN_CRAFT_POH_STOOL_4109 }
if (reward == -1) return
if (removeItemsIfPlayerHasEnough(player, *deco.items) || player.isAdmin) {
closeInterface(player)
@ -101,15 +94,15 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
*/
@JvmStatic
fun standUpFromWorkbench(player: Player) {
val directions = getAttribute(player, attributeDirections, arrayOf(Direction.WEST, Direction.NORTH, Direction.EAST))
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { animationSitOak } else { animationSit }
setAttribute(player, attributeStandingUp, true)
val directions = getAttribute(player, ATTRIBUTE_DIRECTIONS, arrayOf(Direction.WEST, Direction.NORTH, Direction.EAST))
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { Animations.HUMAN_SEATED_POH_OAK_STOOL_4108 } else { Animations.HUMAN_SEATED_POH_STOOL_4107 }
setAttribute(player, ATTRIBUTE_WORKBENCH_STANDING_UP, true)
lock(player, 1)
animate(player, animation)
queueScript(player, 0, QueueStrength.SOFT) {
forceMove(player, player.location, player.location.transform(directions[2], 1),
0, ticksToCycles(1), directions[2], animationStandUp) {
removeAttributes(player, attributeDirections, attributeSitting, attributeStandingUp)
0, ticksToCycles(1), directions[2], Animations.HUMAN_STAND_POH_STOOL_4105) {
removeAttributes(player, ATTRIBUTE_DIRECTIONS, ATTRIBUTE_WORKBENCH_SEATED, ATTRIBUTE_WORKBENCH_STANDING_UP)
removeTimer<StaySeated>(player)
}
return@queueScript stopExecuting(player)
@ -122,12 +115,12 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
* Animates the player sitting down at the workbench, and opens the workbench interface.
*/
on(workbenches, IntType.SCENERY, "work-at") { player, node ->
setAttribute(player, attributeWorkbenchId, node.id)
setAttribute(player, ATTRIBUTE_WORKBENCH_ID, node.id)
// Skips the animation if the player is already sitting down.
if (getAttribute(player, attributeSitting, false)) {
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { animationSitOak } else { animationSit }
if (getAttribute(player, ATTRIBUTE_WORKBENCH_SEATED, false)) {
val animation = if (getScenery(player.location)?.id == Scenery.STOOL_13720) { Animations.HUMAN_SEATED_POH_OAK_STOOL_4108 } else { Animations.HUMAN_SEATED_POH_STOOL_4107 }
animate(player, animation)
openInterface(player, workbenchInterface)
openInterface(player, Components.POH_WORKBENCH_397)
return@on true
}
// Ascertains the room rotation from where the stool is, to coordinate animations
@ -143,14 +136,14 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
Pair(4,3) -> arrayOf(Direction.SOUTH, Direction.WEST, Direction.NORTH)
else -> arrayOf(Direction.EAST, Direction.SOUTH, Direction.WEST)
}
setAttribute(player, attributeDirections, directions)
setAttribute(player, ATTRIBUTE_DIRECTIONS, directions)
forceMove(player, player.location, player.location.transform(directions[0], 1),
0, ticksToCycles(1), directions[1], animationSitDown) {
val animation = if (obj.id == Scenery.STOOL_13720) { animationSitOak } else { animationSit }
0, ticksToCycles(1), directions[1], Animations.HUMAN_SIT_POH_STOOL_4103) {
val animation = if (obj.id == Scenery.STOOL_13720) { Animations.HUMAN_SEATED_POH_OAK_STOOL_4108 } else { Animations.HUMAN_SEATED_POH_STOOL_4107 }
animate(player, animation)
setAttribute(player, attributeSitting, true)
setAttribute(player, ATTRIBUTE_WORKBENCH_SEATED, true)
registerTimer(player, StaySeated())
openInterface(player, workbenchInterface)
openInterface(player, Components.POH_WORKBENCH_397)
}
return@on true
}
@ -209,25 +202,25 @@ class WorkbenchListeners : InteractionListener, InterfaceListener {
/**
* Directs the player to the appropriate decoration building interface.
*/
on(workbenchInterface) { player, _, _, buttonID, _, _ ->
on(Components.POH_WORKBENCH_397) { player, _, _, buttonID, _, _ ->
val index = buttonID - 111
if (index < 0 || index >= decoCategories.size) return@on false
val hotspot = decoCategories[index]
setAttribute(player, attributeSelection, hotspot)
setAttribute(player, attributeFlatpackMode, true)
setAttribute(player, ATTRIBUTE_WORKBENCH_SELECTION, hotspot)
setAttribute(player, ATTRIBUTE_FLATPACK_MODE, true)
BuildingUtils.openBuildInterface(player, hotspot)
return@on true
}
onClose(workbenchInterface) { player, _ ->
if (!getAttribute(player, attributeFlatpackMode, false)) {
removeAttributes(player, attributeFlatpackMode, attributeSelection, attributeWorkbenchId)
onClose(Components.POH_WORKBENCH_397) { player, _ ->
if (!getAttribute(player, ATTRIBUTE_FLATPACK_MODE, false)) {
removeAttributes(player, ATTRIBUTE_FLATPACK_MODE, ATTRIBUTE_WORKBENCH_SELECTION, ATTRIBUTE_WORKBENCH_ID)
}
return@onClose true
}
onClose(ConstructionInterface.decorationInterface) { player, _ ->
removeAttributes(player, attributeFlatpackMode, attributeSelection, attributeWorkbenchId)
onClose(Components.POH_DECORATION_396) { player, _ ->
removeAttributes(player, ATTRIBUTE_FLATPACK_MODE, ATTRIBUTE_WORKBENCH_SELECTION, ATTRIBUTE_WORKBENCH_ID)
return@onClose true
}
}