mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Rewrote MysteriousRuinPlugin to a listener
Fixed Varrock earth tiara easy diary task
This commit is contained in:
parent
18fa8357a8
commit
5a6a148cfc
4 changed files with 109 additions and 132 deletions
|
|
@ -1,12 +1,8 @@
|
|||
package content.global.skill.runecrafting;
|
||||
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.world.map.Location;
|
||||
|
||||
import static core.api.ContentAPIKt.hasRequirement;
|
||||
|
||||
/**
|
||||
* Represents a mysterious ruin.
|
||||
* @author 'Vexia
|
||||
|
|
@ -67,32 +63,6 @@ public enum MysteriousRuin {
|
|||
this.tiara = tiara;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters the ruin.
|
||||
* @param player the player.
|
||||
*/
|
||||
public void enter(Player player) {
|
||||
if (this == DEATH) {
|
||||
if (!hasRequirement(player, "Mourning's End Part II"))
|
||||
return;
|
||||
}
|
||||
if (this == BLOOD) {
|
||||
if (!hasRequirement(player, "Legacy of Seergaze"))
|
||||
return;
|
||||
}
|
||||
if (player.getEquipment().get(EquipmentContainer.SLOT_HAT) == null) {
|
||||
return;
|
||||
}
|
||||
if (getTiara() == null) {
|
||||
return;
|
||||
}
|
||||
if (getTiara().getTiara().getId() != player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId()) {
|
||||
return;
|
||||
}
|
||||
player.getProperties().setTeleportLocation(getEnd());
|
||||
player.getPacketDispatch().sendMessage("You feel a powerful force take hold of you...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object.
|
||||
* @return The object.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
package content.global.skill.runecrafting
|
||||
|
||||
import content.region.misthalin.varrock.diary.VarrockAchivementDiary.Companion.EasyTasks.ENTER_EARTH_ALTAR
|
||||
import core.api.*
|
||||
import core.game.container.impl.EquipmentContainer.SLOT_HAT
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.item.Item
|
||||
import core.game.requirement.QuestReq
|
||||
import core.game.requirement.QuestRequirements.*
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.Animation
|
||||
|
||||
class MysteriousRuinListener : InteractionListener {
|
||||
|
||||
private val animation = Animation(827)
|
||||
private val allowedUsed = arrayOf(1438, 1448, 1444, 1440, 1442, 5516, 1446, 1454, 1452, 1462, 1458, 1456, 1450, 1460).toIntArray()
|
||||
private val allowedWith = allRuins()
|
||||
private val nothingInteresting = "Nothing interesting happens"
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.SCENERY, allowedUsed, *allowedWith) { player, used, with ->
|
||||
return@onUseWith handleTalisman(player, used, with)
|
||||
}
|
||||
on(allowedWith, IntType.SCENERY, "enter") { player, node ->
|
||||
return@on handleTiara(player, node)
|
||||
}
|
||||
}
|
||||
|
||||
private fun allRuins(): IntArray {
|
||||
return MysteriousRuin
|
||||
.values()
|
||||
.flatMap { ruins -> ruins.`object`.asList() }
|
||||
.toIntArray()
|
||||
}
|
||||
|
||||
private fun handleTalisman(player: Player, used: Node, with: Node): Boolean {
|
||||
val ruin = MysteriousRuin.forObject(with.asScenery())
|
||||
if (!checkQuestCompletion(player, ruin)) {
|
||||
return true
|
||||
}
|
||||
|
||||
val talisman = Talisman.forItem(used.asItem())
|
||||
if (talisman != ruin.talisman && talisman != Talisman.ELEMENTAL) {
|
||||
sendMessage(player, nothingInteresting)
|
||||
return false
|
||||
}
|
||||
if (talisman == Talisman.ELEMENTAL && (ruin.talisman != Talisman.AIR && ruin.talisman != Talisman.WATER && ruin.talisman != Talisman.FIRE && ruin.talisman != Talisman.EARTH)) {
|
||||
sendMessage(player, nothingInteresting)
|
||||
return false
|
||||
}
|
||||
|
||||
teleportToRuinTalisman(player, used.asItem(), ruin)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun handleTiara(player: Player, node: Node): Boolean {
|
||||
val ruin = MysteriousRuin.forObject(node.asScenery())
|
||||
|
||||
if (!checkQuestCompletion(player, ruin)) {
|
||||
return true
|
||||
}
|
||||
|
||||
val tiara = Tiara.forItem(player.equipment.get(SLOT_HAT))
|
||||
if (tiara == null || tiara != ruin.tiara) {
|
||||
sendMessage(player, nothingInteresting)
|
||||
return false
|
||||
}
|
||||
|
||||
submitTeleportPulse(player, ruin, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun checkQuestCompletion(player: Player, ruin: MysteriousRuin): Boolean {
|
||||
return when (ruin) {
|
||||
MysteriousRuin.DEATH -> hasRequirement(player, QuestReq(MEP_2), true)
|
||||
MysteriousRuin.BLOOD -> hasRequirement(player, QuestReq(SEERGAZE), true)
|
||||
else -> hasRequirement(player, QuestReq(RUNE_MYSTERIES), true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun teleportToRuinTalisman(player: Player, talisman: Item, ruin: MysteriousRuin) {
|
||||
lock(player, 4)
|
||||
animate(player, animation)
|
||||
sendMessage(player, "You hold the ${talisman.name} towards the mysterious ruins.")
|
||||
submitTeleportPulse(player, ruin, 3)
|
||||
}
|
||||
|
||||
private fun submitTeleportPulse(player: Player, ruin: MysteriousRuin, delay: Int) {
|
||||
sendMessage(player, "You feel a powerful force take hold of you.")
|
||||
submitWorldPulse(object : Pulse(delay, player) {
|
||||
override fun pulse(): Boolean {
|
||||
teleport(player, ruin.end)
|
||||
if (ruin == MysteriousRuin.EARTH) {
|
||||
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, ENTER_EARTH_ALTAR)
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package content.global.skill.runecrafting;
|
||||
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.info.Rights;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Handles the entering into a mysterious ruin.
|
||||
* @author Vexia
|
||||
*/
|
||||
public final class MysteriousRuinPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the animation used.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(827);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code RunecraftingOptionPlugin} {@code Object}.
|
||||
*/
|
||||
public MysteriousRuinPlugin() {
|
||||
super(1438, 1448, 1444, 1440, 1442, 5516, 1446, 1454, 1452, 1462, 1458, 1456, 1450, 1460);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (MysteriousRuin ruin : MysteriousRuin.values()) {
|
||||
for (int i : ruin.getObject()) {
|
||||
addHandler(i, OBJECT_TYPE, this);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (!player.getQuestRepository().isComplete("Rune Mysteries") && player.getDetails().getRights() != Rights.ADMINISTRATOR) {
|
||||
player.getPacketDispatch().sendMessage("You need to finish the Rune Mysteries Quest in order to do this.");
|
||||
return true;
|
||||
}
|
||||
final Talisman talisman = Talisman.forItem(event.getUsedItem());
|
||||
final MysteriousRuin ruin = MysteriousRuin.forObject(((Scenery) event.getUsedWith()));
|
||||
if (talisman != ruin.getTalisman() && talisman != Talisman.ELEMENTAL) {
|
||||
return false;
|
||||
}
|
||||
if (talisman == Talisman.ELEMENTAL && (ruin.getTalisman() != Talisman.AIR && ruin.getTalisman() != Talisman.WATER && ruin.getTalisman() != Talisman.FIRE && ruin.getTalisman() != Talisman.EARTH)) {
|
||||
return false;
|
||||
}
|
||||
teleport(player, event, ruin);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the player to the ruin location.
|
||||
* @param player the player.
|
||||
* @param event the event.
|
||||
* @param ruin the ruin.
|
||||
*/
|
||||
private void teleport(final Player player, final NodeUsageEvent event, final MysteriousRuin ruin) {
|
||||
player.lock(4);
|
||||
player.animate(ANIMATION);
|
||||
player.getPacketDispatch().sendMessage("You hold the " + event.getUsedItem().getName() + " towards the mysterious ruins.");
|
||||
player.getPacketDispatch().sendMessage("You feel a powerful force take hold of you.");
|
||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
player.getProperties().setTeleportLocation(ruin.getEnd());
|
||||
// Enter the Earth Altar using an earth tiara or talisman
|
||||
if (ruin == MysteriousRuin.EARTH) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 0, 13);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package content.global.skill.runecrafting;
|
||||
|
||||
import content.global.travel.EssenceTeleport;
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.cache.def.impl.NPCDefinition;
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
|
|
@ -13,15 +14,14 @@ import core.game.node.entity.player.info.Rights;
|
|||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.map.Location;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.MinimapStateContext;
|
||||
import core.net.packet.out.MinimapState;
|
||||
import core.plugin.ClassScanner;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import content.global.travel.EssenceTeleport;
|
||||
import core.game.world.GameWorld;
|
||||
import core.plugin.ClassScanner;
|
||||
|
||||
import static core.api.ContentAPIKt.hasRequirement;
|
||||
|
||||
|
|
@ -38,7 +38,6 @@ public class RunecraftingPlugin extends OptionHandler {
|
|||
ClassScanner.definePlugin(new TiaraPlugin());
|
||||
ClassScanner.definePlugin(new RunePouchPlugin());
|
||||
ClassScanner.definePlugin(new EnchantTiaraPlugin());
|
||||
ClassScanner.definePlugin(new MysteriousRuinPlugin());
|
||||
ClassScanner.definePlugin(new CombinationRunePlugin());
|
||||
SceneryDefinition.forId(2492).getHandlers().put("option:use", this);
|
||||
NPCDefinition.forId(553).getHandlers().put("option:teleport", this);
|
||||
|
|
@ -107,15 +106,8 @@ public class RunecraftingPlugin extends OptionHandler {
|
|||
final Talisman talisman = Talisman.forItem(((Item) node));
|
||||
talisman.locate(player);
|
||||
break;
|
||||
case "enter":
|
||||
final MysteriousRuin ruin = MysteriousRuin.forObject(((Scenery) node));
|
||||
if (ruin == null) {
|
||||
return true;
|
||||
}
|
||||
ruin.enter(player);
|
||||
break;
|
||||
case "climb":
|
||||
int id = ((Scenery) node).getId();
|
||||
int id = (node).getId();
|
||||
switch (id) {
|
||||
case 26849:
|
||||
ClimbActionHandler.climb(player, null, new Location(3271, 4861, 0));
|
||||
|
|
@ -137,11 +129,6 @@ public class RunecraftingPlugin extends OptionHandler {
|
|||
SceneryDefinition.forId(altar.getObject()).getHandlers().put("option:craft-rune", this);
|
||||
SceneryDefinition.forId(altar.getPortal()).getHandlers().put("option:use", this);
|
||||
}
|
||||
for (MysteriousRuin ruin : MysteriousRuin.values()) {
|
||||
for (int i : ruin.getObject()) {
|
||||
SceneryDefinition.forId(i).getHandlers().put("option:enter", this);
|
||||
}
|
||||
}
|
||||
for (Talisman talisman : Talisman.values()) {
|
||||
ItemDefinition.forId(talisman.getTalisman().getId()).getHandlers().put("option:locate", this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue