From 25d7b3ca0313b7fa501951e4a40f743bf1389da3 Mon Sep 17 00:00:00 2001 From: Bishop Date: Thu, 30 Jul 2026 20:40:16 -0500 Subject: [PATCH] Animation tools --- Server/src/main/core/api/ContentAPI.kt | 20 ++++++ .../command/sets/AnimationCommandSet.kt | 66 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/Server/src/main/core/api/ContentAPI.kt b/Server/src/main/core/api/ContentAPI.kt index 7423518a7..d1c3a40ef 100644 --- a/Server/src/main/core/api/ContentAPI.kt +++ b/Server/src/main/core/api/ContentAPI.kt @@ -586,6 +586,26 @@ fun resetAnimator(player: Player) { player.animator.animate(Animation(-1, Animator.Priority.VERY_HIGH)) } +/** + * Sets a player's render animation to a given animation. + * @param player the player whose render animation to set + * @param animation the ID of the render animation to set + */ +fun renderAnimation(player: Player, animation: Int) { + player.appearance.setAnimations(Animation(animation)) + player.appearance.sync() +} + +/** + * Resets a player's render animation to the default. + * @param player the player whose render animation to reset + */ +fun resetRenderAnimation(player: Player) { + player.appearance.setDefaultAnimations() + player.appearance.setAnimations() + player.appearance.sync() +} + /** * Get the number of ticks an animation lasts * @param animation the Animation object to check the duration of 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 d06258333..ba5dc8201 100644 --- a/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt @@ -2,6 +2,7 @@ package core.game.system.command.sets import core.api.animate import core.api.delayScript +import core.api.log import core.api.queueScript import core.api.stopExecuting import core.game.interaction.QueueStrength @@ -12,6 +13,7 @@ import core.plugin.Initializable import core.game.system.command.CommandPlugin.Companion.toInteger import core.game.system.command.Privilege import core.game.world.GameWorld +import core.tools.Log import java.util.* @Initializable @@ -113,5 +115,69 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { player.appearance.setAnimations() player.appearance.sync() } + + + /** + * Dumps the animations contained within a given render animation, by ID. + */ + define("ranimdump", Privilege.ADMIN, "::ranimdump Animation ID", "Dumps the render animation sub-animations for the given animation ID.") { player, args -> + if (args.size < 2) { + reject(player, "Syntax error: ::ranimdump ") + } + val argAnimId = args[1].toInt() + val def = core.cache.def.impl.RenderAnimationDefinition.forId(argAnimId) + notify(player, "Sub-animations of render anim ID $argAnimId: stand=${def.standAnimationId}, walk=${def.walkAnimationId}, run=${def.runAnimationId},") + notify(player, "Sub-animations of render anim ID $argAnimId: turn180=${def.turn180Animation}, turnCW=${def.turnCWAnimation}, turnCCW=${def.turnCCWAnimation}") + } + + + /** + * Searches all animations for render animations containing a given animation as a sub-animation, by ID. + */ + define("ranimsearch", Privilege.ADMIN, "::ranimsearch Animation ID", "Searches all animation definitions for render animations that incorporate the given animation ID.") { player, args -> + if (args.size < 2) { + reject(player, "Syntax error: ::ranimsearch ") + } + val argAnimId = args[1].toInt() + val everyRAnim = core.cache.Cache.getIndexes()[2].getFilesSize(32) + var hits = 0 + for (animId in 0 until everyRAnim) { + val def = core.cache.def.impl.RenderAnimationDefinition.forId(animId) ?: continue + if (def.standAnimationId == argAnimId || def.walkAnimationId == argAnimId || def.runAnimationId == argAnimId || + def.turn180Animation == argAnimId || def.turnCWAnimation == argAnimId || def.turnCCWAnimation == argAnimId) { + hits++ + val output1 = "Sub-animations of render anim ID $animId: stand=${def.standAnimationId}, walk=${def.walkAnimationId}, run=${def.runAnimationId}" + val output2 = "Sub-animations of render anim ID $animId: turn180=${def.turn180Animation}, turnCW=${def.turnCWAnimation}, turnCCW=${def.turnCCWAnimation}" + if (hits <= 20) { + notify(player, output1) + notify(player, output2) + } + log(this::class.java, Log.DEBUG, output1) + log(this::class.java, Log.DEBUG, output2) + } + } + val total = "$hits render animations found referencing animation ID $argAnimId." + notify(player, total) + log(this::class.java, Log.DEBUG, total) + if (hits > 20) { + notify(player, "Displayed results truncated to 20, see console for full list.") + } + } + + + /** + * Prints the render animation ID of a given NPC, and its sub-animations, by NPC ID. + */ + define("ranimnpc", Privilege.ADMIN, "::ranimnpc NPC ID", "Prints the render animation ID (and sub-animation IDs) of an NPC.") { player, args -> + if (args.size < 2) { + reject(player, "Syntax error: ::ranimnpc ") + } + val targetNPC = args[1].toInt() + val rAnimId = core.cache.def.impl.NPCDefinition.forId(targetNPC).renderAnimationId + val def = core.cache.def.impl.RenderAnimationDefinition.forId(rAnimId) + notify(player, "Render animation for NPC ID $targetNPC: animation ID $rAnimId") + notify(player, "Sub-animations of render anim ID $rAnimId: stand=${def.standAnimationId}, walk=${def.walkAnimationId}, run=${def.runAnimationId},") + notify(player, "Sub-animations of render anim ID $rAnimId: turn180=${def.turn180Animation}, turnCW=${def.turnCWAnimation}, turnCCW=${def.turnCCWAnimation}") + } } }