Rewrote (un)holy symbol blessing handling
This commit is contained in:
@@ -8,6 +8,9 @@ import org.rs09.consts.Items
|
|||||||
import core.game.dialogue.DialogueFile
|
import core.game.dialogue.DialogueFile
|
||||||
import core.game.interaction.InteractionListener
|
import core.game.interaction.InteractionListener
|
||||||
import core.game.interaction.IntType
|
import core.game.interaction.IntType
|
||||||
|
import core.game.node.Node
|
||||||
|
import core.game.node.entity.skill.Skills
|
||||||
|
import core.game.node.item.Item
|
||||||
|
|
||||||
class GodBookListeners : InteractionListener {
|
class GodBookListeners : InteractionListener {
|
||||||
|
|
||||||
@@ -20,16 +23,42 @@ class GodBookListeners : InteractionListener {
|
|||||||
openDialogue(player, HOLY_DIALOGUE(BOOK.SARA))
|
openDialogue(player, HOLY_DIALOGUE(BOOK.SARA))
|
||||||
return@on true
|
return@on true
|
||||||
}
|
}
|
||||||
|
|
||||||
on(GB_ZAMORAK, IntType.ITEM, "preach"){ player, _ ->
|
on(GB_ZAMORAK, IntType.ITEM, "preach"){ player, _ ->
|
||||||
openDialogue(player, HOLY_DIALOGUE(BOOK.ZAM))
|
openDialogue(player, HOLY_DIALOGUE(BOOK.ZAM))
|
||||||
return@on true
|
return@on true
|
||||||
}
|
}
|
||||||
|
|
||||||
on(GB_GUTHIX, IntType.ITEM, "preach"){ player, _ ->
|
on(GB_GUTHIX, IntType.ITEM, "preach"){ player, _ ->
|
||||||
openDialogue(player, HOLY_DIALOGUE(BOOK.GUTHIX))
|
openDialogue(player, HOLY_DIALOGUE(BOOK.GUTHIX))
|
||||||
return@on true
|
return@on true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun bless(player: Player, node: Node, product: Int) {
|
||||||
|
if (player.skills.getStaticLevel(Skills.PRAYER) < 50) {
|
||||||
|
sendMessage(player, "You need a Prayer level of at least 50 in order to do this.")
|
||||||
|
} else if (player.skills.prayerPoints < 4) {
|
||||||
|
sendMessage(player, "You need at least 4 prayer points in order to do this.")
|
||||||
|
} else {
|
||||||
|
sendMessage(player, "You bless the ${node.asItem().name.lowercase()}.")
|
||||||
|
player.skills.decrementPrayerPoints(4.0)
|
||||||
|
replaceSlot(player, node.asItem().slot, Item(product), node.asItem())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onUseWith(IntType.ITEM, GB_SARADOMIN, Items.UNBLESSED_SYMBOL_1716) { player, _, symbol ->
|
||||||
|
bless(player, symbol, Items.HOLY_SYMBOL_1718)
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
onUseWith(IntType.ITEM, GB_ZAMORAK, Items.UNPOWERED_SYMBOL_1722) { player, _, symbol ->
|
||||||
|
bless(player, symbol, Items.UNHOLY_SYMBOL_1724)
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
onUseWith(IntType.ITEM, GB_GUTHIX, Items.UNBLESSED_SYMBOL_1716) { player, _, symbol ->
|
||||||
|
bless(player, symbol, Items.HOLY_SYMBOL_1718)
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
onUseWith(IntType.ITEM, GB_GUTHIX, Items.UNPOWERED_SYMBOL_1722) { player, _, symbol ->
|
||||||
|
bless(player, symbol, Items.UNHOLY_SYMBOL_1724)
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum class BOOK {
|
internal enum class BOOK {
|
||||||
@@ -129,6 +158,5 @@ class GodBookListeners : InteractionListener {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ public class GodBookPlugin extends OptionHandler {
|
|||||||
for (GodBook book : GodBook.values()) {
|
for (GodBook book : GodBook.values()) {
|
||||||
book.getDamagedBook().getDefinition().getHandlers().put("option:check", this);
|
book.getDamagedBook().getDefinition().getHandlers().put("option:check", this);
|
||||||
}
|
}
|
||||||
ClassScanner.definePlugins(new PageHandler(), new GodBookItem(), new SymbolBlessHandler());
|
ClassScanner.definePlugins(new PageHandler(), new GodBookItem());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,77 +51,6 @@ public class GodBookPlugin extends OptionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the blessing of a symbol with a god book.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public class SymbolBlessHandler extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code SymbolBlessHandler} {@code Object}
|
|
||||||
*/
|
|
||||||
public SymbolBlessHandler() {
|
|
||||||
super(1716);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
for (GodBook book : GodBook.values()) {
|
|
||||||
addHandler(book.getBook().getId(), ITEM_TYPE, this);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
GodBook book = GodBook.forItem(event.getUsedItem(), false);
|
|
||||||
if (book == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Item symbol = event.getUsedWith().asItem();
|
|
||||||
if (player.getSkills().getLevel(Skills.PRAYER) < 50) {
|
|
||||||
player.sendMessage("You need a Prayer level of at least 50 in order to do this.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (player.getSkills().getPrayerPoints() < 4) {
|
|
||||||
player.sendMessage("You need at least 4 prayer points in order to do this.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (book == GodBook.BOOK_OF_BALANCE) {
|
|
||||||
player.getDialogueInterpreter().sendOptions("Select an Option", "Unholy symbol", "Holy symbol");
|
|
||||||
player.getDialogueInterpreter().addAction(new DialogueAction() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(Player player, int buttonId) {
|
|
||||||
bless(player, symbol, buttonId == 1 ? GodBook.UNHOLY_BOOK : GodBook.HOLY_BOOK);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bless(player, symbol, book);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blesses a symbol.
|
|
||||||
* @param player the player.
|
|
||||||
* @param book the book.
|
|
||||||
*/
|
|
||||||
private void bless(Player player, Item symbol, GodBook book) {
|
|
||||||
if (!player.getInventory().containsItem(symbol)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (player.getInventory().get(symbol.getSlot()) == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.getInventory().replace(book.getBlessItem()[0], symbol.getSlot());
|
|
||||||
player.getSkills().decrementPrayerPoints(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A god book item.
|
* A god book item.
|
||||||
* @author Vexia
|
* @author Vexia
|
||||||
|
|||||||
Reference in New Issue
Block a user