Rewrote String Jewellery lunar spell
This commit is contained in:
-166
@@ -1,166 +0,0 @@
|
|||||||
package core.game.node.entity.skill.magic.lunar;
|
|
||||||
|
|
||||||
import core.game.node.entity.skill.SkillPulse;
|
|
||||||
import core.game.node.entity.skill.Skills;
|
|
||||||
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.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the jewllery stringing spell.
|
|
||||||
* @author 'Vexia
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public final class StringJewellerySpell extends MagicSpell {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the animation of this spell.
|
|
||||||
*/
|
|
||||||
private static final Animation ANIMATION = Animation.create(4412);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the graphic of this spell.
|
|
||||||
*/
|
|
||||||
private static final Graphics GRAPHIC = new Graphics(728, 100);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the array of unstrung jewellery.
|
|
||||||
*/
|
|
||||||
private static final int[] UNSTRUNG = { 1673, 1675, 1677, 1679, 1681, 1683, 1714 };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an array of strung jewellery.
|
|
||||||
*/
|
|
||||||
private static final int[] STRUNG = { 1692, 1694, 1696, 1698, 1700, 1702, 1718 };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code CureOtherSpell} {@code Object}.
|
|
||||||
*/
|
|
||||||
public StringJewellerySpell() {
|
|
||||||
super(SpellBook.LUNAR, 80, 87, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 10), new Item(Runes.WATER_RUNE.getId(), 5) });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
|
|
||||||
SpellBook.LUNAR.register(22, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean cast(Entity entity, Node target) {
|
|
||||||
final Player p = (Player) entity;
|
|
||||||
boolean contains = false;
|
|
||||||
Item item = null;
|
|
||||||
for (int i : UNSTRUNG) {
|
|
||||||
if (p.getInventory().contains(i, 1)) {
|
|
||||||
contains = true;
|
|
||||||
item = new Item(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!contains) {
|
|
||||||
p.getPacketDispatch().sendMessage("You need jewellery in order to use this spell.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!meetsRequirements(entity, true, false)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
p.getPulseManager().run(new LunarStringPulse(p, item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the skill pulse used to string a jewellery.
|
|
||||||
* @author 'Vexia
|
|
||||||
*/
|
|
||||||
public class LunarStringPulse extends SkillPulse<Item> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code LunarStringPulse} {@code Object}.
|
|
||||||
* @param player the player.
|
|
||||||
* @param node the node.
|
|
||||||
*/
|
|
||||||
public LunarStringPulse(final Player player, final Item node) {
|
|
||||||
super(player, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkRequirements() {
|
|
||||||
if (!player.getInventory().containsItem(node)) {
|
|
||||||
stop();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void animate() {
|
|
||||||
player.animate(ANIMATION);
|
|
||||||
player.graphics(GRAPHIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean reward() {
|
|
||||||
if (getDelay() == 1) {
|
|
||||||
setDelay(2);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (meetsRequirements(player, true, true) && player.getInventory().remove(node)) {
|
|
||||||
player.getAudioManager().send(2903, 1, 1);
|
|
||||||
player.getInventory().add(new Item(STRUNG[getIndex()]));
|
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, 4, true);
|
|
||||||
player.getSkills().addExperience(Skills.MAGIC, 83, true);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return nextItem() == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() {
|
|
||||||
super.stop();
|
|
||||||
player.graphics(new Graphics(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void message(int type) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used to get index.
|
|
||||||
* @return the index.
|
|
||||||
*/
|
|
||||||
public int getIndex() {
|
|
||||||
for (int i = 0; i < UNSTRUNG.length; i++) {
|
|
||||||
if (node.getId() == UNSTRUNG[i]) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used to get the next string.
|
|
||||||
* @return the string.
|
|
||||||
*/
|
|
||||||
public Item nextItem() {
|
|
||||||
for (int i : UNSTRUNG) {
|
|
||||||
if (player.getInventory().contains(i, 1)) {
|
|
||||||
node = new Item(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ package rs09.game.node.entity.skill.magic
|
|||||||
|
|
||||||
import api.*
|
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
|
||||||
@@ -19,8 +18,10 @@ import core.game.world.update.flag.context.Graphics
|
|||||||
import org.rs09.consts.Components
|
import org.rs09.consts.Components
|
||||||
import org.rs09.consts.Items
|
import org.rs09.consts.Items
|
||||||
import rs09.game.node.entity.skill.farming.FarmingPatch
|
import rs09.game.node.entity.skill.farming.FarmingPatch
|
||||||
|
import rs09.game.node.entity.skill.magic.LunarListeners.JewelleryString.Companion.productOfString
|
||||||
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
|
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
|
||||||
import rs09.game.system.config.NPCConfigParser
|
import rs09.game.system.config.NPCConfigParser
|
||||||
|
import java.util.Deque
|
||||||
|
|
||||||
class LunarListeners : SpellListener("lunar") {
|
class LunarListeners : SpellListener("lunar") {
|
||||||
private val BAKE_PIE_ANIM = Animation(4413)
|
private val BAKE_PIE_ANIM = Animation(4413)
|
||||||
@@ -33,6 +34,8 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
private 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_ANIM = Animation(6298)
|
||||||
private val PLANK_MAKE_GFX = Graphics(1063, 120)
|
private val PLANK_MAKE_GFX = Graphics(1063, 120)
|
||||||
|
private val STRING_JEWELLERY_ANIM = Animation(4412)
|
||||||
|
private val STRING_JEWELLERY_GFX = Graphics(728, 100)
|
||||||
|
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
|
|
||||||
@@ -161,6 +164,10 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
requires(player, 86, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.NATURE_RUNE_561, 1), Item(Items.EARTH_RUNE_557, 15)))
|
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())
|
plankMake(player, node!!.asItem())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCast(Lunar.STRING_JEWELLERY, NONE) { player, _ ->
|
||||||
|
stringJewellery(player)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun plankMake(player: Player, item: Item) {
|
private fun plankMake(player: Player, item: Item) {
|
||||||
@@ -263,7 +270,7 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
for(item in player.inventory.toArray()){
|
for(item in player.inventory.toArray()){
|
||||||
if(item == null) continue
|
if(item == null) continue
|
||||||
val pie = CookableItems.forId(item.id) ?: continue
|
val pie = CookableItems.forId(item.id) ?: continue
|
||||||
if(!pie.name.toLowerCase().contains("pie")) continue
|
if(!pie.name.lowercase().contains("pie")) continue
|
||||||
if(player.skills.getLevel(Skills.COOKING) < pie.level) continue
|
if(player.skills.getLevel(Skills.COOKING) < pie.level) continue
|
||||||
playerPies.add(item)
|
playerPies.add(item)
|
||||||
}
|
}
|
||||||
@@ -319,4 +326,61 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
}
|
}
|
||||||
sendTeleport(player,xp,loc)
|
sendTeleport(player,xp,loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun stringJewellery(player: Player) {
|
||||||
|
val playerJewellery = ArrayDeque<Item>()
|
||||||
|
|
||||||
|
for(item in player.inventory.toArray()) {
|
||||||
|
if(item == null) continue
|
||||||
|
if(!JewelleryString.unstrungContains(item.id)) continue
|
||||||
|
playerJewellery.add(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
player.pulseManager.run(object : Pulse() {
|
||||||
|
var counter = 0
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
removeAttribute(player, "spell:runes")
|
||||||
|
requires(player, 80, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.EARTH_RUNE_557, 10), Item(Items.WATER_RUNE_555, 5)))
|
||||||
|
if(counter == 0) delay = animationDuration(STRING_JEWELLERY_ANIM) + 1
|
||||||
|
val item = playerJewellery[0]
|
||||||
|
val strung = JewelleryString.forId(item.id)
|
||||||
|
setDelay(player,false)
|
||||||
|
if(removeItem(player, item) && addItem(player, strung)) {
|
||||||
|
removeRunes(player, true)
|
||||||
|
visualizeSpell(player, STRING_JEWELLERY_ANIM, STRING_JEWELLERY_GFX, 2903)
|
||||||
|
rewardXP(player, Skills.CRAFTING, 4.0)
|
||||||
|
addXP(player, 83.0)
|
||||||
|
playerJewellery.remove(item)
|
||||||
|
}
|
||||||
|
counter++
|
||||||
|
return playerJewellery.isEmpty()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private 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),
|
||||||
|
EMERALD(Items.EMERALD_AMULET_1677, Items.EMERALD_AMULET_1696),
|
||||||
|
RUBY(Items.RUBY_AMULET_1679, Items.RUBY_AMULET_1698),
|
||||||
|
DIAMOND(Items.DIAMOND_AMULET_1681, Items.DIAMOND_AMULET_1700),
|
||||||
|
DRAGONSTONE(Items.DRAGONSTONE_AMMY_1683, Items.DRAGONSTONE_AMMY_1702),
|
||||||
|
ONYX(Items.ONYX_AMULET_6579, Items.ONYX_AMULET_6581),
|
||||||
|
SALVE(Items.SALVE_SHARD_4082, Items.SALVE_AMULET_4081),
|
||||||
|
HOLY(Items.UNSTRUNG_SYMBOL_1714, Items.UNBLESSED_SYMBOL_1716),
|
||||||
|
UNHOLY(Items.UNSTRUNG_EMBLEM_1720, Items.UNPOWERED_SYMBOL_1722);
|
||||||
|
companion object {
|
||||||
|
val productOfString = values().associate { it.unstrung to it.strung }
|
||||||
|
fun forId(id : Int) : Int {
|
||||||
|
return productOfString[id]!!
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unstrungContains(id : Int) : Boolean {
|
||||||
|
return productOfString.contains(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ abstract class SpellListener(val bookName: String) : Listener {
|
|||||||
SpellListeners.add(spellID,type,ids,bookName,method)
|
SpellListeners.add(spellID,type,ids,bookName,method)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requires(player: Player, magicLevel: Int = 0, runes: Array<Item> = arrayOf<Item>(), specialEquipment: IntArray = intArrayOf()){
|
fun requires(player: Player, magicLevel: Int = 0, runes: Array<Item> = arrayOf<Item>(), specialEquipment: IntArray = intArrayOf()) {
|
||||||
if(player.getAttribute("magic-delay",0) > GameWorld.ticks){
|
if(player.getAttribute("magic-delay",0) > GameWorld.ticks){
|
||||||
throw IllegalStateException()
|
throw IllegalStateException()
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ abstract class SpellListener(val bookName: String) : Listener {
|
|||||||
}
|
}
|
||||||
for(rune in runes){
|
for(rune in runes){
|
||||||
if(!SpellUtils.hasRune(player,rune)){
|
if(!SpellUtils.hasRune(player,rune)){
|
||||||
player.sendMessage("You don't have enough ${rune.definition.name.toLowerCase()}s to cast this spell.")
|
player.sendMessage("You don't have enough ${rune.definition.name.lowercase()}s to cast this spell.")
|
||||||
throw IllegalStateException()
|
throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ object Lunar {
|
|||||||
const val KHAZARD_TELEPORT = 18
|
const val KHAZARD_TELEPORT = 18
|
||||||
const val MOONCLAN_TELEPORT = 20
|
const val MOONCLAN_TELEPORT = 20
|
||||||
const val CATHERBY_TELEPORT = 21
|
const val CATHERBY_TELEPORT = 21
|
||||||
|
const val STRING_JEWELLERY = 22
|
||||||
const val WATERBIRTH_TELEPORT = 24
|
const val WATERBIRTH_TELEPORT = 24
|
||||||
const val ICE_PLATEAU_TELEPORT = 28
|
const val ICE_PLATEAU_TELEPORT = 28
|
||||||
const val OURANIA_TELEPORT = 31
|
const val OURANIA_TELEPORT = 31
|
||||||
|
|||||||
Reference in New Issue
Block a user