Removed the unnecessary and annoying player lock when cooking an item
Moved all the achievement diary checks out into the achievement event receiver Refactored `ResourceGatheredEvent` -> `ResourceProducedEvent` and added a new optional field, `original` for item processing
This commit is contained in:
@@ -5,7 +5,7 @@ import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.link.TeleportManager.TeleportType
|
||||
|
||||
data class ResourceGatheredEvent(val itemId: Int, val amount: Int, val source: Node) : Event
|
||||
data class ResourceProducedEvent(val itemId: Int, val amount: Int, val source: Node, val original: Int = -1) : Event
|
||||
data class NPCKillEvent(val npc: NPC) : Event
|
||||
data class TeleportEvent(val type: TeleportType, val source: Int = -1) : Event
|
||||
data class LitFireEvent(val logId: Int) : Event
|
||||
|
||||
@@ -3,7 +3,7 @@ package rs09.game
|
||||
import api.events.*
|
||||
|
||||
object Event {
|
||||
val ResourceGathered = ResourceGatheredEvent::class.java
|
||||
val ResourceProduced = ResourceProducedEvent::class.java
|
||||
val NPCKilled = NPCKillEvent::class.java
|
||||
val Teleport = TeleportEvent::class.java
|
||||
val FireLit = LitFireEvent::class.java
|
||||
|
||||
@@ -10,7 +10,6 @@ import core.game.node.entity.skill.gather.mining.MiningNode
|
||||
import core.game.node.entity.skill.gather.woodcutting.WoodcuttingNode
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.system.SystemLogger
|
||||
|
||||
/**
|
||||
* Event receivers for tutorial island
|
||||
@@ -191,9 +190,9 @@ object TutorialInteractionReceiver : EventHook<InteractionEvent>
|
||||
}
|
||||
}
|
||||
|
||||
object TutorialResourceReceiver : EventHook<ResourceGatheredEvent>
|
||||
object TutorialResourceReceiver : EventHook<ResourceProducedEvent>
|
||||
{
|
||||
override fun process(entity: Entity, event: ResourceGatheredEvent) {
|
||||
override fun process(entity: Entity, event: ResourceProducedEvent) {
|
||||
if(entity !is Player) return
|
||||
|
||||
when(getAttribute(entity, "tutorial:stage", 0))
|
||||
|
||||
@@ -11,7 +11,6 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.Event
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.GameWorld.settings
|
||||
import rs09.game.world.repository.Repository
|
||||
@@ -31,7 +30,7 @@ object TutorialStage {
|
||||
{
|
||||
player.hook(Event.ButtonClicked, TutorialButtonReceiver)
|
||||
player.hook(Event.Interaction, TutorialInteractionReceiver)
|
||||
player.hook(Event.ResourceGathered, TutorialResourceReceiver)
|
||||
player.hook(Event.ResourceProduced, TutorialResourceReceiver)
|
||||
player.hook(Event.UsedWith, TutorialUseWithReceiver)
|
||||
player.hook(Event.FireLit, TutorialFireReceiver)
|
||||
player.hook(Event.NPCKilled, TutorialKillReceiver)
|
||||
|
||||
@@ -16,7 +16,7 @@ import rs09.game.Event
|
||||
class DiaryEventHook : LoginListener
|
||||
{
|
||||
override fun login(player: Player) {
|
||||
player.hook(Event.ResourceGathered, DiaryGatherHooks)
|
||||
player.hook(Event.ResourceProduced, DiaryGatherHooks)
|
||||
player.hook(Event.Teleport, DiaryTeleportHooks)
|
||||
player.hook(Event.NPCKilled, DiaryCombatHooks)
|
||||
player.hook(Event.FireLit, DiaryFireHooks)
|
||||
@@ -72,9 +72,9 @@ class DiaryEventHook : LoginListener
|
||||
}
|
||||
}
|
||||
|
||||
private object DiaryGatherHooks : EventHook<ResourceGatheredEvent>
|
||||
private object DiaryGatherHooks : EventHook<ResourceProducedEvent>
|
||||
{
|
||||
override fun process(entity: Entity, event: ResourceGatheredEvent) {
|
||||
override fun process(entity: Entity, event: ResourceProducedEvent) {
|
||||
if(entity !is Player) return
|
||||
val regionId = entity.viewport.region.id
|
||||
when(event.itemId)
|
||||
@@ -129,19 +129,35 @@ class DiaryEventHook : LoginListener
|
||||
Items.SILVER_ORE_442 -> if(regionId == 13107) finishTask(entity, DiaryType.LUMBRIDGE, 2, 10)
|
||||
|
||||
Items.COAL_453 -> if(regionId == 12593) finishTask(entity, DiaryType.LUMBRIDGE, 2, 11)
|
||||
|
||||
Items.BASS_365 -> if(regionId == 11317 && getAttribute(entity, "diary:seers:bass-caught", false)) finishTask(entity, DiaryType.SEERS_VILLAGE, 1, 11)
|
||||
|
||||
Items.SHARK_385 -> if(regionId == 11317 && getAttribute(entity, "diary:seers:shark-cooked", false) && isEquipped(entity, Items.COOKING_GAUNTLETS_775)) entity.incrementAttribute("/save:diary:seers:shark-cooked")
|
||||
|
||||
Items.LOBSTER_379 -> if(event.source.id == Scenery.COOKING_RANGE_114) finishTask(entity, DiaryType.LUMBRIDGE, 2, 4)
|
||||
}
|
||||
|
||||
when(event.original)
|
||||
{
|
||||
Items.RAW_RAT_MEAT_2134 -> if((regionId == 12593 || regionId == 12849) && event.itemId == Items.COOKED_MEAT_2142) finishTask(entity, DiaryType.LUMBRIDGE, 1, 10)
|
||||
}
|
||||
|
||||
if(getAttribute(entity, "diary:seers:shark-caught", 0) >= 5)
|
||||
finishTask(entity, DiaryType.SEERS_VILLAGE, 2, 7)
|
||||
if(getAttribute(entity, "diary:seers:shark-cooked", 0) >= 5)
|
||||
finishTask(entity, DiaryType.SEERS_VILLAGE, 2, 8)
|
||||
|
||||
if((regionId == 12593 || regionId == 12849) && event.source.name.startsWith("dead", true))
|
||||
finishTask(entity, DiaryType.LUMBRIDGE, 1, 8)
|
||||
|
||||
if(event.source.id == 333 && entity.zoneMonitor.isInZone("karamja"))
|
||||
if(event.source.id == NPCs.FISHING_SPOT_333 && entity.zoneMonitor.isInZone("karamja"))
|
||||
finishTask(entity, DiaryType.KARAMJA, 0, 6)
|
||||
|
||||
if(event.source.id == Scenery.YEW_TREE_8513 && regionId == 11828)
|
||||
finishTask(entity, DiaryType.FALADOR, 2, 3)
|
||||
|
||||
if(event.source.id == Scenery.COOKING_RANGE_114 && regionId == 12850)
|
||||
finishTask(entity, DiaryType.LUMBRIDGE, 0, 7)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package rs09.game.node.entity.skill.cooking
|
||||
|
||||
import api.*
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
@@ -32,7 +32,7 @@ class DoughMakingListener : InteractionListener() {
|
||||
end()
|
||||
if(removeItem(player!!, used) && removeItem(player!!, with)){
|
||||
addItem(player!!, products[buttonID - 1])
|
||||
player!!.dispatch(ResourceGatheredEvent(products[buttonID - 1], 1, player!!))
|
||||
player!!.dispatch(ResourceProducedEvent(products[buttonID - 1], 1, player!!))
|
||||
sendMessage(player!!, "You mix the flower and the water to make some ${getItemName(products[buttonID - 1]).toLowerCase()}.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package rs09.game.node.entity.skill.gather.fishing
|
||||
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.game.content.global.SkillingPets
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
@@ -113,7 +113,7 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
|
||||
if (player.skillTasks.hasTask()) {
|
||||
updateSkillTask()
|
||||
}
|
||||
player.dispatch(ResourceGatheredEvent(fish!!.item.id, fish!!.item.amount, node!!))
|
||||
player.dispatch(ResourceProducedEvent(fish!!.item.id, fish!!.item.amount, node!!))
|
||||
SkillingPets.checkPetDrop(player, SkillingPets.HERON)
|
||||
val item = fish!!.item
|
||||
if (isActive(SkillcapePerks.GREAT_AIM, player) && RandomFunction.random(100) <= 5) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package rs09.game.node.entity.skill.gather.mining
|
||||
|
||||
import api.*
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
@@ -118,7 +118,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
|
||||
reward = calculateReward(reward) // calculate rewards
|
||||
rewardAmount = calculateRewardAmount(reward) // calculate amount
|
||||
|
||||
player.dispatch(ResourceGatheredEvent(reward, rewardAmount, node))
|
||||
player.dispatch(ResourceProducedEvent(reward, rewardAmount, node))
|
||||
SkillingPets.checkPetDrop(player, SkillingPets.GOLEM) // roll for pet
|
||||
|
||||
//add experience
|
||||
|
||||
Reference in New Issue
Block a user