mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
mucho refactoring
This commit is contained in:
parent
55126ce8a6
commit
6553ed1e4c
155 changed files with 444 additions and 575 deletions
|
|
@ -1,10 +0,0 @@
|
|||
package core.game.content.global.worldevents.shootingstar;
|
||||
|
||||
public class ScoreboardEntry{
|
||||
public String playerName;
|
||||
public int time;
|
||||
public ScoreboardEntry(String player, int time){
|
||||
this.playerName = player;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package core.game.content.global.worldevents.shootingstar;
|
||||
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.game.interaction.OptionHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.player.Player;
|
||||
import rs09.game.world.GameWorld;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
public class ScoreboardHandler extends OptionHandler {
|
||||
int index = 0;
|
||||
int ifaceid = ShootingStarScoreboard.iface.getId();
|
||||
@Override
|
||||
public boolean handle(Player player, Node node, String option) {
|
||||
ScoreboardManager.getEntries().forEach(e -> {
|
||||
player.getPacketDispatch().sendString("" + Math.floor(((GameWorld.getTicks() - e.time) / 0.6) / 60) + " minutes ago",ifaceid,index + 6);
|
||||
player.getPacketDispatch().sendString(e.playerName,ifaceid,index + 11);
|
||||
index++;
|
||||
});
|
||||
index = 0;
|
||||
player.getInterfaceManager().open(ShootingStarScoreboard.iface);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
SceneryDefinition.forId(38669).getHandlers().put("option:read",this);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package core.game.content.global.worldevents.shootingstar;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import rs09.game.world.GameWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScoreboardManager {
|
||||
public static List<ScoreboardEntry> entries = new ArrayList<>(20);
|
||||
|
||||
public static void submit(Player player){
|
||||
if(entries.size() == 5){
|
||||
entries.remove(0);
|
||||
}
|
||||
entries.add(new ScoreboardEntry(player.getUsername(), GameWorld.getTicks()));
|
||||
}
|
||||
|
||||
public static List<ScoreboardEntry> getEntries(){
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package core.game.content.global.worldevents.shootingstar;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.component.ComponentDefinition;
|
||||
import core.game.component.ComponentPlugin;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
public class ShootingStarScoreboard extends ComponentPlugin {
|
||||
public static Component iface = new Component(787);
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ComponentDefinition.put(iface.getId(),this);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ import rs09.game.interaction.InteractionListener
|
|||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
class ExplorersRingPlugin : InteractionListener() {
|
||||
class ExplorersRingPlugin : InteractionListener {
|
||||
|
||||
val RINGS = intArrayOf(Items.EXPLORERS_RING_1_13560, Items.EXPLORERS_RING_2_13561, Items.EXPLORERS_RING_3_13562)
|
||||
val CABBAGE_PORT = Location.create(3051, 3291, 0)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import rs09.tools.END_DIALOGUE
|
|||
* @author Ceikry
|
||||
* @version 1.0
|
||||
*/
|
||||
class NPCTradePlugin : InteractionListener() {
|
||||
class NPCTradePlugin : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPC, "trade", "shop"){player, node ->
|
||||
val npc = node as NPC
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* Handles the culino chest options.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class CulinoChestListener : InteractionListener() {
|
||||
class CulinoChestListener : InteractionListener {
|
||||
val CULINO_CHEST = Scenery.CHEST_12309
|
||||
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import rs09.game.world.GameWorld
|
|||
import rs09.plugin.ClassScanner
|
||||
|
||||
|
||||
class GardenObjectsPlugin : InteractionListener() {
|
||||
class GardenObjectsPlugin : InteractionListener {
|
||||
|
||||
val SQIRK_TREES = intArrayOf(21767, 21768, 21769, 21766)
|
||||
val FOUNTAIN = 21764
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import rs09.game.node.entity.skill.cooking.CookingDialogue
|
|||
* @author Ceikry
|
||||
* @author bushtail - added bear meat for sinew making
|
||||
*/
|
||||
class CookingRewrite : InteractionListener() {
|
||||
class CookingRewrite : InteractionListener {
|
||||
|
||||
val RAW_FOODS: IntArray
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package core.game.node.entity.skill.firemaking
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class FiremakingListener : InteractionListener()
|
||||
class FiremakingListener : InteractionListener
|
||||
{
|
||||
val logs = intArrayOf(1511, 1521, 1513, 1515, 1517, 1519, 1521, 2862, 3438, 3440, 3442, 3444, 3446, 3448, 6211, 6213, 6332, 6333, 7404, 7405, 7406, 8934, 9067, 10328, 10329, 10808, 10810, 10812, 11035, 12581, 12583, 3125)
|
||||
|
||||
|
|
|
|||
49
Server/src/main/kotlin/api/Commands.kt
Normal file
49
Server/src/main/kotlin/api/Commands.kt
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package api
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import rs09.game.system.command.Command
|
||||
import rs09.game.system.command.CommandMapping
|
||||
import rs09.game.system.command.Privilege
|
||||
import rs09.tools.stringtools.colorize
|
||||
|
||||
/**
|
||||
* An interface for writing content that allows the class to define commands.
|
||||
*
|
||||
* Includes methods [reject] and [notify] for notifying the player of a command rejection or some output text respectively.
|
||||
*
|
||||
* Includes the method [define] to define individual commands
|
||||
*
|
||||
* Commands should ideally be defined in the required [defineCommands] method.
|
||||
*/
|
||||
interface Commands : ContentInterface {
|
||||
/**
|
||||
* Glorified player.sendMessage with red text coloring. Please use this
|
||||
* rather than just player.sendMessage for anything that involves informing the player
|
||||
* of proper usage or invalid syntax. Throws an IllegalStateException and ends command execution immediately.
|
||||
*/
|
||||
fun reject(player: Player, vararg message: String){
|
||||
for(msg in message) {
|
||||
player.sendMessage(colorize("-->%R$msg"))
|
||||
}
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Glorified player.sendMessage with black text coloring and an arrow. Use this when you need to
|
||||
* notify/inform a player of some information from within the command without ending execution.
|
||||
*/
|
||||
fun notify(player: Player, message: String){
|
||||
player.sendMessage(colorize("-->$message"))
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to define commands. define("name",(optional) privilege override){ handle }
|
||||
* @param name the name of the command. Example: ::example would be just "example"
|
||||
* @param privilege the rights level needed to execute the command. Options are [Privilege.STANDARD], [Privilege.MODERATOR], [Privilege.ADMIN]. Defaults to [Privilege.STANDARD]
|
||||
*/
|
||||
fun define(name: String, privilege: Privilege = Privilege.STANDARD, handle: (Player, Array<String>) -> Unit){
|
||||
CommandMapping.register(Command(name, privilege, handle))
|
||||
}
|
||||
|
||||
fun defineCommands()
|
||||
}
|
||||
|
|
@ -6,17 +6,14 @@ import core.game.world.map.Location
|
|||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.ai.general.GeneralBotCreator
|
||||
import rs09.game.ai.general.ScriptAPI
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.content.global.worldevents.shootingstar.ShootingStarEvent
|
||||
import rs09.game.interaction.InteractionListener.Companion.SCENERY
|
||||
import rs09.game.content.global.worldevents.shootingstar.ShootingStarPlugin
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InteractionListeners
|
||||
import kotlin.concurrent.timer
|
||||
|
||||
class ShootingStarBot : Script() {
|
||||
private var state = State.FULL_IDLE
|
||||
private var timerCountdown = 0
|
||||
val star = (WorldEvents.get("shooting-stars") as? ShootingStarEvent)!!.star
|
||||
val star = ShootingStarPlugin.getStar()
|
||||
|
||||
override fun tick() {
|
||||
bot.fullRestore()
|
||||
|
|
@ -36,7 +33,7 @@ class ShootingStarBot : Script() {
|
|||
}
|
||||
|
||||
State.MINING -> {
|
||||
InteractionListeners.run(star.starObject.id, SCENERY, "mine", bot, star.starObject)
|
||||
InteractionListeners.run(star.starObject.id, InteractionListener.SCENERY, "mine", bot, star.starObject)
|
||||
}
|
||||
|
||||
State.TELEPORT_BACK -> {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ private val LIGHT_ANIM = Animation(7307)
|
|||
* Handles interactions for beacons
|
||||
* @author Ceikry
|
||||
*/
|
||||
class AFUBeaconListeners : InteractionListener(){
|
||||
class AFUBeaconListeners : InteractionListener{
|
||||
|
||||
override fun defineListeners() {
|
||||
on(SCENERY,"add-logs","light"){ player, node ->
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import java.util.*
|
|||
* Handles repairing and climbing of the 3 beacon shortcuts needed to access them
|
||||
* @author Ceikry
|
||||
*/
|
||||
class AFURepairClimbHandler : InteractionListener() {
|
||||
class AFURepairClimbHandler : InteractionListener {
|
||||
|
||||
val repairIDs = intArrayOf(38480,38470,38494)
|
||||
val climbIDs = intArrayOf(38469,38471,38486,38481,38469)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import rs09.game.interaction.InterfaceListener
|
|||
* @author definitely phil who didn't get help from ceikry at all haha :)
|
||||
* @version 69.0
|
||||
*/
|
||||
class BlastFurnaceInterfaceListener : InterfaceListener() {
|
||||
class BlastFurnaceInterfaceListener : InterfaceListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
|
||||
on(Components.BLAST_FURNACE_BAR_STOCK_28){ player, _, _, buttonID, _, _ ->
|
||||
val bar = BFBars.forId(buttonID) ?: return@on false
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import rs09.game.node.entity.npc.other.BlastFurnaceOre
|
|||
* That lives in OrdanDialogue.kt
|
||||
* @author phil lips*/
|
||||
|
||||
class BlastFurnaceListeners : InteractionListener() {
|
||||
class BlastFurnaceListeners : InteractionListener {
|
||||
|
||||
val disLoc = getScenery(1941, 4963, 0)
|
||||
val brokenPotPipe = 9117
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import rs09.game.interaction.InterfaceListener
|
|||
* Only updates the gauge if people are actually looking at it
|
||||
* @author phil lips*/
|
||||
|
||||
class PhunnyGaugeTempInterfaceListener : InterfaceListener(){
|
||||
class PhunnyGaugeTempInterfaceListener : InterfaceListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(30) {player, component ->
|
||||
BlastFurnace.gaugeViewList.add(player)
|
||||
return@onOpen true
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import kotlin.math.ceil
|
|||
* Option handler for fishing trawler
|
||||
* @author Ceikry
|
||||
*/
|
||||
class FishingTrawlerInteractionHandler : InteractionListener() {
|
||||
class FishingTrawlerInteractionHandler : InteractionListener {
|
||||
val ENTRANCE_PLANK = 2178
|
||||
val EXIT_PLANK = 2179
|
||||
val HOLE = 2167
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* @author bushtail
|
||||
*/
|
||||
|
||||
class CraftingGuildListeners : InteractionListener() {
|
||||
class CraftingGuildListeners : InteractionListener {
|
||||
private val GUILD_DOOR = Scenery.GUILD_DOOR_2647
|
||||
private val APRON = Items.BROWN_APRON_1757
|
||||
private val CAPE = Items.CRAFTING_CAPE_9780
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import rs09.game.interaction.InteractionListener
|
|||
import rs09.game.node.entity.skill.magic.SpellListener
|
||||
import rs09.game.node.entity.skill.magic.spellconsts.Modern
|
||||
|
||||
class MTAListeners : InteractionListener() {
|
||||
class MTAListeners : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPCs.MAZE_GUARDIAN_3102,NPC,"talk-to"){player,node ->
|
||||
player.dialogueInterpreter.open(node.id, node)
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ import org.rs09.consts.Scenery
|
|||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
|
||||
/**
|
||||
* The "controller" class for pyramid plunder. Handles per-tick updates, logout hooks, and defines interaction listeners for the minigame.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class PyramidPlunderMinigame : InteractionListener(), TickListener, LogoutListener {
|
||||
class PyramidPlunderMinigame : InteractionListener, TickListener, LogoutListener {
|
||||
override fun tick() {
|
||||
val playersToExpel = PlunderUtils.decrementTimeRemaining()
|
||||
playersToExpel.forEach {player -> PlunderUtils.expel(player, false) }
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ object VinesweeperTeleport {
|
|||
}
|
||||
}
|
||||
|
||||
class VinesweeperListener : InteractionListener() {
|
||||
class VinesweeperListener : InteractionListener {
|
||||
fun dig(player: Player, loc: Location) {
|
||||
if(isSeed(loc)) {
|
||||
val oldPoints = player.getAttribute("vinesweeper:points", 0)
|
||||
|
|
@ -439,7 +439,7 @@ class VinesweeperZone : MapZone("Vinesweeper", true) {
|
|||
}
|
||||
}
|
||||
|
||||
class VinesweeperRewards : InterfaceListener() {
|
||||
class VinesweeperRewards : InterfaceListener {
|
||||
val IFACE = 686
|
||||
val TRADE_FOR_XP_BUTTON = 53
|
||||
val XP_CONFIRM = 72
|
||||
|
|
@ -506,7 +506,7 @@ class VinesweeperRewards : InterfaceListener() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(IFACE) { _, _ ->
|
||||
/*for((buttonID, reward) in REWARDS) {
|
||||
sendItemOnInterface(player, IFACE, buttonID, reward.itemID, 5)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import core.game.node.item.Item
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class WGuildListeners : InteractionListener() {
|
||||
class WGuildListeners : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
onEquip(Items.DEFENSIVE_SHIELD_8856){player, node ->
|
||||
if (node is Item) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.rs09.consts.Items
|
|||
import rs09.game.content.ame.RandomEventManager
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class CerterEventInterface : InterfaceListener() {
|
||||
class CerterEventInterface : InterfaceListener {
|
||||
val CERTER_INTERFACE = 184
|
||||
val OPTION_A_CHILD = 1
|
||||
val OPTION_B_CHILD = 2
|
||||
|
|
@ -31,7 +31,7 @@ class CerterEventInterface : InterfaceListener() {
|
|||
Items.NULL_6198 to "A necklace."
|
||||
)
|
||||
val falseOptions = arrayOf("An axe.", "An arrow.", "A pair of boots.", "A pair of gloves.", "A staff.", "A bow.", "A feather.", "The disenfrachaised youth of 1940's Columbia.")
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(CERTER_INTERFACE) { player, _, _, buttonID, _, _ ->
|
||||
val answer = buttonID - 7
|
||||
val correctAnswer = player.getAttribute("certer:correctIndex", 0)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import core.game.system.task.Pulse
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class DrillDemonListeners : InteractionListener() {
|
||||
class DrillDemonListeners : InteractionListener {
|
||||
val MATS = intArrayOf(10076,10077,10078,10079)
|
||||
override fun defineListeners() {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.rs09.consts.Items
|
|||
import rs09.game.content.ame.RandomEventManager
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class SandwichLadyInterface : InterfaceListener(){
|
||||
class SandwichLadyInterface : InterfaceListener{
|
||||
|
||||
val SANDWICH_INTERFACE = 297
|
||||
val baguette = Items.BAGUETTE_6961
|
||||
|
|
@ -16,7 +16,7 @@ class SandwichLadyInterface : InterfaceListener(){
|
|||
val kebab = Items.KEBAB_1971
|
||||
val chocobar = Items.CHOCOLATE_BAR_1973
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(SANDWICH_INTERFACE){player, _, _, buttonID, _, _ ->
|
||||
val item =
|
||||
when(buttonID) {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import org.rs09.consts.Components
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class SEPatternInterface : InterfaceListener() {
|
||||
class SEPatternInterface : InterfaceListener {
|
||||
|
||||
val COMPONENT = Components.PATTERN_NEXT_103
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
|
||||
on(COMPONENT){player, component, opcode, buttonID, slot, itemID ->
|
||||
val index = buttonID - 10
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.rs09.consts.NPCs
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.inter.ExperienceInterface
|
||||
|
||||
class SupriseExamListeners : InteractionListener() {
|
||||
class SupriseExamListeners : InteractionListener {
|
||||
val MORDAUT = NPCs.MR_MORDAUT_6117
|
||||
val BOOK_OF_KNOWLEDGE = Items.BOOK_OF_KNOWLEDGE_11640
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import rs09.game.system.config.ItemConfigParser
|
|||
* @author Ceikry
|
||||
* @author Woah
|
||||
*/
|
||||
class EquipHandler : InteractionListener() {
|
||||
class EquipHandler : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class GiftRollPlugin : XPGainPlugin() {
|
|||
}
|
||||
}
|
||||
|
||||
class XMASMboxHandler : InteractionListener() {
|
||||
class XMASMboxHandler : InteractionListener {
|
||||
val MBOX = Items.MYSTERY_BOX_6199
|
||||
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class EasterEventListeners : InteractionListener() {
|
||||
class EasterEventListeners : InteractionListener {
|
||||
|
||||
val EGG_ATTRIBUTE = "/save:easter:eggs"
|
||||
val eggs = intArrayOf(Items.EASTER_EGG_11027, Items.EASTER_EGG_11028, Items.EASTER_EGG_11029, Items.EASTER_EGG_11030)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import rs09.game.interaction.InteractionListener
|
|||
import rs09.game.world.GameWorld
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class TrickOrTreatHandler : InteractionListener() {
|
||||
class TrickOrTreatHandler : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPC, "trick-or-treat"){player, node ->
|
||||
val hasDone5 = getDailyTrickOrTreats(player) == 5
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import core.game.content.quest.PluginInteraction
|
|||
import core.game.content.quest.PluginInteractionManager
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class PenguinSpyingHandler : InteractionListener(){
|
||||
class PenguinSpyingHandler : InteractionListener{
|
||||
|
||||
override fun defineListeners() {
|
||||
on(PENGUINS, NPC, "spy-on"){player, node ->
|
||||
|
|
|
|||
|
|
@ -71,15 +71,15 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando
|
|||
starSprite.location = starObject.location
|
||||
starSprite.init()
|
||||
spriteSpawned = true
|
||||
ShootingStarEvent.getStoreFile().clear()
|
||||
ShootingStarPlugin.getStoreFile().clear()
|
||||
return
|
||||
}
|
||||
level = getNextType()
|
||||
maxDust = level.totalStardust
|
||||
dustLeft = level.totalStardust
|
||||
|
||||
ShootingStarEvent.getStoreFile()["level"] = level.ordinal
|
||||
ShootingStarEvent.getStoreFile()["isDiscovered"] = isDiscovered
|
||||
ShootingStarPlugin.getStoreFile()["level"] = level.ordinal
|
||||
ShootingStarPlugin.getStoreFile()["isDiscovered"] = isDiscovered
|
||||
|
||||
val newStar = Scenery(level.objectId, starObject.location)
|
||||
SceneryBuilder.replace(starObject, newStar)
|
||||
|
|
@ -114,10 +114,10 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando
|
|||
* Rebuilds some of the variables with new information.
|
||||
*/
|
||||
fun rebuildVars(){
|
||||
if(firstStar && ShootingStarEvent.getStoreFile().isNotEmpty()){
|
||||
level = ShootingStarType.values()[ShootingStarEvent.getStoreFile().getInt("level")]
|
||||
location = ShootingStarEvent.getStoreFile().getString("location")
|
||||
isDiscovered = ShootingStarEvent.getStoreFile().getBoolean("isDiscovered")
|
||||
if(firstStar && ShootingStarPlugin.getStoreFile().isNotEmpty()){
|
||||
level = ShootingStarType.values()[ShootingStarPlugin.getStoreFile().getInt("level")]
|
||||
location = ShootingStarPlugin.getStoreFile().getString("location")
|
||||
isDiscovered = ShootingStarPlugin.getStoreFile().getBoolean("isDiscovered")
|
||||
} else {
|
||||
level = ShootingStarType.values().random()
|
||||
location = crash_locations.entries.random().key
|
||||
|
|
@ -128,9 +128,9 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando
|
|||
dustLeft = level.totalStardust
|
||||
starObject = Scenery(level.objectId, crash_locations.get(location))
|
||||
|
||||
ShootingStarEvent.getStoreFile()["level"] = level.ordinal
|
||||
ShootingStarEvent.getStoreFile()["location"] = location
|
||||
ShootingStarEvent.getStoreFile()["isDiscovered"] = false
|
||||
ShootingStarPlugin.getStoreFile()["level"] = level.ordinal
|
||||
ShootingStarPlugin.getStoreFile()["location"] = location
|
||||
ShootingStarPlugin.getStoreFile()["isDiscovered"] = false
|
||||
|
||||
ticks = 0
|
||||
firstStar = false
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.command.CommandSet
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.system.command.CommandPlugin
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* A few assorted commands for shooting stars.
|
||||
*/
|
||||
class ShootingStarCommands : CommandPlugin(){
|
||||
override fun newInstance(arg: Any?): Plugin<Any?>{
|
||||
link(CommandSet.DEVELOPER)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun parse(player: Player?, name: String?, args: Array<String?>?): Boolean {
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
when (name) {
|
||||
"tostar" -> {
|
||||
player!!.teleport(star.starObject.location.transform(1, 1, 0))
|
||||
}
|
||||
"submit" -> {
|
||||
star.fire()
|
||||
}
|
||||
"resettime" -> player!!.savedData.globalData.starSpriteDelay = 0L
|
||||
"stardust" -> {
|
||||
val dust = 8
|
||||
println("Cosmic Runes: " + 0.76 * dust)
|
||||
println("Astral runes: " + 0.26 * dust)
|
||||
println("Gold ores: " + 0.1 * dust)
|
||||
println("GP: " + 250.1 * dust)
|
||||
}
|
||||
"setsprite" -> player!!.savedData.globalData.starSpriteDelay = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import core.game.content.global.worldevents.shootingstar.ScoreboardHandler
|
||||
import core.game.content.global.worldevents.shootingstar.ShootingStarScoreboard
|
||||
import core.game.content.global.worldevents.shootingstar.StarChartPlugin
|
||||
import core.game.system.task.Pulse
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.ServerStore
|
||||
import rs09.game.content.global.worldevents.PluginSet
|
||||
import rs09.game.content.global.worldevents.WorldEvent
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.world.GameWorld
|
||||
|
||||
|
||||
/**
|
||||
* The world event class for shooting stars. Keeps track of event-related data like the ShootingStar instance.
|
||||
* Also handles spawning new shooting stars based on time.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class ShootingStarEvent : WorldEvent("shooting-stars") {
|
||||
val star = ShootingStar()
|
||||
val tickDelay = if(GameWorld.settings?.isDevMode == true) 200 else 25000
|
||||
|
||||
|
||||
override fun initialize() {
|
||||
plugins = PluginSet(
|
||||
ScoreboardHandler(),
|
||||
ShootingStarScoreboard(),
|
||||
StarChartPlugin(),
|
||||
ShootingStarCommands(),
|
||||
StarSpriteDialogue(),
|
||||
ShootingStarLogin()
|
||||
)
|
||||
super.initialize()
|
||||
GameWorld.Pulser.submit(StarPulse())
|
||||
log("Shooting Star event has been initialized.")
|
||||
}
|
||||
|
||||
override fun checkTrigger(): Boolean {
|
||||
/**
|
||||
* Spawn a new star only if: star's ticks are greater than the tickDelay and star sprite is not spawned OR,
|
||||
* neither the star or the sprite are spawned.
|
||||
*/
|
||||
star.ticks += 10
|
||||
if ((star.ticks >= tickDelay && !star.spriteSpawned) || (!star.isSpawned && !star.spriteSpawned)) {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the sprite when we have passed the tickDelay + (1/3) of the tickDelay.
|
||||
* This gives players a little extra time before the star respawns to run to the bank and grab
|
||||
* stardust or whatever. Once the sprite is cleared a new star will be allowed to spawn.
|
||||
*/
|
||||
val maxDelay = tickDelay + (tickDelay / 3)
|
||||
if(star.ticks > maxDelay && star.spriteSpawned){
|
||||
star.clearSprite()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun checkActive(): Boolean {
|
||||
return true //this event is always active.
|
||||
}
|
||||
|
||||
override fun fireEvent() {
|
||||
log("Fired new shooting star event.")
|
||||
star.fire()
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles checking star status and spawning new ones if necessary.
|
||||
*/
|
||||
class StarPulse : Pulse(10){
|
||||
override fun pulse(): Boolean {
|
||||
val event = WorldEvents.get("shooting-stars")
|
||||
event ?: return true
|
||||
|
||||
if(event.checkTrigger()){
|
||||
event.fireEvent()
|
||||
}
|
||||
|
||||
return false //always returns false because it needs to run forever.
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getStoreFile() : JSONObject {
|
||||
return ServerStore.getArchive("shooting-star")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import core.plugin.Plugin
|
||||
import core.plugin.PluginManifest
|
||||
import core.plugin.PluginType
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
|
||||
/**
|
||||
* A plugin that handles the message a player receives on login pertaining to shooting stars.
|
||||
*/
|
||||
@PluginManifest(type = PluginType.LOGIN)
|
||||
class ShootingStarLogin : Plugin<Player?> {
|
||||
@Throws(Throwable::class)
|
||||
override fun newInstance(arg: Player?): Plugin<Player?>? {
|
||||
if (arg is Player) {
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
if (star.isSpawned) {
|
||||
arg.sendMessage("<img=12><col=CC6600>News: A shooting star (Level " + (star.level.ordinal + 1).toString() + ") has just crashed near the " + star.location + "!")
|
||||
}
|
||||
return this
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun fireEvent(identifier: String, vararg args: Any): Any {
|
||||
return Unit
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import api.*
|
||||
import core.game.content.global.worldevents.shootingstar.ScoreboardManager
|
||||
import core.game.node.scenery.Scenery
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.SkillPulse
|
||||
|
|
@ -50,7 +49,7 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin
|
|||
player.incrementAttribute("/save:shooting-star:bonus-xp", bonusXp)
|
||||
Repository.sendNews(player.username + " is the discoverer of the crashed star near " + star.location + "!")
|
||||
player.sendMessage("You have ${player.skills.experienceMutiplier * player.getAttribute("shooting-star:bonus-xp", 0).toDouble()} bonus xp towards mining stardust.")
|
||||
ScoreboardManager.submit(player)
|
||||
ShootingStarPlugin.submitScoreBoard(player)
|
||||
star.isDiscovered = true
|
||||
return player.skills.getLevel(Skills.MINING) >= star.miningLevel
|
||||
}
|
||||
|
|
@ -63,7 +62,7 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin
|
|||
player.packetDispatch.sendMessage("You do not have a pickaxe to use.")
|
||||
return false
|
||||
}
|
||||
if (player.inventory.freeSlots() < 1 && !player.inventory.contains(ShootingStarOptionHandler.STAR_DUST, 1)) {
|
||||
if (player.inventory.freeSlots() < 1 && !player.inventory.contains(ShootingStarPlugin.STAR_DUST, 1)) {
|
||||
player.dialogueInterpreter.sendDialogue("Your inventory is too full to hold any more stardust.")
|
||||
return false
|
||||
}
|
||||
|
|
@ -98,8 +97,8 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin
|
|||
}
|
||||
|
||||
player.skills.addExperience(Skills.MINING, xp)
|
||||
if (ShootingStarOptionHandler.getStarDust(player) < 200) {
|
||||
player.inventory.add(Item(ShootingStarOptionHandler.STAR_DUST, 1))
|
||||
if (ShootingStarPlugin.getStarDust(player) < 200) {
|
||||
player.inventory.add(Item(ShootingStarPlugin.STAR_DUST, 1))
|
||||
}
|
||||
if(!inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !inBank(player, Items.ANCIENT_BLUEPRINT_14651)){
|
||||
rollBlueprint(player)
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
/**
|
||||
* Option handlers for the various shooting star objects.
|
||||
*/
|
||||
class ShootingStarOptionHandler : InteractionListener() {
|
||||
|
||||
val SHOOTING_STARS = ShootingStarType.values().map(ShootingStarType::objectId).toIntArray()
|
||||
|
||||
override fun defineListeners() {
|
||||
on(SHOOTING_STARS,SCENERY,"mine"){ player, _ ->
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
star.mine(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(SHOOTING_STARS,SCENERY,"prospect"){ player, _ ->
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
star.prospect(player)
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val STAR_DUST = 13727
|
||||
/**
|
||||
* Gets the star dust amount for a player.
|
||||
* @param player The player.
|
||||
* @return The stardust amount.
|
||||
*/
|
||||
fun getStarDust(player: Player): Int {
|
||||
return player.inventory.getAmount(STAR_DUST) + player.bank.getAmount(STAR_DUST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.TeleportManager
|
||||
import core.game.node.entity.skill.Skills
|
||||
import org.json.simple.JSONObject
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Scenery
|
||||
import rs09.ServerStore
|
||||
import rs09.ServerStore.Companion.getBoolean
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.command.Privilege
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.tools.secondsToTicks
|
||||
|
||||
class ShootingStarPlugin : LoginListener, InteractionListener, TickListener, Commands, StartupListener {
|
||||
override fun login(player: Player) {
|
||||
if(star.isSpawned && !star.spriteSpawned)
|
||||
sendMessage(player, "<img=12><col=CC6600>News: A shooting star (Level ${star.level.ordinal + 1}) has just crashed near the ${star.location}!")
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
++star.ticks
|
||||
|
||||
val maxDelay = tickDelay + (tickDelay / 3)
|
||||
if(star.ticks > maxDelay && star.spriteSpawned){
|
||||
star.clearSprite()
|
||||
}
|
||||
|
||||
if ((star.ticks >= tickDelay && !star.spriteSpawned) || (!star.isSpawned && !star.spriteSpawned)) {
|
||||
star.fire()
|
||||
}
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
on(Scenery.SHOOTING_STAR_NOTICEBOARD_38669, SCENERY, "read") { player, _ ->
|
||||
var index = 0
|
||||
scoreboardEntries.forEach { entry ->
|
||||
val timeElapsed = secondsToTicks(GameWorld.ticks - entry.time) / 60
|
||||
setInterfaceText(player, "$timeElapsed minutes ago", scoreboardIface, index + 6)
|
||||
setInterfaceText(player, entry.player, scoreboardIface, index + 11)
|
||||
++index
|
||||
}
|
||||
openInterface(player, scoreboardIface)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(SHOOTING_STARS,SCENERY,"mine"){ player, _ ->
|
||||
star.mine(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(SHOOTING_STARS,SCENERY,"prospect"){ player, _ ->
|
||||
star.prospect(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(RING, ITEM, "rub", "operate"){player, node ->
|
||||
if(getRingStoreFile().getBoolean(player.username.toLowerCase())){
|
||||
sendDialogue(player, "The ring is still recharging.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
val condition: (Player) -> Boolean = when(star.location.toLowerCase()){
|
||||
"canifis bank" -> { p -> p.questRepository.isComplete("Priest in Peril")}
|
||||
"crafting guild" -> {p -> hasLevelStat(p, Skills.CRAFTING, 40) }
|
||||
"south crandor mining site" -> {p -> p.questRepository.isComplete("Dragon Slayer")}
|
||||
else -> {_ -> true}
|
||||
}
|
||||
|
||||
if(!condition.invoke(player) || player.skullManager.isWilderness){
|
||||
sendDialogue(player, "Magical forces prevent your teleportation.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
val shouldWarn = when(star.location){
|
||||
"North Edgeville mining site",
|
||||
"Southern wilderness mine",
|
||||
"Pirates' Hideout mine",
|
||||
"Lava Maze mining site",
|
||||
"Mage Arena bank" -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
openDialogue(player, RingDialogue(shouldWarn, star))
|
||||
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
|
||||
override fun defineCommands() {
|
||||
define("tostar", Privilege.ADMIN) { player, _ ->
|
||||
teleport(player, star.starObject.location.transform(1,1,0))
|
||||
}
|
||||
|
||||
define("submit", Privilege.ADMIN) { _, _ ->
|
||||
star.fire()
|
||||
}
|
||||
|
||||
define("resetsprite", Privilege.ADMIN) { player, _ ->
|
||||
player.savedData.globalData.starSpriteDelay = 0L
|
||||
}
|
||||
}
|
||||
|
||||
override fun startup() {
|
||||
SystemLogger.logInfo("Shooting Stars initialized.")
|
||||
}
|
||||
|
||||
private data class ScoreboardEntry(val player: String, val time: Int)
|
||||
|
||||
private class RingDialogue(val shouldWarn: Boolean, val star: ShootingStar) : DialogueFile(){
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
if(shouldWarn){
|
||||
when(stage) {
|
||||
0 -> dialogue("WARNING: That mining site is located in the wilderness.").also { stage++ }
|
||||
1 -> player!!.dialogueInterpreter.sendOptions("Continue?","Yes","No").also { stage++ }
|
||||
2 -> when(buttonID){
|
||||
1 -> teleport(player!!, star).also { end() }
|
||||
2 -> end()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when(stage){
|
||||
0 -> player!!.dialogueInterpreter.sendOptions("Teleport to the Star?", "Yes", "No").also { stage++ }
|
||||
1 -> when(buttonID){
|
||||
1 -> teleport(player!!, star).also { end() }
|
||||
2 -> end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun teleport(player: Player, star: ShootingStar){
|
||||
teleport(player, star.crash_locations[star.location]!!.transform(0, -1, 0), TeleportManager.TeleportType.MINIGAME)
|
||||
getRingStoreFile()[player.username.toLowerCase()] = true
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val star = ShootingStar()
|
||||
private val tickDelay = if(GameWorld.settings?.isDevMode == true) 200 else 25000
|
||||
private val scoreboardEntries = ArrayList<ScoreboardEntry>()
|
||||
private val scoreboardIface = 787
|
||||
val SHOOTING_STARS = ShootingStarType.values().map(ShootingStarType::objectId).toIntArray()
|
||||
val STAR_DUST = Items.STARDUST_13727
|
||||
val RING = Items.RING_OF_THE_STAR_SPRITE_14652
|
||||
|
||||
|
||||
@JvmStatic fun submitScoreBoard(player: Player)
|
||||
{
|
||||
if(scoreboardEntries.size == 5)
|
||||
scoreboardEntries.removeAt(0)
|
||||
scoreboardEntries.add(ScoreboardEntry(player.username, GameWorld.ticks))
|
||||
}
|
||||
|
||||
@JvmStatic fun getStar(): ShootingStar
|
||||
{
|
||||
return star
|
||||
}
|
||||
|
||||
@JvmStatic fun getStoreFile() : JSONObject {
|
||||
return ServerStore.getArchive("shooting-star")
|
||||
}
|
||||
|
||||
@JvmStatic fun getRingStoreFile() : JSONObject {
|
||||
return ServerStore.getArchive("daily-star-ring")
|
||||
}
|
||||
|
||||
fun getStarDust(player: Player): Int {
|
||||
return player.inventory.getAmount(STAR_DUST) + player.bank.getAmount(STAR_DUST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import core.game.content.dialogue.FacialExpression
|
|||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.tools.RandomFunction
|
||||
import org.json.simple.JSONObject
|
||||
import org.rs09.consts.Items
|
||||
|
|
@ -21,6 +22,7 @@ import java.util.concurrent.TimeUnit
|
|||
/**
|
||||
* Dialogue for the star sprite.
|
||||
*/
|
||||
@Initializable
|
||||
class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +72,7 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) {
|
|||
} else if (inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && getAttribute(player, "star-ring:bp-shown", false)) {
|
||||
playerl(FacialExpression.HALF_ASKING, "So about those rings...")
|
||||
stage = 2000
|
||||
} else if (getStoreFile().getBoolean(player.username.toLowerCase()) || !player.getInventory().contains(ShootingStarOptionHandler.STAR_DUST, 1)) {
|
||||
} else if (getStoreFile().getBoolean(player.username.toLowerCase()) || !player.getInventory().contains(ShootingStarPlugin.STAR_DUST, 1)) {
|
||||
npc("Hello, strange creature.")
|
||||
stage = 0
|
||||
} else {
|
||||
|
|
@ -185,8 +187,8 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) {
|
|||
41 -> end()
|
||||
50 -> {
|
||||
val wearingRing = inEquipment(player, Items.RING_OF_THE_STAR_SPRITE_14652)
|
||||
val dust = if (player.getInventory().getAmount(ShootingStarOptionHandler.STAR_DUST) > 200) 200 else player.getInventory().getAmount(ShootingStarOptionHandler.STAR_DUST)
|
||||
if (player.getInventory().remove(Item(ShootingStarOptionHandler.STAR_DUST, dust))) {
|
||||
val dust = if (player.getInventory().getAmount(ShootingStarPlugin.STAR_DUST) > 200) 200 else player.getInventory().getAmount(ShootingStarPlugin.STAR_DUST)
|
||||
if (player.getInventory().remove(Item(ShootingStarPlugin.STAR_DUST, dust))) {
|
||||
val cosmicRunes = (Math.ceil(0.76 * dust) * AMPLIFIER).toInt()
|
||||
val astralRunes = (Math.ceil(0.26 * dust) * AMPLIFIER).toInt()
|
||||
val goldOre = (Math.ceil(0.1 * dust) * AMPLIFIER).toInt()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit
|
|||
* Handles the work-for actions for the NPCs
|
||||
* @author Ceikry
|
||||
*/
|
||||
class WorkForInteractionListener : InteractionListener(), LoginListener {
|
||||
class WorkForInteractionListener : InteractionListener, LoginListener {
|
||||
val possibleWeaponLooks = arrayListOf(
|
||||
Items.BRONZE_SCIMITAR_1321,
|
||||
Items.STEEL_SCIMITAR_1325,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import api.*
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class DSEquipListeners : InteractionListener() {
|
||||
class DSEquipListeners : InteractionListener {
|
||||
|
||||
private val restrictedItems = intArrayOf(
|
||||
Items.RUNE_PLATEBODY_1127,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class JohnathonAntiPosionInteraction: InteractionListener() {
|
||||
class JohnathonAntiPosionInteraction: InteractionListener {
|
||||
override fun defineListeners() {
|
||||
val poisons = intArrayOf(Items.ANTIPOISON4_2446, Items.ANTIPOISON3_175, Items.ANTIPOISON2_177, Items.ANTIPOISON1_179)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ fun doDoor(player: Player, scenery: Scenery) {
|
|||
|
||||
}
|
||||
|
||||
class WitchavenLeverInteraction : InteractionListener() {
|
||||
class WitchavenLeverInteraction : InteractionListener {
|
||||
val DOWN_ANIMATION = Animation(2140)
|
||||
val UP_ANIMATION = Animation(2139)
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class BrotherCedricDialogue : DialogueFile() {
|
|||
* Handles BrotherCedricListener to launch the dialogue
|
||||
* @author Kya
|
||||
*/
|
||||
class BrotherCedricListener : InteractionListener() {
|
||||
class BrotherCedricListener : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPCs.BROTHER_CEDRIC_280, NPC, "talk-to"){ player, _ ->
|
||||
player.dialogueInterpreter.open(BrotherCedricDialogue(), NPC(NPCs.BROTHER_CEDRIC_280))
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class BrotherOmadDialogue : DialogueFile() {
|
|||
* Handles BrotherCedricListener to launch the dialogue
|
||||
* @author Kya
|
||||
*/
|
||||
class BrotherOmadListener : InteractionListener() {
|
||||
class BrotherOmadListener : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPCs.BROTHER_OMAD_279, NPC, "talk-to"){ player, _ ->
|
||||
player.dialogueInterpreter.open(BrotherOmadDialogue(), NPC(NPCs.BROTHER_OMAD_279))
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class MonasteryMonkDialogue : DialogueFile() {
|
|||
* Handles BrotherCedricListener to launch the dialogue
|
||||
* @author Kya
|
||||
*/
|
||||
class MonasteryMonkListener : InteractionListener() {
|
||||
class MonasteryMonkListener : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
on(NPCs.MONK_281, NPC, "talk-to"){ player, _ ->
|
||||
player.dialogueInterpreter.open(MonasteryMonkDialogue(), NPC(NPCs.MONK_281))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import rs09.game.system.SystemLogger
|
|||
import rs09.game.system.config.ShopParser
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class NSListeners : InteractionListener() {
|
||||
class NSListeners : InteractionListener {
|
||||
|
||||
val GROTTO_TREE = 3517
|
||||
val GROTTO_ENTRANCE = 3516
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import rs09.game.world.GameWorld.Pulser
|
|||
import kotlin.math.abs
|
||||
import kotlin.math.atan2
|
||||
|
||||
class HunterTalismanListener : InteractionListener() {
|
||||
class HunterTalismanListener : InteractionListener {
|
||||
|
||||
val TALISMAN = Items.HUNTERS_TALISMAN_3696
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import api.sendMessage
|
|||
import core.game.container.access.BitregisterAssembler
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class SeerLockInterfaceListener : InterfaceListener() {
|
||||
class SeerLockInterfaceListener : InterfaceListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
val LETTERONEBACK = 39
|
||||
val LETTERONEFORWARD = 40
|
||||
val LETTERTWOBACK = 35
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import rs09.game.content.dialogue.DialogueFile
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.tools.stringtools.RED
|
||||
|
||||
class SeersHouseListeners : InteractionListener() {
|
||||
class SeersHouseListeners : InteractionListener {
|
||||
|
||||
val WESTDOOR = 4165
|
||||
val EASTDOOR = 4166
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import rs09.game.system.config.ItemConfigParser
|
|||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
|
||||
class TFTInteractionListeners : InteractionListener(){
|
||||
class TFTInteractionListeners : InteractionListener{
|
||||
|
||||
val BEER = Items.BEER_1917
|
||||
val WORKER = NPCs.COUNCIL_WORKMAN_1287
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import core.game.node.entity.skill.gather.SkillingTool
|
|||
import core.game.world.map.Location
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class DramenTreeListener : InteractionListener() {
|
||||
class DramenTreeListener : InteractionListener {
|
||||
|
||||
val DRAMEN_TREE = 1292
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import rs09.game.world.GameWorld
|
|||
* handles pickpocketing sigmund during the lost tribe quest
|
||||
* @author Ceikry
|
||||
*/
|
||||
class PickpocketSigmund : InteractionListener(){
|
||||
class PickpocketSigmund : InteractionListener{
|
||||
val SIGMUND = NPCs.SIGMUND_2082
|
||||
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import api.setInterfaceText
|
|||
import core.game.world.map.Location
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class TTDoorCodeInterfaceListener : InterfaceListener() {
|
||||
class TTDoorCodeInterfaceListener : InterfaceListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
val LETTERONEBACK = 10
|
||||
val LETTERONEFORWARD = 11
|
||||
val LETTERTWOBACK = 12
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import core.game.world.update.flag.context.Animation
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class TribalTotemListeners : InteractionListener(){
|
||||
class TribalTotemListeners : InteractionListener{
|
||||
|
||||
val frontDoor = 2706
|
||||
val wizCrate = 2707
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import core.game.world.map.Location
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class WaterfallListeners : InteractionListener(){
|
||||
class WaterfallListeners : InteractionListener{
|
||||
|
||||
val HUDON = NPCs.HUDON_305
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* Handles tutorial-specific node interactions
|
||||
* @author Ceikry
|
||||
*/
|
||||
class TutorialListeners : InteractionListener() {
|
||||
class TutorialListeners : InteractionListener {
|
||||
val GUIDE_HOUSE_DOOR = 3014
|
||||
val COOKS_DOOR = 3017
|
||||
val COOKS_EXIT = 3018
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import core.tools.RandomFunction
|
|||
*/
|
||||
val SINISTER_CHEST_HERBS = arrayOf(Item(205, 2), Item(207, 3), Item(209), Item(211), Item(213), Item(219))
|
||||
|
||||
public class YanilleAgilityDungeonListeners : InteractionListener() {
|
||||
public class YanilleAgilityDungeonListeners : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
ZoneBuilder.configure(YanilleAgilityDungeon());
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class OrdanDialogue(player: Player? = null) : DialoguePlugin(player) {
|
|||
* just comment those options out if you don't want em
|
||||
* aka "WOW I CAN'T BELIEVE IT'S ALL CONDITIONALS*/
|
||||
|
||||
class OrdanUnnoteListener : InteractionListener() {
|
||||
class OrdanUnnoteListener : InteractionListener {
|
||||
val notedOre = intArrayOf(
|
||||
Items.IRON_ORE_441,
|
||||
Items.COPPER_ORE_437,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ private val FILL_ANIM = Animation(1649)
|
|||
private val WIND_ANIM = Animation(1648)
|
||||
private val SCOOP_ANIM = Animation(1650)
|
||||
|
||||
class BoneGrinderListener : InteractionListener() {
|
||||
class BoneGrinderListener : InteractionListener {
|
||||
|
||||
private val boneIDs = Bones.values().map { it.itemId }.toIntArray()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import rs09.game.world.GameWorld
|
|||
* Handles the corporeal beast warning interface
|
||||
* @author Ceikry
|
||||
*/
|
||||
class CorporealBeastWarningInterface : InterfaceListener(){
|
||||
class CorporealBeastWarningInterface : InterfaceListener{
|
||||
|
||||
val COMPONENT_ID = 650
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(COMPONENT_ID,17){player,component,_,_,_,_ ->
|
||||
if(player.getAttribute("corp-beast-cave-delay",0) <= GameWorld.ticks) {
|
||||
player.properties.teleportLocation = player.location.transform(4, 0, 0).also { close(player,component) }
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
package rs09.game.interaction
|
||||
|
||||
import api.ContentInterface
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.world.map.Location
|
||||
|
||||
abstract class InteractionListener : Listener{
|
||||
companion object {
|
||||
val ITEM = 0
|
||||
val SCENERY = 1
|
||||
val NPC = 2
|
||||
val GROUNDITEM = 3
|
||||
}
|
||||
interface InteractionListener : ContentInterface{
|
||||
val ITEM: Int
|
||||
get() = 0
|
||||
val SCENERY: Int
|
||||
get() = 1
|
||||
val NPC: Int
|
||||
get() = 2
|
||||
val GROUNDITEM: Int
|
||||
get() = 3
|
||||
|
||||
fun on(id: Int, type: Int, vararg option: String,handler: (player: Player, node: Node) -> Boolean){
|
||||
InteractionListeners.add(id,type,option,handler)
|
||||
}
|
||||
|
|
@ -65,4 +69,14 @@ abstract class InteractionListener : Listener{
|
|||
fun onDig(location: Location,method: (player: Player) -> Unit){
|
||||
SpadeDigListener.registerListener(location,method)
|
||||
}
|
||||
|
||||
fun defineListeners()
|
||||
|
||||
companion object
|
||||
{
|
||||
val ITEM = 0
|
||||
val SCENERY = 1
|
||||
val NPC = 2
|
||||
val GROUNDITEM = 3
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
package rs09.game.interaction
|
||||
|
||||
import api.ContentInterface
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.player.Player
|
||||
|
||||
abstract class InterfaceListener : Listener {
|
||||
/**
|
||||
* An interface for writing content that allows the class to handle game interface interactions
|
||||
*
|
||||
* Interactions should be defined in the required [defineInterfaceListeners] method.
|
||||
*/
|
||||
interface InterfaceListener : ContentInterface {
|
||||
fun defineInterfaceListeners()
|
||||
|
||||
fun on(componentID: Int, buttonID: Int, handler: (player: Player, component: Component, opcode: Int, buttonID: Int, slot: Int, itemID: Int) -> Boolean){
|
||||
InterfaceListeners.add(componentID,buttonID,handler)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ package rs09.game.interaction
|
|||
import api.StartupListener
|
||||
|
||||
interface Listener : StartupListener {
|
||||
fun defineListeners()
|
||||
override fun startup() {
|
||||
defineListeners()
|
||||
}
|
||||
|
||||
fun defineListeners()
|
||||
}
|
||||
|
|
@ -7,12 +7,12 @@ import org.rs09.consts.Components
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class CreditShopInterface : InterfaceListener() {
|
||||
class CreditShopInterface : InterfaceListener {
|
||||
|
||||
val CREDIT_SHOP = Components.CREDIT_SHOP
|
||||
val TEXT_CHILD = 39
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(CREDIT_SHOP){player, component, opcode, buttonID, slot, itemID ->
|
||||
val item = getItem(buttonID)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ val RING_3 = arrayOf('p','s','r','q')
|
|||
* Handles the fairy ring interface
|
||||
* @author Ceikry
|
||||
*/
|
||||
class FairyRingInterface : InterfaceListener(){
|
||||
class FairyRingInterface : InterfaceListener{
|
||||
|
||||
val RINGS = 734
|
||||
val TRAVEL_LOG = 735
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
|
||||
onOpen(RINGS){player, _ ->
|
||||
player.interfaceManager.openSingleTab(Component(TRAVEL_LOG))
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ import org.rs09.consts.Components
|
|||
import rs09.game.interaction.InterfaceListener
|
||||
import rs09.game.world.GameWorld.settings
|
||||
|
||||
class MainGameInterface : InterfaceListener() {
|
||||
class MainGameInterface : InterfaceListener {
|
||||
val TOPLEVEL = Components.TOPLEVEL_548
|
||||
val TOPLEVEL_FS = Components.TOPLEVEL_FULLSCREEN_746
|
||||
val RUN_BUTTON = Components.TOPSTAT_RUN_750
|
||||
val FILTER_BUTTONS = Components.FILTERBUTTONS_751
|
||||
val REPORT_ABUSE = Components.SNAPSHOT_MAIN_553
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(FILTER_BUTTONS){player, _, _, buttonID, _, _ ->
|
||||
if(buttonID == 27)
|
||||
openReport(player)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.rs09.consts.NPCs
|
|||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class NPCContactInterface : InterfaceListener() {
|
||||
class NPCContactInterface : InterfaceListener {
|
||||
val contactNPCs = arrayOf(NPCs.HONEST_JIMMY_4362, NPCs.BERT_3108, NPCs.ADVISOR_GHRIM_1375, NPCs.TURAEL_8273, NPCs.LANTHUS_1526, NPCs.SUMONA_7780, NPCs.MAZCHNA_8274, NPCs.DURADEL_8275, NPCs.VANNAKA_1597, NPCs.DARK_MAGE_2262, NPCs.CHAELDAR_1598, NPCs.CYRISUS_432, NPCs.LARRY_5424)
|
||||
val DialogueFiles = arrayOf<DialogueFile?>(
|
||||
/*TODO("Honest Jimmy"),
|
||||
|
|
@ -25,7 +25,7 @@ class NPCContactInterface : InterfaceListener() {
|
|||
TODO("Larry")*/
|
||||
)
|
||||
val INTER = 429
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
|
||||
//Remove a bunch of the buttons/heads so that people don't
|
||||
//waste runes on spells that aren't implemented
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ object RulesAndInfo {
|
|||
}
|
||||
}
|
||||
|
||||
class RulesListener : InterfaceListener()
|
||||
class RulesListener : InterfaceListener
|
||||
{
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
onClose(384){player, _ ->
|
||||
if(!getAttribute(player, "rules:confirmed", false))
|
||||
runTask(player, 1) { RulesAndInfo.openFor(player); sendDialogue(player, "Please read the rules.") }
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ import org.rs09.consts.Items
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class SilverInterface : InterfaceListener() {
|
||||
class SilverInterface : InterfaceListener {
|
||||
|
||||
val IFACE = Components.CRAFTING_SILVER_CASTING_438
|
||||
val ANIM = getAnimation(899)
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(IFACE){player, _ ->
|
||||
sendItemOnInterface(player, IFACE, 17, 1718)
|
||||
sendItemOnInterface(player, IFACE, 24, 1724)
|
||||
|
|
@ -89,7 +89,7 @@ class SilverInterface : InterfaceListener() {
|
|||
}
|
||||
}
|
||||
|
||||
class SilverBarUseWith : InteractionListener() {
|
||||
class SilverBarUseWith : InteractionListener {
|
||||
val FURNACES = intArrayOf(2966, 3044, 3294, 4304, 6189, 11009, 11010, 11666, 12100, 12809, 18497, 18525, 18526, 21879, 22721, 26814, 28433, 28434, 30021, 30510, 36956, 37651)
|
||||
override fun defineListeners() {
|
||||
onUseWith(SCENERY, Items.SILVER_BAR_2355, *FURNACES){ player, _, _ ->
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import core.game.world.update.flag.context.Graphics
|
|||
import org.rs09.consts.Components
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class TeleotherInterface : InterfaceListener() {
|
||||
class TeleotherInterface : InterfaceListener {
|
||||
val IFACE = Components.TELEPORT_OTHER_326
|
||||
|
||||
override fun defineListeners() {
|
||||
override fun defineInterfaceListeners() {
|
||||
on(IFACE){player, _, _, button, _, _ ->
|
||||
if(button == 5){
|
||||
player.lock(2)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import core.game.node.entity.player.Player
|
|||
import org.rs09.consts.Components
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
|
||||
class ExchangeItemSets : InterfaceListener() {
|
||||
override fun defineListeners() {
|
||||
class ExchangeItemSets : InterfaceListener {
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(Components.EXCHANGE_ITEMSETS_645) { player, _ ->
|
||||
val listener: InventoryListener
|
||||
setAttribute(player, "ge-listener", InventoryListener(player).also { listener = it })
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import rs09.game.system.SystemLogger
|
|||
* Handles the grand exchange interface (Stock Market)
|
||||
* @author Ceikry
|
||||
*/
|
||||
class StockMarket : InterfaceListener() {
|
||||
override fun defineListeners() {
|
||||
class StockMarket : InterfaceListener {
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(Components.STOCKMARKET_105){player, _ ->
|
||||
player.packetDispatch.sendInterfaceConfig(105, 193, true)
|
||||
player.packetDispatch.sendAccessMask(6, 211, 105, -1, -1)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* Handles the bracelet of clay operate option.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class BraceletOfClayPlugin : InteractionListener() {
|
||||
class BraceletOfClayPlugin : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* @author bushtail
|
||||
*/
|
||||
|
||||
class CadavaPotionListener : InteractionListener() {
|
||||
class CadavaPotionListener : InteractionListener {
|
||||
|
||||
var POTION = Items.CADAVA_POTION_756
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import api.*
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class DrinkBlamishOilListener : InteractionListener() {
|
||||
class DrinkBlamishOilListener : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
on(Items.BLAMISH_OIL_1582, ITEM, "drink"){player, _ ->
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import java.util.*
|
|||
* Listener for enchanted jewellery options
|
||||
* @author Ceikry
|
||||
*/
|
||||
class EnchantedJewelleryListener : InteractionListener() {
|
||||
class EnchantedJewelleryListener : InteractionListener {
|
||||
val IDs: IntArray
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import rs09.game.content.dialogue.DialogueFile
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class GodBookListeners : InteractionListener() {
|
||||
class GodBookListeners : InteractionListener {
|
||||
|
||||
val GB_SARADOMIN = Items.HOLY_BOOK_3840
|
||||
val GB_ZAMORAK = Items.UNHOLY_BOOK_3842
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ private const val LAUNCH_ANIMATION = 4547
|
|||
* Handles the grand tree pod options
|
||||
* @author Ceikry
|
||||
*/
|
||||
class GrandSeedPodHandler : InteractionListener() {
|
||||
class GrandSeedPodHandler : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
on(Items.GRAND_SEED_POD_9469, ITEM, "squash", "launch"){player, _ ->
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import rs09.game.content.global.WeightedItem
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.system.SystemLogger
|
||||
|
||||
class ImplingJarListener : InteractionListener() {
|
||||
class ImplingJarListener : InteractionListener {
|
||||
|
||||
val JARS = ImplingLoot.values().map { it.jarId }.toIntArray()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.rs09.consts.Items
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InteractionListeners.run
|
||||
|
||||
class ItemQuestRequirementListener : InteractionListener() {
|
||||
class ItemQuestRequirementListener : InteractionListener {
|
||||
|
||||
private val fremennikIslesEquipment = intArrayOf(Items.HELM_OF_NEITIZNOT_10828, Items.HELM_OF_NEITIZNOT_E_12680, Items.HELM_OF_NEITIZNOT_CHARGED_12681)
|
||||
private val fremennikTrialsEquipment = intArrayOf(Items.BERSERKER_HELM_3751, Items.BERSERKER_HELM_13408, Items.BERSERKER_HELM_E_12674, Items.BERSERKER_HELM_CHARGED_12675,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import rs09.tools.END_DIALOGUE
|
|||
/**
|
||||
* Handles the Staff of the Raven's (2021 Hween Reward) Recolor Transformation
|
||||
*/
|
||||
class StaffOfTheRaven : InteractionListener() {
|
||||
class StaffOfTheRaven : InteractionListener {
|
||||
val ids = intArrayOf(14654, 14655, 14656)
|
||||
override fun defineListeners() {
|
||||
on(ids, ITEM, "recolor", "operate"){player, node ->
|
||||
|
|
|
|||
|
|
@ -1,94 +0,0 @@
|
|||
package rs09.game.interaction.item
|
||||
|
||||
import api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.TeleportManager
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.world.map.Location
|
||||
import org.json.simple.JSONObject
|
||||
import org.rs09.consts.Items
|
||||
import rs09.ServerStore
|
||||
import rs09.ServerStore.Companion.getBoolean
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.content.global.worldevents.shootingstar.ShootingStar
|
||||
import rs09.game.content.global.worldevents.shootingstar.ShootingStarEvent
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class StarRingListener : InteractionListener(){
|
||||
|
||||
val RING = Items.RING_OF_THE_STAR_SPRITE_14652
|
||||
|
||||
override fun defineListeners() {
|
||||
on(RING, ITEM, "rub", "operate"){player, node ->
|
||||
val star = WorldEvents.get("shooting-stars") as? ShootingStarEvent
|
||||
|
||||
if(star == null) sendDialogue(player, "There is currently no active star.").also { return@on true }
|
||||
|
||||
if(getStoreFile().getBoolean(player.username.toLowerCase())){
|
||||
sendDialogue(player, "The ring is still recharging.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
val condition: (Player) -> Boolean = when(star?.star!!.location.toLowerCase()){
|
||||
"canifis bank" -> { p -> p.questRepository.isComplete("Priest in Peril")}
|
||||
"crafting guild" -> {p -> hasLevelStat(p, Skills.CRAFTING, 40) }
|
||||
"south crandor mining site" -> {p -> p.questRepository.isComplete("Dragon Slayer")}
|
||||
else -> {_ -> true}
|
||||
}
|
||||
|
||||
if(!condition.invoke(player) || player.skullManager.isWilderness){
|
||||
sendDialogue(player, "Magical forces prevent your teleportation.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
val shouldWarn = when(star.star.location){
|
||||
"North Edgeville mining site",
|
||||
"Southern wilderness mine",
|
||||
"Pirates' Hideout mine",
|
||||
"Lava Maze mining site",
|
||||
"Mage Arena bank" -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
openDialogue(player, RingDialogue(shouldWarn, star.star))
|
||||
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
|
||||
internal class RingDialogue(val shouldWarn: Boolean, val star: ShootingStar) : DialogueFile(){
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
if(shouldWarn){
|
||||
when(stage) {
|
||||
0 -> dialogue("WARNING: That mining site is located in the wilderness.").also { stage++ }
|
||||
1 -> player!!.dialogueInterpreter.sendOptions("Continue?","Yes","No").also { stage++ }
|
||||
2 -> when(buttonID){
|
||||
1 -> teleport(player!!, star).also { end() }
|
||||
2 -> end()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when(stage){
|
||||
0 -> player!!.dialogueInterpreter.sendOptions("Teleport to the Star?", "Yes", "No").also { stage++ }
|
||||
1 -> when(buttonID){
|
||||
1 -> teleport(player!!, star).also { end() }
|
||||
2 -> end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun teleport(player: Player, star: ShootingStar){
|
||||
teleport(player, star.crash_locations[star.location]!!.transform(0, -1, 0), TeleportManager.TeleportType.MINIGAME)
|
||||
getStoreFile()[player.username.toLowerCase()] = true
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getStoreFile(): JSONObject {
|
||||
return ServerStore.getArchive("daily-star-ring")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import rs09.game.interaction.InteractionListener
|
|||
* Interaction listener for the Toy Horsey item
|
||||
* @author Woah
|
||||
*/
|
||||
class ToyHorseListener : InteractionListener() {
|
||||
class ToyHorseListener : InteractionListener {
|
||||
|
||||
// Map of horse item ids to their correct emote
|
||||
val HORSEY_MAP = mapOf(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import core.game.world.update.flag.context.Graphics
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class ToyListeners : InteractionListener() {
|
||||
class ToyListeners : InteractionListener {
|
||||
companion object {
|
||||
val MARIONETTES = intArrayOf(Items.RED_MARIONETTE_6867, Items.GREEN_MARIONETTE_6866, Items.BLUE_MARIONETTE_6865)
|
||||
private val MARIONETTE_JUMP = Animation(3003)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import api.*
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class HaySackOnSpear : InteractionListener() {
|
||||
class HaySackOnSpear : InteractionListener {
|
||||
val HAYSACK = Items.HAY_SACK_6057
|
||||
val SPEAR = Items.BRONZE_SPEAR_1237
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import core.game.world.update.flag.context.Animation
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class OilFishingRodListener : InteractionListener() {
|
||||
class OilFishingRodListener : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
onUseWith(ITEM, Items.BLAMISH_OIL_1582, Items.FISHING_ROD_307) {player, used, with ->
|
||||
player.pulseManager.run(object : Pulse() {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import rs09.game.interaction.InteractionListener
|
|||
import kotlin.collections.toIntArray
|
||||
import kotlin.math.min
|
||||
|
||||
class PoisonedWeaponListeners : InteractionListener() {
|
||||
class PoisonedWeaponListeners : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
val poisons = intArrayOf(Items.WEAPON_POISON_187, Items.WEAPON_POISON_PLUS_5937, Items.WEAPON_POISON_PLUS_PLUS_5940)
|
||||
val poisonableItems = PoisonSets.itemMap.keys.toIntArray()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import rs09.game.content.dialogue.DialogueFile
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class TOTTHelmOnCape : InteractionListener() {
|
||||
class TOTTHelmOnCape : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
onUseWith(ITEM, Items.SLAYER_HELMET_13263, Items.SLAYER_CAPE_9786, Items.SLAYER_CAPET_9787){ player, used, with ->
|
||||
val alreadyHasHelm = getAttribute(player, "cape_perks:tott:helmet-stored", false)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import core.game.node.entity.skill.Skills
|
|||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class WatermelonOnSack : InteractionListener() {
|
||||
class WatermelonOnSack : InteractionListener {
|
||||
val SACK = Items.HAY_SACK_6058
|
||||
val WATERMELON = Items.WATERMELON_5982
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.rs09.consts.NPCs
|
|||
import rs09.game.content.dialogue.region.examcentre.ArchaeologistcalExpertUsedOnDialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
open class ArchaeologicalExpertListener() : InteractionListener() {
|
||||
open class ArchaeologicalExpertListener() : InteractionListener {
|
||||
val staff = Items.ANCIENT_STAFF_4675
|
||||
val unidentifiedLiquid = Items.UNIDENTIFIED_LIQUID_702
|
||||
val nitroglycerin = Items.NITROGLYCERIN_703
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import core.game.node.entity.player.link.diary.DiaryType
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class BonesOnStrayDog : InteractionListener() {
|
||||
class BonesOnStrayDog : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
val bones = Bones.array
|
||||
val dogs = intArrayOf(NPCs.STRAY_DOG_4766, NPCs.STRAY_DOG_4767, NPCs.STRAY_DOG_5917, NPCs.STRAY_DOG_5918)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class CatOnArdougneCivilian: InteractionListener() {
|
||||
class CatOnArdougneCivilian: InteractionListener {
|
||||
|
||||
private val civilians = intArrayOf(
|
||||
NPCs.CIVILIAN_785,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import org.rs09.consts.Items
|
|||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class CiderOnForester : InteractionListener() {
|
||||
class CiderOnForester : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
val ids = intArrayOf(1,2,3,4,5)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.rs09.consts.NPCs
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
|
||||
class GCItemOnCat : InteractionListener() {
|
||||
class GCItemOnCat : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
val GERTCAT = "Gertrude's Cat"
|
||||
val BEND_DOWN = 827
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import rs09.game.content.dialogue.DialogueFile
|
|||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
val graphics = 482
|
||||
class HatEasterEgg : InteractionListener(){
|
||||
class HatEasterEgg : InteractionListener {
|
||||
|
||||
val MACHINE = 20040
|
||||
val WIZ_HAT = Items.WIZARD_HAT_579
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import rs09.game.content.dialogue.DialogueFile
|
|||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class MistagEasterEgg : InteractionListener() {
|
||||
class MistagEasterEgg : InteractionListener {
|
||||
val DIAMOND = Items.DIAMOND_1601
|
||||
val MISTAG = NPCs.MISTAG_2084
|
||||
val ZANIK_RING = 14649
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.rs09.consts.NPCs
|
|||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class PoisonChaliceOnKingArthur : InteractionListener() {
|
||||
class PoisonChaliceOnKingArthur : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
onUseWith(NPC, Items.POISON_CHALICE_197, NPCs.KING_ARTHUR_251){player, used, with ->
|
||||
player.dialogueInterpreter.open(PoisonChaliceOnKingArthurDialogue(),with)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue