diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index 72d959a10..17024af16 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -56,7 +56,6 @@ import rs09.game.world.repository.Repository * @param pickaxe whether or not we are trying to get a pickaxe. * @return the tool which meets the requirements or null if none. */ - fun getTool(player: Player, pickaxe: Boolean): SkillingTool? { return if(pickaxe) SkillingTool.getPickaxe(player) else SkillingTool.getHatchet(player) } @@ -68,7 +67,6 @@ fun getTool(player: Player, pickaxe: Boolean): SkillingTool? { * @param level the level to check against * @return true if the check succeeds, false otherwise */ - fun hasLevelDyn(player: Player, skill: Int, level: Int): Boolean { return player.skills.getLevel(skill) >= level } @@ -80,7 +78,6 @@ fun hasLevelDyn(player: Player, skill: Int, level: Int): Boolean { * @param level the level to check against * @return true if the check succeeds, false otherwise */ - fun hasLevelStat(player: Player, skill: Int, level: Int): Boolean { return player.skills.getStaticLevel(skill) >= level } @@ -92,7 +89,6 @@ fun hasLevelStat(player: Player, skill: Int, level: Int): Boolean { * @param amount the amount to check for * @return true if the player has >= the given item in the given amount, false otherwise. */ - fun inInventory(player: Player, item: Int, amount: Int = 1): Boolean { return player.inventory.contains(item, amount) } @@ -103,7 +99,6 @@ fun inInventory(player: Player, item: Int, amount: Int = 1): Boolean { * @param id the ID of the item to check for the amount of * @return the amount of the given ID in the player's inventory */ - fun amountInInventory(player: Player, id: Int): Int{ return player.inventory.getAmount(id) } @@ -114,7 +109,6 @@ fun amountInInventory(player: Player, id: Int): Int{ * @param id the ID of the item to check for * @return the amount of the ID in the player's bank. */ - fun amountInBank(player: Player, id: Int): Int{ return player.bank.getAmount(id) } @@ -125,7 +119,6 @@ fun amountInBank(player: Player, id: Int): Int{ * @param id the ID of the item to check for * @return the amount of the ID in the player's equipment. */ - fun amountInEquipment(player: Player, id: Int): Int{ return player.equipment.getAmount(id) } @@ -137,6 +130,23 @@ fun isEquipped(player: Player, id: Int): Boolean { return amountInEquipment(player, id) > 0 } +data class ContainerisedItem(val container: core.game.container.Container?, val itemId: Int) + +/** + * Check if player has any of the specified item IDs equipped, in inventory, or in banks + * Returns a ContainerisedItem containing the container and the item ID if found, otherwise ContainerisedItem(null, -1) if not found + */ +fun hasAnItem(player: Player, vararg ids: Int): ContainerisedItem { + for (searchSpace in arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary)) { + for (id in ids) { + if (searchSpace.containItems(id)) { + return ContainerisedItem(searchSpace, id) + } + } + } + return ContainerisedItem(null, -1) +} + /** * Check if a player has an item equipped which corresponds to the given God * @param player the player to check @@ -155,7 +165,6 @@ fun hasGodItem(player: Player, god: God): Boolean * @param item the ID or Item object to remove from the player's inventory * @param container the Container to remove the items from. An enum exists for this in the api package called Container. Ex: api.Container.BANK */ - fun removeItem(player: Player, item: T, container: Container = Container.INVENTORY): Boolean { item ?: return false val it = when (item) { @@ -213,7 +222,6 @@ fun replaceSlot(player: Player, slot: Int, item: Item, container: Container = Co * @param id the ID of the item to add to the player's inventory * @param amount the amount of the ID to add to the player's inventory, defaults to 1 */ - fun addItemOrDrop(player: Player, id: Int, amount: Int = 1){ val item = Item(id, amount) if(!player.inventory.add(item)) GroundItemManager.create(item,player) @@ -223,7 +231,6 @@ fun addItemOrDrop(player: Player, id: Int, amount: Int = 1){ * Clears an NPC with the "poof" smoke graphics commonly seen with random event NPCs. * @param npc the NPC object to initialize */ - fun poofClear(npc: NPC){ submitWorldPulse(object : Pulse(){ var counter = 0 @@ -246,7 +253,6 @@ fun poofClear(npc: NPC){ * @param amount the amount to check for, defaults to 1 * @return true if the item exists in the given amount in the player's bank */ - fun inBank(player: Player, item: Int, amount: Int = 1): Boolean { return player.bank.contains(item, amount) } @@ -258,7 +264,6 @@ fun inBank(player: Player, item: Int, amount: Int = 1): Boolean { * @param amount the amount to check for, defaults to 1 * @return true if the item exists in the given amount in the player's equipment */ - fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean { return player.equipment.contains(item, amount) } @@ -268,7 +273,6 @@ fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean { * @param player the player to check * @return the number of free slots in the player's inventory */ - fun freeSlots(player: Player): Int { return player.inventory.freeSlots() } @@ -278,7 +282,6 @@ fun freeSlots(player: Player): Int { * @param id the ID of the animation to use * @return an Animation object with the given ID. */ - fun getAnimation(id: Int): Animation { return Animation(id) } @@ -289,7 +292,6 @@ fun getAnimation(id: Int): Animation { * @param priority the Animator.Priority enum instance to represent the desired priority * @return an Animation object with the given ID and priority */ - fun getAnimationWithPriority(id: Int, priority: Animator.Priority): Animation { return Animation(id, Animator.Priority.values()[priority.ordinal]) } @@ -298,7 +300,6 @@ fun getAnimationWithPriority(id: Int, priority: Animator.Priority): Animation { * Reset a player's animator * @param player the player whose animator to reset */ - fun resetAnimator(player: Player) { player.animator.animate(Animation(-1, Animator.Priority.VERY_HIGH)) } @@ -308,7 +309,6 @@ fun resetAnimator(player: Player) { * @param animation the Animation object to check the duration of * @return the number of ticks the given animation lasts for */ - fun animationDuration(animation: Animation): Int { return animation.definition.durationTicks } @@ -319,7 +319,6 @@ fun animationDuration(animation: Animation): Int { * @param skill the Skill ID to reward XP for. There is a Skills enum you can use for this. Example: Skills.STRENGTH * @param amount the amount, including decimal place, of experience to award */ - fun rewardXP(player: Player, skill: Int, amount: Double) { player.skills.addExperience(skill, amount) } @@ -331,7 +330,6 @@ fun rewardXP(player: Player, skill: Int, amount: Double) { * @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent. * @param loc the location to move the new object to if necessary. Defaults to null. */ - fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, loc: Location? = null) { val newLoc = when(loc){ null -> toReplace.location @@ -353,7 +351,6 @@ fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, loc: Location? * @Param rotation the Direction of the rotation it should use. Direction.NORTH, Direction.SOUTH, etc * @param loc the location to move the new object to if necessary. Defaults to null. */ - fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, rotation: Direction, loc: Location? = null){ val newLoc = when(loc){ null -> toReplace.location @@ -382,7 +379,6 @@ fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, rotation: Dire * @param id the ID of the item to get the name of * @return the name of the item */ - fun getItemName(id: Int): String { return ItemDefinition.forId(id).name } @@ -391,7 +387,6 @@ fun getItemName(id: Int): String { * Removes a ground item * @param node the GroundItem object to remove */ - fun removeGroundItem(node: GroundItem) { GroundItemManager.destroy(node) } @@ -401,7 +396,6 @@ fun removeGroundItem(node: GroundItem) { * @param node the GroundItem object to check the validity of * @return true if the node is valid, false otherwise */ - fun isValidGroundItem(node: GroundItem): Boolean { return GroundItemManager.getItems().contains(node) } @@ -412,7 +406,6 @@ fun isValidGroundItem(node: GroundItem): Boolean { * @param item the Item to check against * @return true if the player's inventory has space for the item */ - fun hasSpaceFor(player: Player, item: Item): Boolean { return player.inventory.hasSpaceFor(item) } @@ -420,7 +413,6 @@ fun hasSpaceFor(player: Player, item: Item): Boolean { /** * Get the number of ticks passed since server startup */ - fun getWorldTicks(): Int { return GameWorld.ticks } @@ -428,7 +420,6 @@ fun getWorldTicks(): Int { /** * Gets an Audio object with specified id, volume, etc */ - fun getAudio(id: Int, volume: Int = 10, delay: Int = 1): Audio { return Audio(id, volume, delay) } @@ -439,7 +430,6 @@ fun getAudio(id: Int, volume: Int = 10, delay: Int = 1): Audio { * @param amount the amount of damage to deal * @param type the type of hit splat to use, ImpactHandler.HitsplatType is an enum containing these options. */ - fun impact(entity: Entity, amount: Int, type: ImpactHandler.HitsplatType = ImpactHandler.HitsplatType.NORMAL) { entity.impactHandler.manualHit(entity, amount, type) } @@ -449,7 +439,6 @@ fun impact(entity: Entity, amount: Int, type: ImpactHandler.HitsplatType = Impac * @param id the ID of the item to get the definition of * @return the ItemDefinition for the given ID. */ - fun itemDefinition(id: Int): ItemDefinition { return ItemDefinition.forId(id) } @@ -457,7 +446,6 @@ fun itemDefinition(id: Int): ItemDefinition { /** * Send an object animation */ - fun animateScenery(player: Player, obj: Scenery, animationId: Int, global: Boolean = false) { player.packetDispatch.sendSceneryAnimation(obj, getAnimation(animationId), global) } @@ -465,7 +453,6 @@ fun animateScenery(player: Player, obj: Scenery, animationId: Int, global: Boole /** * Send an object animation independent of a player */ - fun animateScenery(obj: Scenery, animationId: Int){ val animation = Animation(animationId) animation.setObject(obj) @@ -475,7 +462,6 @@ fun animateScenery(obj: Scenery, animationId: Int){ /** * Produce a ground item owned by the player */ - fun produceGroundItem(player: Player, item: Int) { GroundItemManager.create(Item(item), player) } @@ -483,7 +469,6 @@ fun produceGroundItem(player: Player, item: Int) { /** * Spawns a projectile */ - fun spawnProjectile(source: Entity, dest: Entity, projectileId: Int) { Projectile.create(source, dest, projectileId).send() } @@ -499,7 +484,6 @@ fun spawnProjectile(source: Entity, dest: Entity, projectileId: Int) { * @param speed the speed the projectile travels at * @param angle the angle the projectile travels at */ - fun spawnProjectile(source: Location, dest: Location, projectile: Int, startHeight: Int, endHeight: Int, delay: Int, speed: Int, angle: Int){ Projectile.create(source, dest, projectile, startHeight, endHeight, delay, speed, angle, source.getDistance(dest).toInt()).send() } @@ -510,7 +494,6 @@ fun spawnProjectile(source: Location, dest: Location, projectile: Int, startHeig * @param toFace the thing to face * @param duration how long you wish to face the thing for */ - fun face(entity: Entity, toFace: Node, duration: Int = -1) { if (duration == -1) { when (toFace) { @@ -530,7 +513,6 @@ fun face(entity: Entity, toFace: Node, duration: Int = -1) { * @param player the player to open the interface for * @param id the ID of the interface to open */ - fun openInterface(player: Player, id: Int) { player.interfaceManager.open(Component(id)) } @@ -540,7 +522,6 @@ fun openInterface(player: Player, id: Int) { * @param player the player to open the interface for * @param id the ID of the interface to open */ - fun openOverlay(player: Player, id: Int){ player.interfaceManager.openOverlay(Component(id)) } @@ -549,7 +530,6 @@ fun openOverlay(player: Player, id: Int){ * Closes any open overlays for the given player * @param player the player to close for */ - fun closeOverlay(player: Player){ player.interfaceManager.closeOverlay() } @@ -559,7 +539,6 @@ fun closeOverlay(player: Player){ * @param entity the entity to run the emote on * @param emote the Emotes enum entry to run */ - fun emote(entity: Entity, emote: Emotes) { entity.animate(emote.animation) } @@ -568,7 +547,6 @@ fun emote(entity: Entity, emote: Emotes) { * Sends a message to the given player. * @param player the player to send the message to. */ - fun sendMessage(player: Player, message: String) { player.sendMessage(message) } @@ -578,7 +556,6 @@ fun sendMessage(player: Player, message: String) { * @param entity the entity to send the chat for * @param message the message to display */ - fun sendChat(entity: Entity, message: String) { entity.sendChat(message) } @@ -588,7 +565,6 @@ fun sendChat(entity: Entity, message: String) { * @param player the player to send the dialogue to * @param message the message to send, lines are split automatically. */ - fun sendDialogue(player: Player, message: String) { player.dialogueInterpreter.sendDialogue(*splitLines(message)) } @@ -599,7 +575,6 @@ fun sendDialogue(player: Player, message: String) { * @param anim the animation to play, can be an ID or an Animation object. * @param forced whether or not to force the animation (usually not necessary) */ - fun animate(entity: Entity, anim: T, forced: Boolean = false) { val animation = when(anim){ is Int -> Animation(anim) @@ -620,7 +595,6 @@ fun animate(entity: Entity, anim: T, forced: Boolean = false) { * @param audio the Audio to play * @param global if other nearby entities should be able to hear it */ - fun playAudio(player: Player, audio: Audio, global: Boolean = false) { player.audioManager.send(audio, global) } @@ -631,7 +605,6 @@ fun playAudio(player: Player, audio: Audio, global: Boolean = false) { * @param dialogue either the dialogue key or an instance of a DialogueFile * @param args various args to pass to the opened dialogue */ - fun openDialogue(player: Player, dialogue: Any, vararg args: Any) { player.dialogueInterpreter.close() when (dialogue) { @@ -647,7 +620,6 @@ fun openDialogue(player: Player, dialogue: Any, vararg args: Any) { * @param id the ID of the NPC to locate * @returns an NPC instance matching the ID if it finds one, null otherwise */ - fun findNPC(id: Int): NPC? { return Repository.findNPC(id) } @@ -658,7 +630,6 @@ fun findNPC(id: Int): NPC? { * @param y the Y coordinate to use * @param z the Z coordinate to use */ - fun getScenery(x: Int, y: Int, z: Int): Scenery?{ return RegionManager.getObject(z,x,y) } @@ -667,7 +638,6 @@ fun getScenery(x: Int, y: Int, z: Int): Scenery?{ * Gets the spawned scenery from the world map using the given Location object. * @param loc the Location object to use. */ - fun getScenery(loc: Location): Scenery?{ return RegionManager.getObject(loc) } @@ -678,7 +648,6 @@ fun getScenery(loc: Location): Scenery?{ * @param id the ID of the NPC to locate * @returns an NPC instance matching the ID if it finds one, null otherwise */ - fun findNPC(refLoc: Location, id: Int): NPC? { return Repository.npcs.firstOrNull { it.id == id && it.location.withinDistance(refLoc) } } @@ -689,7 +658,6 @@ fun findNPC(refLoc: Location, id: Int): NPC? { * @param id the ID of the NPC to locate * @returns an NPC matching the given ID or null if none is found */ - fun findLocalNPC(entity: Entity, id: Int): NPC? { return RegionManager.getLocalNpcs(entity).firstOrNull { it.id == id } } @@ -699,7 +667,6 @@ fun findLocalNPC(entity: Entity, id: Int): NPC? { * @param entity the entity to check around * @param ids the IDs of the NPCs to look for */ - fun findLocalNPCs(entity: Entity, ids: IntArray): List{ return RegionManager.getLocalNpcs(entity).filter { it.id in ids }.toList() } @@ -710,7 +677,6 @@ fun findLocalNPCs(entity: Entity, ids: IntArray): List{ * @param ids the IDs of the NPCs to look for * @param distance The maximum distance to the entity. */ - fun findLocalNPCs(entity: Entity, ids: IntArray, distance: Int): List{ return RegionManager.getLocalNpcs(entity, distance).filter { it.id in ids }.toList() } @@ -730,7 +696,6 @@ fun getRegionBorders(regionId: Int) : ZoneBorders * @param attribute the attribute key to use * @param default the default value to return if the attribute does not exist */ - fun getAttribute(entity: Entity, attribute: String, default: T): T { return entity.getAttribute(attribute, default) } @@ -741,7 +706,6 @@ fun getAttribute(entity: Entity, attribute: String, default: T): T { * @param attribute the attribute key to use * @param value the value to set the attribute to */ - fun setAttribute(entity: Entity, attribute: String, value: T) { entity.setAttribute(attribute, value) } @@ -751,7 +715,6 @@ fun setAttribute(entity: Entity, attribute: String, value: T) { * @param entity the entity to lock * @param duration the number of ticks to lock for */ - fun lock(entity: Entity, duration: Int) { entity.lock(duration) } @@ -761,7 +724,6 @@ fun lock(entity: Entity, duration: Int) { * @param entity the entity to lock * @param duration the duration in ticks to lock for */ - fun lockInteractions(entity: Entity, duration: Int) { entity.locks.lockInteractions(duration) } @@ -770,7 +732,6 @@ fun lockInteractions(entity: Entity, duration: Int) { * Unlocks the given entity * @param entity the entity to unlock */ - fun unlock(entity: Entity) { entity.unlock() } @@ -781,7 +742,6 @@ fun unlock(entity: Entity) { * @param transformTo the ID of the NPC to turn into * @param restoreTicks the number of ticks until the NPC returns to normal */ - fun transformNpc(npc: NPC, transformTo: Int, restoreTicks: Int){ npc.transform(transformTo) Pulser.submit(object : Pulse(restoreTicks){ @@ -795,7 +755,6 @@ fun transformNpc(npc: NPC, transformTo: Int, restoreTicks: Int){ /** * Produces a Location object using the given x,y,z values */ - fun location(x: Int, y: Int, z: Int): Location{ return Location.create(x,y,z) } @@ -817,7 +776,6 @@ fun inBorders(entity: Entity, swX: Int, swY: Int, neX: Int, neY: Int): Boolean { /** * AHeals the given entity for the given number of hitpoints */ - fun heal(entity: Entity, amount: Int){ entity.skills.heal(amount) } @@ -829,7 +787,6 @@ fun heal(entity: Entity, amount: Int){ * @param offset the offset of the desired varbit inside the varp. * @param value the value to set the varbit to */ - fun setVarbit(player: Player, varpIndex: Int, offset: Int, value: Int, save: Boolean = false){ player.varpManager.get(varpIndex).setVarbit(offset,value).send(player) if(save) player.varpManager.flagSave(varpIndex) @@ -840,7 +797,6 @@ fun setVarbit(player: Player, varpIndex: Int, offset: Int, value: Int, save: Boo * @param player the player to clear for * @param varpIndex the index of the varp to clear */ - fun clearVarp(player: Player, varpIndex: Int){ player.varpManager.get(varpIndex).clear() } @@ -851,7 +807,6 @@ fun clearVarp(player: Player, varpIndex: Int){ * @param varpIndex the index of the varp to calculate the value of * @return the value of the varp */ - fun getVarpValue(player: Player, varpIndex: Int): Int{ return player.varpManager.get(varpIndex).getValue() } @@ -863,7 +818,6 @@ fun getVarpValue(player: Player, varpIndex: Int): Int{ * @param offset the offset of the varbit inside the varp * @return the value of the given varbit */ - fun getVarbitValue(player: Player, varpIndex: Int, offset: Int): Int { return player.varpManager.get(varpIndex).getVarbitValue(offset) ?: 0 } @@ -874,7 +828,6 @@ fun getVarbitValue(player: Player, varpIndex: Int, offset: Int): Int { * @param dest the Location object to walk to * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, "clip" for the noclip pathfinder, anything else for DUMB. */ - fun forceWalk(entity: Entity, dest: Location, type: String){ if(type == "clip"){ ForceMovement(entity, dest, 10, 10).run() @@ -892,7 +845,6 @@ fun forceWalk(entity: Entity, dest: Location, type: String){ * Interrupts a given entity's walking queue * @param entity the entity to interrupt */ - fun stopWalk(entity: Entity){ entity.walkingQueue.reset() } @@ -903,7 +855,6 @@ fun stopWalk(entity: Entity){ * @param slot the Equipment slot to use, EquipmentSlot enum contains the options. * @return the Item in the given slot, or null if none. */ - fun getItemFromEquipment(player: Player, slot: EquipmentSlot): Item? { return player.equipment.get(slot.ordinal) } @@ -920,7 +871,6 @@ fun getChildren(scenery: Int): IntArray { * @param node the node to adjust the charge of * @param amount the amount to adjust by */ - fun adjustCharge(node: Node, amount: Int){ when(node){ is Item -> node.charge += amount @@ -934,7 +884,6 @@ fun adjustCharge(node: Node, amount: Int){ * @param node the node whose charge to check * @return amount of charges the node has, or -1 if the node does not accept charges. */ - fun getCharge(node: Node): Int{ when(node){ is Item -> return node.charge @@ -948,7 +897,6 @@ fun getCharge(node: Node): Int{ * @param node the node to set the charge for * @param charge the amount to set the node's charge to (default is 1000) */ - fun setCharge(node: Node, charge: Int){ when(node){ is Item -> node.charge = charge @@ -962,7 +910,6 @@ fun setCharge(node: Node, charge: Int){ * @param player the player to get the used option for. * @return the option the player used */ - fun getUsedOption(player: Player): String { return player.getAttribute("interact:option","INVALID") } @@ -973,7 +920,6 @@ fun getUsedOption(player: Player): String { * @param anim the Animation object to use, can also be an ID. * @param gfx the Graphics object to use, can also be an ID. */ - fun visualize(entity: Entity, anim: A, gfx: G){ val animation = when(anim){ is Int -> Animation(anim) @@ -994,7 +940,6 @@ fun visualize(entity: Entity, anim: A, gfx: G){ * Used to submit a pulse to the GameWorld's Pulser. * @param pulse the Pulse object to submit */ - fun submitWorldPulse(pulse: Pulse){ GameWorld.Pulser.submit(pulse) } @@ -1005,7 +950,6 @@ fun submitWorldPulse(pulse: Pulse){ * @param loc the Location object to move them to * @param type the teleport type to use (defaults to instant). An enum exists as TeleportManager.TeleportType. */ - fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = TeleportManager.TeleportType.INSTANT){ if(type == TeleportManager.TeleportType.INSTANT) entity.properties.teleportLocation = loc else entity.teleporter.send(loc,type) @@ -1017,7 +961,6 @@ fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = * @param skill the Skill to set. A Skills enum exists that can be used. Ex: Skills.STRENGTH * @param level the level to set the skill to */ - fun setTempLevel(entity: Entity, skill: Int, level: Int){ entity.skills.setLevel(skill, level) } @@ -1028,7 +971,6 @@ fun setTempLevel(entity: Entity, skill: Int, level: Int){ * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH * @return the static level of the skill */ - fun getStatLevel(entity: Entity, skill: Int): Int { return entity.skills.getStaticLevel(skill) } @@ -1039,7 +981,6 @@ fun getStatLevel(entity: Entity, skill: Int): Int { * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH * @return the dynamic level of the skill */ - fun getDynLevel(entity: Entity, skill: Int): Int { return entity.skills.getLevel(skill) } @@ -1050,7 +991,6 @@ fun getDynLevel(entity: Entity, skill: Int): Int { * @param skill the Skill to adjust. A Skills enum exists that can be used. Ex: Skills.STRENGTH * @param amount the amount to adjust the skill by. Ex-Buff: 5, Ex-Debuff: -5 */ - fun adjustLevel(entity: Entity, skill: Int, amount: Int){ entity.skills.setLevel(skill, entity.skills.getStaticLevel(skill) + amount) } @@ -1061,7 +1001,6 @@ fun adjustLevel(entity: Entity, skill: Int, amount: Int){ * @param item the item to remove. Can be an Item object or an ID. * @param container the Container to remove the item from. An enum exists for this called Container. Ex: Container.BANK */ - fun removeAll(player: Player, item: T, container: Container){ val it = when(item){ is Item -> item.id @@ -1083,7 +1022,6 @@ fun removeAll(player: Player, item: T, container: Container){ * @param iface the ID of the interface to use * @param child the index of the child to send the string to */ - fun setInterfaceText(player: Player, string: String, iface: Int, child: Int){ player.packetDispatch.sendString(string,iface,child) } @@ -1092,7 +1030,6 @@ fun setInterfaceText(player: Player, string: String, iface: Int, child: Int){ * Closes any open (non-chat) interfaces for the player * @param player the player to close the interface for */ - fun closeInterface(player: Player){ player.interfaceManager.close() } @@ -1101,7 +1038,6 @@ fun closeInterface(player: Player){ * Closes any opened tab interfaces for the player * @param player the player to close the tab for */ - fun closeTabInterface(player: Player){ player.interfaceManager.closeSingleTab() } @@ -1112,7 +1048,6 @@ fun closeTabInterface(player: Player){ * @param msg the message to send. * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY */ - fun sendPlayerDialogue(player: Player, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ player.dialogueInterpreter.sendDialogues(player, expr, *splitLines(msg)) } @@ -1123,7 +1058,6 @@ fun sendPlayerDialogue(player: Player, msg: String, expr: FacialExpression = Fac * @param iface the ID of the interface to send it to * @param child the index of the child on the interface to send the model to */ - fun sendPlayerOnInterface(player: Player, iface: Int, child: Int){ player.packetDispatch.sendPlayerOnInterface(iface,child) } @@ -1135,7 +1069,6 @@ fun sendPlayerOnInterface(player: Player, iface: Int, child: Int){ * @param msg the message to send. * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY */ - fun sendNPCDialogue(player: Player, npc: Int, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ player.dialogueInterpreter.sendDialogues(npc, expr, *splitLines(msg)) } @@ -1147,7 +1080,6 @@ fun sendNPCDialogue(player: Player, npc: Int, msg: String, expr: FacialExpressio * @param iface the ID of the interface to send the animation to * @param child the index of the child on the interface to send the model to */ - fun sendAnimationOnInterface(player: Player, anim: Int, iface: Int, child: Int){ player.packetDispatch.sendAnimationInterface(anim,iface,child) } @@ -1157,7 +1089,6 @@ fun sendAnimationOnInterface(player: Player, anim: Int, iface: Int, child: Int){ * @param player the player to register the listener for * @param handler the method to run when the listener is invoked (when the player logs out) */ - fun registerLogoutListener(player: Player, key: String, handler: (p: Player) -> Unit){ player.logoutListeners[key] = handler } @@ -1167,7 +1098,6 @@ fun registerLogoutListener(player: Player, key: String, handler: (p: Player) -> * @param player the player to remove the logout listner from * @param key the key of the logout listener to remove. */ - fun clearLogoutListener(player: Player, key: String){ player.logoutListeners.remove(key) } @@ -1180,7 +1110,6 @@ fun clearLogoutListener(player: Player, key: String){ * @param item the ID of the item to send * @param amount the amount of the item to send - defaults to 1 */ - fun sendItemOnInterface(player: Player, iface: Int, child: Int, item: Int, amount: Int = 1){ player.packetDispatch.sendItemOnInterface(item,amount,iface,child) } @@ -1191,7 +1120,6 @@ fun sendItemOnInterface(player: Player, iface: Int, child: Int, item: Int, amoun * @param item the ID of the item to show * @param message the text to display */ - fun sendItemDialogue(player: Player, item: Int, message: String){ player.dialogueInterpreter.sendItemMessage(item, *splitLines(message)) } @@ -1203,7 +1131,6 @@ fun sendItemDialogue(player: Player, item: Int, message: String){ * @param item2 the ID of the second item to show * @param message the text to display */ - fun sendDoubleItemDialogue(player: Player, item1: Int, item2: Int, message: String){ player.dialogueInterpreter.sendDoubleItemMessage(item1, item2, message) } @@ -1215,7 +1142,6 @@ fun sendDoubleItemDialogue(player: Player, item1: Int, item2: Int, message: Stri * @param prompt what to prompt the player * @param handler the method that handles the value gained from the input dialogue */ - fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: (value: Any) -> Unit){ if(numeric) sendInputDialogue(player, InputType.NUMERIC, prompt, handler) else sendInputDialogue(player, InputType.STRING_SHORT, prompt, handler) @@ -1228,7 +1154,6 @@ fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: * @param prompt what to prompt the player * @param handler the method that handles the value from the input dialogue */ - fun sendInputDialogue(player: Player, type: InputType, prompt: String, handler: (value: Any) -> Unit){ when(type){ InputType.NUMERIC, InputType.STRING_SHORT -> player.dialogueInterpreter.sendInput(type != InputType.NUMERIC, prompt) @@ -1243,7 +1168,6 @@ fun sendInputDialogue(player: Player, type: InputType, prompt: String, handler: * @param entity the entity to make flee * @param from the entity to flee from */ - fun flee(entity: Entity, from: Entity){ lock(entity, 5) face(entity, from, 5) @@ -1259,7 +1183,6 @@ fun flee(entity: Entity, from: Entity){ * @param entity the entity to submit the pulse to * @param pulse the pulse to submit */ - fun submitIndividualPulse(entity: Entity, pulse: Pulse){ entity.pulseManager.run(pulse) } @@ -1267,7 +1190,6 @@ fun submitIndividualPulse(entity: Entity, pulse: Pulse){ /** * Similar to submitIndividualPulse, but for non-repeating tasks, with a cleaner syntax. */ - fun runTask(entity: Entity, delay: Int = 0, task: () -> Unit){ entity.pulseManager.run(object : Pulse(delay) { override fun pulse(): Boolean { @@ -1282,23 +1204,20 @@ fun runTask(entity: Entity, delay: Int = 0, task: () -> Unit){ * @param player the player to get the QP for * @return the number of QP the player has */ - -fun getQP(player: Player): Int{ +fun getQP(player: Player): Int { return player.questRepository.points } /** * Gets the stage for the given quest for the given player */ - -fun questStage(player: Player, quest: String): Int{ +fun questStage(player: Player, quest: String): Int { return player.questRepository.getStage(quest) } /** * Sets the stage for the given quest for the given player */ - fun setQuestStage(player: Player, quest: String, stage: Int) { player.questRepository.setStage(QuestRepository.getQuests()[quest]!!, stage) player.questRepository.syncronizeTab(player) @@ -1307,17 +1226,34 @@ fun setQuestStage(player: Player, quest: String, stage: Int) { /** * Check if a quest is complete */ - fun isQuestComplete(player: Player, quest: String): Boolean { return player.questRepository.getStage(quest) == 100 } + +/** + * Check if a player meets the requirements to start a quest, and then starts it if they do. Returns success bool + */ +fun startQuest(player: Player, quest: String): Boolean { + val quest = player.questRepository.getQuest(quest) + val canStart = quest.hasRequirements(player) + if (!canStart) return false + quest.start(player) + return true +} + +/** + * Finishes a quest, gives rewards, marks as completed, etc + */ +fun finishQuest(player: Player, quest: String) { + player.questRepository.getQuest(quest).finish(player) +} + /** * Gets a scenery definition from the given ID * @param id the ID of the scenery to get the definition for. * @return the scenery definition */ - fun sceneryDefinition(id: Int): SceneryDefinition{ return SceneryDefinition.forId(id) } @@ -1327,7 +1263,6 @@ fun sceneryDefinition(id: Int): SceneryDefinition{ * @param zone the zone to register * @param borders the ZoneBorders that compose the zone */ - fun registerMapZone(zone: MapZone, borders: ZoneBorders){ ZoneBuilder.configure(zone) zone.register(borders) @@ -1340,7 +1275,6 @@ fun registerMapZone(zone: MapZone, borders: ZoneBorders){ * @param child the child on the interface to animate. * @param anim the ID of the animation to use. */ - fun animateInterface(player: Player, iface: Int, child: Int, anim: Int){ player.packetDispatch.sendAnimationInterface(anim,iface,child) } @@ -1350,7 +1284,6 @@ fun animateInterface(player: Player, iface: Int, child: Int, anim: Int){ * @param ladderLoc the location of the ladder/stairs object you want to climb. * @param dest the destination for the climb. */ - fun addClimbDest(ladderLoc: Location, dest: Location){ SpecialLadders.add(ladderLoc,dest) } @@ -1359,7 +1292,6 @@ fun addClimbDest(ladderLoc: Location, dest: Location){ * Sends a news announcement in game chat. * @param message the message to announce */ - fun sendNews(message: String){ Repository.sendNews(message, 12, "CC6600") } @@ -1369,7 +1301,6 @@ fun sendNews(message: String){ * @param gfx the Graphics object, or the Integer ID of the graphics, to send. Either works. * @param location the location to send it to */ - fun sendGraphics(gfx: G, location: Location){ when(gfx){ is Int -> Graphics.send(Graphics(gfx),location) @@ -1390,7 +1321,6 @@ fun announceIfRare(player: Player, item: Item) { * @param player the player * @return a List of skill names */ - fun getMasteredSkillNames(player: Player): List { val hasMastered = player.getSkills().masteredSkills > 0 val masteredSkills = ArrayList() @@ -1415,7 +1345,6 @@ fun getMasteredSkillNames(player: Player): List { * @author ceik * @author James Triantafylos */ - fun dumpContainer(player: Player, container: core.game.container.Container) { val bank = player.bank container.toArray().filterNotNull().forEach { item -> @@ -1446,7 +1375,6 @@ fun dumpContainer(player: Player, container: core.game.container.Container) { * @param player the player. * @return boolean indicating presence of house. */ - fun hasHouse(player: Player): Boolean { return player.houseManager.hasHouse() } @@ -1479,4 +1407,4 @@ fun getPathableRandomLocalCoordinate(target: Entity, radius: Int, center: Locati } return target.location -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/AvanDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/AvanDialogue.kt index 3e2c85db9..3bf7d736e 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/AvanDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/AvanDialogue.kt @@ -1,10 +1,12 @@ -package core.game.content.quest.members.familycrest +package rs09.game.content.quest.members.familycrest +import api.* import core.game.content.dialogue.DialoguePlugin 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 org.rs09.consts.Items @Initializable class AvanDialogue (player: Player? = null): DialoguePlugin(player) { @@ -19,8 +21,8 @@ class AvanDialogue (player: Player? = null): DialoguePlugin(player) { npc = (args[0] as NPC).getShownNPC(player) val qstage = player?.questRepository?.getStage("Family Crest") ?: -1 - if(qstage == 100){ - options("Can you enchant these gauntlets for me?", "Nevermind") + if (qstage == 100) { + options("Can you change my gauntlets for me?", "Nevermind") stage = 6000 return true } @@ -173,42 +175,35 @@ class AvanDialogue (player: Player? = null): DialoguePlugin(player) { "it is a priceless family heirloom.").also{stage = 1000 player.inventory.add(CREST_PIECE_AVAN)} - 6000 -> when(buttonId){ - 1-> if(DoMissingGuantletCheck() != -1){ - var gauntletID = DoMissingGuantletCheck() - - if(gauntletID == 776){ - npc("You already have the Goldsmith guantlets.") - stage = 1000 - } - else{ - npc("Here you go") - player.inventory.remove(Item(gauntletID)) - player.inventory.add(Item(776)) - stage = 1000 - } + 6000 -> when (buttonId) { + 1 -> { + var freeThisTime = getAttribute(player, "family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778) == Items.FAMILY_GAUNTLETS_778 + npc("Yes certainly, though it will cost you 25,000 coins" + if (freeThisTime) " next time." else ".").also { stage = 6001 } } - else{ - npc("You do not have the guantlets with you in your inventory") - stage = 1000 - } - 2-> player("Never mind").also{stage = 1000} + 2 -> player("Never mind").also{ stage = 1000 } } + 6001 -> options("Great thanks!", "No that's okay thanks.").also{ stage++ } + 6002 -> when (buttonId) { + 1 -> { + stage = 1000 + val givingGauntletsId = Items.GOLDSMITH_GAUNTLETS_776 + val npcString = SwapGauntletsHelper.swapGauntlets(player, givingGauntletsId) + if (npcString == "") + { + end() + } + else { + npc(npcString) + } + } + 2 -> end() + } + 1000 -> end() } - return true } - private fun DoMissingGuantletCheck(): Int{ - var itemsToCheck = listOf(775, 776, 777, 778) - for(item in itemsToCheck){ - if(player.inventory.containItems(item)) - return item - } - return -1 - } - override fun getIds(): IntArray { return intArrayOf(663) } diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/BootDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/BootDialogue.kt index dc443a652..dad7cf56f 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/BootDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/BootDialogue.kt @@ -1,4 +1,4 @@ -package core.game.content.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression @@ -69,4 +69,4 @@ class BootDialogue (player: Player? = null): DialoguePlugin(player){ return intArrayOf(665) } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CalebDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CalebDialogue.kt index a527b6d08..01f5ffab8 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CalebDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CalebDialogue.kt @@ -1,10 +1,12 @@ -package core.game.content.quest.members.familycrest +package rs09.game.content.quest.members.familycrest +import api.* import core.game.content.dialogue.DialoguePlugin 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 org.rs09.consts.Items @Initializable @@ -20,8 +22,8 @@ class CalebDialogue (player: Player? = null): DialoguePlugin(player) { npc = (args[0] as NPC).getShownNPC(player) val qstage = player?.questRepository?.getStage("Family Crest") ?: -1 - if(qstage == 100){ - options("Can you enchant these gauntlets for me?", "Nevermind") + if (qstage == 100) { + options("Can you change my gauntlets for me?", "Nevermind") stage = 6000 return true } @@ -201,51 +203,39 @@ class CalebDialogue (player: Player? = null): DialoguePlugin(player) { player.inventory.add(CREST_PIECE) } 406 -> npc("I suggest you be less careless in the future. ", - "The crest is extremely valuable, and utterly irreplacable.").also{stage = 1000} + "The crest is extremely valuable, and utterly irreplaceable.").also{stage = 1000} - 6000 -> when(buttonId){ - 1-> if(DoMissingGuantletCheck() != -1){ - var gauntletID = DoMissingGuantletCheck() - - if(gauntletID == 775){ - npc("You already have the Cooking Guantlets.") - stage = 1000 - } - else{ - npc("Here you go") - player.inventory.remove(Item(gauntletID)) - player.inventory.add(Item(775)) - stage = 1000 - } + 6000 -> when (buttonId) { + 1 -> { + var freeThisTime = getAttribute(player, "family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778) == Items.FAMILY_GAUNTLETS_778 + npc("Yes certainly, though it will cost you 25,000 coins" + if (freeThisTime) " next time." else ".").also { stage = 6001 } } - else{ - npc("You do not have the guantlets with you in your inventory") + 2 -> player("Never mind").also{ stage = 1000 } + } + 6001 -> options("Great thanks!", "No that's okay thanks.").also{ stage++ } + 6002 -> when (buttonId) { + 1 -> { stage = 1000 + val givingGauntletsId = Items.COOKING_GAUNTLETS_775 + val npcString = SwapGauntletsHelper.swapGauntlets(player, givingGauntletsId) + if (npcString == "") + { + end() + } + else { + npc(npcString) + } } - 2-> player("Never mind").also{stage = 1000} + 2 -> end() } 1000 -> end() - } return true } - - - private fun DoMissingGuantletCheck(): Int{ - var itemsToCheck = listOf(775, 776, 777, 778) - for(item in itemsToCheck){ - if(player.inventory.containItems(item)) - return item - } - return -1 - } - - override fun getIds(): IntArray { return intArrayOf(666) } - -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonCaveZone.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonCaveZone.kt index 1a02e8802..7bcb3ea09 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonCaveZone.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonCaveZone.kt @@ -10,6 +10,7 @@ import core.game.world.map.zone.ZoneBorders import core.game.world.map.zone.ZoneBuilder import core.plugin.Initializable import core.plugin.Plugin +import rs09.game.content.quest.members.familycrest.ChronozonNPC @Initializable @@ -62,4 +63,4 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin { } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonNPC.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonNPC.kt index 4b929820b..8d25d0c70 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonNPC.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/ChronozonNPC.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import core.game.node.entity.Entity import core.game.node.entity.combat.BattleState diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CrestCombiningInteration.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CrestCombiningInteration.kt index 1203e32ac..70910727d 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CrestCombiningInteration.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/CrestCombiningInteration.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import core.game.interaction.NodeUsageEvent import core.game.interaction.UseWithHandler @@ -50,4 +50,4 @@ class CrestCombiningInteraction: UseWithHandler(779, 780,781) { else -> false } } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/DimintheisDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/DimintheisDialogue.kt index de211a3a7..64f0e4625 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/DimintheisDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/DimintheisDialogue.kt @@ -1,200 +1,189 @@ -package plugin.quest.members.familycrest - - -import core.game.content.dialogue.DialoguePlugin -import core.game.node.entity.npc.NPC -import core.game.node.entity.player.Player -import core.game.node.entity.skill.Skills -import core.game.node.item.Item -import core.plugin.Initializable - - - - -@Initializable -/** -* Handles DimintheisDialogue Dialogue -* @author Plex -*/ -class DimintheisDialogue(player: Player? = null): DialoguePlugin(player) { - override fun newInstance(player: Player?): DialoguePlugin { - return DimintheisDialogue(player) - } - - - override fun open(vararg args: Any?): Boolean { - npc = (args[0] as NPC).getShownNPC(player) - val qstage = player?.questRepository?.getStage("Family Crest") ?: -1 - - if(qstage == 100 && !DoMissingGuantletCheck()){ - npc("Thank you for saving our family honour, ", - "We will never forget you") - stage = 1000 - return true - } - - if(qstage == 100 && DoMissingGuantletCheck()){ - player("I've lost the guantlets you gave me") - stage = 6000 - } - - if(qstage == 20 && player.inventory.containItems(782)){ - player("I have retrieved your crest.").also{stage = 5000} - return true; - } - - when(qstage) { - 0 -> npc("Hello. My name is Dimintheis, ", - "of the noble family Fitzharmon.").also { stage = 1 } - 10 -> player("Where did you say I could find your son Caleb again?").also { stage = 3000 } - 11 -> player("Where did you say I could find your son Caleb again?").also { stage = 3000 } - 12 -> npc("Have you found my crest yet?").also{stage = 4000} - 13 -> npc("Have you found my crest yet?").also{stage = 4000} - 14 -> npc("Have you found my crest yet?").also{stage = 4000} - 15 -> npc("Have you found my crest yet?").also{stage = 4000} - 16 -> npc("Have you found my crest yet?").also{stage = 4000} - 17 -> npc("Have you found my crest yet?").also{stage = 4000} - 18 -> npc("Have you found my crest yet?").also{stage = 4000} - 19 -> npc("Have you found my crest yet?").also{stage = 4000} - } - return true - } - - override fun handle(interfaceId: Int, buttonId: Int): Boolean { - when(stage){ - 1 -> options( - "Why would a nobleman live in a dump like this?", - "You're rich then? Can i have some money?", - "Hi, i am a bold adventurer.").also {stage++} - 2 -> when(buttonId){ - 1 -> npc("The King has taken my estate from me ", - "until such time as I can show my family crest to him.").also { stage = 3} - 2 -> npc("Gah! Lousy beggar! " , - "Your sort is what's ruining this great land! ", - "Why don't you just go and get a " , - "job if you need money so badly?").also { stage = 1000} - 3 -> npc("An adventurer hmmm? How lucky. I may have an adventure for you. " , - "I desperately need my family crest returning to me. " , - "It is of utmost importance.").also { stage = 4 } - } - 3 -> options("Why would he do that?", - "So where is this crest?").also {stage = 5} - - 4 -> options("Why are you so desperate for it?", - "So where is this crest?", - "I'm not interested in that adventure right now").also { stage = 6} - 5 -> when(buttonId){ - 1-> npc("Well, there is a long standing rule of chivalry " , - "amongst the Varrockian aristocracy,").also{stage = 2000} - 2-> npc("Well, my three sons took it with them " , - "many years ago when they rode ").also { stage = 2007 } - } - 6 -> when(buttonId){ - 1 -> npc("Well, there is a long standing rule of chivalry " , - "amongst the Varrockian aristocracy,").also{stage = 2000} - 2 -> npc("Well, my three sons took it with them " , - "many years ago when they rode ").also { stage = 2007 } - 3 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000} - - } - 2000 -> npc( - "where each noble family is in possession of a unique crest, ", - "which signifies the honour and lineage of the family. ").also { stage++} - 2001 -> npc("More than this however, it also represents the ", - "lawful rights of each family to prove their ownership of ", - "their wealth and lands. If the family crest is lost,").also { stage++ } - - 2002 -> npc( "then the family's estate is handed over to the ", - "current monarch until the crest is restored.").also{stage++} - 2003 -> npc("This dates back to the times when there was much in-fighting " , - "amongst the noble families and their clans, and ", - "was introduced as a way of reducing the bloodshed that was ", - "devastating the ranks of the ruling classes at that time.").also { stage++ } - 2004 -> npc("When you captured a rival family's clan, " , - "you also captured their lands and wealth.").also{ stage++} - - 2005 -> options("So where is this crest?", "I'm not interested in an adventure right now").also{stage++} - - 2006 -> when(buttonId){ - 1-> npc("Well, my three sons took it ", - "with them many years ago when they rode out ").also { stage++ } - - 2 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000} - - } - 2007 -> npc("to fight in the war against the undead necromancer " , - "and his army in the battle to save Varrock.").also { stage++} - 2008 -> npc("For many years I had assumed them all dead, " , - "as I had heard no word from them.").also { stage++} - 2009 -> npc("Recently I heard that my son Caleb is alive and well, " , - "trying to earn his fortune as a great fish chef in Catherby.").also { stage++ } - 2010 -> options("Ok, I will help you", "I'm not interested in an adventure right now").also { stage++ } - 2011 -> when(buttonId){ - 1 -> npc("I thank you greatly adventurer!").also { stage++} - 2 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000 } - } - 2012 -> if(player.questRepository.getQuest("Family Crest").hasRequirements(player)) { - npc("If you find Caleb, or my other sons... please... ", - "let them know their father still loves them...").also { stage = 1000 }.also { player.questRepository.getQuest("Family Crest").start(player) }.also { player.questRepository.syncronizeTab(player) } - }else{ - npc("But im sorry, but you cannot help me right now").also{stage = 1000} - } - - 3000 ->npc("The only thing I have heard of my son Caleb ", - "is that he is trying to earn his fortune as a great fish chef.").also{stage++} - 3001 ->npc("I believe he is staying with a friend ", - "who lives just outside the west gates of Varrock.").also{stage = 1000} - - 4000 -> player("I'm still looking for it").also{stage = 1000} - - - 5000 -> npc("Adventurer... I can only thank you for your kindness, " , - "although the words are insufficient " , - "to express the gratitude I feel!").also{stage++} - 5001 -> npc("You are truly a hero in every sense, " , - "and perhaps your efforts can begin to " , - "patch the wounds that have torn this family apart...").also{stage++} - 5002 -> npc("I know not how I can adequately reward you for your efforts... " , - "although I do have these mystical gauntlets, " , - "a family heirloom that through some power unknown to me, " , - "have always returned to the head of the family whenever lost,").also{stage++} - - 5003 -> npc(" or if the owner has died. " , - "I will pledge these to you, " , - "and if you should lose them return to me, " , - "and they will be here.").also{stage++ - } - 5004 -> npc("They can also be granted extra powers. " , - "Take them to one of my sons, " , - "they should be able to imbue them with a skill for you.").also{stage = 1000 - player.questRepository.getQuest("Family Crest").finish(player) - player.questRepository.getQuest("Family Crest").setStage(player, 100) - } - - 6000 -> npc("Not to worry, here they are").also{ - stage = 1000 - player.inventory.add(Item(778)) - } - 1000 -> end() - - } - - - return true; - } - - private fun DoMissingGuantletCheck(): Boolean{ - var itemsToCheck = listOf(775, 776, 777, 778) - for(item in itemsToCheck){ - if(player.inventory.containItems(item)) - return true - if(player.bank.containItems(item)) - return true - } - return false - } - override fun getIds(): IntArray { - return intArrayOf(8171) - } - -} +package rs09.game.content.quest.members.familycrest + + +import api.* +import core.game.content.dialogue.DialoguePlugin +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.plugin.Initializable +import org.rs09.consts.Items + + +@Initializable +/** +* Handles DimintheisDialogue Dialogue +* @author Plex +*/ +class DimintheisDialogue(player: Player? = null): DialoguePlugin(player) { + override fun newInstance(player: Player?): DialoguePlugin { + return DimintheisDialogue(player) + } + + private val questName = "Family Crest" + + override fun open(vararg args: Any?): Boolean { + npc = (args[0] as NPC).getShownNPC(player) + val questStage = questStage(player, questName) + val questComplete = isQuestComplete(player, questName) + + if (questStage == 20 && inInventory(player, Items.FAMILY_CREST_782)) { + player("I have retrieved your crest.").also{ stage = 5000 } + return true; + } + + val hasGauntlets = hasAnItem(player, Items.COOKING_GAUNTLETS_775, Items.GOLDSMITH_GAUNTLETS_776, Items.CHAOS_GAUNTLETS_777, Items.FAMILY_GAUNTLETS_778).container != null + + if (questComplete && hasGauntlets) { + npc("Thank you for saving our family honour, ", + "We will never forget you") + stage = 1000 + return true + } + + if (questComplete && !hasGauntlets) { + player("I've lost the gauntlets you gave me") + stage = 6000 + return true + } + + when(questStage) { + 0 -> npc("Hello. My name is Dimintheis, ", + "of the noble family Fitzharmon.").also { stage = 1 } + 10 -> player("Where did you say I could find your son Caleb again?").also { stage = 3000 } + 11 -> player("Where did you say I could find your son Caleb again?").also { stage = 3000 } + 12 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 13 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 14 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 15 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 16 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 17 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 18 -> npc("Have you found my crest yet?").also{ stage = 4000 } + 19 -> npc("Have you found my crest yet?").also{ stage = 4000 } + } + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when(stage){ + 1 -> options( + "Why would a nobleman live in a dump like this?", + "You're rich then? Can i have some money?", + "Hi, i am a bold adventurer.").also { stage++ } + 2 -> when(buttonId){ + 1 -> npc("The King has taken my estate from me ", + "until such time as I can show my family crest to him.").also { stage = 3 } + 2 -> npc("Gah! Lousy beggar! " , + "Your sort is what's ruining this great land! ", + "Why don't you just go and get a " , + "job if you need money so badly?").also { stage = 1000} + 3 -> npc("An adventurer hmmm? How lucky. I may have an adventure for you. " , + "I desperately need my family crest returning to me. " , + "It is of utmost importance.").also { stage = 4 } + } + 3 -> options("Why would he do that?", + "So where is this crest?").also { stage = 5 } + + 4 -> options("Why are you so desperate for it?", + "So where is this crest?", + "I'm not interested in that adventure right now").also { stage = 6 } + 5 -> when(buttonId){ + 1-> npc("Well, there is a long standing rule of chivalry " , + "amongst the Varrockian aristocracy,").also{ stage = 2000 } + 2-> npc("Well, my three sons took it with them " , + "many years ago when they rode ").also { stage = 2007 } + } + 6 -> when(buttonId){ + 1 -> npc("Well, there is a long standing rule of chivalry " , + "amongst the Varrockian aristocracy,").also{ stage = 2000 } + 2 -> npc("Well, my three sons took it with them " , + "many years ago when they rode ").also { stage = 2007 } + 3 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000} + + } + 2000 -> npc( + "where each noble family is in possession of a unique crest, ", + "which signifies the honour and lineage of the family. ").also { stage++} + 2001 -> npc("More than this however, it also represents the ", + "lawful rights of each family to prove their ownership of ", + "their wealth and lands. If the family crest is lost,").also { stage++ } + + 2002 -> npc( "then the family's estate is handed over to the ", + "current monarch until the crest is restored.").also{ stage++ } + 2003 -> npc("This dates back to the times when there was much in-fighting " , + "amongst the noble families and their clans, and ", + "was introduced as a way of reducing the bloodshed that was ", + "devastating the ranks of the ruling classes at that time.").also { stage++ } + 2004 -> npc("When you captured a rival family's clan, " , + "you also captured their lands and wealth.").also{ stage++} + + 2005 -> options("So where is this crest?", "I'm not interested in an adventure right now").also{stage++} + + 2006 -> when(buttonId){ + 1-> npc("Well, my three sons took it ", + "with them many years ago when they rode out ").also { stage++ } + 2 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000 } + + } + 2007 -> npc("to fight in the war against the undead necromancer " , + "and his army in the battle to save Varrock.").also { stage++ } + 2008 -> npc("For many years I had assumed them all dead, " , + "as I had heard no word from them.").also { stage++ } + 2009 -> npc("Recently I heard that my son Caleb is alive and well, " , + "trying to earn his fortune as a great fish chef in Catherby.").also { stage++ } + 2010 -> options("Ok, I will help you", "I'm not interested in an adventure right now").also { stage++ } + 2011 -> when(buttonId){ + 1 -> npc("I thank you greatly adventurer!").also { stage++ } + 2 -> npc("I realise it was a lot to ask of a stranger.").also { stage = 1000 } + } + 2012 -> if(startQuest(player, questName)) { + npc("If you find Caleb, or my other sons... please... ", + "let them know their father still loves them...").also { stage = 1000 } + } else { + npc("But im sorry, but you cannot help me right now").also{ stage = 1000 } + } + + 3000 ->npc("The only thing I have heard of my son Caleb ", + "is that he is trying to earn his fortune as a great fish chef.").also{ stage++ } + 3001 ->npc("I believe he is staying with a friend ", + "who lives just outside the west gates of Varrock.").also{ stage = 1000 } + + 4000 -> player("I'm still looking for it").also{ stage = 1000 } + + 5000 -> npc("Adventurer... I can only thank you for your kindness, " , + "although the words are insufficient " , + "to express the gratitude I feel!").also{ stage++ } + 5001 -> npc("You are truly a hero in every sense, " , + "and perhaps your efforts can begin to " , + "patch the wounds that have torn this family apart...").also{ stage++ } + 5002 -> npc("I know not how I can adequately reward you for your efforts... " , + "although I do have these mystical gauntlets, " , + "a family heirloom that through some power unknown to me, " , + "have always returned to the head of the family whenever lost,").also{ stage++ } + 5003 -> npc(" or if the owner has died. " , + "I will pledge these to you, " , + "and if you should lose them return to me, " , + "and they will be here.").also{ stage++ } + 5004 -> npc("They can also be granted extra powers. " , + "Take them to one of my sons, " , + "they should be able to imbue them with a skill for you.").also { + stage = 1000 + if (removeItem(player, Items.FAMILY_CREST_782)) { + finishQuest(player, questName) + } + } + + 6000 -> npc("Not to worry, here they are").also { + stage = 1000 + addItem(player, getAttribute(player, "family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778)) + } + + 1000 -> end() + } + + return true; + } + + override fun getIds(): IntArray { + return intArrayOf(8171) + } +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/FamilyCrest.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/FamilyCrest.kt index f16263c8c..c1bba6ff6 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/FamilyCrest.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/FamilyCrest.kt @@ -1,6 +1,8 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest +import api.addItem +import api.setAttribute import core.game.node.entity.player.Player import core.game.node.entity.player.link.quest.Quest import core.game.node.entity.skill.Skills @@ -8,6 +10,7 @@ import core.game.node.item.GroundItemManager import core.game.node.item.Item import core.plugin.Initializable import org.rs09.consts.Items +import rs09.game.system.SystemLogger /** * Represents the "Family Crest" quest. @@ -116,10 +119,10 @@ class FamilyCrest: Quest("Family Crest", 59, 58, 1, 148, 0, 1, 11) { drawReward(player,"A choice of special abilities for the gauntlets",ln++) drawReward(player,"for the gauntlets",ln++) - if(!player.inventory.add(Item(Items.FAMILY_GAUNTLETS_778))){ - GroundItemManager.create(Item(Items.FAMILY_GAUNTLETS_778),player) + if (!addItem(player, Items.FAMILY_GAUNTLETS_778)) { + SystemLogger.logErr("Failed to give gauntlets to ${player.username} at end of quest, this should not occur due to crest item removal needed to finish quest.") } - + setAttribute(player, "/save:family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778) } /*override fun getConfig(player: Player?, stage: Int): IntArray { diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/JohnathonDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/JohnathonDialogue.kt index 8d029d39a..15615a2f3 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/JohnathonDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/JohnathonDialogue.kt @@ -1,11 +1,13 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest +import api.* import core.game.content.dialogue.DialoguePlugin 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 org.rs09.consts.Items @Initializable class JohnathonDialogue(player: Player? = null): DialoguePlugin(player) { @@ -18,14 +20,14 @@ class JohnathonDialogue(player: Player? = null): DialoguePlugin(player) { npc = (args[0] as NPC).getShownNPC(player) val qstage = player?.questRepository?.getStage("Family Crest") ?: -1 - if(qstage == 100){ - options("Can you enchant these gauntlets for me?", "Nevermind") + if (qstage == 100) { + options("Can you change my gauntlets for me?", "Nevermind") stage = 6000 return true } if(qstage < 16){ - npc("I dont feel so well... maybe we can talk later") + npc("I don't feel so well... maybe we can talk later") stage = 1000; } else{ @@ -42,7 +44,7 @@ class JohnathonDialogue(player: Player? = null): DialoguePlugin(player) { } override fun handle(interfaceId: Int, buttonId: Int): Boolean { - when(stage){ + when(stage) { 1 -> npc("That... I am...").also { stage++ } 2 -> player("I am here to retrieve your fragment " , @@ -50,7 +52,7 @@ class JohnathonDialogue(player: Player? = null): DialoguePlugin(player) { 3 -> npc("The... poison... it is all... " , "too much... My head... " , "will not... stop spinning...").also { stage++ } - 4 -> sendDialogue("Sweat is pouring down Jonathons'face.").also { stage = 1000 + 4 -> sendDialogue("Sweat is pouring down Jonathons' face.").also { stage = 1000 player.questRepository.getQuest("Family Crest").setStage(player, 17); } @@ -89,45 +91,37 @@ class JohnathonDialogue(player: Player? = null): DialoguePlugin(player) { 4 -> npc("My thanks for the assistance adventure").also{stage = 1000} } - 6000 -> when(buttonId){ - 1-> if(DoMissingGuantletCheck() != -1){ - var gauntletID = DoMissingGuantletCheck() - - if(gauntletID == 777){ - npc("You already have the Chaos Guantlets.") - stage = 1000 - } - else{ - npc("Here you go") - player.inventory.remove(Item(gauntletID)) - player.inventory.add(Item(777)) - stage = 1000 - } + 6000 -> when (buttonId) { + 1 -> { + var freeThisTime = getAttribute(player, "family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778) == Items.FAMILY_GAUNTLETS_778 + npc("Yes certainly, though it will cost you 25,000 coins" + if (freeThisTime) " next time." else ".").also { stage = 6001 } } - else{ - npc("You do not have the guantlets with you in your inventory") - stage = 1000 - } - 2-> player("Never mind").also{stage = 1000} + 2 -> player("Never mind").also{ stage = 1000 } + } + 6001 -> options("Great thanks!", "No that's okay thanks.").also{ stage++ } + 6002 -> when (buttonId) { + 1 -> { + stage = 1000 + val givingGauntletsId = Items.CHAOS_GAUNTLETS_777 + val npcString = SwapGauntletsHelper.swapGauntlets(player, givingGauntletsId) + if (npcString == "") + { + end() + } + else { + npc(npcString) + } + } + 2 -> end() } - 1000 -> end() } - return true; - } - - private fun DoMissingGuantletCheck(): Int{ - var itemsToCheck = listOf(775, 776, 777, 778) - for(item in itemsToCheck){ - if(player.inventory.containItems(item)) - return item - } - return -1 + return true } override fun getIds(): IntArray { return intArrayOf(668) } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectGoldSmeltingHandler.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectGoldSmeltingHandler.kt index 074b80505..e98608943 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectGoldSmeltingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectGoldSmeltingHandler.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import api.addItem diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryHandler.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryHandler.kt index daac34edf..aaa7c69a4 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryHandler.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import core.game.content.dialogue.DialogueInterpreter import core.game.content.dialogue.DialoguePlugin @@ -61,4 +61,4 @@ class PerfectJewelryHandler (player: Player? = null): DialoguePlugin(player){ return intArrayOf(DialogueInterpreter.getDialogueKey("perfect-jewelry")) } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryOnUseHandler.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryOnUseHandler.kt index 8d352b6ef..40652dc01 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryOnUseHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/PerfectJewelryOnUseHandler.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import org.rs09.consts.Items @@ -25,4 +25,4 @@ class PerfectJewelryOnUseHandler : UseWithHandler(Items.PERFECT_GOLD_BAR_2365){ } -//event.getPlayer().getDialogueInterpreter().open("perfect-jewelry"); \ No newline at end of file +//event.getPlayer().getDialogueInterpreter().open("perfect-jewelry"); diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/SwapGauntletsHelper.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/SwapGauntletsHelper.kt new file mode 100644 index 000000000..4c6e2919a --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/SwapGauntletsHelper.kt @@ -0,0 +1,45 @@ +package rs09.game.content.quest.members.familycrest + +import api.* +import core.game.node.entity.player.Player +import core.game.node.item.Item +import org.rs09.consts.Items + +class SwapGauntletsHelper { + companion object { + private val legalGauntlets = setOf(Items.COOKING_GAUNTLETS_775, Items.GOLDSMITH_GAUNTLETS_776, Items.CHAOS_GAUNTLETS_777, Items.FAMILY_GAUNTLETS_778) + + @JvmStatic + fun swapGauntlets(player: Player, givingGauntletsId: Int): String { + if (givingGauntletsId !in legalGauntlets) { + throw IllegalArgumentException("givingGauntletsId not in list of legal gauntlets.") + } + if (inInventory(player, givingGauntletsId)) { + val gauntletString = Item(givingGauntletsId).name + return "You already have the $gauntletString." + } + var otherGauntlets = -1 + val otherPossibleGauntlets = legalGauntlets.toMutableSet() + otherPossibleGauntlets.remove(givingGauntletsId) + for (gauntletId in otherPossibleGauntlets) { + if (inInventory(player, gauntletId)) + { + otherGauntlets = gauntletId + } + } + if (otherGauntlets == -1) { + return "You do not have the gauntlets with you in your inventory." + } + val fee = 25000 + val shouldBeFree = getAttribute(player, "family-crest:gauntlets", Items.FAMILY_GAUNTLETS_778) == Items.FAMILY_GAUNTLETS_778 + if (!shouldBeFree && !inInventory(player, Items.COINS_995, fee)) { + return "You do not have enough coins." + } + if ((shouldBeFree || removeItem(player, Item(Items.COINS_995, fee))) && removeItem(player, otherGauntlets)) { + addItem(player, givingGauntletsId) + setAttribute(player, "/save:family-crest:gauntlets", givingGauntletsId) + } + return "" + } + } +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/WitchavenLeverInteraction.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/WitchavenLeverInteraction.kt index 4973bc451..94e40e360 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/WitchavenLeverInteraction.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/familycrest/WitchavenLeverInteraction.kt @@ -1,4 +1,4 @@ -package core.game.content.quest.members.familycrest +package rs09.game.content.quest.members.familycrest import core.game.node.entity.impl.ForceMovement import core.game.node.entity.player.Player diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherCedricNPC.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherCedricNPC.kt index f7325df2a..442e8c300 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherCedricNPC.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherCedricNPC.kt @@ -1,6 +1,8 @@ package rs09.game.content.quest.members.monksfriend +import api.questStage import api.sendItemDialogue +import api.setQuestStage import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC import core.game.node.item.Item @@ -16,7 +18,8 @@ import rs09.tools.END_DIALOGUE */ class BrotherCedricDialogue : DialogueFile() { override fun handle(componentID: Int, buttonID: Int) { - val questStage = player!!.questRepository.getStage("Monk's Friend") + val questName = "Monk's Friend" + val questStage = questStage(player!!, questName) when { questStage < 30 -> { when(stage) { @@ -33,7 +36,7 @@ class BrotherCedricDialogue : DialogueFile() { 0 -> playerl(FacialExpression.HAPPY, "Brother Cedric are you okay?").also{stage++} 1 -> npcl(FacialExpression.DRUNK, "Yeesshhh, I'm very, very drunk..hic..up..").also{stage++} 2 -> playerl(FacialExpression.NEUTRAL, "Brother Omad needs the wine for the party.").also{stage++} - 3 -> npcl(FacialExpression.SAD, "Oh dear, oh dear, I knew I had to do something!").also{stage = END_DIALOGUE}.also{setQuest(player!!, 40)} + 3 -> npcl(FacialExpression.SAD, "Oh dear, oh dear, I knew I had to do something!").also{stage = END_DIALOGUE}.also{ setQuestStage(player!!, questName, 40) } } } questStage == 40 -> { @@ -51,7 +54,7 @@ class BrotherCedricDialogue : DialogueFile() { sendItemDialogue(player!!, Items.JUG_OF_WATER_1937, "You hand the monk a jug of water.") stage=0 player!!.inventory.remove(Item(Items.JUG_OF_WATER_1937)) - setQuest(player!!, 41) + setQuestStage(player!!, questName, 41) } } } @@ -69,7 +72,7 @@ class BrotherCedricDialogue : DialogueFile() { } 5 -> npcl(FacialExpression.HAPPY, "In that case I'd better drink more wine! It helps me think.").also {stage=END_DIALOGUE} 10 -> npcl(FacialExpression.HAPPY, "Excellent, I just need some wood.").also{stage++} - 11 -> playerl(FacialExpression.NEUTRAL, "Ok, I'll see what I can find.").also{stage = END_DIALOGUE}.also{setQuest(player!!, 42)} + 11 -> playerl(FacialExpression.NEUTRAL, "Ok, I'll see what I can find.").also{stage = END_DIALOGUE}.also{setQuestStage(player!!, questName, 42)} } } questStage == 42 -> { @@ -86,7 +89,7 @@ class BrotherCedricDialogue : DialogueFile() { 4 -> playerl(FacialExpression.HAPPY, "Ok! I'll see you later!").also{ stage=END_DIALOGUE player!!.inventory.remove(Item(Items.LOGS_1511)) - setQuest(player!!, 50) + setQuestStage(player!!, questName, 50) } } } @@ -116,4 +119,4 @@ class BrotherCedricListener : InteractionListener { return@on true } } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherOmadNPC.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherOmadNPC.kt index 2487cbf4f..361a89b83 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherOmadNPC.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/BrotherOmadNPC.kt @@ -22,7 +22,8 @@ import rs09.tools.END_DIALOGUE */ class BrotherOmadDialogue : DialogueFile() { override fun handle(componentID: Int, buttonID: Int) { - val questStage = player!!.questRepository.getStage("Monk's Friend") + val questName = "Monk's Friend" + val questStage = questStage(player!!, questName) when (questStage) { 0 -> { when(stage) { @@ -69,7 +70,7 @@ class BrotherOmadDialogue : DialogueFile() { } 31 -> npcl(FacialExpression.HAPPY, "Really, that's excellent, well done! Maybe now I will be able to get some rest.").also{stage++} 32 -> npcl(FacialExpression.SAD, "*yawn*..I'm off to bed! Farewell brave traveller!").also{player!!.inventory.remove(Item(Items.CHILDS_BLANKET_90)) - setQuest(player!!, 20); stage = END_DIALOGUE} + setQuestStage(player!!, questName, 20); stage = END_DIALOGUE} } } 20 -> { @@ -103,7 +104,7 @@ class BrotherOmadDialogue : DialogueFile() { 996 -> npcl(FacialExpression.NEUTRAL, "Okay traveller, take care.").also{stage = END_DIALOGUE} 997 -> npcl(FacialExpression.NEUTRAL, "Of course, but we need the wine first.").also{stage = END_DIALOGUE} 42 -> npcl(FacialExpression.FRIENDLY, "Oh, he won't be far. Probably out in the forest.").also{stage++} - 43 -> playerl(FacialExpression.FRIENDLY, "Ok, I'll go and find him.").also { stage = END_DIALOGUE}.also{ setQuest(player!!, 30);} + 43 -> playerl(FacialExpression.FRIENDLY, "Ok, I'll go and find him.").also { stage = END_DIALOGUE}.also{ setQuestStage(player!!, questName, 30)} } } 30 -> { @@ -191,7 +192,6 @@ class BrotherOmadDialogue : DialogueFile() { } 25 -> if (questComplete) { player!!.questRepository.getQuest("Monk's Friend").finish(player) - player!!.questRepository.getQuest("Monk's Friend").setStage(player, 100) } } count++ @@ -212,4 +212,4 @@ class BrotherOmadListener : InteractionListener { return@on true } } -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/MonksFriend.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/MonksFriend.kt index 506aafef8..66eba34d3 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/MonksFriend.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/monksfriend/MonksFriend.kt @@ -64,8 +64,3 @@ class MonksFriend: Quest("Monk's Friend", 89, 88, 1, 30, 0, 1, 80) { player.inventory.add(Item(563, 8)) } } - -fun setQuest(player: Player, stage: Int){ - player.questRepository.getQuest("Monk's Friend").setStage(player, stage) -} -