forked from 2009Scape/Server
Players can now freely swap between unlocked spellbooks with the magic interface sort buttons.
The "Level Order" button is the Modern spellbook, "Combat First" is Ancient, and "Teleports first" is Lunar. This makes the ability to swap spellbooks with the Mage's book obsolete, so that feature has been removed.
This commit is contained in:
parent
590e9fe44f
commit
b372d5e963
2 changed files with 38 additions and 91 deletions
|
|
@ -14,6 +14,9 @@ import core.game.node.entity.player.link.SpellBookManager.SpellBook;
|
|||
import core.game.world.GameWorld;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
import content.data.Quests;
|
||||
import static core.api.ContentAPIKt.hasRequirement;
|
||||
|
||||
/**
|
||||
* Represents the magic book interface handling of non-combat spells.
|
||||
* @author 'Vexia
|
||||
|
|
@ -42,9 +45,44 @@ public final class MagicBookInterface extends ComponentPlugin {
|
|||
? SpellBook.ANCIENT
|
||||
: SpellBook.LUNAR;
|
||||
|
||||
// Snowscape: Allow switching between unlocked spellbooks with the magic interface sort buttons
|
||||
if (spellBook == SpellBook.MODERN) {
|
||||
if (button == 65 && swapSpellBook(player, SpellBook.ANCIENT)) {
|
||||
return true;
|
||||
} else if (button == 66 && swapSpellBook(player, SpellBook.LUNAR)) {
|
||||
return true;
|
||||
}
|
||||
} else if (spellBook == SpellBook.ANCIENT) {
|
||||
if (button == 29 && swapSpellBook(player, SpellBook.MODERN)) {
|
||||
return true;
|
||||
} else if (button == 31 && swapSpellBook(player, SpellBook.LUNAR)) {
|
||||
return true;
|
||||
}
|
||||
} else if (spellBook == SpellBook.LUNAR) {
|
||||
if (button == 40 && swapSpellBook(player, SpellBook.MODERN)) {
|
||||
return true;
|
||||
} else if (button == 41 && swapSpellBook(player, SpellBook.ANCIENT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SpellListeners.run(button, SpellListener.NONE, SpellUtils.getBookFromInterface(component.getId()),player,null);
|
||||
boolean result = MagicSpell.castSpell(player, spellBook, button, player);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Snowscape custom function
|
||||
private boolean swapSpellBook(final Player player, SpellBook spellBook) {
|
||||
if (spellBook == SpellBook.ANCIENT && !hasRequirement(player, Quests.DESERT_TREASURE)) {
|
||||
return false;
|
||||
} else if (spellBook == SpellBook.LUNAR && !hasRequirement(player, Quests.LUNAR_DIPLOMACY)) {
|
||||
return false;
|
||||
}
|
||||
player.getSpellBookManager().setSpellBook(spellBook);
|
||||
player.getSpellBookManager().update(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
package content.global.handlers.item
|
||||
|
||||
import core.api.*
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.SpellBookManager.SpellBook
|
||||
//import core.game.node.item.Item
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.IntType
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.game.dialogue.*
|
||||
import core.tools.START_DIALOGUE
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Sounds
|
||||
import org.rs09.consts.Scenery
|
||||
import org.rs09.consts.Animations
|
||||
import content.data.Quests
|
||||
|
||||
//import core.game.component.Component
|
||||
|
||||
/**
|
||||
* Listener for the Mage's Book from Mage Training Arena. The other spellbooks can be inscribed into the book by using it on the respective altar.
|
||||
* Operate the book to switch to spellbooks that have been added.
|
||||
*
|
||||
*/
|
||||
class SnowscapeMagesBook : InteractionListener {
|
||||
|
||||
|
||||
override fun defineListeners() {
|
||||
on(Items.MAGES_BOOK_6889, IntType.ITEM, "operate") { player, node ->
|
||||
if (player.inCombat()) {
|
||||
player.sendMessage("You cannot concentrate on the book during combat.")
|
||||
} else {
|
||||
player.animate(Animation(6299))
|
||||
player.graphics(Graphics(1062))
|
||||
openDialogue(player, SnowscapeMagesBookDialogue())
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
|
||||
val altars = intArrayOf(Scenery.ALTAR_6552,Scenery.ALTAR_17010)
|
||||
|
||||
onUseWith(IntType.SCENERY, Items.MAGES_BOOK_6889, *altars) { player, used, with ->
|
||||
val ancient = (with.getId() == Scenery.ALTAR_6552)
|
||||
val quest = if (ancient) Quests.DESERT_TREASURE else Quests.LUNAR_DIPLOMACY
|
||||
val attribute = if (ancient) "/save:snowscape:magesbook:2" else "/save:snowscape:magesbook:3"
|
||||
|
||||
if (hasRequirement(player, quest)){
|
||||
setAttribute(player, attribute, true)
|
||||
sendDialogue(player, "You carefully focus on the magic in the altar, and inscribe it into the book.")
|
||||
playAudio(player, Sounds.LUNAR_STAT_SPY_3620)
|
||||
playAudio(player, Sounds.LUNAR_STAT_SPY_IMPACT_3621)
|
||||
animate(player, Animations.LUNAR_SPELLBOOK_STATSPY_6293)
|
||||
}
|
||||
return@onUseWith true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class SnowscapeMagesBookDialogue : DialogueFile() {
|
||||
|
||||
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
when (stage) {
|
||||
START_DIALOGUE -> options("Modern","Ancient","Lunar").also {stage++}
|
||||
|
||||
1 -> {
|
||||
end()
|
||||
if (player == null) return
|
||||
// This is ordered a little strange, but checking the quest comes first so that access to the spellbook is lost when the quest is released, until it's completed.
|
||||
if (buttonID == 2 && !hasRequirement(player!!, Quests.DESERT_TREASURE)) return
|
||||
if (buttonID == 3 && !hasRequirement(player!!, Quests.LUNAR_DIPLOMACY)) return
|
||||
if (buttonID > 1 && !getAttribute(player!!, "snowscape:magesbook:$buttonID", false)) {
|
||||
val altarDescription = if (buttonID == 2) "altar in the Pyramid" else "Astral altar"
|
||||
sendDialogue(player!!, "The book does not contain the knowledge of those spells. Use the book on the $altarDescription to inscribe it.")
|
||||
return
|
||||
}
|
||||
player!!.spellBookManager.setSpellBook(SpellBook.values()[buttonID - 1])
|
||||
player!!.spellBookManager.update(player!!)
|
||||
playAudio(player!!, Sounds.PRAYER_RECHARGE_2674)
|
||||
sendMessage(player!!, "You retrieve the inscribed knowledge and let it fill your mind.")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue