mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-18 12:30:18 -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
|
||||
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.audio.Audio
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.interaction.OptionListener
|
||||
import rs09.game.system.config.ItemConfigParser
|
||||
import rs09.game.world.GameWorld.ticks
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.tools.Items
|
||||
|
||||
/**
|
||||
|
|
@ -22,49 +24,12 @@ class EquipHandler : OptionListener() {
|
|||
override fun defineListeners() {
|
||||
|
||||
on(ITEM,"equip","wield","wear"){player,node ->
|
||||
val item = node.asItem()
|
||||
|
||||
if(item == null || player.inventory[item.slot] != item){
|
||||
return@on true
|
||||
}
|
||||
|
||||
val equipStateListener = item.definition.getConfiguration<Plugin<Any>>("equipment", null)
|
||||
if(equipStateListener != null){
|
||||
val bool = equipStateListener.fireEvent("equip",player,item)
|
||||
if(bool != true){
|
||||
return@on true
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
handleEquip(player,node)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val lock = player.locks.equipmentLock
|
||||
if (lock != null && lock.isLocked) {
|
||||
if (lock.message != null) {
|
||||
player.packetDispatch.sendMessage(lock.message)
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
player.setAttribute("equipLock:" + item.id, ticks + 2)
|
||||
|
||||
if (player.equipment.add(item, item.slot, true, true)) {
|
||||
//check if a brawling glove is being equipped and register it
|
||||
if (item.id in 13845..13857) {
|
||||
player.debug("Registering gloves... ID: " + item.id)
|
||||
player.brawlingGlovesManager.registerGlove(item.id)
|
||||
}
|
||||
if (item.id == Items.BLACK_CHAINBODY_1107 && player.getAttribute("diary:falador:black-chain-bought", false)
|
||||
&& ZoneBorders(2969, 3310, 2975, 3314, 0).insideBorder(player)
|
||||
) {
|
||||
player.achievementDiaryManager.finishTask(player, DiaryType.FALADOR, 0, 2)
|
||||
}
|
||||
player.dialogueInterpreter.close()
|
||||
player.audioManager.send(item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244))
|
||||
if (player.properties.autocastSpell != null) {
|
||||
player.properties.autocastSpell = null
|
||||
val wif = player.getExtension<WeaponInterface>(WeaponInterface::class.java)
|
||||
wif.selectAutoSpell(-1, true)
|
||||
wif.openAutocastSelect()
|
||||
}
|
||||
}
|
||||
})
|
||||
return@on true
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +37,51 @@ class EquipHandler : OptionListener() {
|
|||
|
||||
}
|
||||
|
||||
fun handleEquip(player: Player,node: Node){
|
||||
val item = node.asItem()
|
||||
|
||||
if(item == null || player.inventory[item.slot] != item){
|
||||
return
|
||||
}
|
||||
|
||||
val equipStateListener = item.definition.getConfiguration<Plugin<Any>>("equipment", null)
|
||||
if(equipStateListener != null){
|
||||
val bool = equipStateListener.fireEvent("equip",player,item)
|
||||
if(bool != true){
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
val lock = player.locks.equipmentLock
|
||||
if (lock != null && lock.isLocked) {
|
||||
if (lock.message != null) {
|
||||
player.packetDispatch.sendMessage(lock.message)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (player.equipment.add(item, item.slot, true, true)) {
|
||||
//check if a brawling glove is being equipped and register it
|
||||
if (item.id in 13845..13857) {
|
||||
player.debug("Registering gloves... ID: " + item.id)
|
||||
player.brawlingGlovesManager.registerGlove(item.id)
|
||||
}
|
||||
if (item.id == Items.BLACK_CHAINBODY_1107 && player.getAttribute("diary:falador:black-chain-bought", false)
|
||||
&& ZoneBorders(2969, 3310, 2975, 3314, 0).insideBorder(player)
|
||||
) {
|
||||
player.achievementDiaryManager.finishTask(player, DiaryType.FALADOR, 0, 2)
|
||||
}
|
||||
player.dialogueInterpreter.close()
|
||||
player.audioManager.send(item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244))
|
||||
if (player.properties.autocastSpell != null) {
|
||||
player.properties.autocastSpell = null
|
||||
val wif = player.getExtension<WeaponInterface>(WeaponInterface::class.java)
|
||||
wif.selectAutoSpell(-1, true)
|
||||
wif.openAutocastSelect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Unequips an item.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue