Fixes for 'perfect gold' smelting, mining and a prospecting bug for depleted rocks

This commit is contained in:
downthecrop
2022-04-23 12:55:33 +00:00
committed by Ryan
parent 051d6d09ec
commit 0812cfa0c7
4 changed files with 41 additions and 24 deletions
@@ -107,7 +107,7 @@ public final class FurnaceOptionPlugin extends OptionHandler {
/** /**
* Represents the ids. * Represents the ids.
*/ */
private static final int[] IDS = new int[] { 4304, 6189, 11010, 11666, 12100, 12809, 14921, 18497, 26814, 30021, 30510, 36956, 37651 }; public static final int[] furnaceIDS = new int[] { 4304, 6189, 11010, 11666, 12100, 12809, 14921, 18497, 26814, 30021, 30510, 36956, 37651 };
/** /**
* Constructs a new {@code SmeltUseWithHandler} {@code Object}. * Constructs a new {@code SmeltUseWithHandler} {@code Object}.
@@ -118,7 +118,7 @@ public final class FurnaceOptionPlugin extends OptionHandler {
@Override @Override
public Plugin<Object> newInstance(Object arg) throws Throwable { public Plugin<Object> newInstance(Object arg) throws Throwable {
for (int i : IDS) { for (int i : furnaceIDS) {
addHandler(i, OBJECT_TYPE, this); addHandler(i, OBJECT_TYPE, this);
} }
return this; return this;
@@ -1,10 +1,13 @@
package plugin.quest.members.familycrest package plugin.quest.members.familycrest
import api.addItem
import api.animate;
import api.removeItem
import core.game.interaction.NodeUsageEvent import core.game.interaction.NodeUsageEvent
import core.game.interaction.UseWithHandler import core.game.interaction.UseWithHandler
import core.game.node.entity.skill.Skills import core.game.node.entity.skill.Skills
import core.game.node.item.Item import core.game.node.entity.skill.smithing.FurnaceOptionPlugin
import core.game.system.task.Pulse import core.game.system.task.Pulse
import core.plugin.Initializable import core.plugin.Initializable
import core.plugin.Plugin import core.plugin.Plugin
@@ -15,11 +18,12 @@ import rs09.game.world.GameWorld.Pulser
@Initializable @Initializable
class PerfectGoldSmeltingHandler : UseWithHandler(Items.PERFECT_GOLD_ORE_446){ class PerfectGoldSmeltingHandler : UseWithHandler(Items.PERFECT_GOLD_ORE_446){
val furnaceIDs = listOf(2349, 2351, 2353, 2359, 2361, 2363, 2366, 2368, 9467, 11286, 1540, 11710, 11712, 11714, 11666, 11686, 11688, 11692)
private val furnaceIDs: IntArray = FurnaceOptionPlugin.SmeltUseWithHandler.furnaceIDS;
override fun newInstance(arg: Any?): Plugin<Any> { override fun newInstance(arg: Any?): Plugin<Any> {
for(furnaces in furnaceIDs){ for(furnace in furnaceIDs){
addHandler(furnaces, OBJECT_TYPE, this) addHandler(furnace, OBJECT_TYPE, this)
} }
return this return this
} }
@@ -27,16 +31,18 @@ class PerfectGoldSmeltingHandler : UseWithHandler(Items.PERFECT_GOLD_ORE_446){
override fun handle(event: NodeUsageEvent?): Boolean { override fun handle(event: NodeUsageEvent?): Boolean {
event ?: return false event ?: return false
val player = event.player
Pulser.submit(object : Pulse(2, event.player) { Pulser.submit(object : Pulse(2, player) {
override fun pulse(): Boolean { override fun pulse(): Boolean {
event.player.inventory.remove(Item(446)) if(removeItem(player,Items.PERFECT_GOLD_ORE_446)){
event.player.inventory.add(Item(2365)) animate(player,3243)
event.player.skills.addExperience(Skills.SMITHING,22.5) addItem(player,Items.PERFECT_GOLD_BAR_2365)
player.skills.addExperience(Skills.SMITHING,22.5)
}
return true return true
} }
}) })
return true return true
} }
} }
@@ -7,8 +7,6 @@ import core.game.container.impl.EquipmentContainer
import core.game.content.dialogue.FacialExpression import core.game.content.dialogue.FacialExpression
import core.game.content.global.SkillingPets import core.game.content.global.SkillingPets
import core.game.node.Node import core.game.node.Node
import core.game.node.scenery.Scenery
import core.game.node.scenery.SceneryBuilder
import core.game.node.entity.impl.Animator import core.game.node.entity.impl.Animator
import core.game.node.entity.npc.drop.DropFrequency import core.game.node.entity.npc.drop.DropFrequency
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
@@ -18,7 +16,10 @@ import core.game.node.entity.skill.gather.SkillingTool
import core.game.node.entity.skill.gather.mining.MiningNode import core.game.node.entity.skill.gather.mining.MiningNode
import core.game.node.item.ChanceItem import core.game.node.item.ChanceItem
import core.game.node.item.Item import core.game.node.item.Item
import core.game.node.scenery.Scenery
import core.game.node.scenery.SceneryBuilder
import core.game.system.task.Pulse import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Animation
import core.tools.RandomFunction import core.tools.RandomFunction
import core.tools.StringUtils import core.tools.StringUtils
@@ -37,6 +38,15 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
private var isMiningGems = false private var isMiningGems = false
private var ticks = 0 private var ticks = 0
protected var resetAnimation = true protected var resetAnimation = true
// Perfect Gold Ore in Witchhaven Dungeon (Family Crest)
private val perfectGoldOreLocations = listOf(
Location(2735, 9695, 0),
Location(2737, 9689, 0),
Location(2740, 9684, 0),
Location(2737, 9683, 0),
)
fun message(type: Int) { fun message(type: Int) {
if (type == 0) { if (type == 0) {
player.packetDispatch.sendMessage("You swing your pickaxe at the rock...") player.packetDispatch.sendMessage("You swing your pickaxe at the rock...")
@@ -67,6 +77,12 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
if (resource == null) { if (resource == null) {
return return
} }
if (resource!!.id == 2099 &&
!perfectGoldOreLocations.contains(node.location) ) {
// Perfect Gold Ore Id's outside of Witchhaven
// are replaced with a normal gold rock.
resource = MiningNode.forId(2098)
}
if (resource!!.id == 2491) { if (resource!!.id == 2491) {
isMiningEssence = true isMiningEssence = true
} }
@@ -1,4 +1,4 @@
package rs09.game.interaction.`object` package rs09.game.node.entity.skill.gather.mining
import api.* import api.*
import core.game.node.entity.skill.gather.SkillingResource import core.game.node.entity.skill.gather.SkillingResource
@@ -14,13 +14,13 @@ class ProspectListener : InteractionListener {
override fun defineListeners() { override fun defineListeners() {
on(SCENERY, "prospect") { player, node -> on(SCENERY, "prospect") { player, node ->
/** Check if the rock contains gems */ val rock = SkillingResource.forId(node.id)
if(MiningNode.forId(node.id).identifier == 13.toByte()) {
val rock = SkillingResource.forId(node.asScenery().id)
if(rock == null) { if(rock == null) {
sendMessage(player, "There is no ore currently available in this rock.") sendMessage(player, "There is no ore currently available in this rock.")
return@on true return@on true
} }
/** Check if the rock contains gems */
if(MiningNode.forId(node.id).identifier == 13.toByte()) {
sendMessage(player,"You examine the rock for ores...") sendMessage(player,"You examine the rock for ores...")
/** Send a simple text string saying it's a gem rock */ /** Send a simple text string saying it's a gem rock */
player.pulseManager.run(object : Pulse(3) { player.pulseManager.run(object : Pulse(3) {
@@ -32,11 +32,6 @@ class ProspectListener : InteractionListener {
} }
/** If it doesn't contain gems */ /** If it doesn't contain gems */
else { else {
val rock = SkillingResource.forId(node.id)
if(rock == null) {
sendMessage(player, "There is no ore currently available in this rock.")
return@on true
}
sendMessage(player,"You examine the rock for ores...") sendMessage(player,"You examine the rock for ores...")
/** Get the name of the rock's reward and sends a message to the player */ /** Get the name of the rock's reward and sends a message to the player */
player.pulseManager.run(object : Pulse(3) { player.pulseManager.run(object : Pulse(3) {