mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
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:
parent
0a014e86f3
commit
63e5c9a6b8
6 changed files with 155 additions and 226 deletions
|
|
@ -1,76 +0,0 @@
|
|||
package core.game.node.entity.skill.magic.lunar;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.magic.MagicSpell;
|
||||
import core.game.node.entity.skill.magic.Runes;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.equipment.SpellType;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.audio.Audio;
|
||||
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
|
||||
import core.game.node.entity.state.EntityState;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* The cure group spell.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class CureGroupSpell extends MagicSpell {
|
||||
|
||||
/**
|
||||
* Represents the animation of this graphics.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(4409);
|
||||
|
||||
/**
|
||||
* Represents the graphic to use.
|
||||
*/
|
||||
private static final Graphics GRAPHIC = new Graphics(751, 130);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code CureGroupSpell} {@code Object}.
|
||||
*/
|
||||
public CureGroupSpell() {
|
||||
super(SpellBook.LUNAR, 74, 74, ANIMATION, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.LAW_RUNE.getId(), 2), new Item(Runes.COSMIC_RUNE.getId(), 2) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
|
||||
SpellBook.LUNAR.register(3, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(Entity entity, Node target) {
|
||||
Player p = (Player) entity;
|
||||
if (!meetsRequirements(entity, true, true)) {
|
||||
return false;
|
||||
}
|
||||
p.animate(ANIMATION);
|
||||
p.graphics(GRAPHIC);
|
||||
p.getAudioManager().send(new Audio (2882), true);
|
||||
p.getStateManager().remove(EntityState.POISONED);
|
||||
for (Player players : RegionManager.getLocalPlayers(p, 1)) {
|
||||
Player o = (Player) players;
|
||||
if (!o.isActive() || o.getLocks().isInteractionLocked()) {
|
||||
continue;
|
||||
}
|
||||
if (!o.getSettings().isAcceptAid()) {
|
||||
continue;
|
||||
}
|
||||
o.getStateManager().remove(EntityState.POISONED);
|
||||
o.getAudioManager().send(new Audio(2889), true);
|
||||
o.graphics(GRAPHIC);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package core.game.node.entity.skill.magic.lunar;
|
||||
|
||||
import core.game.node.entity.skill.magic.MagicSpell;
|
||||
import core.game.node.entity.skill.magic.Runes;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.equipment.SpellType;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.audio.Audio;
|
||||
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
|
||||
import core.game.node.entity.state.EntityState;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* The cure me spell.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class CureMeSpell extends MagicSpell {
|
||||
|
||||
/**
|
||||
* Represents the animation of this graphics.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(4411);
|
||||
|
||||
/**
|
||||
* Repesents the graphick, next spells of this spell.
|
||||
*/
|
||||
private static final Graphics GRAPHIC = new Graphics(731, 90);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code CureOtherSpell} {@code Object}.
|
||||
*/
|
||||
public CureMeSpell() {
|
||||
super(SpellBook.LUNAR, 71, 69, ANIMATION, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.LAW_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 2) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
|
||||
SpellBook.LUNAR.register(23, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(Entity entity, Node target) {
|
||||
Player p = (Player) entity;
|
||||
if (!p.getStateManager().hasState(EntityState.POISONED)) {
|
||||
p.getPacketDispatch().sendMessage("You are not poisoned.");
|
||||
return false;
|
||||
}
|
||||
if (!meetsRequirements(entity, true, true)) {
|
||||
return false;
|
||||
}
|
||||
p.getAudioManager().send(2880);
|
||||
p.animate(ANIMATION);
|
||||
p.graphics(GRAPHIC);
|
||||
p.getStateManager().remove(EntityState.POISONED);
|
||||
p.getAudioManager().send(2900);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
package core.game.node.entity.skill.magic.lunar;
|
||||
|
||||
import core.game.node.entity.skill.magic.MagicSpell;
|
||||
import core.game.node.entity.skill.magic.Runes;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.equipment.SpellType;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.audio.Audio;
|
||||
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
|
||||
import core.game.node.entity.state.EntityState;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* The cure other spell.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class CureOtherSpell extends MagicSpell {
|
||||
|
||||
/**
|
||||
* Represents the animation of this graphics.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(4411);
|
||||
|
||||
/**
|
||||
* Repesents the graphick, next spells of this spell.
|
||||
*/
|
||||
private static final Graphics GRAPHIC = new Graphics(738, 130);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code CureOtherSpell} {@code Object}.
|
||||
*/
|
||||
public CureOtherSpell() {
|
||||
super(SpellBook.LUNAR, 68, 65, ANIMATION, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 1), new Item(Runes.LAW_RUNE.getId(), 1), new Item(Runes.EARTH_RUNE.getId(), 10) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
|
||||
SpellBook.LUNAR.register(1, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(Entity entity, Node target) {
|
||||
Player p = (Player) entity;
|
||||
if (!(target instanceof Player)) {
|
||||
p.getPacketDispatch().sendMessage("You can only cast this spell on other players.");
|
||||
return false;
|
||||
}
|
||||
Player o = (Player) target;
|
||||
if (!o.isActive() || o.getLocks().isInteractionLocked()) {
|
||||
p.getPacketDispatch().sendMessage("This player is busy.");
|
||||
return false;
|
||||
}
|
||||
if (!o.getSettings().isAcceptAid()) {
|
||||
p.getPacketDispatch().sendMessage("The player is not accepting any aid.");
|
||||
return false;
|
||||
}
|
||||
if (!o.getStateManager().hasState(EntityState.POISONED)) {
|
||||
p.getPacketDispatch().sendMessage("This player is not poisoned.");
|
||||
return false;
|
||||
}
|
||||
if (!meetsRequirements(entity, true, true)) {
|
||||
return false;
|
||||
}
|
||||
p.face(o);
|
||||
p.getAudioManager().send(new Audio (2886), true);
|
||||
p.animate(ANIMATION);
|
||||
o.graphics(GRAPHIC);
|
||||
o.getAudioManager().send(new Audio(2889), true);
|
||||
o.getStateManager().remove(EntityState.POISONED);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue