RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.thieving.Thieving Class Reference

Handles the thieving skill. More...

Inheritance diagram for com.runehive.content.skill.impl.thieving.Thieving:
Collaboration diagram for com.runehive.content.skill.impl.thieving.Thieving:

Public Member Functions

 Thieving (int level, double experience)
Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
double addExperience (double amount)
 Adds experiences to this skill by the given amount.
void addLevel (int amount)
 Adds levels to this skill by the given amount.
void divideExperience (double amount)
 Divides the current experience of this skill by a given amount.
void divideLevel (double amount)
 Divides the current level of this skill by a given amount.
double getExperience ()
 Gets the skill experience.
int getLevel ()
 Gets the current skill level.
int getMaxLevel ()
 Gets the maximum skill level.
int getRoundedExperience ()
 Gets the floor experience.
int getSkill ()
 Gets the skill id.
boolean isDoingSkill ()
double modifyExperience (Function< Double, Double > function)
 Modifies the current experience with a given function.
double modifyExperience (Function< Double, Double > function, int lowerBounds, int upperBounds)
 Modifies the current experience with a given function.
void modifyLevel (Function< Integer, Integer > function)
 Modifies the current level with a given function.
void modifyLevel (Function< Integer, Integer > function, int lowerBounds, int upperBounds)
 Modifies the current level with a given function.
void multiplyExperience (double amount)
 Multiplies the current experience of this skill by a given amount.
void multiplyLevel (double amount)
 Multiplies the current level of this skill by a given amount.
boolean onEvent (Player player, InteractionEvent interactionEvent)
void removeExperience (double amount)
 Removes experiences from this skill by the given amount.
void removeLevel (int amount)
 Removes levels from this skill by the given amount.
boolean reqLevel (int level)
 Determines if your level is greater than or equal to level.
void setDoingSkill (boolean doingSkill)
void setExperience (double experience)
 Sets the experience for this skill.
void setLevel (int level)
 Sets the level for this skill.
void setMaxLevel (int maxLevel)
 Sets the maximum level for this skill.
 Skill (int skill, int level, double experience)
 Constructs a new Skill.
String toString ()

Static Public Member Functions

static void exchange (Player player)
Static Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
static Function< Integer, Integer > add (int amount)
 Creates a function that adds a number by an amount.
static Function< Integer, Integer > divide (double amount)
 Creates a function that divides a number by an amount.
static final int getExperienceForLevel (int level)
 Gets the experience for a given level.
static final byte getLevelForExperience (double experience)
 Gets the level for a given experience amount.
static String getName (int skill)
 Gets the name for a skill id.
static Function< Integer, Integer > multiply (double amount)
 Creates a function that multiplies a number by an amount.
static Function< Integer, Integer > subtract (int amount)
 Creates a function that subtracts a number by an amount.

Protected Member Functions

boolean clickNpc (Player player, NpcInteractionEvent event)
boolean clickObject (Player player, ObjectInteractionEvent event)
double modifier ()
Protected Member Functions inherited from com.runehive.game.world.entity.skill.Skill
boolean clickButton (Player player, ClickButtonInteractionEvent event)
boolean clickItem (Player player, ItemInteractionEvent event)
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Private Member Functions

int failureRate (PickpocketData pickpocket, Player player)
 The failure rate for pickpocketing.

Additional Inherited Members

Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
transient final Stopwatch stopwatch = Stopwatch.start()
Static Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
static final int AGILITY = 16
 The agility skill id.
static final int ATTACK = 0
 The attack skill id.
static final int CONSTRUCTION = 21
 The construction skill id.
static final int COOKING = 7
 The cooking skill id.
static final int CRAFTING = 12
 The crafting skill id.
static final int DEFENCE = 1
 The defence skill id.
static final int FARMING = 19
 The farming skill id.
static final int FIREMAKING = 11
 The firemaking skill id.
static final int FISHING = 10
 The fishing skill id.
static final int FLETCHING = 9
 The fletching skill id.
static final int HERBLORE = 15
 The herblore skill id.
static final int HITPOINTS = 3
 The hitpoints skill id.
static final int HUNTER = 22
 The hunter skill id.
static final int[][] INTERFACE_DATA
 Skill tab string data.
static final int MAGIC = 6
 The magic skill id.
static final int MINING = 14
 The mining skill id.
static final int PRAYER = 5
 The prayer skill id.
static final int RANGED = 4
 The ranged skill id.
static final int RUNECRAFTING = 20
 The runecrafting skill id.
static final int SKILL_COUNT = 23
 The amount of available skills.
static final int SLAYER = 18
 The slayer skill id.
static final int SMITHING = 13
 The smithing skill id.
static final int STRENGTH = 2
 The strength skill id.
static final int THIEVING = 17
 The thieving skill id.
static final int TOTAL_SKILL_LEVEL = 99 * SKILL_COUNT
 The total skill amount.
static final int WOODCUTTING = 8
 The woodcutting skill id.

Detailed Description

Handles the thieving skill.

Author
Daniel

Definition at line 31 of file Thieving.java.

Constructor & Destructor Documentation

◆ Thieving()

com.runehive.content.skill.impl.thieving.Thieving.Thieving ( int level,
double experience )

Definition at line 33 of file Thieving.java.

33 {
34 super(Skill.THIEVING, level, experience);
35 }

References com.runehive.game.world.entity.skill.Skill.experience, com.runehive.game.world.entity.skill.Skill.level, and com.runehive.game.world.entity.skill.Skill.Skill().

Here is the call graph for this function:

Member Function Documentation

◆ clickNpc()

boolean com.runehive.content.skill.impl.thieving.Thieving.clickNpc ( Player player,
NpcInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 52 of file Thieving.java.

52 {
53 if (event.getOpcode() != 1) {
54 return false;
55 }
56
57 Npc npc = event.getNpc();
58 PickpocketData pickpocket = PickpocketData.forId(npc.id);
59
60 if (pickpocket == null) {
61 return false;
62 }
63
64 if (player.skills.get(THIEVING).isDoingSkill()) {
65 return true;
66 }
67
68 if (player.skills.getLevel(Skill.THIEVING) < pickpocket.getLevel()) {
69 player.send(new SendMessage("You need a thieving level of " + pickpocket.getLevel() + " to do this!"));
70 return true;
71 }
72
73 boolean failed = Utility.random(100) < failureRate(pickpocket, player);
74
75 player.animate(new Animation(881));
76 player.locking.lock(1, LockType.MASTER);
77 player.skills.get(THIEVING).setDoingSkill(true);
78 player.send(new SendMessage("You attempt to pickpocket the " + npc.getName() + "..."));
79
80 World.schedule(2, () -> {
81 if (failed) {
82 npc.animate(new Animation(422));
83 npc.speak("What do you think you're doing?");
84 player.locking.lock(pickpocket.getStun(), LockType.STUN);
85 player.damage(new Hit(Utility.random(pickpocket.getDamage())));
86 player.send(new SendMessage("You failed to pickpocketing the " + npc.getName() + "."));
87 return;
88 }
89
90 double experience = Area.inSuperDonatorZone(player) || Area.inRegularDonatorZone(player) ? pickpocket.getExperience() * 2 : pickpocket.getExperience();
91
92 player.skills.get(THIEVING).setDoingSkill(false);
93 player.inventory.add(Utility.randomElement(pickpocket.getLoot()));
94 player.send(new SendMessage("You have successfully pickpocket the " + npc.getName() + "."));
95 player.skills.addExperience(Skill.THIEVING, experience * Config.THIEVING_MODIFICATION);
96 RandomEventHandler.trigger(player);
97 Pets.onReward(player, PetData.ROCKY);
98 player.playerAssistant.activateSkilling(1);
99 });
100 return true;
101 }

References com.runehive.game.world.entity.mob.player.PlayerAssistant.activateSkilling(), com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.skill.SkillManager.addExperience(), com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.game.world.entity.mob.Mob.damage(), com.runehive.game.world.entity.skill.Skill.experience, failureRate(), com.runehive.content.skill.impl.thieving.PickpocketData.forId(), com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.content.skill.impl.thieving.PickpocketData.getDamage(), com.runehive.content.skill.impl.thieving.PickpocketData.getExperience(), com.runehive.content.skill.impl.thieving.PickpocketData.getLevel(), com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.content.skill.impl.thieving.PickpocketData.getLoot(), com.runehive.game.world.entity.mob.npc.Npc.getName(), com.runehive.game.world.entity.mob.Mob.getNpc(), com.runehive.content.skill.impl.thieving.PickpocketData.getStun(), com.runehive.game.world.entity.mob.Mob.id, com.runehive.game.world.position.Area.inRegularDonatorZone(), com.runehive.game.world.position.Area.inSuperDonatorZone(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.entity.skill.Skill.isDoingSkill(), com.runehive.game.world.entity.mob.Locking.lock, com.runehive.game.world.entity.mob.Mob.locking, com.runehive.game.world.entity.mob.data.LockType.MASTER, com.runehive.content.pet.Pets.onReward(), com.runehive.game.world.entity.mob.player.Player.playerAssistant, com.runehive.util.Utility.random(), com.runehive.util.Utility.randomElement(), com.runehive.content.pet.PetData.ROCKY, com.runehive.game.world.World.schedule(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.skill.Skill.setDoingSkill(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, com.runehive.game.world.entity.mob.Mob.speak(), com.runehive.game.world.entity.mob.data.LockType.STUN, com.runehive.game.world.entity.skill.Skill.THIEVING, com.runehive.Config.THIEVING_MODIFICATION, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Here is the call graph for this function:

◆ clickObject()

boolean com.runehive.content.skill.impl.thieving.Thieving.clickObject ( Player player,
ObjectInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 104 of file Thieving.java.

104 {
105 if (event.getOpcode() == 0 && event.getObject().getId() == 7236) {
106 WallSafe.thieve(player);
107 return true;
108 }
109
110 if (event.getOpcode() != 1) {
111 return false;
112 }
113
114 GameObject object = event.getObject();
115
116 if (!StallData.forId(object.getId()).isPresent()) {
117 return false;
118 }
119
120 StallData stall = StallData.forId(object.getId()).get();
121
122 if (!player.inventory.hasCapacityFor(stall.getItem())) {
123 player.send(new SendMessage("You need at least 1 free inventory space to do this!"));
124 return true;
125 }
126
127 if (player.skills.get(THIEVING).getLevel() < stall.getLevel()) {
128 player.send(new SendMessage("You need a thieving level of " + stall.getLevel() + " to steal from this stall."));
129 return true;
130 }
131
132 if (player.skills.get(THIEVING).isDoingSkill()) {
133 return true;
134 }
135
136 int base_chance = 50;
137 int modified_chance = (int) (PlayerRight.isDonator(player) ? base_chance * 2.3
138 : SkillCape.isEquipped(player, SkillCape.THIEVING) ? 2.2 : base_chance);
139 boolean failed = Utility.random(modified_chance) == 0;
140
141 player.animate(new Animation(832));
142 player.locking.lock(1, LockType.MASTER);
143 player.skills.get(THIEVING).setDoingSkill(true);
144
145 World.schedule(3, () -> {
146 double experience = stall.getExperience() * Config.THIEVING_MODIFICATION;
147 double newExperience = Area.inSuperDonatorZone(player) || Area.inRegularDonatorZone(player)? experience * 2 : experience;
148
149 if (failed) {
150 player.damage(new Hit(Utility.random(3, 6)));
151 player.speak("Ouch!");
152 player.send(new SendMessage("You failed to thieve from the stall and were instead inflicted pain!"));
153 return;
154 }
155
156 player.inventory.add(stall.getItem());
157
158 if (PlayerRight.isSuper(player) && Utility.random(0, 10) > 8) {
159 player.inventory.addOrDrop(stall.getItem());
160 }
161
162 player.skills.get(THIEVING).setDoingSkill(false);
163 player.skills.addExperience(THIEVING, newExperience);
164 player.forClan(channel -> channel.activateTask(ClanTaskKey.THIEVING_STALL, player.getName()));
165 Pets.onReward(player, PetData.ROCKY);
166 RandomEventHandler.trigger(player);
167 player.playerAssistant.activateSkilling(1);
168 });
169 return true;
170 }

References com.runehive.game.world.entity.mob.player.PlayerAssistant.activateSkilling(), com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.skill.SkillManager.addExperience(), com.runehive.game.world.items.containers.inventory.Inventory.addOrDrop(), com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.game.world.entity.mob.Mob.damage(), com.runehive.game.world.entity.skill.Skill.experience, com.runehive.game.world.entity.mob.player.Player.forClan(), com.runehive.content.skill.impl.thieving.StallData.forId(), com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.content.skill.impl.thieving.StallData.getExperience(), com.runehive.content.skill.impl.thieving.StallData.getItem(), com.runehive.content.skill.impl.thieving.StallData.getLevel(), com.runehive.game.world.entity.skill.Skill.getLevel(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.game.world.position.Area.inRegularDonatorZone(), com.runehive.game.world.position.Area.inSuperDonatorZone(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.entity.skill.Skill.isDoingSkill(), com.runehive.game.world.entity.mob.player.PlayerRight.isDonator(), com.runehive.content.skillcape.SkillCape.isEquipped(), com.runehive.game.world.entity.mob.player.PlayerRight.isSuper(), com.runehive.game.world.entity.mob.Locking.lock, com.runehive.game.world.entity.mob.Mob.locking, com.runehive.game.world.entity.mob.data.LockType.MASTER, com.runehive.content.pet.Pets.onReward(), com.runehive.game.world.entity.mob.player.Player.playerAssistant, com.runehive.util.Utility.random(), com.runehive.content.pet.PetData.ROCKY, com.runehive.game.world.World.schedule(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.skill.Skill.setDoingSkill(), com.runehive.game.world.entity.mob.Mob.skills, com.runehive.game.world.entity.mob.Mob.speak(), com.runehive.content.skill.impl.thieving.WallSafe.thieve(), com.runehive.content.skillcape.SkillCape.THIEVING, com.runehive.game.world.entity.skill.Skill.THIEVING, com.runehive.Config.THIEVING_MODIFICATION, com.runehive.content.clanchannel.content.ClanTaskKey.THIEVING_STALL, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Here is the call graph for this function:

◆ exchange()

void com.runehive.content.skill.impl.thieving.Thieving.exchange ( Player player)
static

Definition at line 172 of file Thieving.java.

172 {
173 int amount = 0, count = 0;
174
175 for (Item item : player.inventory.toArray()) {
176 if (StallData.isReward(item) && player.inventory.remove(item, -1, false)) {
177 amount += StallData.getValue(item);
178 count++;
179 }
180 }
181
182 if (count == 0) {
183 player.dialogueFactory.sendNpcChat(3439, Expression.ANGRY, "You do not have any items of which I am interested", "in purchasing.").execute();
184 return;
185 }
186
187 if (player.inventory.add(new Item(Config.CURRENCY, amount))) {
188 player.send(new SendMessage("You have exchanged " + count + " goods for " + Utility.formatDigits(amount) + " coins."));
189 player.inventory.refresh();
190 return;
191 }
192
193 player.send(new SendMessage("You have no items which the merchant would like to purchase."));
194 }

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.content.dialogue.Expression.ANGRY, com.runehive.Config.CURRENCY, com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.content.dialogue.DialogueFactory.execute(), com.runehive.util.Utility.formatDigits(), com.runehive.content.skill.impl.thieving.StallData.getValue(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.content.skill.impl.thieving.StallData.isReward(), com.runehive.game.world.items.containers.inventory.Inventory.refresh(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.content.dialogue.DialogueFactory.sendNpcChat(), and com.runehive.game.world.items.containers.ItemContainer.toArray().

Here is the call graph for this function:

◆ failureRate()

int com.runehive.content.skill.impl.thieving.Thieving.failureRate ( PickpocketData pickpocket,
Player player )
private

The failure rate for pickpocketing.

Definition at line 40 of file Thieving.java.

40 {
41 double f1 = (double) pickpocket.getLevel() / 10;
42 double f2 = (double) 100 / ((player.skills.getMaxLevel(Skill.THIEVING) + 1) - pickpocket.getLevel());
43 return (int) Math.floor((f2 + f1) / 2);
44 }

References com.runehive.content.skill.impl.thieving.PickpocketData.getLevel(), com.runehive.game.world.entity.skill.SkillManager.getMaxLevel(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by clickNpc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modifier()

double com.runehive.content.skill.impl.thieving.Thieving.modifier ( )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 47 of file Thieving.java.

47 {
48 return Config.THIEVING_MODIFICATION;
49 }

References com.runehive.Config.THIEVING_MODIFICATION.


The documentation for this class was generated from the following file: