From 70b4c7e6387e80ab932562bd06a40a36fd849d55 Mon Sep 17 00:00:00 2001 From: psyopcutie Date: Tue, 21 Jul 2026 06:42:44 +0200 Subject: [PATCH] ::gfxs & ::sanims also formatting --- .../command/sets/AnimationCommandSet.kt | 80 +++++++++++++++---- .../command/sets/DevelopmentCommandSet.kt | 8 +- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt b/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt index f9e31b091..4ecf47951 100644 --- a/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt @@ -1,21 +1,17 @@ package core.game.system.command.sets -import core.api.animate -import core.api.animateInterface -import core.api.delayScript -import core.api.openInterface -import core.api.queueScript -import core.api.stopExecuting +import core.api.* import core.game.interaction.QueueStrength import core.game.node.entity.npc.NPC -import core.game.system.task.Pulse -import core.game.world.update.flag.context.Animation -import core.plugin.Initializable import core.game.system.command.CommandPlugin.Companion.toInteger import core.game.system.command.Privilege import core.game.system.config.HumanoidAnimationIds +import core.game.system.task.Pulse import core.game.world.GameWorld -import java.util.* +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import core.game.world.update.flag.context.Graphics +import core.plugin.Initializable @Initializable class AnimationCommandSet : CommandSet(Privilege.ADMIN) { @@ -29,7 +25,7 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { */ define("anim", Privilege.ADMIN, "::anim Animation ID", "Plays the animation with the given ID."){ player, args -> if (args.size < 2) { - reject(player, "Syntax error: ::anim ") + reject(player, "Syntax error: ::anim Animation ID") } val animation = Animation(args[1].toInt()) player.animate(animation) @@ -38,7 +34,7 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { define("anims", Privilege.ADMIN, "::anims From Animation ID To Animation ID (opt) Duration Per Animation", "Plays animations from the From ID to the To ID, with a delay of 3 between animations, unless specified otherwise"){ player, args -> if (args.size < 3) { - reject(player, "Syntax error: ::anims <(opt) Duration Per Animation>") + reject(player, "Syntax error: ::anims From Animation ID To Animation ID (opt) Duration Per Animation") } val animationFrom = args[1].toInt() val animationTo = args[2].toInt() @@ -61,7 +57,7 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { define("panims", Privilege.ADMIN, "::panims From Animation ID To Animation ID (opt) Duration Per Animation", "Same as ::anims but only plays animations compatible with the player/humanoid skeleton."){ player, args -> if (args.size < 3) { - reject(player, "Syntax error: ::panims <(opt) Duration Per Animation>") + reject(player, "Syntax error: ::panims From Animation ID To Animation ID (opt) Duration Per Animation") } val animationFrom = args[1].toInt() val animationTo = args[2].toInt() @@ -86,10 +82,36 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { } } + /** Cycles graphics on the player. */ + define("gfxs", Privilege.ADMIN, "::gfxs From Graphic ID To Graphic ID (opt) Duration (opt) Height", "Cycles graphics on the player.") { player, args -> + if (args.size !in 3..5) { + reject(player, "Syntax error: ::gfxs From Graphic ID To Graphic ID (opt) Duration (opt) Height") + } + + val graphicsFrom = args[1].toInt() + val graphicsTo = args[2].toInt() + val graphicsDelay = (args.getOrNull(3) ?: "3").toInt() + val graphicsHeight = (args.getOrNull(4) ?: "0").toInt() + + var graphicsId = graphicsFrom + + queueScript(player, 1, QueueStrength.SOFT) { + visualize(player, -1, Graphics(graphicsId, graphicsHeight)) + notify(player, "Playing graphics $graphicsId") + + if (graphicsId == graphicsTo) { + return@queueScript stopExecuting(player) + } + + graphicsId++ + return@queueScript delayScript(player, graphicsDelay) + } + } + /** Cycles animations on an interface child. */ define("ianims", Privilege.ADMIN, "::ianims Interface ID Child ID From Animation ID To Animation ID (opt) Duration", "Cycles animations on an interface child.") { player, args -> if (args.size !in 4..6) { - reject(player, "Syntax error: ::ianims <(opt) Duration>") + reject(player, "Syntax error: ::ianims Interface ID Child ID From Animation ID To Animation ID (opt) Duration") } val interfaceId = args[1].toInt() @@ -114,6 +136,36 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { } } + /** Cycles animations on a scenery object. */ + define("sanims", Privilege.ADMIN, "::sanims From Animation ID To Animation ID X Y (opt) Duration", "Cycles animations on scenery at the given tile.") { player, args -> + if (args.size !in 5..6) { + reject(player, "Syntax error: ::sanims From Animation ID To Animation ID X Y (opt) Duration") + } + + val animationFrom = args[1].toInt() + val animationTo = args[2].toInt() + val location = Location(args[3].toInt(), args[4].toInt(), player.location.z) + val animationDelay = (args.getOrNull(5) ?: "3").toInt() + val sceneryObject = getScenery(location) ?: run { + reject(player, "No scenery found at $location.") + return@define + } + + var animationId = animationFrom + + queueScript(player, 1, QueueStrength.SOFT) { + animateScenery(player, sceneryObject, animationId) + notify(player, "Playing scenery animation $animationId on scenery ${sceneryObject.id}") + + if (animationId == animationTo) { + return@queueScript stopExecuting(player) + } + + animationId++ + return@queueScript delayScript(player, animationDelay) + } + } + /** * Force the player to loop animation */ diff --git a/Server/src/main/core/game/system/command/sets/DevelopmentCommandSet.kt b/Server/src/main/core/game/system/command/sets/DevelopmentCommandSet.kt index c6a3baa56..22615a7ef 100644 --- a/Server/src/main/core/game/system/command/sets/DevelopmentCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/DevelopmentCommandSet.kt @@ -370,9 +370,9 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) { setAttribute(player, "draw-intersect", !getAttribute(player, "draw-intersect", false)) } - define("expression", Privilege.ADMIN, "::expression expression id [npc id]", "Visualizes chathead animations from ID. Works with ::pnpc") { player, args -> + define("expression", Privilege.ADMIN, "::expression expression id (opt) npc id", "Visualizes chathead animations from ID. Works with ::pnpc") { player, args -> if (args.size !in 2..3 || args[1].toIntOrNull() == null || (args.size == 3 && args[2].toIntOrNull() == null)) { - reject(player, "Usage: ::expression expression id [npc id]") + reject(player, "Usage: ::expression expression id (opt) npc id") return@define } @@ -396,9 +396,9 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) { } } - define("expressions", Privilege.ADMIN, "::expressions expression id expression id [duration] [npc id]", "Cycles chathead animations from expression id to id") { player, args -> + define("expressions", Privilege.ADMIN, "::expressions expression id expression id (opt) duration (opt) npc id", "Cycles chathead animations from expression id to id") { player, args -> if (args.size !in 3..5 || args[1].toIntOrNull() == null || args[2].toIntOrNull() == null || (args.size >= 4 && args[3].toIntOrNull() == null) || (args.size == 5 && args[4].toIntOrNull() == null)) { - reject(player, "Usage: ::expressions expression id expression id [duration] [npc id]") + reject(player, "Usage: ::expressions expression id expression id (opt) duration (opt) npc id") return@define }