Last active
January 24, 2020 16:01
-
-
Save titandino/5467b5b838abc931be548897fd1dadbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rs.game.player.content.world.regions.dungeons; | |
import com.rs.game.item.Item; | |
import com.rs.game.player.Equipment; | |
import com.rs.game.player.Player; | |
import com.rs.game.player.content.dialogue.Conversation; | |
import com.rs.game.player.content.dialogue.Dialogue; | |
import com.rs.game.player.content.dialogue.Options; | |
import com.rs.game.player.quests.Quest; | |
import com.rs.plugin.annotations.NPCClickHandler; | |
import com.rs.plugin.annotations.PluginEventHandler; | |
import com.rs.plugin.events.NPCClickEvent; | |
import com.rs.utils.Utils; | |
@PluginEventHandler | |
public class TzHaar { | |
public static final int TOKKUL = 6529; | |
public static final int TOKKUL_ZO_CHARGED = 23643; | |
public static final int TOKKUL_ZO_UNCHARGED = 23644; | |
@NPCClickHandler(ids = { 15166 }) | |
public static void handleTzhaarMejJeh(NPCClickEvent e) { | |
e.getPlayer().startConversation(new Conversation(e.getPlayer()) { | |
{ | |
addNPC(15166, HeadE.CONFUSED, "What do you need from me?"); | |
addOptions("What would you like to say?", new Options() { | |
@Override | |
public void create() { | |
boolean recTZ = player.getBool("recTokkulZo"); | |
if (!player.containsItems(TOKKUL_ZO_UNCHARGED, TOKKUL_ZO_CHARGED)) { | |
if (Quest.ELDER_KILN.meetsRequirements(player)) { | |
option("Can I have a Tokkul-Zo?" + (recTZ ? " I've lost mine." : ""), new Dialogue() | |
.addPlayer(HeadE.CONFUSED, "Can I have a Tokkul-Zo?" + (player.getBool("recTokkulZo") ? " I've lost mine." : "")) | |
.addNPC(15166, HeadE.CALM_TALK, "Alright, you have proven yourself. Try not to lose it." | |
+ (recTZ ? "" : "As this is your first time recieving the ring, I have fully charged it for you for free.")) | |
.addPlayer(HeadE.CHEERFUL, "Thank you!") | |
.addItem(TOKKUL_ZO_CHARGED, "TzHaar-Mej-Jeh hands you a ring. It is extremely hot.", p -> { | |
if (!player.getInventory().hasFreeSlots()) { | |
player.sendMessage("You don't have enough inventory space."); | |
return; | |
} | |
if (!recTZ) { | |
player.getInventory().addItem(new Item(TOKKUL_ZO_CHARGED).addMetaData("tzhaarCharges", 3000)); | |
player.save("recTokkulZo", true); | |
} else { | |
player.getInventory().addItem(TOKKUL_ZO_UNCHARGED); | |
} | |
})); | |
} else | |
player.sendMessage("You must meet the requirements for The Elder Kiln before obtaining a Tokkul-Zo."); | |
} | |
option("About the Tokkul-Zo", new Dialogue() | |
.addNPC(15166, HeadE.CONFUSED, "You want to know more about Tokkul-Zo?") | |
.addPlayer(HeadE.CONFUSED, "Yes, what does it do?") | |
.addNPC(15166, HeadE.CALM_TALK, "This ring has a piece of Tokkul in it. When worn, it will guide " | |
+ "your hand and make you better when fighting TzHaar, fire creatures, and maybe even TokHaar.") | |
.addPlayer(HeadE.CONFUSED, "How does it do that?") | |
.addNPC(15166, HeadE.CALM_TALK, "My magic taps into the memories in the ring, so you better at fighting like a TzHaar. " | |
+ "The magic will fade after time. When this happens, return to me and I will recharge it for you... for a price.") | |
.addPlayer(HeadE.CONFUSED, "What's your price?") | |
.addNPC(15166, HeadE.CALM_TALK, "48,000 Tokkul for a full recharge. Normally I would do it for free, but we need all the Tokkul we can " | |
+ "get, so they we can melt it down in the sacred lave, and release our ancestors from their suffering.")); | |
if (player.getInventory().containsItem(TOKKUL_ZO_UNCHARGED) || player.getInventory().containsItem(TOKKUL_ZO_UNCHARGED)) | |
option("Recharging the Tokkul-Zo", new Dialogue() | |
.addPlayer(HeadE.CONFUSED, "Could you please recharge my ring?") | |
.addNPC(15166, HeadE.CALM_TALK, player.getInventory().containsItem(TOKKUL, 16) ? "Of course. Here you go." : "You don't have enough Tokkul with you.", p -> { | |
rechargeTokkulZo(player); | |
})); | |
} | |
}); | |
} | |
}); | |
} | |
public static void rechargeTokkulZo(Player player) { | |
Item ring = player.getItemOnPlayer(TOKKUL_ZO_UNCHARGED); | |
if (ring != null) { | |
int chargesToAdd = Utils.clampI(player.getInventory().getAmountOf(TOKKUL)/16, 0, 3000); | |
if (chargesToAdd > 0) { | |
player.getInventory().deleteItem(TOKKUL, chargesToAdd * 16); | |
ring.setId(TOKKUL_ZO_CHARGED); | |
ring.addMetaData("tzhaarCharges", chargesToAdd); | |
player.getInventory().refresh(); | |
player.getEquipment().refresh(Equipment.RING); | |
player.sendMessage("TzHaar-Mej-Jeh adds " + chargesToAdd + " charges to your ring in exchange for " + Utils.formatNumber(chargesToAdd * 16) + " Tokkul."); | |
} | |
return; | |
} | |
ring = player.getItemOnPlayer(TOKKUL_ZO_UNCHARGED); | |
if (ring != null) { | |
int charges = ring.getMetaDataInt("tzhaarCharges", -1); | |
int chargesToAdd = Utils.clampI(player.getInventory().getAmountOf(TOKKUL)/16, 0, 3000-charges); | |
if (chargesToAdd > 0) { | |
player.getInventory().deleteItem(TOKKUL, chargesToAdd * 16); | |
ring.addMetaData("tzhaarCharges", chargesToAdd); | |
} | |
player.sendMessage("TzHaar-Mej-Jeh adds " + chargesToAdd + " charges to your ring in exchange for " + Utils.formatNumber(chargesToAdd * 16) + " Tokkul."); | |
} | |
} | |
public static boolean depleteTokkulZo(Player player) { | |
Item ring = player.getEquipment().get(Equipment.RING); | |
if (ring != null && ring.getId() == TzHaar.TOKKUL_ZO_CHARGED) { | |
int charges = ring.getMetaDataInt("tzhaarCharges", -1); | |
if (charges <= 1) { | |
ring.setId(TzHaar.TOKKUL_ZO_UNCHARGED); | |
player.getEquipment().refresh(Equipment.RING); | |
player.sendMessage("<col=FF0000>Your Tokkul-Zo has degraded and requires recharging."); | |
return false; | |
} | |
ring.addMetaData("tzhaarCharges", charges - 1); | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment