From 5af39b5b217f411b81195d775e05a98f1f1e5591 Mon Sep 17 00:00:00 2001 From: bushtail Date: Sat, 1 Oct 2022 05:51:09 +0000 Subject: [PATCH] Lunar spell Fertile Soil translated to Kotlin --- .../skill/magic/lunar/FertileSoilSpell.java | 76 ----------------- .../game/node/entity/skill/farming/Patch.kt | 4 + .../game/node/entity/skill/magic/LunarData.kt | 19 +++-- .../node/entity/skill/magic/LunarListeners.kt | 83 ++++++++++++++----- .../entity/skill/magic/spellconsts/Lunar.kt | 17 ++++ 5 files changed, 93 insertions(+), 106 deletions(-) delete mode 100644 Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java diff --git a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java deleted file mode 100644 index 6b6edf91d..000000000 --- a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java +++ /dev/null @@ -1,76 +0,0 @@ -package core.game.node.entity.skill.magic.lunar; - -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.skill.magic.MagicSpell; -import core.game.node.entity.skill.magic.Runes; -import core.game.node.item.Item; -import core.game.node.scenery.Scenery; -import core.game.world.update.flag.context.Animation; -import core.game.world.update.flag.context.Graphics; -import core.plugin.Initializable; -import core.plugin.Plugin; -import rs09.game.node.entity.skill.farming.CompostType; -import rs09.game.node.entity.skill.farming.FarmingPatch; -import rs09.game.node.entity.skill.farming.Patch; - -/** - * Represents the fertile soil spell plugin. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class FertileSoilSpell extends MagicSpell { - - /** - * Represents the graphic to use. - */ - private static final Graphics GRAPHIC = new Graphics(141, 96); - - /** - * Represents the animaton to use. - */ - private static final Animation ANIMATION = new Animation(724); - - /** - * Constructs a new {@code FertileSoilSpell} {@code Object}. - */ - public FertileSoilSpell() { - super(SpellBook.LUNAR, 83, 87, null, null, null, new Item[] { new Item(Runes.NATURE_RUNE.getId(), 2), new Item(Runes.ASTRAL_RUNE.getId(), 3), new Item(Runes.EARTH_RUNE.getId(), 15) }); - } - - @Override - public Plugin newInstance(SpellType arg) throws Throwable { - SpellBook.LUNAR.register(2, this); - return this; - } - - @Override - public boolean cast(Entity entity, Node target) { - final Player player = ((Player) entity); - final Scenery object = (Scenery) target; - final FarmingPatch fPatch = FarmingPatch.forObject(object); - if(fPatch == null){ - player.sendMessage("Um... I don't want to fertilize that!"); - return false; - } - final Patch patch = fPatch.getPatchFor(player); - if(patch.getCompost() != CompostType.NONE){ - player.sendMessage("This patch has already been composted."); - return false; - } - if (!super.meetsRequirements(player, true, true)) { - return false; - } - patch.setCompost(CompostType.SUPER); - player.sendMessage("You fertilize the soil."); - player.graphics(GRAPHIC); - player.animate(ANIMATION); - player.getAudioManager().send(2891, 1, 1); - return true; - } -} diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt index bf75ccd7c..dfa79ead6 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt @@ -96,6 +96,10 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl updateBit() } + fun isFertilized(): Boolean { + return compost != CompostType.NONE + } + fun isGrown(): Boolean{ return currentGrowthStage == (plantable?.stages ?: 0) } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarData.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarData.kt index 646ff6537..b85af4fa5 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarData.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarData.kt @@ -4,22 +4,27 @@ import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics import org.rs09.consts.Items +// Animations val BAKE_PIE_ANIM = Animation(4413) -val BAKE_PIE_GFX = Graphics(746,75) val STATSPY_ANIM = Animation(6293) -val STATSPY_GFX = Graphics(1059) val CURE_PLANT_ANIM = Animation(4409) -val CURE_PLANT_GFX = Graphics(742,100) val NPC_CONTACT_ANIM = Animation(4413) -val NPC_CONTACT_GFX = Graphics(730,130) val PLANK_MAKE_ANIM = Animation(6298) -val PLANK_MAKE_GFX = Graphics(1063, 120) val STRING_JEWELLERY_ANIM = Animation(4412) -val STRING_JEWELLERY_GFX = Graphics(728, 100) val SUPERGLASS_MAKE_ANIM = Animation(4413) -val SUPERGLASS_MAKE_GFX = Graphics(729, 120) +val FERTILE_SOIL_ANIM = Animation(724) +// Graphics +val BAKE_PIE_GFX = Graphics(746,75) +val STATSPY_GFX = Graphics(1059) +val CURE_PLANT_GFX = Graphics(742,100) +val NPC_CONTACT_GFX = Graphics(730,130) +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) + enum class JewelleryString(val unstrung: Int, val strung: Int) { GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692), SAPPHIRE(Items.SAPPHIRE_AMULET_1675, Items.SAPPHIRE_AMULET_1694), diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarListeners.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarListeners.kt index 388fd148a..e2749ac7a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarListeners.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/LunarListeners.kt @@ -13,11 +13,11 @@ import core.game.node.item.Item import core.game.system.task.Pulse import core.game.world.map.Location import core.game.world.map.RegionManager -import core.game.world.update.flag.context.Animation -import core.game.world.update.flag.context.Graphics import core.tools.RandomFunction import org.rs09.consts.Components import org.rs09.consts.Items +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.config.NPCConfigParser @@ -26,24 +26,24 @@ class LunarListeners : SpellListener("lunar") { override fun defineListeners() { - onCast(Lunar.HOME_TELEPORT, NONE){player, _ -> + onCast(Lunar.HOME_TELEPORT, NONE) { player, _ -> requires(player) sendTeleport(player,0.0, Location.create(2100, 3914, 0)) } - onCast(Lunar.MOONCLAN_TELEPORT, NONE){player, _ -> + onCast(Lunar.MOONCLAN_TELEPORT, NONE) { player, _ -> requires(player,69, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,2))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,66.0, Location.create(2111, 3916, 0)) } - onCast(Lunar.MOONCLAN_GR_TELEPORT, NONE){player, _ -> + onCast(Lunar.MOONCLAN_GR_TELEPORT, NONE) { player, _ -> requires(player,70, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,4))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,67.0,"Moonclan Island",Location.create(2111, 3916, 0)) } - onCast(Lunar.OURANIA_TELEPORT, NONE){player,_ -> + onCast(Lunar.OURANIA_TELEPORT, NONE) { player, _ -> requires(player,71, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,6))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,69.0, Location.create(2469, 3247, 0)) @@ -55,88 +55,88 @@ class LunarListeners : SpellListener("lunar") { sendTeleport(player,71.0, Location.create(2527, 3739, 0)) } - onCast(Lunar.WATERBIRTH_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.WATERBIRTH_GR_TELEPORT, NONE) { player, _ -> requires(player,73, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563), Item(Items.WATER_RUNE_555,5))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,72.0,"Waterbirth Island", Location.create(2527, 3739, 0)) } - onCast(Lunar.BARBARIAN_TELEPORT, NONE){player,_ -> + onCast(Lunar.BARBARIAN_TELEPORT, NONE) { player, _ -> requires(player,75, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.FIRE_RUNE_554,3))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,76.0, Location.create(2544, 3572, 0)) } - onCast(Lunar.BARBARIAN_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.BARBARIAN_GR_TELEPORT, NONE) { player, _ -> requires(player,77, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.FIRE_RUNE_554,6))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,77.0,"Barbarian Outpost", Location.create(2544, 3572, 0)) } - onCast(Lunar.KHAZARD_TELEPORT, NONE){player,_ -> + onCast(Lunar.KHAZARD_TELEPORT, NONE) { player, _ -> requires(player,78, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.WATER_RUNE_555,4))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,80.0, Location.create(2656, 3157, 0)) } - onCast(Lunar.KHAZARD_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.KHAZARD_GR_TELEPORT, NONE) { player, _ -> requires(player,79, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.WATER_RUNE_555,8))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,81.0, "Port Khazard", Location.create(2656, 3157, 0)) } - onCast(Lunar.FISHING_GUILD_TELEPORT, NONE){player,_ -> + onCast(Lunar.FISHING_GUILD_TELEPORT, NONE) { player, _ -> requires(player,85, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,10))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,89.0, Location.create(2611, 3393, 0)) } - onCast(Lunar.FISHING_GUILD_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.FISHING_GUILD_GR_TELEPORT, NONE) { player, _ -> requires(player,86, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,14))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,90.0,"Fishing Guild", Location.create(2611, 3393, 0)) } - onCast(Lunar.CATHERBY_TELEPORT, NONE){player,_ -> + onCast(Lunar.CATHERBY_TELEPORT, NONE) { player, _ -> requires(player,87, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,10))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,92.0, Location.create(2804, 3433, 0)) } - onCast(Lunar.CATHERBY_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.CATHERBY_GR_TELEPORT, NONE) { player, _ -> requires(player,88, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,15))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,93.0,"Catherby", Location.create(2804, 3433, 0)) } - onCast(Lunar.ICE_PLATEAU_TELEPORT, NONE){player,_ -> + onCast(Lunar.ICE_PLATEAU_TELEPORT, NONE) { player, _ -> requires(player,89, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,8))) player.getAudioManager().send(Audio(200), true) sendTeleport(player,96.0, Location.create(2972, 3873, 0)) } - onCast(Lunar.ICE_PLATEAU_GR_TELEPORT, NONE){player,_ -> + onCast(Lunar.ICE_PLATEAU_GR_TELEPORT, NONE) { player, _ -> requires(player,90, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,16))) player.getAudioManager().send(Audio(200), true) sendGroupTeleport(player,99.0, "Ice Plateau", Location.create(2972, 3873, 0)) } - onCast(Lunar.BAKE_PIE, NONE){player,_ -> + onCast(Lunar.BAKE_PIE, NONE) { player, _ -> requires(player,65, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.FIRE_RUNE_554,5), Item(Items.WATER_RUNE_555,4))) bakePie(player) } - onCast(Lunar.MONSTER_EXAMINE, NPC){player,node -> + onCast(Lunar.MONSTER_EXAMINE, NPC) { player, node -> requires(player,66, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.MIND_RUNE_558), Item(Items.COSMIC_RUNE_564))) examineMonster(player,node!!.asNpc()) } - onCast(Lunar.CURE_PLANT, OBJECT){player,node -> + onCast(Lunar.CURE_PLANT, OBJECT) { player, node -> requires(player,66, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.EARTH_RUNE_557,8))) curePlant(player,node!!.asScenery()) } - onCast(Lunar.NPC_CONTACT, NONE){ player, _ -> + onCast(Lunar.NPC_CONTACT, NONE) { player, _ -> requires(player,67, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.COSMIC_RUNE_564), Item(Items.AIR_RUNE_556,2))) player.interfaceManager.open(Component(429)) player.setAttribute("contact-caller"){ @@ -157,10 +157,14 @@ class LunarListeners : SpellListener("lunar") { stringJewellery(player) } - onCast(Lunar.SUPERGLASS_MAKE, NONE) {player, _ -> + onCast(Lunar.SUPERGLASS_MAKE, NONE) { player, _ -> requires(player, 77, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.FIRE_RUNE_554, 6), Item(Items.AIR_RUNE_556, 10))) superglassMake(player) } + + onCast(Lunar.FERTILE_SOIL, OBJECT) { player, node -> + fertileSoil(player, node!!.asScenery()) + } } private fun plankMake(player: Player, item: Item) { @@ -393,4 +397,37 @@ class LunarListeners : SpellListener("lunar") { addXP(player, 78.0) } } -} \ No newline at end of file + + private fun fertileSoil(player: Player, target: Scenery) { + if (CompostBins.forObjectID(target.id) != null) { + sendMessage(player, "No, that would be silly.") + return + } + + val fPatch = FarmingPatch.forObject(target) + if(fPatch == null) { + sendMessage(player, "Um... I don't want to fertilize that!") + return + } + + val patch = fPatch.getPatchFor(player) + if (patch.isGrown()) { + sendMessage(player, "Composting isn't going to make it get any bigger.") + return + } + if (patch.isFertilized()) { + sendMessage(player, "This patch has already been composted.") + return + } + requires(player, 83, arrayOf(Item(Items.ASTRAL_RUNE_9075, 3), Item(Items.NATURE_RUNE_561, 2), Item(Items.EARTH_RUNE_557, 15))) + removeRunes(player, true) + visualizeSpell(player, FERTILE_SOIL_ANIM, FERTILE_SOIL_GFX, 2891) + patch.compost = CompostType.SUPER + sendMessage(player, "You fertilize the soil.") + addXP(player, 87.0) + } +} + + + + diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/spellconsts/Lunar.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/spellconsts/Lunar.kt index a8d23b761..d9100596d 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/spellconsts/Lunar.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/magic/spellconsts/Lunar.kt @@ -2,19 +2,36 @@ package rs09.game.node.entity.skill.magic.spellconsts object Lunar { const val BARBARIAN_TELEPORT = 0 + const val CURE_OTHER = 1 + const val FERTILE_SOIL = 2 + const val CURE_GROUP = 3 const val NPC_CONTACT = 4 + const val ENERGY_TRANSFER = 5 const val MONSTER_EXAMINE = 6 + const val HUMIDIFY = 7 + const val HUNTER_KIT = 8 + const val STAT_SPY = 9 + const val DREAM = 10 const val PLANK_MAKE = 11 + const val SPELLBOOK_SWAP = 12 + const val MAGIC_IMBUE = 13 + const val VENGEANCE = 14 const val BAKE_PIE = 15 const val HOME_TELEPORT = 16 const val FISHING_GUILD_TELEPORT = 17 const val KHAZARD_TELEPORT = 18 + const val VENGEANCE_OTHER = 19 const val MOONCLAN_TELEPORT = 20 const val CATHERBY_TELEPORT = 21 const val STRING_JEWELLERY = 22 + const val CURE_ME = 23 const val WATERBIRTH_TELEPORT = 24 const val SUPERGLASS_MAKE = 25 + const val BOOST_POTION_SHARE = 26 + const val STAT_RESTORE_POT_SHARE = 27 const val ICE_PLATEAU_TELEPORT = 28 + const val HEAL_OTHER = 29 + const val HEAL_GROUP = 30 const val OURANIA_TELEPORT = 31 const val CURE_PLANT = 32 const val MOONCLAN_GR_TELEPORT = 33