Added ::poison <username> <damage> debug command for testing

Converted Cure Me to kotlin
Converted Cure Other to kotlin
Converted Translated Cure Group to kotlin
This commit is contained in:
bushtail
2022-10-12 13:43:05 +00:00
committed by Ryan
parent 0a014e86f3
commit 63e5c9a6b8
6 changed files with 155 additions and 226 deletions
+43
View File
@@ -27,6 +27,7 @@ import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.gather.SkillingTool
import core.game.node.entity.skill.slayer.Tasks
import core.game.node.entity.skill.summoning.familiar.BurdenBeast
import core.game.node.entity.state.EntityState
import core.game.node.item.GroundItem
import core.game.node.item.GroundItemManager
import core.game.node.item.Item
@@ -1029,6 +1030,7 @@ fun getUsedOption(player: Player): String {
/**
* Used to play both an Animation and Graphics object simultaneously.
* Use -1 in place of anim or graphics if not needed.
* @param entity the entity to perform this on
* @param anim the Animation object to use, can also be an ID.
* @param gfx the Graphics object to use, can also be an ID.
@@ -2157,4 +2159,45 @@ fun requireQuest(player: Player, questName: String, message: String) : Boolean {
return true
}
/**
* Determines whether or not a specified entity has a state
* @param entity the entity whose state we are checking
* @param state the state to check for
* @return whether or not the entity has the provided state
*/
fun hasState(entity: Entity, state: EntityState) : Boolean {
return entity.stateManager.hasState(state)
}
/**
* Adds a state to the entity
* @param entity the entity whose state we are adding
* @param state the state to add
* @param override whether or not it's to override another state
*/
fun addState(entity: Entity, state: EntityState, override: Boolean, vararg args: Any?) {
if(!entity.stateManager.hasState(state)) {
entity.stateManager.register(state, override, *args)
}
}
/**
* Removes a state from the entity
* @param entity the entity whose state we are removing
* @param state the state to remove
*/
fun removeState(entity: Entity, state: EntityState) {
entity.stateManager.remove(state)
}
/**
* Determines whether or not specified node is a player
* @param entity the node whom we are checking
* @return whether or not the entity is a player
*/
fun isPlayer(node: Node) : Boolean {
return (node is Player)
}
private class ContentAPI
@@ -13,6 +13,9 @@ val PLANK_MAKE_ANIM = Animation(6298)
val STRING_JEWELLERY_ANIM = Animation(4412)
val SUPERGLASS_MAKE_ANIM = Animation(4413)
val FERTILE_SOIL_ANIM = Animation(724)
val CURE_ME_ANIM = Animation(4411)
val CURE_GROUP_ANIM = Animation(4409)
val CURE_OTHER_ANIM = Animation(4411)
// Graphics
@@ -24,6 +27,9 @@ val PLANK_MAKE_GFX = Graphics(1063, 120)
val STRING_JEWELLERY_GFX = Graphics(728, 100)
val SUPERGLASS_MAKE_GFX = Graphics(729, 120)
val FERTILE_SOIL_GFX = Graphics(141, 96)
val CURE_ME_GFX = Graphics(731, 90)
val CURE_GROUP_GFX = Graphics(751, 130)
val CURE_OTHER_GFX = Graphics(738, 130)
enum class JewelleryString(val unstrung: Int, val strung: Int) {
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
@@ -2,6 +2,8 @@ package rs09.game.node.entity.skill.magic
import api.*
import core.game.component.Component
import core.game.node.Node
import core.game.node.entity.Entity
import core.game.node.scenery.Scenery
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
@@ -9,6 +11,7 @@ import core.game.node.entity.player.link.audio.Audio
import core.game.node.entity.player.link.TeleportManager
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.cooking.CookableItems
import core.game.node.entity.state.EntityState
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.map.Location
@@ -16,13 +19,16 @@ import core.game.world.map.RegionManager
import core.tools.RandomFunction
import org.rs09.consts.Components
import org.rs09.consts.Items
import rs09.game.interaction.item.withnpc.graphics
import rs09.game.node.entity.skill.farming.CompostBins
import rs09.game.node.entity.skill.farming.CompostType
import rs09.game.node.entity.skill.farming.FarmingPatch
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
import rs09.game.system.command.Privilege
import rs09.game.system.config.NPCConfigParser
import rs09.game.world.repository.Repository
class LunarListeners : SpellListener("lunar") {
class LunarListeners : SpellListener("lunar"), Commands {
override fun defineListeners() {
@@ -163,10 +169,44 @@ class LunarListeners : SpellListener("lunar") {
}
onCast(Lunar.FERTILE_SOIL, OBJECT) { player, node ->
fertileSoil(player, node!!.asScenery())
node?.let { fertileSoil(player, node.asScenery()) }
}
onCast(Lunar.CURE_ME, NONE) { player, _ ->
cureMe(player)
}
onCast(Lunar.CURE_GROUP, NONE) { player, _ ->
cureGroup(player)
}
onCast(Lunar.CURE_OTHER, PLAYER) { player, node ->
node?.let { cureOther(player, node) }
}
}
// Lunar spellbook-related debug commands
override fun defineCommands() {
define("poison", privilege = Privilege.ADMIN) { player, strings ->
if(strings.size == 3) {
var dmg = strings[2].toIntOrNull()
val p = Repository.getPlayerByName(strings[1])
if(p == null) {
sendMessage(player, "Player ${strings[1]} does not exist.")
return@define
}
if(dmg != null) {
p?.let { addState(it, EntityState.POISONED, false, (dmg * 10 + 8), player) }
} else {
sendMessage(player, "Damage must be an integer. Format:")
sendMessage(player, "::poison username damage")
}
} else {
sendMessage(player, "Invalid arguments provided. Format:")
sendMessage(player, "::poison username damage")
}
}
}
private fun plankMake(player: Player, item: Item) {
val plankType = PlankType.getForLog(item)
@@ -426,8 +466,72 @@ class LunarListeners : SpellListener("lunar") {
sendMessage(player, "You fertilize the soil.")
addXP(player, 87.0)
}
private fun cureMe(player: Player) {
if(!hasState(player, EntityState.POISONED)) {
sendMessage(player, "You are not poisoned.")
return
}
requires(player, 71, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.LAW_RUNE_563, 1), Item(Items.COSMIC_RUNE_564, 2)))
removeRunes(player, true)
visualizeSpell(player, CURE_ME_ANIM, CURE_ME_GFX, 2880)
removeState(player, EntityState.POISONED)
addXP(player, 69.0)
playAudio(player, Audio(2900))
sendMessage(player, "You have been cured of poison.")
}
private fun cureGroup(player: Player) {
requires(player, 74, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.LAW_RUNE_563, 2), Item(Items.COSMIC_RUNE_564, 2)))
removeRunes(player, true)
visualizeSpell(player, CURE_GROUP_ANIM, CURE_GROUP_GFX, 2882)
removeState(player, EntityState.POISONED)
for(acct in RegionManager.getLocalPlayers(player, 1)) {
if(!acct.isActive || acct.locks.isInteractionLocked) {
continue
}
if(!acct.settings.isAcceptAid) {
continue
}
removeState(acct, EntityState.POISONED)
sendMessage(acct, "You have been cured of poison.")
playAudio(acct, Audio(2889), true)
visualize(acct, -1, CURE_GROUP_GFX)
}
addXP(player, 74.0)
}
private fun cureOther(player: Player, target: Node) {
if(!isPlayer(target)) {
sendMessage(player, "You can only cast this spell on other players.")
return
}
val p = target.asPlayer()
if(!p.isActive || p.locks.isInteractionLocked) {
sendMessage(player, "This player is busy.")
return
}
if(!p.settings.isAcceptAid) {
sendMessage(player, "This player is not accepting any aid.")
return
}
if(!hasState(p, EntityState.POISONED)) {
sendMessage(player, "This player is not poisoned.")
return
}
requires(player, 68, arrayOf(Item(Items.ASTRAL_RUNE_9075, 1), Item(Items.LAW_RUNE_563), Item(Items.EARTH_RUNE_557, 10)))
player.face(p)
visualizeSpell(player, CURE_OTHER_ANIM, CURE_OTHER_GFX, 2886)
visualize(p, -1, CURE_OTHER_GFX)
playAudio(p, Audio(2889), true)
removeRunes(player, true)
removeState(p, EntityState.POISONED)
sendMessage(p, "You have been cured of poison.")
addXP(player, 65.0)
}
}