From e7eec8153d7a4fb088fabe6c2366201df5b08e27 Mon Sep 17 00:00:00 2001
From: Ryan <2804894-ryannathans@users.noreply.gitlab.com>
Date: Sat, 29 Jan 2022 20:42:24 +0000
Subject: [PATCH] rewrote plank make lunar spell, now authentic and has sound
effects
---
.../skill/magic/lunar/PlankMeSpell.java | 185 ------------------
.../node/entity/skill/magic/LunarListeners.kt | 110 ++++++++---
.../entity/skill/magic/spellconsts/Lunar.kt | 1 +
3 files changed, 79 insertions(+), 217 deletions(-)
delete mode 100644 Server/src/main/java/core/game/node/entity/skill/magic/lunar/PlankMeSpell.java
diff --git a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/PlankMeSpell.java b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/PlankMeSpell.java
deleted file mode 100644
index 78587dec3..000000000
--- a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/PlankMeSpell.java
+++ /dev/null
@@ -1,185 +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.SpellBookManager.SpellBook;
-import core.game.node.item.Item;
-import rs09.game.world.repository.Repository;
-import core.game.world.update.flag.context.Animation;
-import core.game.world.update.flag.context.Graphics;
-import core.plugin.Plugin;
-
-/**
- * Turns one log into a plank, without need of the sawmill. Coins are still
- * required to convert a log into a plank, but the amount is decreased.
- * @author 'Vexia
- */
-@Initializable
-public class PlankMeSpell extends MagicSpell {
-
- /**
- * The graphic.
- */
- private static final Graphics GRAPHIC = new Graphics(1063, 120);
-
- /**
- * The animation.
- */
- private static final Animation ANIMATION = new Animation(6298);
-
- /**
- * Constructs a new {@code StatRestoreSpell} {@code Object}.
- */
- public PlankMeSpell() {
- super(SpellBook.LUNAR, 86, 90, null, null, null, new Item[] { new Item(Runes.NATURE_RUNE.getId(), 1), new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 15) });
- }
-
- @Override
- public Plugin newInstance(SpellType arg) throws Throwable {
- SpellBook.LUNAR.register(11, this);
- return this;
- }
-
- @Override
- public boolean cast(Entity entity, Node target) {
- final Player player = ((Player) entity);
- final Plank plank = Plank.forLog(((Item) target));
- player.getInterfaceManager().setViewedTab(6);
- final Item item = ((Item) target);
- if (plank == null) {
- player.getPacketDispatch().sendMessage("You need to use this spell on logs.");
- return false;
- }
- if (!player.getInventory().contains(995, plank.getPrice())) {
- player.getPacketDispatch().sendMessage("You need " + plank.getPrice() + " coins to convert that log into a plank.");
- return false;
- }
- player.lock(4);
- create(player, plank, player.getInventory().getAmount(item));
- return true;
- }
-
- /**
- * Method used to create a plank from a log.
- * @param player the player.
- * @param plank the plank.
- * @param amount the amount.
- */
- public final void create(final Player player, final Plank plank, int amount) {
- player.getInterfaceManager().close();
- if (amount > player.getInventory().getAmount(plank.getLog())) {
- amount = player.getInventory().getAmount(plank.getLog());
- }
- if (!player.getInventory().containsItem(plank.getLog())) {
- player.getDialogueInterpreter().sendDialogues(Repository.findNPC(4250), null, "You'll need to bring me some more logs.");
- return;
- }
- int newAmt = 1;
- for (int i = 1; i <= amount; i++) {
- if (player.getInventory().contains(995, plank.getPrice() * amount)) {
- newAmt = i;
- continue;
- }
- }
- amount = newAmt;
- if (!player.getInventory().contains(995, plank.getPrice() * amount)) {
- player.getDialogueInterpreter().sendDialogues(player, null, "Sorry, I don't have enough coins to pay for that.");
- return;
- }
- if (!player.getInventory().contains(plank.getLog().getId(), amount)) {
- return;
- }
- Item coins = new Item(995, plank.getPrice() * amount);
- if (!player.getInventory().containsItem(coins)) {
- return;
- }
- if (super.meetsRequirements(player, true, true)) {
- player.graphics(GRAPHIC);
- player.animate(ANIMATION);
- if (player.getInventory().remove(coins)) {
- Item remove = plank.getLog();
- remove.setAmount(amount);
- if (player.getInventory().remove(remove)) {
- Item planks = plank.getPlank();
- planks.setAmount(amount);
- player.getInventory().add(planks);
- }
- }
- }
- }
-
- /**
- * Represents an enum of planks to be boughten.
- * @author 'Vexia
- * @date Oct 8, 2013
- */
- public enum Plank {
- WOOD(new Item(1511), new Item(960), 70), OAK(new Item(1521), new Item(8778), 175), TEAK(new Item(6333), new Item(8780), 350), MAHOGANY(new Item(6332), new Item(8782), 1050);
- /**
- * Constructs a new {@code SawmillPlankInterface} {@code Object}.
- * @param log the log.
- * @param plank the plank.
- * @param price the price.
- */
- Plank(Item log, Item plank, int price) {
- this.log = log;
- this.plank = plank;
- this.price = price;
- }
-
- /**
- * Represents the item needed.
- */
- private final Item log;
-
- /**
- * Represents the item given.
- */
- private final Item plank;
-
- /**
- * Represents the price of the plank.
- */
- private final int price;
-
- /**
- * Gets the plank.
- * @param item the item.
- * @return the plank.
- */
- public static Plank forLog(final Item item) {
- for (Plank p : Plank.values()) {
- if (p.getLog().getId() == item.getId()) {
- return p;
- }
- }
- return null;
- }
-
- /**
- * @return the log.
- */
- public Item getLog() {
- return log;
- }
-
- /**
- * @return the plank.
- */
- public Item getPlank() {
- return plank;
- }
-
- /**
- * @return the price.
- */
- public int getPrice() {
- return price;
- }
- }
-}
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 5c42bb50d..5b99115a8 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
@@ -1,6 +1,8 @@
package rs09.game.node.entity.skill.magic
+import api.*
import core.game.component.Component
+import core.game.node.Node
import core.game.node.scenery.Scenery
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
@@ -20,113 +22,115 @@ import rs09.game.node.entity.skill.magic.spellconsts.Lunar
import rs09.game.system.config.NPCConfigParser
class LunarListeners : SpellListener("lunar") {
- 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)
+ private val BAKE_PIE_ANIM = Animation(4413)
+ private val BAKE_PIE_GFX = Graphics(746,75)
+ private val STATSPY_ANIM = Animation(6293)
+ private val STATSPY_GFX = Graphics(1059)
+ private val CURE_PLANT_ANIM = Animation(4409)
+ private val CURE_PLANT_GFX = Graphics(742,100)
+ private val NPC_CONTACT_ANIM = Animation(4413)
+ private val NPC_CONTACT_GFX = Graphics(730,130)
+ private val PLANK_MAKE_ANIM = Animation(6298)
+ private val PLANK_MAKE_GFX = Graphics(1063, 120)
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)))
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)))
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)))
sendTeleport(player,69.0, Location.create(2469, 3247, 0))
}
- onCast(Lunar.WATERBIRTH_TELEPORT,NONE){player, _ ->
+ onCast(Lunar.WATERBIRTH_TELEPORT, NONE){player, _ ->
requires(player,72, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563), Item(Items.WATER_RUNE_555)))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
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,node ->
+ 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"){
@@ -136,6 +140,48 @@ class LunarListeners : SpellListener("lunar") {
visualizeSpell(player,NPC_CONTACT_ANIM,NPC_CONTACT_GFX)
}
}
+
+ onCast(Lunar.PLANK_MAKE, ITEM) { player, node ->
+ requires(player, 86, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.NATURE_RUNE_561, 1), Item(Items.EARTH_RUNE_557, 15)))
+ plankMake(player, node!!.asItem())
+ }
+ }
+
+ private fun plankMake(player: Player, item: Item) {
+
+ val plankType = PlankType.getForLog(item)
+ if (plankType == null) {
+ sendMessage(player, "You need to use this spell on logs.")
+ return
+ }
+ if (!removeItem(player, Item(Items.COINS_995, plankType.price))) {
+ sendMessage(player, "You need ${plankType.price} coins to convert that log into a plank.")
+ return
+ }
+ lock(player, 3)
+ setDelay(player, false)
+ visualizeSpell(player, PLANK_MAKE_ANIM, PLANK_MAKE_GFX, 3617)
+ removeRunes(player)
+ replaceSlot(player, item.slot, plankType.plank)
+ addXP(player, 90.0)
+ showMagicTab(player)
+ }
+
+ enum class PlankType (val log: Item, val plank: Item, val price: Int) {
+ WOOD(Item(1511), Item(960), 70),
+ OAK(Item(1521), Item(8778), 175),
+ TEAK(Item(6333), Item(8780), 350),
+ MAHOGANY(Item(6332), Item(8782), 1050);
+ companion object {
+ fun getForLog(item: Item): PlankType? {
+ for (plankType in values()) {
+ if (plankType.log.id == item.id) {
+ return plankType
+ }
+ }
+ return null
+ }
+ }
}
fun curePlant(player: Player, obj: Scenery){
@@ -166,7 +212,7 @@ class LunarListeners : SpellListener("lunar") {
setDelay(player,false)
}
- fun examineMonster(player: Player, npc: NPC){
+ private fun examineMonster(player: Player, npc: NPC){
if(!npc.location.withinDistance(player.location)){
player.sendMessage("You must get closer to use this spell.")
return
@@ -191,7 +237,7 @@ class LunarListeners : SpellListener("lunar") {
player.packetDispatch.sendString(poisonStatus,Components.DREAM_MONSTER_STAT_522,4)
}
- fun bakePie(player: Player){
+ private fun bakePie(player: Player){
val playerPies = ArrayList- ()
for(item in player.inventory.toArray()){
@@ -227,7 +273,7 @@ class LunarListeners : SpellListener("lunar") {
})
}
- fun sendTeleport(player: Player, xp: Double, loc: Location){
+ private fun sendTeleport(player: Player, xp: Double, loc: Location){
if(player.locks.isTeleportLocked){
player.sendMessage("A magical force prevents you from teleporting.")
return
@@ -239,7 +285,7 @@ class LunarListeners : SpellListener("lunar") {
}
}
- fun sendGroupTeleport(player: Player,xp: Double,destName: String,loc: Location){
+ private fun sendGroupTeleport(player: Player, xp: Double, destName: String, loc: Location){
RegionManager.getLocalPlayers(player,1).forEach {
if(it == player) return@forEach
if(it.locks.isTeleportLocked) return@forEach
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 37a8d13cc..04a1f8ecb 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
@@ -4,6 +4,7 @@ object Lunar {
const val BARBARIAN_TELEPORT = 0
const val NPC_CONTACT = 4
const val MONSTER_EXAMINE = 6
+ const val PLANK_MAKE = 11
const val BAKE_PIE = 15
const val HOME_TELEPORT = 16
const val FISHING_GUILD_TELEPORT = 17