mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-19 04:50:23 -07:00
added probably more authentic equip timing
This commit is contained in:
parent
42a4e99f78
commit
e54f8c393c
1 changed files with 53 additions and 43 deletions
|
|
@ -1,15 +1,17 @@
|
||||||
package rs09.game.content.global.action
|
package rs09.game.content.global.action
|
||||||
|
|
||||||
import core.game.container.impl.EquipmentContainer
|
import core.game.container.impl.EquipmentContainer
|
||||||
|
import core.game.node.Node
|
||||||
import core.game.node.entity.combat.equipment.WeaponInterface
|
import core.game.node.entity.combat.equipment.WeaponInterface
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.entity.player.link.audio.Audio
|
import core.game.node.entity.player.link.audio.Audio
|
||||||
import core.game.node.entity.player.link.diary.DiaryType
|
import core.game.node.entity.player.link.diary.DiaryType
|
||||||
|
import core.game.system.task.Pulse
|
||||||
import core.game.world.map.zone.ZoneBorders
|
import core.game.world.map.zone.ZoneBorders
|
||||||
import core.plugin.Plugin
|
import core.plugin.Plugin
|
||||||
import rs09.game.interaction.OptionListener
|
import rs09.game.interaction.OptionListener
|
||||||
import rs09.game.system.config.ItemConfigParser
|
import rs09.game.system.config.ItemConfigParser
|
||||||
import rs09.game.world.GameWorld.ticks
|
import rs09.game.world.GameWorld
|
||||||
import rs09.tools.Items
|
import rs09.tools.Items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,17 +24,31 @@ class EquipHandler : OptionListener() {
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
|
|
||||||
on(ITEM,"equip","wield","wear"){player,node ->
|
on(ITEM,"equip","wield","wear"){player,node ->
|
||||||
|
GameWorld.Pulser.submit(object : Pulse(){
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
handleEquip(player,node)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun handleEquip(player: Player,node: Node){
|
||||||
val item = node.asItem()
|
val item = node.asItem()
|
||||||
|
|
||||||
if(item == null || player.inventory[item.slot] != item){
|
if(item == null || player.inventory[item.slot] != item){
|
||||||
return@on true
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val equipStateListener = item.definition.getConfiguration<Plugin<Any>>("equipment", null)
|
val equipStateListener = item.definition.getConfiguration<Plugin<Any>>("equipment", null)
|
||||||
if(equipStateListener != null){
|
if(equipStateListener != null){
|
||||||
val bool = equipStateListener.fireEvent("equip",player,item)
|
val bool = equipStateListener.fireEvent("equip",player,item)
|
||||||
if(bool != true){
|
if(bool != true){
|
||||||
return@on true
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,9 +57,8 @@ class EquipHandler : OptionListener() {
|
||||||
if (lock.message != null) {
|
if (lock.message != null) {
|
||||||
player.packetDispatch.sendMessage(lock.message)
|
player.packetDispatch.sendMessage(lock.message)
|
||||||
}
|
}
|
||||||
return@on true
|
return
|
||||||
}
|
}
|
||||||
player.setAttribute("equipLock:" + item.id, ticks + 2)
|
|
||||||
|
|
||||||
if (player.equipment.add(item, item.slot, true, true)) {
|
if (player.equipment.add(item, item.slot, true, true)) {
|
||||||
//check if a brawling glove is being equipped and register it
|
//check if a brawling glove is being equipped and register it
|
||||||
|
|
@ -65,11 +80,6 @@ class EquipHandler : OptionListener() {
|
||||||
wif.openAutocastSelect()
|
wif.openAutocastSelect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return@on true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue