RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.mining.Mining Class Reference

Handles the mining skill. More...

Inheritance diagram for com.runehive.content.skill.impl.mining.Mining:
Collaboration diagram for com.runehive.content.skill.impl.mining.Mining:

Public Member Functions

 Mining (int level, double experience)
 Constructs a new Mining skill.
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 double getBonus (Player player)
static boolean success (Player player, int level, PickaxeData pickaxe)
static boolean success (Player player, OreData ore, PickaxeData pickaxe)
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 clickObject (Player player, ObjectInteractionEvent event)
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 clickNpc (Player player, NpcInteractionEvent event)
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
double modifier ()
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Static Package Attributes

static final Chance< ItemGEM_ITEMS

Private Member Functions

void attempt (Player player, GameObject object, OreData ore)
void start (Player player, GameObject object, OreData ore, PickaxeData pickaxe)

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 mining skill.

Author
Daniel

Definition at line 22 of file Mining.java.

Constructor & Destructor Documentation

◆ Mining()

com.runehive.content.skill.impl.mining.Mining.Mining ( int level,
double experience )

Constructs a new Mining skill.

Definition at line 59 of file Mining.java.

59 {
60 super(Skill.MINING, level, experience);
61 }

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

◆ attempt()

void com.runehive.content.skill.impl.mining.Mining.attempt ( Player player,
GameObject object,
OreData ore )
private

Definition at line 89 of file Mining.java.

89 {
90 PickaxeData pickaxe = PickaxeData.getBestPickaxe(player).orElse(null);
91
92 if (pickaxe == null) {
93 player.message("You don't have a pickaxe.");
94 return;
95 }
96
97 if (!player.skills.get(Skill.MINING).reqLevel(pickaxe.level)) {
98 player.message("You need a level of " + pickaxe.level + " to use this pickaxe!");
99 return;
100 }
101
102 if (!player.skills.get(Skill.MINING).reqLevel(ore.level)) {
103 player.message("You need a mining level of " + ore.level + " to mine this ore!");
104 return;
105 }
106
107
108 start(player, object, ore, pickaxe);
109 }

References com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.content.skill.impl.mining.PickaxeData.getBestPickaxe(), com.runehive.content.skill.impl.mining.OreData.level, com.runehive.content.skill.impl.mining.PickaxeData.level, com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.game.world.entity.skill.Skill.reqLevel(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and start().

Referenced by clickObject().

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

◆ clickObject()

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

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

Definition at line 64 of file Mining.java.

64 {
65 GameObject object = event.getObject();
66 OreData ore = OreData.forId(object.getDefinition().getId());
67
68 if (ore == null) {
69 return false;
70 }
71
72 if (!object.active()) {
73 return false;
74 }
75
76 switch (event.getType()) {
77 case FIRST_CLICK_OBJECT:
78 attempt(player, object, ore);
79
80 break;
81 case SECOND_CLICK_OBJECT:
82 player.send(new SendMessage("You examine the rock for ores..."));
83 World.schedule(2, () -> player.send(new SendMessage("This rock contains " + Utility.formatEnum(ore.name()) + ".")));
84 break;
85 }
86 return true;
87 }

References attempt(), com.runehive.content.skill.impl.mining.OreData.forId(), com.runehive.util.Utility.formatEnum(), com.runehive.game.world.World.schedule(), and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ getBonus()

double com.runehive.content.skill.impl.mining.Mining.getBonus ( Player player)
static

Definition at line 31 of file Mining.java.

31 {
32 double bonus = 0;
33 if(player.equipment.getId(0) == 12013 || player.equipment.getId(0) == 25549)
34 bonus += 0.4;
35 if(player.equipment.getId(4) == 12014 || player.equipment.getId(0) == 25551)
36 bonus += 0.8;
37 if(player.equipment.getId(7) == 12015 || player.equipment.getId(0) == 25553)
38 bonus += 0.6;
39 if(player.equipment.getId(10) == 12016 || player.equipment.getId(0) == 25555)
40 bonus += 0.2;
41
42 var wornPieces = 0;
43 int[] pieces = {12013, 12014, 12015, 12016, 25549, 25551, 25553, 25555};
44 for (int piece : pieces) {
45 if (player.equipment.contains(piece)) {
46 wornPieces++;
47 }
48 }
49
50 if (wornPieces > 3) {
51 bonus = 2.5;
52 }
53
54 return bonus;
55 }

References com.runehive.game.world.items.containers.equipment.Equipment.contains(), com.runehive.game.world.entity.mob.player.Player.equipment, and com.runehive.game.world.items.containers.ItemContainer.getId().

Referenced by com.runehive.game.world.entity.skill.SkillManager.addExperience().

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

◆ start()

void com.runehive.content.skill.impl.mining.Mining.start ( Player player,
GameObject object,
OreData ore,
PickaxeData pickaxe )
private

Definition at line 111 of file Mining.java.

111 {
112 if (!object.getGenericAttributes().has("ores")) {
113 object.getGenericAttributes().set("ores", ore.oreCount);
114 }
115 player.walkTo(object.getPosition(), () -> {
116 player.face(object.getPosition());
117 });
118 World.schedule(1, () -> {
119 player.animate(pickaxe.animation);
120 player.action.execute(new MiningAction(player, object, ore, pickaxe));
121 player.skills.get(Skill.MINING).setDoingSkill(true);
122 });
123 player.message(true, "You swing your pick at the rock...");
124 }

References com.runehive.game.world.entity.mob.Mob.action, com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.content.skill.impl.mining.PickaxeData.animation, com.runehive.game.action.ActionManager.execute(), com.runehive.game.world.entity.mob.Mob.face(), com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.content.skill.impl.mining.OreData.oreCount, com.runehive.game.world.World.schedule(), com.runehive.game.world.entity.skill.Skill.setDoingSkill(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and com.runehive.game.world.entity.mob.Mob.walkTo().

Referenced by attempt().

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

◆ success() [1/2]

boolean com.runehive.content.skill.impl.mining.Mining.success ( Player player,
int level,
PickaxeData pickaxe )
static

Definition at line 138 of file Mining.java.

138 {
139 return SkillRepository.isSuccess(player, Skill.MINING, level, pickaxe.level);
140 }

References com.runehive.content.skill.SkillRepository.isSuccess(), com.runehive.content.skill.impl.mining.PickaxeData.level, 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:

◆ success() [2/2]

boolean com.runehive.content.skill.impl.mining.Mining.success ( Player player,
OreData ore,
PickaxeData pickaxe )
static

Definition at line 126 of file Mining.java.

126 {
127 var playerMiningLevel = player.skills.getMaxLevel(Skill.MINING);
128 //Mining boost for celestial rings
129 if (player.equipment.containsAny(25539, 25541, 25543, 25545)) {
130 playerMiningLevel += 4;
131 }
132 double level = (playerMiningLevel + pickaxe.level) / 2.0D;
133 double successChance = Math.ceil((((level * 50.0D) - ((double) ore.level * 15.0D)) / (double) ore.level / 3.0D) * 4.0D);
134 int roll = Utility.random(99);
135 return successChance >= roll;
136 }

References com.runehive.game.world.items.containers.ItemContainer.containsAny(), com.runehive.game.world.entity.mob.player.Player.equipment, com.runehive.game.world.entity.skill.SkillManager.getMaxLevel(), com.runehive.content.skill.impl.mining.OreData.level, com.runehive.content.skill.impl.mining.PickaxeData.level, com.runehive.game.world.entity.skill.Skill.level, com.runehive.util.Utility.random(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by com.runehive.content.shootingstar.ShootingStarAction.mine(), and com.runehive.content.skill.impl.mining.MiningAction.mine().

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

Member Data Documentation

◆ GEM_ITEMS

final Chance<Item> com.runehive.content.skill.impl.mining.Mining.GEM_ITEMS
staticpackage
Initial value:
= new Chance<>(Arrays.asList(
new WeightedChance<>(6, new Item(1623, 1)),
new WeightedChance<>(5, new Item(1621, 1)),
new WeightedChance<>(4, new Item(1619, 1)),
new WeightedChance<>(3, new Item(1617, 1)),
new WeightedChance<>(1, new Item(1631, 1))
))
The container class that represents an item that can be interacted with.
Definition Item.java:21
Handles a random chance.
Definition Chance.java:14

Definition at line 23 of file Mining.java.

Referenced by com.runehive.content.skill.impl.mining.MiningAction.mine().


The documentation for this class was generated from the following file:
  • java/com/runehive/content/skill/impl/mining/Mining.java