Rewrote lumbridge guide dialogue

This commit is contained in:
Ceikry
2022-12-22 06:45:38 +00:00
committed by Ryan
parent 4848d465e3
commit 94b94cb5a3
5 changed files with 140 additions and 296 deletions
@@ -149,7 +149,9 @@ public final class DialogueInterpreter {
DialogueFile file = dialogue.file;
if (!activeTopics.isEmpty()) {
Topic<?> topic = activeTopics.get(buttonId - 2);
sendDialogues(player, topic.getExpr(), topic.getText());
if (!topic.getSkipPlayer())
sendDialogues(player, topic.getExpr(), topic.getText());
if(topic.getToStage() instanceof DialogueFile) {
DialogueFile topicFile = (DialogueFile) topic.getToStage();
@@ -160,6 +162,10 @@ public final class DialogueInterpreter {
else file.setStage(stage);
}
activeTopics.clear();
if (topic.getSkipPlayer())
handle(componentId, buttonId);
return;
}
@@ -1,289 +0,0 @@
package core.game.content.dialogue;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.info.Rights;
import core.game.node.entity.player.link.IronmanMode;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.world.map.zone.impl.ModeratorZone;
import core.net.amsc.MSPacketRepository;
import core.plugin.Initializable;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.List;
/**
* Represents the lumbridge guide dialogue plugin.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class LumbridgeGuideDialogue extends DialoguePlugin {
/**
* The list of options.
*/
private List<String> options;
/**
* Constructs a new {@code LumbridgeGuideDialogue} {@code Object}.
*/
public LumbridgeGuideDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code LumbridgeGuideDialogue} {@code Object}.
* @param player the player.
*/
public LumbridgeGuideDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new LumbridgeGuideDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
npc("Greetings, adventurer. I am Phileas, the Lumbridge", "Guide. I am here to give information and directions to", "new players. Do you require any help?");
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 0:
if (!player.isStaff() && !player.getIronmanManager().isIronman()) {
options("Where can I find a quest to go on?", "What monsters should I fight?", "Where can I make money?", "I'd like to know more about security.", "Where can I find a bank?");
stage = 103;
return true;
}
options = new ArrayList<>(5);
options.add("Yes please.");
if (player.getRights() == Rights.PLAYER_MODERATOR && ModeratorZone.isOpen() || player.isAdmin()) {
options.add("I would like to access the P-Mod room.");
}
if (player.getIronmanManager().isIronman() && player.getIronmanManager().getMode() != IronmanMode.HARDCORE) {
options.add("Would you like to remove Ironman Mode?");
}
options(options.toArray(new String[] {}));
stage = 900;
break;
case 900:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, null, "Yes please.");
stage = 102;
break;
case 2:
if (options.get(1).contains("remove")) {
options("Yes, please.", "No.");
stage = 804;
break;
}
if (options.get(1).contains("room")) {
stage = 690;
npc("Yes, of course.");
} else {
stage = 901;
npc("Yes, of course.");
}
break;
case 3:
if (options.get(2).contains("remove")) {
options("Yes, please.", "No.");
stage = 804;
break;
}
stage = 901;
npc("Yes, of course.");
break;
}
break;
case 804:
if (buttonId == 1) {
player("Yes, please.");
stage = 806;
} else {
player("No.");
stage = 805;
}
break;
case 805:
end();
break;
case 806:
npc("You are no longer an Ironman.");
stage++;
break;
case 807:
player.getIronmanManager().setMode(IronmanMode.NONE);
end();
break;
case 10:
options("Tell me about the town of Lumbridge.", "I'm fine for now, thanks.");
stage = 11;
break;
case 1:
case 11:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, null, "Yes please.");
stage = 100;
break;
case 2:
interpreter.sendDialogues(player, null, "No, I can find things myself thank you.");
stage = 200;
break;
}
break;
case 200:
end();
break;
case 100:
npc("First I must warn you to take every precaution to", "keep your " + GameWorld.getSettings().getName() + " password and PIN secure. The", "most important thing to remember is to never give your", "password to, or share you account with, anyone.");
stage = 101;
break;
case 101:
npc("I have much more information to impart; what would", "you like to know about?");
stage = 102;
break;
case 102:
options("Where can I find a quest to go on?", "What monsters should I fight?", "Where can I make money?", "I'd like to know more about security.", "Where can I find a bank?");
stage = 103;
break;
case 103:
switch (buttonId) {
case 1:
player("Where can I find a quest to go on?");
stage = 1100;
break;
case 2:
player("What monsters should I fight?");
stage = 1200;
break;
case 3:
player("Where can I make money?");
stage = 1300;
break;
case 4:
player("I'd like to know more about security.");
stage = 1400;
break;
case 5:
player("Where can I find a bank?");
stage = 1500;
break;
}
break;
case 1400:
npc("I can tell you about password security, avoiding item", "scamming and in-game moderation. I can also tell you", "about a place called the Stronghold of Security, where", "you can learn more about account security and have a");
stage = 1401;
break;
case 1401:
npc("bit of an adventure at the same time.");
stage = 1402;
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 17);
break;
case 1402:
end();
break;
case 1300:
npc("There are many ways to make money in the game. I", "would suggest either killing monsters or doing a trade", "skill such as Smithing or Fishing.");
stage = 1301;
break;
case 1301:
npc("Please don't try to get money by begging off other", "players. It will make you unpopular. Nobody likes a", "beggar. It is very irritating to have other players asking", "for your hard-earned cash.");
stage = 1302;
break;
case 1302:
end();
break;
case 1200:
npc("You're strong enough to work out what monsters to", "fight for yourself now, but the combat tutors might help", "you with any questions you have about the skills;", "they're just over there to the south of the general store.");
stage = 1201;
break;
case 1201:
npc("There are things to kill all over the place! At your level,", "you might like to try wandering westwards to the", "Wizards' Tower or north-west to the Barbarian Village.", "Non-player characters usually appear as yellow dots on");
stage = 1202;
break;
case 1202:
npc("your mini-map, although there are some that you won't", "be able to fight, such as myself. If you explore further", "afield you may be able to find areas that are less", "crowded, but watch out for monsters which are tougher");
stage = 1203;
break;
case 1203:
npc("than you. A monster's combat level is shown next to", "their 'Attack' option. If that level is coloured green it", "means the monster is weaker than you. If it is red, it", "means that the monster is tougher than you.");
stage = 1204;
break;
case 1204:
npc("Remember, you wil do better if you have better", "armour and weapons and it's always worth carrying a", "bit of food to heal yourself.");
stage = 1205;
break;
case 1205:
end();
break;
case 1500:
npc("You'll find a bank upstairs in Lumbridge Castle - go", "right to the top.");
stage = 1501;
break;
case 1501:
end();
break;
case 1100:
stage = 1101;
if (!player.getQuestRepository().isComplete("Cook's Assistant")) {
npc("You can try talking to the Cook in the Lumbridge Castle", "I hear he is always looking for some help.");
return true;
}
if (!player.getQuestRepository().isComplete("Sheep Shearer")) {
npc("You can try talking to Fred the Farmer north-west of here", "I hear he is always looking for some help.");
return true;
}
interpreter.sendDialogues(npc, null, "You are such an accomplished adventurer already; you", "should be telling me some good quests to go on.");
break;
case 1101:
end();
break;
case 104:
end();
break;
case 680:
switch (buttonId) {
case 1:
interpreter.sendDialogues(player, null, "Yes please.");
stage = 100;
break;
case 2:
stage = 690;
npc("Yes, of course.");
break;
case 3:
interpreter.sendDialogues(player, null, "No, I can find things myself thank you.");
stage = 200;
break;
}
break;
case 690:
end();
if (ModeratorZone.isOpen() && player.getDetails().getRights() == Rights.PLAYER_MODERATOR) {
ModeratorZone.teleport(player);
} else if (player.getDetails().getRights() == Rights.ADMINISTRATOR) {
ModeratorZone.teleport(player);
}
break;
}
return true;
}
@Override
public int[] getIds() {
return new int[] { 2244 };
}
}
@@ -59,10 +59,10 @@ public final class CuratorHaigHalenDialogue extends DialoguePlugin {
showTopics(
new IfTopic("I have the Shield of Arrav", new CuratorHaigHalenSOADialogue(),
player.getQuestRepository().getQuest("Shield of Arrav").getStage(player) == 70
),
, false),
new IfTopic("I'm looking for a statuette recovered from the city of Uzer.", new CuratorHaigHalenGolemDialogue(),
player.getQuestRepository().getQuest("The Golem").getStage(player) >= 3
)
, false)
);
break;
}
@@ -6,9 +6,9 @@ import core.game.content.dialogue.FacialExpression
* Topic/IfTopic system backported from my personal project
* @author Ceikry
*/
open class Topic<T>(val expr: FacialExpression, val text: String, val toStage: T) {
constructor(text: String, toStage: T) : this(FacialExpression.ASKING, text, toStage)
open class Topic<T>(val expr: FacialExpression, val text: String, val toStage: T, val skipPlayer: Boolean = false) {
constructor(text: String, toStage: T, skipPlayer: Boolean = false) : this(FacialExpression.ASKING, text, toStage, skipPlayer)
}
class IfTopic<T>(expr: FacialExpression, text: String, toStage: T, val showCondition: Boolean) : Topic<T>(expr, text, toStage) {
constructor(text: String, toStage: T, showCondition: Boolean) : this(FacialExpression.ASKING, text, toStage, showCondition)
class IfTopic<T>(expr: FacialExpression, text: String, toStage: T, val showCondition: Boolean, skipPlayer: Boolean = false) : Topic<T>(expr, text, toStage, skipPlayer) {
constructor(text: String, toStage: T, showCondition: Boolean, skipPlayer: Boolean = false) : this(FacialExpression.ASKING, text, toStage, showCondition, skipPlayer)
}
@@ -0,0 +1,127 @@
package rs09.game.content.dialogue.region.lumbridge
import api.isQuestComplete
import api.sendGraphics
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.IronmanMode
import core.game.node.entity.player.link.diary.DiaryType
import core.game.world.map.zone.impl.ModeratorZone
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.IfTopic
import rs09.game.content.dialogue.Topic
import rs09.tools.END_DIALOGUE
@Initializable
class LumbridgeGuideDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return LumbridgeGuideDialogue(player)
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
val staff = player.isStaff
val ironman = player.ironmanManager.isIronman
val sheepShearerComplete = isQuestComplete(player, "Sheep Shearer")
val cooksAssistantComplete = isQuestComplete(player, "Cook's Assistant")
when (stage) {
0 -> npcl(FacialExpression.FRIENDLY, "Greetings, adventurer. I am Phileas, the Lumbridge Guide. I am here to give information and directions to new players. Do you require any help?").also { stage++ }
1 -> showTopics(
Topic("Where can I find a quest to go on?", 10),
Topic("What monsters should I fight?", 20),
Topic("Where can I make money?", 30),
Topic("I'd like to know more about security.", 40),
IfTopic("Where can I find a bank?", 50, !staff && !ironman),
IfTopic("More Options...", 100, staff || ironman, skipPlayer = true),
)
//More Options...
100 -> showTopics(
Topic("Where can I find a bank?", 50),
IfTopic("I would like to access the P-Mod room.", 200, staff),
IfTopic("I would like to de-iron.", 300, ironman),
Topic("Go back...", 1, skipPlayer = true)
)
//Where can I find a quest?
10 -> {
if (!cooksAssistantComplete)
npcl(FacialExpression.HALF_THINKING, "You can try talking to the Cook in the Lumbridge Castle. I hear he is always looking for some help.")
else if (!sheepShearerComplete)
npcl(FacialExpression.HALF_THINKING, "You can try talking to Fred the Farmer north-west of here. I hear he is always looking for some help.")
else
npcl(FacialExpression.FRIENDLY, "You are such an accomplished adventurer already; you should be telling me some good quests to go on.")
stage = END_DIALOGUE
}
//What monsters should I fight?
20 -> if (player.properties.currentCombatLevel >= 30) {
npcl(FacialExpression.FRIENDLY, "You're strong enough to work out what monsters to fight for yourself now, but the tutors might help you with any questions you have about the skills; they're just south of the general store.")
stage = END_DIALOGUE
} else {
npcl(FacialExpression.FRIENDLY, "There are things to kill all over the place! At your level, you might like to try wandering westwards to the Wizards' Tower or north-west to the Barbarian Village.")
stage++
}
21 -> npcl(FacialExpression.FRIENDLY, "Non-player characters usually appear as yellow dots on your mini-map, although there are some that you won't be able to fight, such as myself. Watch out for monsters which are tougher").also { stage++ }
22 -> npcl(FacialExpression.FRIENDLY, "than you. A monster's combat level is shown next to their 'Attack' option. If that level is coloured green it means the monster is weaker than you. If it is red, it means the monster is tougher than you.").also { stage++ }
23 -> npcl(FacialExpression.FRIENDLY, "Remember, you will do better if you have better armour and weapons and it's always worth carrying a bit of food to heal yourself.").also { stage = 1 }
//Where can I make money?
30 -> npcl(FacialExpression.FRIENDLY, "There are many ways to make money in the game. I would suggest either killing monsters or doing a trade skill such as Smithing or Fishing.").also { stage++ }
31 -> npcl(FacialExpression.FRIENDLY, "Please don't try to get money by begging off other players. It will make you unpopular. Nobody likes a beggar. It is very irritating to have other players asking for your hard-earned cash.").also { stage = 1 }
//I'd like to know more about security
40 -> npcl(FacialExpression.FRIENDLY, "I can tell you about password security, avoiding item scamming and in-game moderation. I can also tell you about a place called the Stronghold of Security, where you can learn more about account security and have a").also { stage++ }
41 -> {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 17)
npcl(FacialExpression.FRIENDLY, "bit of an adventure at the same time. In fact, why don't you just head there instead? It's a lot more fun, I promise. You can find it down the hole in the middle of Barbarian Village to the north-west.")
stage = 1
}
//Where can I find a bank?
50 -> npcl(FacialExpression.FRIENDLY, "You'll find a bank upstairs in Lumbridge Castle - go right to the top!").also { stage = 1 }
//visit pmod room
200 -> npcl(FacialExpression.FRIENDLY, "Yes, of course.").also { stage++ }
201 -> {
end()
if (player.isStaff)
ModeratorZone.teleport(player)
}
//deiron
300 -> npcl(FacialExpression.FRIENDLY, "Of course, but first let me give you a word of warning.").also { stage++ }
301 -> npcl(FacialExpression.FRIENDLY, "Should you choose to step away from the path of the ironman now, you will not have the option to return.").also { stage++ }
302 -> npcl(FacialExpression.FRIENDLY, "Now I ask you to make sure, are you sure you want to <b>permanently</b> remove ironman mode?").also { stage++ }
303 -> showTopics(
Topic(FacialExpression.FRIENDLY, "Yes, I'm sure.", 310),
Topic(FacialExpression.FRIENDLY, "No, I've changed my mind.", END_DIALOGUE)
)
//yes - deiron
310 -> npcl(FacialExpression.FRIENDLY, "Very well, let me just check one thing...").also { stage++ }
311 -> if (player.ironmanManager.mode == IronmanMode.HARDCORE) {
npcl(FacialExpression.WORRIED, "Oh, dear, it's just as I feared. You're a hardcore ironman! My apologies, but there's nothing I can do to help.").also { stage = END_DIALOGUE }
} else {
npcl(FacialExpression.FRIENDLY, "Oh, wonderful. It appears everything is in order. Sit still for a moment...").also { stage++ }
}
312 -> {
sendGraphics(342, player.location)
sendDialogue("------------------", "The wise old wizard casts a strange spell.", "------------------")
stage++
}
313 -> {
player.ironmanManager.mode = IronmanMode.NONE
npcl(FacialExpression.HALF_ASKING, "There, I believe it is done. You should no longer be restricted from the wider world.")
stage = END_DIALOGUE
}
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.LUMBRIDGE_GUIDE_2244)
}
}