Made the PulseManager capable of running multiple pulses simultaneously, in different slots (this makes it function a bit more like an entity queue, though not quite)
Fixed the dupe in the ectofuntus by demoting the action pulses for grinding bones from world pulses to individual pulses, and correcting a bit of the logic Added function to remove multiple attributes at once to the ContentAPI
This commit is contained in:
@@ -788,7 +788,11 @@ fun <T> setAttribute(entity: Entity, attribute: String, value: T) {
|
||||
}
|
||||
|
||||
fun removeAttribute(entity: Entity, attribute: String) {
|
||||
entity.removeAttribute(attribute)
|
||||
entity.removeAttribute(attribute.replace("/save:",""))
|
||||
}
|
||||
|
||||
fun removeAttributes(entity: Entity, vararg attributes: String) {
|
||||
for (attribute in attributes) removeAttribute(entity, attribute)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -277,7 +277,7 @@ class GreenDragonKiller(val style: CombatStyle, area: ZoneBorders? = null) : Scr
|
||||
override fun canSwing(entity: Entity, victim: Entity): InteractionType? {
|
||||
if(victim is Player || victim.name.contains("revenant", ignoreCase = true)) {
|
||||
script.state = State.RUNNING
|
||||
script.bot.pulseManager.current.stop()
|
||||
script.bot.pulseManager.clear()
|
||||
}
|
||||
return super.canSwing(entity, victim)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package rs09.game.content.ame
|
||||
|
||||
import api.poofClear
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.node.entity.impl.PulseType
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
@@ -36,7 +37,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
||||
|
||||
open fun terminate() {
|
||||
finalized = true
|
||||
pulseManager.clear("amemovement")
|
||||
pulseManager.clear(PulseType.STANDARD)
|
||||
RandomEventManager.getInstance(player)?.event = null
|
||||
if (initialized) {
|
||||
poofClear(this)
|
||||
@@ -49,7 +50,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
||||
face(player)
|
||||
return false
|
||||
}
|
||||
}), "amemovement")
|
||||
}), PulseType.STANDARD)
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package rs09.game.content.ame.events.certer
|
||||
|
||||
import api.addItemOrDrop
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.impl.PulseType
|
||||
import core.game.node.entity.player.link.emote.Emotes
|
||||
import rs09.game.content.ame.RandomEventManager
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
@@ -47,7 +48,7 @@ class CerterDialogue(val initial: Boolean) : DialogueFile() {
|
||||
super.end()
|
||||
if (player!!.getAttribute("certer:reward", false)) {
|
||||
// Remove movement pulse to stop following player
|
||||
npc!!.pulseManager.clear("amemovement")
|
||||
npc!!.pulseManager.clear(PulseType.STANDARD)
|
||||
// Wave goodbye
|
||||
npc!!.animate(Emotes.WAVE.animation)
|
||||
// Terminate the event
|
||||
|
||||
+20
-17
@@ -3,6 +3,7 @@ package rs09.game.content.zone.phasmatys.bonegrinder
|
||||
import api.Container
|
||||
import api.*
|
||||
import core.game.content.global.Bones
|
||||
import core.game.node.entity.impl.PulseType
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
@@ -146,7 +147,7 @@ class BoneGrinderListener : InteractionListener {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Pulser.submit(fillPulse)
|
||||
player.pulseManager.run(fillPulse, PulseType.CUSTOM_1)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -162,7 +163,7 @@ class BoneGrinderListener : InteractionListener {
|
||||
return true
|
||||
}
|
||||
|
||||
Pulser.submit(object : Pulse(){
|
||||
player.pulseManager.run(object : Pulse(){
|
||||
var stage = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(stage++){
|
||||
@@ -181,7 +182,7 @@ class BoneGrinderListener : InteractionListener {
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
}, PulseType.CUSTOM_1)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -199,14 +200,18 @@ class BoneGrinderListener : InteractionListener {
|
||||
return true
|
||||
}
|
||||
|
||||
fun handleEmpty(player: Player): Boolean{
|
||||
if(!getAttribute(player,BONE_BIN_KEY,false)){
|
||||
sendMessage(player,"You have no bonemeal to collect.")
|
||||
return true
|
||||
}
|
||||
fun handleEmpty(player: Player): Boolean {
|
||||
val inHopper = getAttribute(player, BONE_HOPPER_KEY, false)
|
||||
val boneType = getAttribute(player, LOADED_BONE_KEY, -1)
|
||||
val hasMeal = getAttribute(player, BONE_BIN_KEY, false) && boneType != -1
|
||||
|
||||
if(getAttribute(player,BONE_HOPPER_KEY,false) && !getAttribute(player,BONE_BIN_KEY,false)){
|
||||
sendMessage(player,"You need to wind the wheel to grind the bones.")
|
||||
if(!hasMeal){
|
||||
if (inHopper)
|
||||
sendMessage(player,"You need to wind the wheel to grind the bones.")
|
||||
else if (boneType == -1)
|
||||
sendMessage(player, "You need to load some bones in the hopper first.")
|
||||
else
|
||||
sendMessage(player,"You have no bonemeal to collect.")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -215,31 +220,29 @@ class BoneGrinderListener : InteractionListener {
|
||||
return true
|
||||
}
|
||||
|
||||
val bone = Bones.values()[getAttribute(player,LOADED_BONE_KEY,-1)]
|
||||
val bone = Bones.values()[boneType]
|
||||
|
||||
removeAttributes(player, BONE_HOPPER_KEY, BONE_BIN_KEY, LOADED_BONE_KEY)
|
||||
lock(player, SCOOP_ANIM.duration + 1)
|
||||
|
||||
Pulser.submit(object : Pulse(){
|
||||
player.pulseManager.run(object : Pulse(){
|
||||
var stage = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(stage++){
|
||||
0 -> {
|
||||
face(player,Location(3658, 3525, 1))
|
||||
lock(player, SCOOP_ANIM.duration)
|
||||
animate(player,SCOOP_ANIM)
|
||||
}
|
||||
SCOOP_ANIM.duration -> {
|
||||
if(removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){
|
||||
addItem(player,bone.boneMeal.id)
|
||||
setAttribute(player,BONE_BIN_KEY,false)
|
||||
setAttribute(player,BONE_HOPPER_KEY,false)
|
||||
setAttribute(player,LOADED_BONE_KEY,-1)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
}, PulseType.CUSTOM_1)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package rs09.game.interaction.item
|
||||
import api.openDialogue
|
||||
import api.sendMessage
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.impl.PulseType
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
@@ -29,7 +30,7 @@ class EnchantedJewelleryListener : InteractionListener {
|
||||
}
|
||||
}
|
||||
private fun handle(player: Player, node: Node, isEquipped: Boolean) {
|
||||
player.pulseManager.current.stop()
|
||||
player.pulseManager.clear(PulseType.STANDARD)
|
||||
val item = node.asItem()
|
||||
val jewellery = EnchantedJewellery.idMap[item.id]
|
||||
if (jewellery != null) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class CombatPulse(
|
||||
/**
|
||||
* The entity.
|
||||
*/
|
||||
private val entity: Entity?) : Pulse(1, entity, null) {
|
||||
val entity: Entity?) : Pulse(1, entity, null) {
|
||||
|
||||
/**
|
||||
* The victim.
|
||||
@@ -108,6 +108,11 @@ class CombatPulse(
|
||||
* The last attack recieved.
|
||||
*/
|
||||
var lastReceivedAttack = 0
|
||||
|
||||
init {
|
||||
running = false
|
||||
}
|
||||
|
||||
override fun pulse(): Boolean {
|
||||
if (victim == null || DeathTask.isDead(entity) || DeathTask.isDead(victim)) {
|
||||
return true
|
||||
@@ -179,7 +184,7 @@ class CombatPulse(
|
||||
}
|
||||
}
|
||||
if (!victim.pulseManager.isMovingPulse) {
|
||||
victim.pulseManager.clear("combat")
|
||||
victim.pulseManager.clear()
|
||||
}
|
||||
victim.setAttribute("combat-time", System.currentTimeMillis() + 10000)
|
||||
victim.setAttribute("combat-attacker", entity)
|
||||
@@ -291,7 +296,9 @@ class CombatPulse(
|
||||
}
|
||||
setVictim(victim)
|
||||
entity.onAttack(victim as Entity?)
|
||||
entity.pulseManager.run(this)
|
||||
|
||||
if (!isAttacking)
|
||||
entity.pulseManager.run(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user