RuneHive-Game
Loading...
Searching...
No Matches
Firemaking.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.firemaking;
2
3import com.runehive.Config;
4import com.runehive.content.skillcape.SkillCape;
5import com.runehive.content.activity.randomevent.RandomEventHandler;
6import com.runehive.content.clanchannel.content.ClanTaskKey;
7import com.runehive.content.event.impl.ItemOnItemInteractionEvent;
8import com.runehive.content.event.impl.ObjectInteractionEvent;
9import com.runehive.content.pet.PetData;
10import com.runehive.content.pet.Pets;
11import com.runehive.content.prestige.PrestigePerk;
12import com.runehive.game.action.Action;
13import com.runehive.game.action.policy.WalkablePolicy;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.entity.skill.Skill;
16import com.runehive.game.world.items.Item;
17import com.runehive.game.world.object.GameObject;
18import com.runehive.util.RandomUtils;
19import com.runehive.util.Utility;
20
21/**
22 * The firemaking skill.
23 *
24 * @author Daniel
25 */
26public class Firemaking extends Skill {
27
28 public Firemaking(int level, double experience) {
29 super(Skill.FIREMAKING, level, experience);
30 }
31
32 @Override
33 protected boolean useItem(Player player, ItemOnItemInteractionEvent event) {
34 Item first = event.getFirst();
35 Item second = event.getSecond();
37 Item item = null;
38 if (!FiremakingData.forId(second.getId()).isPresent() && !FiremakingData.forId(first.getId()).isPresent())
39 return false;
40 if (first.getId() == 590) {
41 firemaking = FiremakingData.forId(second.getId()).get();
42 item = second;
43 } else if (second.getId() == 590) {
44 firemaking = FiremakingData.forId(first.getId()).get();
45 item = first;
46 }
47 if (firemaking == null)
48 return false;
49 player.action.execute(new FiremakingAction(player, item, firemaking), true);
50 return true;
51 }
52 public static double getBonus(Player player) {
53 double bonus = 0;
54 if(player.equipment.getId(0) == 20708)
55 bonus += 0.4;
56 if(player.equipment.getId(4) == 20704)
57 bonus += 0.8;
58 if(player.equipment.getId(7) == 20706)
59 bonus += 0.6;
60 if(player.equipment.getId(10) == 20710)
61 bonus += 0.2;
62
63 if(player.equipment.containsAll(20708, 20704, 20706, 20710))
64 bonus = 2.5;
65
66 return bonus;
67 }
68 @Override
69 protected boolean clickObject(Player player, ObjectInteractionEvent event) {
70 if (event.getOpcode() != 0 || event.getObject().getId() != 5249) {
71 return false;
72 }
73
74 if (player.getPosition().equals(event.getObject().getPosition())) {
75 player.message("Please step out of the fire!");
76 return true;
77 }
78
80
81 for (Item item : player.inventory) {
82 if (item != null && FiremakingData.forId(item.getId()).isPresent()) {
83 firemaking = FiremakingData.forId(item.getId()).get();
84 break;
85 }
86 }
87
88 if (firemaking == null) {
89 player.dialogueFactory.sendStatement("You have no logs in your inventory to add to this fire!").execute();
90 return true;
91 }
92
93 if (player.skills.getMaxLevel(Skill.FIREMAKING) < firemaking.getLevel()) {
94 player.message("You need a firemaking level of " + firemaking.getLevel() + " to light this log!");
95 return true;
96 }
97
98 player.action.execute(bonfireAction(player, event.getObject(), firemaking, player.inventory.computeAmountForId(firemaking.getLog())));
99 return true;
100 }
101
102
104 return new Action<Player>(player, 3) {
105 int amount = toBurn;
106
107 @Override
108 public WalkablePolicy getWalkablePolicy() {
110 }
111
112 @Override
113 public String getName() {
114 return "Bonfire action";
115 }
116
117 @Override
118 protected void execute() {
119 if (amount <= 0) {
120 cancel();
121 return;
122 }
123 if (!object.active()) {
124 cancel();
125 return;
126 }
127 if (!player.inventory.contains(firemaking.getLog())) {
128 player.message("You have no more logs!");
129 cancel();
130 return;
131 }
132 final boolean saveLog = SkillCape.isEquipped(player, SkillCape.FIREMAKING) && Utility.random(1, 3) == 1;
133 if (!saveLog) {
134 player.inventory.remove(firemaking.getLog(), 1);
135 }
136 player.animate(733);
137 player.skills.addExperience(Skill.FIREMAKING, firemaking.getExperience() * Config.FIREMAKING_MODIFICATION);
140 Pets.onReward(getMob(), PetData.PHOENIX.getItem(), 8562);
141
143 player.forClan(channel -> channel.activateTask(ClanTaskKey.BURN_WILLOW_LOG, getMob().getName()));
144 }
145
147 player.inventory.remove(firemaking.getLog(), 1);
148 player.skills.addExperience(Skill.FIREMAKING, firemaking.getExperience() * Config.FIREMAKING_MODIFICATION);
149 }
150
151 if (!saveLog) {
152 amount--;
153 }
154 }
155
156 @Override
157 protected void onCancel(boolean logout) {
158// player.resetAnimation();
159 }
160 };
161 }
162}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double FIREMAKING_MODIFICATION
The experience modification for firemaking.
Definition Config.java:256
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
Handles spawning, rewarding and picking up of pets.
Definition Pets.java:27
static void onReward(Player player, int item, int chance)
Handles calculating the chance of a player receiving a skilling pet.
Definition Pets.java:33
boolean hasPerk(PrestigePerk perk)
boolean useItem(Player player, ItemOnItemInteractionEvent event)
boolean clickObject(Player player, ObjectInteractionEvent event)
Action< Player > bonfireAction(Player player, GameObject object, FiremakingData firemaking, int toBurn)
Represents an action an entity can execute.
Definition Action.java:12
public< A extends Action<?> > void execute(A action)
This class represents a character controlled by a player.
Definition Player.java:125
void forClan(Consumer< ClanChannel > action)
Definition Player.java:568
static String getName(int skill)
Gets the name for a skill id.
Definition Skill.java:465
double experience
The current skill experience.
Definition Skill.java:179
int level
The current level of the skill.
Definition Skill.java:173
Skill(int skill, int level, double experience)
Constructs a new Skill.
Definition Skill.java:184
void addExperience(int id, double experience)
Adds experience to a given skill.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
boolean remove(Item item)
Attempts to withdraw item from this container.
final int getId(int index)
Gets the item id located on index.
boolean contains(int id)
Determines if this container contains id.
final boolean containsAll(int... identifiers)
Determines if this container contains all identifiers.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static boolean success(double value)
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to va...
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
Holds the data for pets.
Definition PetData.java:14
Handles the perk rewards from prestiging.
static Optional< FiremakingData > forId(int id)
static boolean isEquipped(Player player, SkillCape cape)
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.