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