mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Refactored Seer NPC
This commit is contained in:
parent
a342f91156
commit
24b314426e
3 changed files with 157 additions and 154 deletions
|
|
@ -0,0 +1,70 @@
|
|||
package content.region.kandarin.seers.dialogue
|
||||
|
||||
import content.region.kandarin.seers.diary.SeerDiaryDialogue
|
||||
import core.api.isQuestInProgress
|
||||
import core.api.openDialogue
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.plugin.Initializable
|
||||
import core.tools.END_DIALOGUE
|
||||
import core.tools.START_DIALOGUE
|
||||
import org.rs09.consts.NPCs
|
||||
import core.game.dialogue.Topic
|
||||
|
||||
|
||||
|
||||
@Initializable
|
||||
class SeerDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
|
||||
override fun getIds(): IntArray {
|
||||
return intArrayOf(NPCs.SEER_388)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val OTHER_TOPIC = 10
|
||||
const val DIARY = 20
|
||||
const val SC_QUEST = 30
|
||||
|
||||
const val MANY_GREETINGS = 60
|
||||
const val POWER = 70
|
||||
}
|
||||
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
npcl(FacialExpression.WORRIED, "Uh, what was that dark force? I've never sensed anything like it...").also { stage = START_DIALOGUE } // https://www.youtube.com/watch?v=mYsxit46rGo May 14 2010
|
||||
return true
|
||||
}
|
||||
|
||||
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
|
||||
when (stage) {
|
||||
START_DIALOGUE ->
|
||||
npcl(FacialExpression.NEUTRAL, "Anyway, sorry about that.").also { stage++ }
|
||||
START_DIALOGUE+1 ->
|
||||
showTopics(
|
||||
Topic("Talk about something else.", OTHER_TOPIC, true),
|
||||
Topic("Talk about achievement diary.", DIARY, true)
|
||||
)
|
||||
|
||||
DIARY -> openDialogue(player, SeerDiaryDialogue(), npc)
|
||||
|
||||
OTHER_TOPIC -> if (isQuestInProgress(player, "Scorpion Catcher", 1, 99)) {
|
||||
npcl(FacialExpression.FURIOUS, "Not implemented").also { stage = END_DIALOGUE }
|
||||
}
|
||||
else{
|
||||
showTopics(
|
||||
Topic("Many greetings.", MANY_GREETINGS),
|
||||
Topic("I seek knowledge and power!", POWER)
|
||||
)
|
||||
}
|
||||
|
||||
MANY_GREETINGS -> npcl(FacialExpression.NEUTRAL,
|
||||
"Remember, whenever you set out to do something, something else must be done first.").also { stage = END_DIALOGUE }
|
||||
|
||||
POWER -> npcl(FacialExpression.NEUTRAL, "Knowledge comes from experience, power comes from battleaxes.").also { stage = END_DIALOGUE }
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
package content.region.kandarin.seers.dialogue;
|
||||
|
||||
import core.game.dialogue.DialoguePlugin;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.link.diary.AchievementDiary;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
/**
|
||||
* Handles the SeerDialoguePlugin dialogue.
|
||||
*
|
||||
* @author 'afaroutdude
|
||||
*/
|
||||
@Initializable
|
||||
public class SeerDialoguePlugin extends DialoguePlugin {
|
||||
|
||||
public SeerDialoguePlugin() {
|
||||
}
|
||||
|
||||
public SeerDialoguePlugin(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[]{388};
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialoguePlugin newInstance(Player player) {
|
||||
|
||||
return new SeerDialoguePlugin(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open(Object... args) {
|
||||
npc = (NPC) args[0];
|
||||
// npc("Uh, what was that dark force? I've never sensed", "anything like it..."); // https://www.youtube.com/watch?v=mYsxit46rGo May 14 2010
|
||||
// npc("Anyway, sorry about that.");
|
||||
options("Talk about something else.", "Talk about achievement diary.");
|
||||
stage = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(int interfaceId, int buttonId) {
|
||||
int level = 0;
|
||||
|
||||
switch (stage) {
|
||||
case 999:
|
||||
end();
|
||||
break;
|
||||
case 0:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
npc("Many greetings.");
|
||||
stage = 1;
|
||||
break;
|
||||
case 2:
|
||||
if (AchievementDiary.canReplaceReward(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
player("I seem to have lost my seers' headband...");
|
||||
stage = 80;
|
||||
break;
|
||||
}
|
||||
else if (AchievementDiary.hasClaimedLevelRewards(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
player("Can you remind me what my headband does?");
|
||||
stage = 90;
|
||||
break;
|
||||
}
|
||||
else if (AchievementDiary.canClaimLevelRewards(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
player("Hi. I've completed the Easy tasks in my Achievement", "Diary.");
|
||||
stage = 200;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
player("Hi! Can you help me out with the Achievement Diary", "tasks?");
|
||||
stage = 101;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 80:
|
||||
AchievementDiary.grantReplacement(player, DiaryType.SEERS_VILLAGE, 0);
|
||||
npc("Here's your replacement. Please be more careful.");
|
||||
stage = 999;
|
||||
break;
|
||||
case 90:
|
||||
npc("Your headband marks you as an honourary seer.", "Geoffrey - who works in the field to the", "south - will give you free flax every day.");
|
||||
stage = 999;
|
||||
break;
|
||||
case 100:
|
||||
npc("I certainly do - we have a set of tasks spanning Seers'", "Village, Catherby, Hemenster and the Sinclair Mansion.", "Just complete the tasks listed in the Achievement Diary", "and they will be ticked off automatically.");
|
||||
stage = 999;
|
||||
break;
|
||||
case 101:
|
||||
npc("I'm afraid not. It is important that adventurers", "complete the tasks unaided. That way, only the truly", "worthy collect the spoils.");
|
||||
stage = 999;
|
||||
break;
|
||||
case 200:
|
||||
npc("Well done, adventurer. You are clearly a " + (player.isMale() ? "man" : "woman") + "of", "great wisdom. I have a gift for you.");
|
||||
stage++;
|
||||
break;
|
||||
case 201:
|
||||
if (!AchievementDiary.flagRewarded(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
npc("Come back when you have two free inventory slots.");
|
||||
stage = 999;
|
||||
} else {
|
||||
interpreter.sendItemMessage(AchievementDiary.getRewards(DiaryType.SEERS_VILLAGE, 0)[0], "The seer hands you a strange-looking headband and a", "rusty lamp.");
|
||||
stage++;
|
||||
}
|
||||
break;
|
||||
case 202:
|
||||
npc("You are now an honourary seer and Geoffrey - who", "works in the field to the south - will give you free flax", "every day. Don't call him 'Geoffrey' though: he prefers", "to be known as 'Flax'.");
|
||||
stage++;
|
||||
break;
|
||||
case 203:
|
||||
player("Flax? What sort of name is that for a person.");
|
||||
stage++;
|
||||
break;
|
||||
case 204:
|
||||
npc("I know, I know. The poor boy is a simple soul - he just", "really loves picking flax. A little too much, I fear.");
|
||||
stage=999;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
options("Many greetings.", "I seek knowledge and power!");
|
||||
stage = 2;
|
||||
break;
|
||||
case 2:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
player("Many greetings.");
|
||||
stage = 10;
|
||||
break;
|
||||
case 2:
|
||||
player("I seek knowledge and power!");
|
||||
stage = 20;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
npc("Remember, whenever you set out to do something,", "something else must be done first.");
|
||||
stage = 999;
|
||||
break;
|
||||
case 20:
|
||||
npc("Knowledge comes from experience, power", "comes from battleaxes.");
|
||||
stage = 999;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package content.region.kandarin.seers.diary
|
||||
|
||||
import core.api.sendItemDialogue
|
||||
import core.game.dialogue.DialogueFile
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.node.entity.player.link.diary.AchievementDiary
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.tools.END_DIALOGUE
|
||||
import core.tools.START_DIALOGUE
|
||||
|
||||
class SeerDiaryDialogue : DialogueFile() {
|
||||
|
||||
companion object {
|
||||
|
||||
const val LOST_HEAD_BAND = 20
|
||||
const val HEAD_BAND_HELP = 30
|
||||
const val CLAIM_HEAD_BAND = 40
|
||||
const val ASK_FOR_HELP = 50
|
||||
}
|
||||
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
when (stage) {
|
||||
START_DIALOGUE ->{
|
||||
if (AchievementDiary.canReplaceReward(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
playerl(FacialExpression.SAD, "I seem to have lost my seers' headband...").also {
|
||||
stage = LOST_HEAD_BAND
|
||||
}
|
||||
} else if (AchievementDiary.hasClaimedLevelRewards(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
playerl(FacialExpression.ASKING, "Can you remind me what my headband does?").also {
|
||||
stage = HEAD_BAND_HELP
|
||||
}
|
||||
} else if (AchievementDiary.canClaimLevelRewards(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
playerl(
|
||||
FacialExpression.HAPPY,
|
||||
"Hi. I've completed the Easy tasks in my Achievement Diary."
|
||||
).also {
|
||||
stage = CLAIM_HEAD_BAND
|
||||
}
|
||||
} else {
|
||||
playerl(FacialExpression.ASKING, "Do you have an Achievement Diary for me?").also {
|
||||
stage = ASK_FOR_HELP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOST_HEAD_BAND -> {
|
||||
if (AchievementDiary.grantReplacement(player, DiaryType.SEERS_VILLAGE, 0))
|
||||
npcl(FacialExpression.ANNOYED, "Here's your replacement. Please be more careful.").also {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
else
|
||||
// This line is just guessed
|
||||
npcl(FacialExpression.HALF_GUILTY, "It seems your inventory is full").also { stage = END_DIALOGUE }
|
||||
}
|
||||
HEAD_BAND_HELP -> npcl(FacialExpression.NEUTRAL, "Your headband marks you as an honourary seer. Geoffrey - who works in the field to the south - will give you free flax every day.").also {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
|
||||
// This has to be npc otherwise wordwrap goes wrong and extends to 5 lines
|
||||
ASK_FOR_HELP -> npc(FacialExpression.HAPPY, "I certainly do - we have a set of tasks spanning Seers'", "Village, Catherby, Hemenster and the Sinclair Mansion.",
|
||||
"Just complete the tasks listed in the Achievement Diary", "and they will be ticked off automatically.").also { stage++ }
|
||||
ASK_FOR_HELP + 1 -> playerl(FacialExpression.ASKING, "Hi! Can you help me out with the Achievement Diary tasks?").also { stage++ }
|
||||
ASK_FOR_HELP + 2 -> npcl(FacialExpression.SAD,
|
||||
"I'm afraid not. It is important that adventurers complete the tasks unaided. That way, only the truly worthy collect the spoils.").also {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
|
||||
CLAIM_HEAD_BAND -> npcl(FacialExpression.HAPPY, "Well done, adventurer. You are clearly a "+(if (player!!.isMale) "man" else "woman")+" of great wisdom. I have a gift for you.").also { stage++ }
|
||||
CLAIM_HEAD_BAND + 1 -> {
|
||||
if (!AchievementDiary.flagRewarded(player, DiaryType.SEERS_VILLAGE, 0)) {
|
||||
npcl(FacialExpression.NEUTRAL, "Come back when you have two free inventory slots.").also {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
} else {
|
||||
sendItemDialogue(player!!, AchievementDiary.getRewards(DiaryType.SEERS_VILLAGE, 0)[0],
|
||||
"The seer hands you a strange-looking headband and a rusty lamp.").also { stage++ }
|
||||
}
|
||||
}
|
||||
CLAIM_HEAD_BAND + 2 -> npcl(FacialExpression.HAPPY, "You are now an honourary seer and Geoffrey - who works in the field to the south - will give you free flax every day. Don't call him 'Geoffrey' though: he prefers to be known as 'Flax'.").also { stage++ }
|
||||
CLAIM_HEAD_BAND + 3 -> playerl(FacialExpression.ASKING, "Flax? What sort of name is that for a person?").also { stage++ }
|
||||
CLAIM_HEAD_BAND + 4 -> npcl(FacialExpression.NEUTRAL, "I know, I know. The poor boy is a simple soul - he just really loves picking flax. A little too much, I fear.").also {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue