mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Ported Peksa from Java to Kotlin
This commit is contained in:
parent
ae53116fee
commit
4f5d753104
2 changed files with 62 additions and 82 deletions
|
|
@ -1,82 +0,0 @@
|
|||
package content.region.misthalin.barbvillage.dialogue;
|
||||
|
||||
import core.game.dialogue.DialoguePlugin;
|
||||
import core.game.dialogue.FacialExpression;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
/**
|
||||
* Represents the plugin used for peksa.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class PeksaDialogue extends DialoguePlugin {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PeksaDialogue} {@code Object}.
|
||||
*/
|
||||
public PeksaDialogue() {
|
||||
/**
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PeksaDialogue} {@code Object}.
|
||||
* @param player the player.
|
||||
*/
|
||||
public PeksaDialogue(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialoguePlugin newInstance(Player player) {
|
||||
return new PeksaDialogue(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open(Object... args) {
|
||||
npc = (NPC) args[0];
|
||||
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Are you interested in buying or selling a helmet?");
|
||||
stage = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(int interfaceId, int buttonId) {
|
||||
switch (stage) {
|
||||
case 0:
|
||||
interpreter.sendOptions("Select an Option", "I could be, yes.", "No, I'll pass on that.");
|
||||
stage = 1;
|
||||
break;
|
||||
case 1:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
end();
|
||||
npc.openShop(player);
|
||||
break;
|
||||
case 2:
|
||||
interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "No, I'll pass on that.");
|
||||
stage = 20;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Well, come back if you change your mind.");
|
||||
stage = 21;
|
||||
break;
|
||||
case 21:
|
||||
end();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 538 };
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package content.region.misthalin.barbvillage.dialogue
|
||||
|
||||
import core.api.getQuestStage
|
||||
import core.api.openDialogue
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.dialogue.IfTopic
|
||||
import core.game.dialogue.Topic
|
||||
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
|
||||
|
||||
@Initializable
|
||||
class PeksaDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||
|
||||
companion object {
|
||||
const val GO_SHOPPING = 10
|
||||
const val LEAVE = 20
|
||||
const val DIALOGUE_SCORPION_CATCHER = 30
|
||||
}
|
||||
|
||||
override fun open(vararg args: Any): Boolean {
|
||||
npc = args[0] as NPC
|
||||
npcl(FacialExpression.HALF_GUILTY, "Are you interested in buying or selling a helmet?").also { stage = START_DIALOGUE }
|
||||
return true
|
||||
}
|
||||
|
||||
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
|
||||
when (stage) {
|
||||
START_DIALOGUE -> {
|
||||
showTopics(
|
||||
Topic("I could be, yes.", GO_SHOPPING),
|
||||
Topic("No, I'll pass on that.", LEAVE),
|
||||
// todo get the quest state from Scorpion catcher to make this work
|
||||
// IfTopic("Scorpion Stuff", SCORPION_CATCHER, getQuestStage(player, "Scorpion Catcher") == 50)
|
||||
)
|
||||
}
|
||||
|
||||
GO_SHOPPING -> {
|
||||
end()
|
||||
npc.openShop(player)
|
||||
}
|
||||
|
||||
LEAVE -> {
|
||||
npcl(FacialExpression.HALF_GUILTY, "Well, come back if you change your mind.").also { stage = END_DIALOGUE }
|
||||
}
|
||||
|
||||
// DIALOGUE_SCORPION_CATCHER -> {
|
||||
// openDialogue(player, PeksaDialogueSC(), npc)
|
||||
// }
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getIds(): IntArray {
|
||||
return intArrayOf(NPCs.PEKSA_538)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue