RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
PickpocketAction.java
1package com.osroyale.content.skill.impl.thieving;
2
3import com.osroyale.Config;
4import com.osroyale.game.Animation;
5import com.osroyale.game.action.Action;
6import com.osroyale.game.action.policy.WalkablePolicy;
7import com.osroyale.game.world.entity.combat.hit.Hit;
8import com.osroyale.game.world.entity.mob.data.LockType;
9import com.osroyale.game.world.entity.mob.npc.Npc;
10import com.osroyale.game.world.entity.mob.player.Player;
11import com.osroyale.game.world.entity.skill.Skill;
12import com.osroyale.game.world.position.Area;
13import com.osroyale.net.packet.out.SendMessage;
14import com.osroyale.util.Utility;
15
21public final class PickpocketAction extends Action<Player> {
23 private final PickpocketData pickpocket;
24
26 private final Npc npc;
27
29 public PickpocketAction(Player player, Npc npc, PickpocketData pickpocket) {
30 super(player, 3);
31 this.npc = npc;
32 this.pickpocket = pickpocket;
33 }
34
36 private int failureRate(Player player) {
37 double f1 = pickpocket.getLevel() / 10;
38 double f2 = 100 / ((player.skills.getMaxLevel(Skill.THIEVING) + 1) - pickpocket.getLevel());
39 return (int) Math.floor((f2 + f1) / 2);
40 }
41
42 @Override
43 public void execute() {
44 boolean failed = Utility.random(100) < failureRate(getMob());
45
46 if (failed) {
47 npc.interact(getMob());
48 npc.face(npc.faceDirection);
49 npc.animate(new Animation(422));
50 npc.speak("What do you think you're doing?");
51 getMob().action.clearNonWalkableActions();
52 getMob().damage(new Hit(Utility.random(pickpocket.getDamage())));
53 getMob().locking.lock(pickpocket.getStun(), LockType.STUN);
54 getMob().send(new SendMessage("You failed to pickpocketing the " + npc.getName() + "."));
55 cancel();
56 return;
57 }
58
59 double experience = Area.inSuperDonatorZone(getMob()) || Area.inRegularDonatorZone(getMob()) ? pickpocket.getExperience() * 2 : pickpocket.getExperience();
60 getMob().skills.addExperience(Skill.THIEVING, experience * Config.THIEVING_MODIFICATION);
61 getMob().send(new SendMessage("You have successfully pickpocket the " + npc.getName() + "."));
62 getMob().inventory.add(Utility.randomElement(pickpocket.getLoot()));
63 getMob().locking.unlock();
64 cancel();
65 }
66
67 @Override
68 public String getName() {
69 return "Thieving pickpocket";
70 }
71
72 @Override
73 public boolean prioritized() {
74 return false;
75 }
76
77 @Override
81}
static final double THIEVING_MODIFICATION
Definition Config.java:328
PickpocketAction(Player player, Npc npc, PickpocketData pickpocket)
Action(T mob, int delay, boolean instant)
Definition Action.java:24
synchronized final void cancel()
Definition Task.java:147
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285