RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.smithing.Smelting Class Reference
Inheritance diagram for com.runehive.content.skill.impl.smithing.Smelting:
Collaboration diagram for com.runehive.content.skill.impl.smithing.Smelting:

Public Member Functions

void execute ()
 A function representing the unit of work that will be carried out.
String getName ()
 Gets the name of this action.
WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
boolean prioritized ()
 Determines if this action is prioritized.
Public Member Functions inherited from com.runehive.game.action.Action< T extends Mob >
 Action (T mob, int delay)
 Creates a new Action randomevent.
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Static Public Member Functions

static void clearInterfaces (Player player)
 Sends the items on the smelting itemcontainer.

Static Public Attributes

static final int[] SMELT_BARS = {2349, 2351, 2355, 2353, 2357, 2359, 2361, 2363}
 The bar identification to be drawn on each frame.

Protected Member Functions

boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()

Static Package Functions

static boolean openInterface (Player player, GameObject object)
 Opens the smelting itemcontainer for the player.
static boolean smelt (Player player, int buttonId)
 Attempts to start smelting for the specified player.

Private Member Functions

boolean smelt ()
 Checks if the player has the requirements to smelt.
 Smelting (Player player, SmeltingData definition, int amount, boolean spell)
 Constructs a new Smelting.

Static Private Member Functions

static void smelt (Player player, SmeltingData data, int amount)
 Smelts the data for the specified player and produces the exact amount the player inputed if he has the requirements.

Private Attributes

int amount
 The amount we're producing.
final SmeltingData definition
 The definition of the bar we're creating.
final boolean spell
 Determines if we're smelting dependant on the superheat spell.

Static Private Attributes

static final int[] FURNACE_IDS = {16469, 3994}
 The array which holds all the possible furnace ids a player can smelt his bars in.
static final int[] SMELT_FRAME = {2405, 2406, 2407, 2409, 2410, 2411, 2412, 2413}
 The array which holds all the frames you can draw an item on.

Additional Inherited Members

Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

Definition at line 18 of file Smelting.java.

Constructor & Destructor Documentation

◆ Smelting()

com.runehive.content.skill.impl.smithing.Smelting.Smelting ( Player player,
SmeltingData definition,
int amount,
boolean spell )
private

Constructs a new Smelting.

Definition at line 38 of file Smelting.java.

38 {
39 super(player, SkillCape.isEquipped(player, SkillCape.SMITHING) ? 1 : 2, false);
40 this.definition = definition;
41 this.amount = amount;
42 this.spell = spell;
43 }

References amount, definition, com.runehive.content.skillcape.SkillCape.isEquipped(), com.runehive.content.skillcape.SkillCape.SMITHING, and spell.

Referenced by smelt(), and smelt().

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

Member Function Documentation

◆ canSchedule()

boolean com.runehive.content.skill.impl.smithing.Smelting.canSchedule ( )
protected

A function executed on registration.

Reimplemented from com.runehive.game.task.Task.

Definition at line 125 of file Smelting.java.

125 {
126 return !getMob().skills.get(Skill.SMITHING).isDoingSkill();
127 }

References com.runehive.game.action.Action< T extends Mob >.getMob(), and com.runehive.game.world.entity.skill.Skill.SMITHING.

Here is the call graph for this function:

◆ clearInterfaces()

void com.runehive.content.skill.impl.smithing.Smelting.clearInterfaces ( Player player)
static

Sends the items on the smelting itemcontainer.

Definition at line 89 of file Smelting.java.

89 {
90 for (int j = 0; j < SMELT_FRAME.length; j++) {
91 player.send(new SendItemModelOnInterface(SMELT_FRAME[j], 150, SMELT_BARS[j]));
92 }
93 }

References com.runehive.game.world.entity.mob.player.Player.send(), SMELT_BARS, and SMELT_FRAME.

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

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

◆ execute()

void com.runehive.content.skill.impl.smithing.Smelting.execute ( )

A function representing the unit of work that will be carried out.

Reimplemented from com.runehive.game.task.Task.

Definition at line 134 of file Smelting.java.

134 {
135 if (!getMob().skills.get(Skill.SMITHING).isDoingSkill()) {
136 cancel();
137 return;
138 }
139
140 if (!smelt()) {
141 cancel();
142 }
143 }

References com.runehive.game.task.Task.cancel(), com.runehive.game.action.Action< T extends Mob >.getMob(), smelt(), and com.runehive.game.world.entity.skill.Skill.SMITHING.

Here is the call graph for this function:

◆ getName()

String com.runehive.content.skill.impl.smithing.Smelting.getName ( )

Gets the name of this action.

Returns
The name of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 162 of file Smelting.java.

162 {
163 return "smelting-action";
164 }

◆ getWalkablePolicy()

WalkablePolicy com.runehive.content.skill.impl.smithing.Smelting.getWalkablePolicy ( )

Gets the WalkablePolicy of this action.

Returns
The walkable policy of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 157 of file Smelting.java.

157 {
158 return WalkablePolicy.NON_WALKABLE;
159 }

References com.runehive.game.action.policy.WalkablePolicy.NON_WALKABLE.

◆ onCancel()

void com.runehive.content.skill.impl.smithing.Smelting.onCancel ( boolean logout)
protected

A function executed on cancellation.

Reimplemented from com.runehive.game.task.Task.

Definition at line 146 of file Smelting.java.

146 {
147 getMob().resetFace();
148 getMob().skills.get(Skill.SMITHING).setDoingSkill(false);
149 }

References com.runehive.game.action.Action< T extends Mob >.getMob(), and com.runehive.game.world.entity.skill.Skill.SMITHING.

Here is the call graph for this function:

◆ onSchedule()

void com.runehive.content.skill.impl.smithing.Smelting.onSchedule ( )
protected

A function executed on registration.

Reimplemented from com.runehive.game.task.Task.

Definition at line 130 of file Smelting.java.

130 {
131 }

◆ openInterface()

boolean com.runehive.content.skill.impl.smithing.Smelting.openInterface ( Player player,
GameObject object )
staticpackage

Opens the smelting itemcontainer for the player.

Definition at line 70 of file Smelting.java.

70 {
71 boolean accessible = false;
72
73 for (int id : FURNACE_IDS) {
74 if (object.getId() == id) {
75 accessible = true;
76 break;
77 }
78 }
79
80 if (!accessible) {
81 return false;
82 }
83
84 player.send(new SendChatBoxInterface(2400));
85 return true;
86 }

References FURNACE_IDS, and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by com.runehive.content.skill.impl.smithing.Smithing.clickObject().

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

◆ prioritized()

boolean com.runehive.content.skill.impl.smithing.Smelting.prioritized ( )

Determines if this action is prioritized.

When making an action prioritized, the next action will be ignored if not queued.

Returns
true if this action is prioritized, false otherwise.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 152 of file Smelting.java.

152 {
153 return false;
154 }

◆ smelt() [1/3]

boolean com.runehive.content.skill.impl.smithing.Smelting.smelt ( )
private

Checks if the player has the requirements to smelt.

Definition at line 96 of file Smelting.java.

96 {
97 if (getMob().skills.get(Skill.SMITHING).getLevel() < definition.requirement) {
98 getMob().message("You need a smithing level of " + definition.requirement + " to smelt this bar.");
99 return false;
100 }
101
102 if (!getMob().inventory.containsAll(definition.required)) {
103 getMob().message("You don't have the required items to smelt this bar.");
104 return false;
105 }
106
107 if (!spell) {
108 getMob().animate(new Animation(899));
109 }
110 getMob().inventory.removeAll(definition.required);
111 getMob().inventory.addAll(definition.produced);
112 getMob().skills.addExperience(Skill.SMITHING, definition.experience * Config.SMITHING_MODIFICATION);
113 getMob().playerAssistant.activateSkilling(1);
114 RandomEventHandler.trigger(getMob());
115 amount--;
116
117 if (amount < 1) {
118 this.cancel();
119 }
120
121 return true;
122 }

References amount, com.runehive.game.task.Task.cancel(), definition, com.runehive.game.action.Action< T extends Mob >.getMob(), com.runehive.game.world.entity.skill.Skill.SMITHING, com.runehive.Config.SMITHING_MODIFICATION, spell, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Referenced by execute(), and smelt().

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

◆ smelt() [2/3]

boolean com.runehive.content.skill.impl.smithing.Smelting.smelt ( Player player,
int buttonId )
staticpackage

Attempts to start smelting for the specified player.

Definition at line 46 of file Smelting.java.

46 {
47 Optional<SmeltingData> data = SmeltingData.getDefinition(buttonId);
48
49 if (!data.isPresent()) {
50 return false;
51 }
52
53 if (data.get().amount == -1) {
54 player.send(new SendInputAmount("How many you would like to melt?", 2, s -> Smelting.smelt(player, data.get(), Integer.parseInt(s))));
55 return true;
56 }
57
58 smelt(player, data.get(), data.get().amount);
59 return true;
60 }

References com.runehive.content.skill.impl.smithing.SmeltingData.getDefinition(), com.runehive.game.world.entity.mob.player.Player.send(), smelt(), and Smelting().

Referenced by com.runehive.content.skill.impl.smithing.Smithing.clickButton().

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

◆ smelt() [3/3]

void com.runehive.content.skill.impl.smithing.Smelting.smelt ( Player player,
SmeltingData data,
int amount )
staticprivate

Smelts the data for the specified player and produces the exact amount the player inputed if he has the requirements.

Definition at line 63 of file Smelting.java.

63 {
64 player.interfaceManager.close();
65 player.action.execute(new Smelting(player, data, amount, false));
66 player.skills.get(Skill.SMITHING).setDoingSkill(true);
67 }

References com.runehive.game.world.entity.mob.Mob.action, amount, com.runehive.game.world.entity.mob.player.InterfaceManager.close(), com.runehive.game.action.ActionManager.execute(), com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.skill.Skill.setDoingSkill(), com.runehive.game.world.entity.mob.Mob.skills, Smelting(), and com.runehive.game.world.entity.skill.Skill.SMITHING.

Here is the call graph for this function:

Member Data Documentation

◆ amount

int com.runehive.content.skill.impl.smithing.Smelting.amount
private

The amount we're producing.

Definition at line 35 of file Smelting.java.

Referenced by smelt(), smelt(), and Smelting().

◆ definition

final SmeltingData com.runehive.content.skill.impl.smithing.Smelting.definition
private

The definition of the bar we're creating.

Definition at line 29 of file Smelting.java.

Referenced by smelt(), and Smelting().

◆ FURNACE_IDS

final int [] com.runehive.content.skill.impl.smithing.Smelting.FURNACE_IDS = {16469, 3994}
staticprivate

The array which holds all the possible furnace ids a player can smelt his bars in.

Definition at line 20 of file Smelting.java.

20{16469, 3994};

Referenced by openInterface().

◆ SMELT_BARS

final int [] com.runehive.content.skill.impl.smithing.Smelting.SMELT_BARS = {2349, 2351, 2355, 2353, 2357, 2359, 2361, 2363}
static

The bar identification to be drawn on each frame.

Definition at line 26 of file Smelting.java.

26{2349, 2351, 2355, 2353, 2357, 2359, 2361, 2363};

Referenced by clearInterfaces(), and com.runehive.content.skill.impl.smithing.Smithing.clickObject().

◆ SMELT_FRAME

final int [] com.runehive.content.skill.impl.smithing.Smelting.SMELT_FRAME = {2405, 2406, 2407, 2409, 2410, 2411, 2412, 2413}
staticprivate

The array which holds all the frames you can draw an item on.

Definition at line 23 of file Smelting.java.

23{2405, 2406, 2407, 2409, 2410, 2411, 2412, 2413};

Referenced by clearInterfaces().

◆ spell

final boolean com.runehive.content.skill.impl.smithing.Smelting.spell
private

Determines if we're smelting dependant on the superheat spell.

Definition at line 32 of file Smelting.java.

Referenced by smelt(), and Smelting().


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