forked from 2009Scape/Server
Implement pickpocketing auto-repeating if the player is wearing Gloves of Silence
The player.lock function doesn't run if the player has gloves on, since it prevents triggering the pickpocket action immediately afterwards. To avoid pickpocketing every tick, we check the game ticks if the player has gloves and only perform the action every other tick. Testing indicates that manual pickpocketing can occur every 2 ticks, so the auto-repeat occurs at the same rate. If the player fails pickpocketing, the stun will prevent the auto-repeat from activating.
This commit is contained in:
parent
490c6d42ec
commit
b35159b5b7
1 changed files with 15 additions and 2 deletions
|
|
@ -15,6 +15,9 @@ import core.game.node.entity.player.Player
|
|||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Sounds
|
||||
|
||||
import core.game.interaction.InteractionListeners
|
||||
import core.game.world.GameWorld
|
||||
|
||||
class ThievingListeners : InteractionListener {
|
||||
|
||||
companion object {
|
||||
|
|
@ -64,6 +67,10 @@ class ThievingListeners : InteractionListener {
|
|||
player.sendMessage("You don't have enough inventory space to do that.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
//Custom portion. If the player has gloves of silence, only proceed every other tick
|
||||
val glovesOfSilence = player.equipment.contains(Items.GLOVES_OF_SILENCE_10075,1)
|
||||
if (!glovesOfSilence || GameWorld.ticks % 2 == 0) {
|
||||
|
||||
player.animator.animate(PICKPOCKET_ANIM)
|
||||
val lootTable = pickpocketRoll(player, pickpocketData.low, pickpocketData.high, pickpocketData.table)
|
||||
|
|
@ -80,11 +87,17 @@ class ThievingListeners : InteractionListener {
|
|||
node.asNpc().face(null)
|
||||
} else {
|
||||
playAudio(player, Sounds.PICK_2581)
|
||||
player.lock(2)
|
||||
if (!glovesOfSilence) {
|
||||
player.lock(2)
|
||||
}
|
||||
lootTable.forEach { player.inventory.add(it) }
|
||||
player.skills.addExperience(Skills.THIEVING,pickpocketData.experience)
|
||||
}
|
||||
|
||||
}
|
||||
// if wearing gloves of silence, pickpocket again.
|
||||
if (glovesOfSilence) {
|
||||
InteractionListeners.run(node.id, IntType.NPC,"Pickpocket",player,node)
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue