mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-01 14:39:13 -06:00
Animation tools
This commit is contained in:
parent
2419bdb65e
commit
25d7b3ca03
2 changed files with 86 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <lt>Animation ID<gt>", "Dumps the render animation sub-animations for the given animation ID.") { player, args ->
|
||||
if (args.size < 2) {
|
||||
reject(player, "Syntax error: ::ranimdump <Animation ID>")
|
||||
}
|
||||
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 <lt>Animation ID<gt>", "Searches all animation definitions for render animations that incorporate the given animation ID.") { player, args ->
|
||||
if (args.size < 2) {
|
||||
reject(player, "Syntax error: ::ranimsearch <Animation ID>")
|
||||
}
|
||||
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 <lt>NPC ID<gt>", "Prints the render animation ID (and sub-animation IDs) of an NPC.") { player, args ->
|
||||
if (args.size < 2) {
|
||||
reject(player, "Syntax error: ::ranimnpc <NPC ID>")
|
||||
}
|
||||
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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue