RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Firemaking.java
1package com.osroyale.content.skill.impl.firemaking;
2
3import com.osroyale.Config;
4import com.osroyale.content.skillcape.SkillCape;
5import com.osroyale.content.activity.randomevent.RandomEventHandler;
6import com.osroyale.content.clanchannel.content.ClanTaskKey;
7import com.osroyale.content.event.impl.ItemOnItemInteractionEvent;
8import com.osroyale.content.event.impl.ObjectInteractionEvent;
9import com.osroyale.content.pet.PetData;
10import com.osroyale.content.pet.Pets;
11import com.osroyale.content.prestige.PrestigePerk;
12import com.osroyale.game.action.Action;
13import com.osroyale.game.action.policy.WalkablePolicy;
14import com.osroyale.game.world.entity.mob.player.Player;
15import com.osroyale.game.world.entity.skill.Skill;
16import com.osroyale.game.world.items.Item;
17import com.osroyale.game.world.object.GameObject;
18import com.osroyale.util.RandomUtils;
19import com.osroyale.util.Utility;
20
54
55public class Firemaking extends Skill {
56
57 public Firemaking(int level, double experience) {
58 super(Skill.FIREMAKING, level, experience);
59 }
60
61 @Override
62 protected boolean useItem(Player player, ItemOnItemInteractionEvent event) {
63 Item first = event.getFirst();
64 Item second = event.getSecond();
65 FiremakingData firemaking = null;
66 Item item = null;
67 if (!FiremakingData.forId(second.getId()).isPresent() && !FiremakingData.forId(first.getId()).isPresent())
68 return false;
69 if (first.getId() == 590) {
70 firemaking = FiremakingData.forId(second.getId()).get();
71 item = second;
72 } else if (second.getId() == 590) {
73 firemaking = FiremakingData.forId(first.getId()).get();
74 item = first;
75 }
76 if (firemaking == null)
77 return false;
78 player.action.execute(new FiremakingAction(player, item, firemaking), true);
79 return true;
80 }
81 public static double getBonus(Player player) {
82 double bonus = 0;
83 if(player.equipment.getId(0) == 20708)
84 bonus += 0.4;
85 if(player.equipment.getId(4) == 20704)
86 bonus += 0.8;
87 if(player.equipment.getId(7) == 20706)
88 bonus += 0.6;
89 if(player.equipment.getId(10) == 20710)
90 bonus += 0.2;
91
92 if(player.equipment.containsAll(20708, 20704, 20706, 20710))
93 bonus = 2.5;
94
95 return bonus;
96 }
97 @Override
98 protected boolean clickObject(Player player, ObjectInteractionEvent event) {
99 if (event.getOpcode() != 0 || event.getObject().getId() != 5249) {
100 return false;
101 }
102
103 if (player.getPosition().equals(event.getObject().getPosition())) {
104 player.message("Please step out of the fire!");
105 return true;
106 }
107
108 FiremakingData firemaking = null;
109
110 for (Item item : player.inventory) {
111 if (item != null && FiremakingData.forId(item.getId()).isPresent()) {
112 firemaking = FiremakingData.forId(item.getId()).get();
113 break;
114 }
115 }
116
117 if (firemaking == null) {
118 player.dialogueFactory.sendStatement("You have no logs in your inventory to add to this fire!").execute();
119 return true;
120 }
121
122 if (player.skills.getMaxLevel(Skill.FIREMAKING) < firemaking.getLevel()) {
123 player.message("You need a firemaking level of " + firemaking.getLevel() + " to light this log!");
124 return true;
125 }
126
127 player.action.execute(bonfireAction(player, event.getObject(), firemaking, player.inventory.computeAmountForId(firemaking.getLog())));
128 return true;
129 }
130
131
132 private Action<Player> bonfireAction(Player player, GameObject object, FiremakingData firemaking, int toBurn) {
133 return new Action<Player>(player, 3) {
134 int amount = toBurn;
135
136 @Override
137 public WalkablePolicy getWalkablePolicy() {
139 }
140
141 @Override
142 public String getName() {
143 return "Bonfire action";
144 }
145
146 @Override
147 protected void execute() {
148 if (amount <= 0) {
149 cancel();
150 return;
151 }
152 if (!object.active()) {
153 cancel();
154 return;
155 }
156 if (!player.inventory.contains(firemaking.getLog())) {
157 player.message("You have no more logs!");
158 cancel();
159 return;
160 }
161 final boolean saveLog = SkillCape.isEquipped(player, SkillCape.FIREMAKING) && Utility.random(1, 3) == 1;
162 if (!saveLog) {
163 player.inventory.remove(firemaking.getLog(), 1);
164 }
165 player.animate(733);
166 player.skills.addExperience(Skill.FIREMAKING, firemaking.getExperience() * Config.FIREMAKING_MODIFICATION);
167 RandomEventHandler.trigger(player);
168 player.playerAssistant.activateSkilling(1);
169 Pets.onReward(getMob(), PetData.PHOENIX.getItem(), 8562);
170
171 if (firemaking == FiremakingData.WILLOW_LOG) {
172 player.forClan(channel -> channel.activateTask(ClanTaskKey.BURN_WILLOW_LOG, getMob().getName()));
173 }
174
175 if (player.prestige.hasPerk(PrestigePerk.FLAME_ON) && RandomUtils.success(.25)) {
176 player.inventory.remove(firemaking.getLog(), 1);
177 player.skills.addExperience(Skill.FIREMAKING, firemaking.getExperience() * Config.FIREMAKING_MODIFICATION);
178 }
179
180 if (!saveLog) {
181 amount--;
182 }
183 }
184
185 @Override
186 protected void onCancel(boolean logout) {
187// player.resetAnimation();
188 }
189 };
190 }
191}
static final double FIREMAKING_MODIFICATION
Definition Config.java:298
final DialogueFactory sendStatement(String... lines)
static void onReward(Player player, int item, int chance)
Definition Pets.java:70
static String getName(int skill)
Definition Skill.java:502
Skill(int skill, int level, double experience)
Definition Skill.java:221
void addExperience(int id, double experience)