RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.runecrafting.Runecraft Class Reference

Handles the runecrafting skill. More...

Inheritance diagram for com.runehive.content.skill.impl.runecrafting.Runecraft:
Collaboration diagram for com.runehive.content.skill.impl.runecrafting.Runecraft:

Public Member Functions

 Runecraft (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 ()

Protected Member Functions

boolean clickItem (Player player, ItemInteractionEvent 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 clickNpc (Player player, NpcInteractionEvent event)
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Private Member Functions

boolean click (Player player, GameObject object)
 Handles teleporting to various runecrafting altars.
void craft (Player player, int essence, int amount, RunecraftData rune)
int getEssence (Player player)
 Gets the essence identification from player.
int multiplier (Player player, RunecraftData rune)
 The runecrafting multiplier.

Additional Inherited Members

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

Author
Daniel

Definition at line 27 of file Runecraft.java.

Constructor & Destructor Documentation

◆ Runecraft()

com.runehive.content.skill.impl.runecrafting.Runecraft.Runecraft ( int level,
double experience )

Definition at line 29 of file Runecraft.java.

29 {
30 super(Skill.RUNECRAFTING, level, experience);
31 }

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

◆ click()

boolean com.runehive.content.skill.impl.runecrafting.Runecraft.click ( Player player,
GameObject object )
private

Handles teleporting to various runecrafting altars.

Definition at line 158 of file Runecraft.java.

158 {
159 if (!RunecraftTeleport.forId(object.getId()).isPresent()) {
160 return false;
161 }
162
163 RunecraftTeleport teleport = RunecraftTeleport.forId(object.getId()).get();
164 player.move(teleport.getPosition());
165 System.out.println("reached here");
166 return true;
167 }

References com.runehive.content.skill.impl.runecrafting.RunecraftTeleport.forId(), and com.runehive.game.world.entity.mob.Mob.move().

Referenced by clickObject().

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

◆ clickItem()

boolean com.runehive.content.skill.impl.runecrafting.Runecraft.clickItem ( Player player,
ItemInteractionEvent event )
protected

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

Definition at line 39 of file Runecraft.java.

39 {
40 Item item = event.getItem();
41
42 RunecraftPouchData pouch = RunecraftPouchData.forItem(item.getId());
43
44 if (pouch == null) {
45 return false;
46 }
47
48 int opcode = event.getOpcode();
49
50 switch (opcode) {
51 case 0:
52 player.runecraftPouch.deposit(pouch);
53 break;
54 case 1:
55 player.runecraftPouch.withdraw(pouch);
56 break;
57 }
58 return true;
59 }

References com.runehive.content.skill.impl.runecrafting.RunecraftPouch.deposit(), com.runehive.content.skill.impl.runecrafting.RunecraftPouchData.forItem(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.entity.mob.player.Player.runecraftPouch, and com.runehive.content.skill.impl.runecrafting.RunecraftPouch.withdraw().

Here is the call graph for this function:

◆ clickObject()

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

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

Definition at line 62 of file Runecraft.java.

62 {
63
64 if (event.getOpcode() != 0) {
65 return false;
66 }
67
68 GameObject object = event.getObject();
69
70 if (click(player, object)) {
71 return true;
72 }
73
74 if (!RunecraftData.forId(object.getId()).isPresent()) {
75 return false;
76 }
77
78 RunecraftData rune = RunecraftData.forId(object.getId()).get();
79
80 int essence = getEssence(player);
81
82 if (player.skills.getLevel(Skill.RUNECRAFTING) < rune.getLevel()) {
83 player.send(new SendMessage("You need a runecrafting level of " + rune.getLevel() + " to do this!"));
84 return true;
85 }
86
87 if (essence == -1) {
88 player.send(new SendMessage("You do not have any essence!"));
89 return true;
90 }
91
92 int amount = player.inventory.computeAmountForId(essence);
93 int multiplier = multiplier(player, rune);
94
95 player.locking.lock(2);
96
97 if (rune == RunecraftData.OURNIA) {
98 player.animate(new Animation(791));
99 player.graphic(new Graphic(186));
100 player.inventory.remove(new Item(essence, amount), -1, true);
101
102 World.schedule(1, () -> {
103 for (int index = 0; index < amount; index++) {
104 RunecraftData data = Utility.randomElement(RunecraftData.values());
105
106 while (data == RunecraftData.OURNIA) {
107 data = Utility.randomElement(RunecraftData.values());
108 }
109
110 player.inventory.add(data.getRunes(), multiplier(player, data) * 2);
111 player.skills.addExperience(Skill.RUNECRAFTING, data.getExperience() * modifier());
112 }
113
114 player.playerAssistant.activateSkilling(1);
115 RandomEventHandler.trigger(player);
116 Pets.onReward(player, PetData.RIFT_GUARDIAN.getItem(), 9000);
117 AchievementHandler.activate(player, AchievementKey.RUNECRAFTING, amount * multiplier);
118 });
119 return true;
120 }
121
122 craft(player, essence, amount, rune);
123
124 World.schedule(1, () -> {
125 player.inventory.add(rune.getRunes(), amount * multiplier);
126 player.playerAssistant.activateSkilling(1);
127 Pets.onReward(player, PetData.RIFT_GUARDIAN.getItem(), 9000);
128 AchievementHandler.activate(player, AchievementKey.RUNECRAFTING, amount * multiplier);
129 });
130 return true;
131 }
val index

References com.runehive.content.achievement.AchievementHandler.activate(), 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(), click(), com.runehive.game.world.items.containers.ItemContainer.computeAmountForId(), craft(), com.runehive.content.skill.impl.runecrafting.RunecraftData.forId(), getEssence(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getExperience(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getLevel(), com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getRunes(), com.runehive.game.world.entity.mob.Mob.graphic, com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.entity.mob.Locking.lock, com.runehive.game.world.entity.mob.Mob.locking, modifier(), multiplier(), com.runehive.content.pet.Pets.onReward(), com.runehive.content.skill.impl.runecrafting.RunecraftData.OURNIA, com.runehive.game.world.entity.mob.player.Player.playerAssistant, com.runehive.util.Utility.randomElement(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.content.pet.PetData.RIFT_GUARDIAN, com.runehive.content.achievement.AchievementKey.RUNECRAFTING, com.runehive.game.world.World.schedule(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Here is the call graph for this function:

◆ craft()

void com.runehive.content.skill.impl.runecrafting.Runecraft.craft ( Player player,
int essence,
int amount,
RunecraftData rune )
private

Definition at line 134 of file Runecraft.java.

134 {
135 if (player.skills.getLevel(Skill.RUNECRAFTING) < rune.getLevel()) {
136 player.send(new SendMessage("You need a runecrafting level of " + rune.getLevel() + " to do this!"));
137 return;
138 }
139
140 if (essence == -1) {
141 player.send(new SendMessage("You do not have any essence!"));
142 return;
143 }
144 player.animate(new Animation(791));
145 player.graphic(new Graphic(186));
146 player.inventory.remove(new Item(essence, amount), -1, true);
147 player.skills.addExperience(Skill.RUNECRAFTING, (rune.getExperience() * amount) * modifier());
148 RandomEventHandler.trigger(player);
149
150 if (rune == RunecraftData.BLOOD) {
151 player.forClan(channel -> channel.activateTask(ClanTaskKey.BLOOD_RUNE, player.getName(), amount));
152 } else if (rune == RunecraftData.DEATH) {
153 player.forClan(channel -> channel.activateTask(ClanTaskKey.DEATH_RUNE, player.getName(), amount));
154 }
155 }

References com.runehive.game.world.entity.skill.SkillManager.addExperience(), com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.content.skill.impl.runecrafting.RunecraftData.BLOOD, com.runehive.content.clanchannel.content.ClanTaskKey.BLOOD_RUNE, com.runehive.content.skill.impl.runecrafting.RunecraftData.DEATH, com.runehive.content.clanchannel.content.ClanTaskKey.DEATH_RUNE, com.runehive.game.world.entity.mob.player.Player.forClan(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getExperience(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getLevel(), com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.Mob.graphic, com.runehive.game.world.entity.mob.player.Player.inventory, modifier(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Referenced by clickObject().

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

◆ getEssence()

int com.runehive.content.skill.impl.runecrafting.Runecraft.getEssence ( Player player)
private

Gets the essence identification from player.

Definition at line 170 of file Runecraft.java.

170 {
171 return player.inventory.contains(1436) ? 1436 : (player.inventory.contains(7936) ? 7936 : -1);
172 }

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

Referenced by clickObject().

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

◆ modifier()

double com.runehive.content.skill.impl.runecrafting.Runecraft.modifier ( )
protected

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

Definition at line 34 of file Runecraft.java.

34 {
35 return Config.RUNECRAFTING_MODIFICATION;
36 }

References com.runehive.Config.RUNECRAFTING_MODIFICATION.

Referenced by clickObject(), and craft().

Here is the caller graph for this function:

◆ multiplier()

int com.runehive.content.skill.impl.runecrafting.Runecraft.multiplier ( Player player,
RunecraftData rune )
private

The runecrafting multiplier.

Definition at line 175 of file Runecraft.java.

175 {
176 int multiplier = 1;
177 for (int i = 0; i < rune.getMultiplier().length; i++) {
178 if (player.skills.getLevel(Skill.RUNECRAFTING) >= rune.getMultiplier()[i]) {
179 multiplier++;
180 }
181 }
182 return multiplier;
183 }

References com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.content.skill.impl.runecrafting.RunecraftData.getMultiplier(), multiplier(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by clickObject(), and multiplier().

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

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