rewrote plank make lunar spell, now authentic and has sound effects
This commit is contained in:
@@ -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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <b>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.</b>
|
|
||||||
* @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<SpellType> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package rs09.game.node.entity.skill.magic
|
package rs09.game.node.entity.skill.magic
|
||||||
|
|
||||||
|
import api.*
|
||||||
import core.game.component.Component
|
import core.game.component.Component
|
||||||
|
import core.game.node.Node
|
||||||
import core.game.node.scenery.Scenery
|
import core.game.node.scenery.Scenery
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
@@ -20,14 +22,16 @@ import rs09.game.node.entity.skill.magic.spellconsts.Lunar
|
|||||||
import rs09.game.system.config.NPCConfigParser
|
import rs09.game.system.config.NPCConfigParser
|
||||||
|
|
||||||
class LunarListeners : SpellListener("lunar") {
|
class LunarListeners : SpellListener("lunar") {
|
||||||
val BAKE_PIE_ANIM = Animation(4413)
|
private val BAKE_PIE_ANIM = Animation(4413)
|
||||||
val BAKE_PIE_GFX = Graphics(746,75)
|
private val BAKE_PIE_GFX = Graphics(746,75)
|
||||||
val STATSPY_ANIM = Animation(6293)
|
private val STATSPY_ANIM = Animation(6293)
|
||||||
val STATSPY_GFX = Graphics(1059)
|
private val STATSPY_GFX = Graphics(1059)
|
||||||
val CURE_PLANT_ANIM = Animation(4409)
|
private val CURE_PLANT_ANIM = Animation(4409)
|
||||||
val CURE_PLANT_GFX = Graphics(742,100)
|
private val CURE_PLANT_GFX = Graphics(742,100)
|
||||||
val NPC_CONTACT_ANIM = Animation(4413)
|
private val NPC_CONTACT_ANIM = Animation(4413)
|
||||||
val NPC_CONTACT_GFX = Graphics(730,130)
|
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() {
|
override fun defineListeners() {
|
||||||
|
|
||||||
@@ -126,7 +130,7 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
curePlant(player,node!!.asScenery())
|
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)))
|
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.interfaceManager.open(Component(429))
|
||||||
player.setAttribute("contact-caller"){
|
player.setAttribute("contact-caller"){
|
||||||
@@ -136,6 +140,48 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
visualizeSpell(player,NPC_CONTACT_ANIM,NPC_CONTACT_GFX)
|
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){
|
fun curePlant(player: Player, obj: Scenery){
|
||||||
@@ -166,7 +212,7 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
setDelay(player,false)
|
setDelay(player,false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun examineMonster(player: Player, npc: NPC){
|
private fun examineMonster(player: Player, npc: NPC){
|
||||||
if(!npc.location.withinDistance(player.location)){
|
if(!npc.location.withinDistance(player.location)){
|
||||||
player.sendMessage("You must get closer to use this spell.")
|
player.sendMessage("You must get closer to use this spell.")
|
||||||
return
|
return
|
||||||
@@ -191,7 +237,7 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
player.packetDispatch.sendString(poisonStatus,Components.DREAM_MONSTER_STAT_522,4)
|
player.packetDispatch.sendString(poisonStatus,Components.DREAM_MONSTER_STAT_522,4)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bakePie(player: Player){
|
private fun bakePie(player: Player){
|
||||||
val playerPies = ArrayList<Item>()
|
val playerPies = ArrayList<Item>()
|
||||||
|
|
||||||
for(item in player.inventory.toArray()){
|
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){
|
if(player.locks.isTeleportLocked){
|
||||||
player.sendMessage("A magical force prevents you from teleporting.")
|
player.sendMessage("A magical force prevents you from teleporting.")
|
||||||
return
|
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 {
|
RegionManager.getLocalPlayers(player,1).forEach {
|
||||||
if(it == player) return@forEach
|
if(it == player) return@forEach
|
||||||
if(it.locks.isTeleportLocked) return@forEach
|
if(it.locks.isTeleportLocked) return@forEach
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ object Lunar {
|
|||||||
const val BARBARIAN_TELEPORT = 0
|
const val BARBARIAN_TELEPORT = 0
|
||||||
const val NPC_CONTACT = 4
|
const val NPC_CONTACT = 4
|
||||||
const val MONSTER_EXAMINE = 6
|
const val MONSTER_EXAMINE = 6
|
||||||
|
const val PLANK_MAKE = 11
|
||||||
const val BAKE_PIE = 15
|
const val BAKE_PIE = 15
|
||||||
const val HOME_TELEPORT = 16
|
const val HOME_TELEPORT = 16
|
||||||
const val FISHING_GUILD_TELEPORT = 17
|
const val FISHING_GUILD_TELEPORT = 17
|
||||||
|
|||||||
Reference in New Issue
Block a user