thieving: Pickpocket sound, hit sounds, fixed stun
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package core.game.node.entity.state.impl;
|
||||
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.impl.Animator;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.audio.Audio;
|
||||
import core.game.node.entity.state.StatePulse;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -18,6 +21,10 @@ public final class StunStatePulse extends StatePulse {
|
||||
*/
|
||||
private static final Graphics STUN_GRAPHIC = new Graphics(80, 96);
|
||||
|
||||
private static final Audio STUN_AUDIO = new Audio(2727, 1, 0);
|
||||
|
||||
private static final Animation STUN_ANIM = new Animation(424, Animator.Priority.VERY_HIGH);
|
||||
|
||||
/**
|
||||
* The stun message.
|
||||
*/
|
||||
@@ -50,7 +57,8 @@ public final class StunStatePulse extends StatePulse {
|
||||
entity.getLocks().lock(getDelay());
|
||||
entity.graphics(STUN_GRAPHIC);
|
||||
if (entity instanceof Player) {
|
||||
entity.asPlayer().getAudioManager().send(3201);
|
||||
entity.asPlayer().getAudioManager().send(STUN_AUDIO);
|
||||
entity.animate(STUN_ANIM);
|
||||
((Player) entity).getPacketDispatch().sendMessage(stunMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ class ThievingListeners : InteractionListener {
|
||||
|
||||
private val PICKPOCKET_ANIM = Animation(881,Animator.Priority.HIGH)
|
||||
private val NPC_ANIM = Animation(422)
|
||||
private val STUN_ANIMATION = Animation(424,Animator.Priority.VERY_HIGH)
|
||||
private val SOUND = Audio(2727, 1, 0)
|
||||
private val SUCCESS = Audio(2581, 1, 0)
|
||||
|
||||
override fun defineListeners() {
|
||||
|
||||
@@ -52,18 +51,23 @@ class ThievingListeners : InteractionListener {
|
||||
|
||||
player.animator.animate(PICKPOCKET_ANIM)
|
||||
val chance = RandomFunction.randomDouble(1.0,100.0)
|
||||
val failTreshold = pickpocketData.getSuccessChance(player) + successMod
|
||||
val failThreshold = pickpocketData.getSuccessChance(player) + successMod
|
||||
|
||||
if(chance > failTreshold){
|
||||
player.stateManager.set(EntityState.STUNNED, secondsToTicks(pickpocketData.stunTime))
|
||||
if(chance > failThreshold){
|
||||
node.asNpc().face(player)
|
||||
node.asNpc().animator.animate(NPC_ANIM)
|
||||
player.animator.animate(STUN_ANIMATION)
|
||||
player.audioManager.send(SOUND)
|
||||
|
||||
val hitSoundId = 518 + RandomFunction.random(4) // choose 1 of 4 possible hit noises
|
||||
player.audioManager.send(hitSoundId, 1, 20) // OSRS defines a delay of 20
|
||||
|
||||
player.stateManager.set(EntityState.STUNNED, secondsToTicks(pickpocketData.stunTime))
|
||||
player.lock(secondsToTicks(pickpocketData.stunTime))
|
||||
|
||||
player.impactHandler.manualHit(node.asNpc(),RandomFunction.random(pickpocketData.stunDamageMin,pickpocketData.stunDamageMax),ImpactHandler.HitsplatType.NORMAL)
|
||||
|
||||
node.asNpc().face(null)
|
||||
} else {
|
||||
player.audioManager.send(SUCCESS)
|
||||
player.lock(2)
|
||||
pickpocketData.table.roll().forEach { player.inventory.add(it) }
|
||||
player.skills.addExperience(Skills.THIEVING,pickpocketData.experience)
|
||||
|
||||
Reference in New Issue
Block a user