RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
FiremakingAction.java
1package com.osroyale.content.skill.impl.firemaking;
2
3import com.osroyale.Config;
4import com.osroyale.content.activity.randomevent.RandomEventHandler;
5import com.osroyale.content.clanchannel.content.ClanTaskKey;
6import com.osroyale.content.pet.PetData;
7import com.osroyale.content.pet.Pets;
8import com.osroyale.content.prestige.PrestigePerk;
9import com.osroyale.content.skill.impl.DestructionSkillAction;
10import com.osroyale.content.skillcape.SkillCape;
11import com.osroyale.game.Animation;
12import com.osroyale.game.task.Task;
13import com.osroyale.game.world.World;
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.items.ground.GroundItem;
18import com.osroyale.game.world.object.CustomGameObject;
19import com.osroyale.game.world.position.Area;
20import com.osroyale.game.world.region.Region;
21import com.osroyale.net.packet.out.SendMessage;
22import com.osroyale.util.RandomUtils;
23import com.osroyale.util.Utility;
24
25import java.util.Optional;
26
62
63public final class FiremakingAction extends DestructionSkillAction {
64 private final Item item;
65 private final FiremakingData firemaking;
66
67 FiremakingAction(Player player, Item item, FiremakingData firemaking) {
68 super(player, Optional.empty(), false);
69 this.item = item;
70 this.firemaking = firemaking;
71 }
72
73 @Override
74 public boolean canInit() {
75 if (getMob().skills.getMaxLevel(Skill.FIREMAKING) < firemaking.getLevel()) {
76 getMob().getPlayer().message("You need a firemaking level of " + firemaking.getLevel() + " to light this log!");
77 return false;
78 }
79 if (Area.inEdgeville(getMob()) || Area.inWilderness(getMob())) {
80 getMob().getPlayer().message("You can not burn a fire here! ");
81 return false;
82 }
83 Region region = getMob().getRegion();
84 if (region.containsObject(getMob().getPosition())) {
85 getMob().getPlayer().send(new SendMessage("You can't light a fire here!"));
86 return false;
87 }
88 return true;
89 }
90
91 @Override
92 public Optional<SkillAnimation> animation() {
93 return Optional.empty();
94 }
95
96 @Override
97 public double experience() {
98 return firemaking.getExperience() * Config.FIREMAKING_MODIFICATION;
99 }
100
101 @Override
102 public int skill() {
103 return Skill.FIREMAKING;
104 }
105
106 @Override
107 public void init() {
108 if (getMob().isPlayer()) {
109 getMob().getPlayer().send(new SendMessage("You attempt to light the log."));
110 }
111 getMob().animate(new Animation(733));
112 }
113
114 @Override
115 public double successFactor() {
116 return 100 - firemaking.getLevel();
117 }
118
119 @Override
120 public void onDestruct(boolean success) {
121 if (success) {
122 Player player = (Player) getMob();
123 final boolean saveLog = SkillCape.isEquipped(player, SkillCape.FIREMAKING) && Utility.random(1, 3) == 1;
124 if (!saveLog) {
125 player.inventory.remove(item);
126 }
127 player.takeStep();
128
129 if (player.prestige.hasPerk(PrestigePerk.FLAME_ON) && RandomUtils.success(.25)) {
130 player.inventory.remove(firemaking.getLog(), 1);
131 player.skills.addExperience(Skill.FIREMAKING, experience());
132 }
133
134 RandomEventHandler.trigger(player);
135 player.playerAssistant.activateSkilling(1);
136 Pets.onReward(player, PetData.PHOENIX.getItem(), 8562);
137 CustomGameObject object = new CustomGameObject(5249, player.getPosition());
138 object.register();
139
140 if (firemaking == FiremakingData.WILLOW_LOG) {
141 player.forClan(channel -> channel.activateTask(ClanTaskKey.BURN_WILLOW_LOG, getMob().getName()));
142 }
143
144 World.schedule(new Task(180) {
145 @Override
146 protected void execute() {
147 GroundItem.createGlobal(player, new Item(592), object.getPosition());
148 object.unregister();
149 cancel();
150 }
151 });
152 }
153 }
154
155 @Override
156 public void onCancel(boolean logout) {
157 Player player = (Player) getMob();
158 player.animate(new Animation(65535));
159 }
160
161 @Override
162 public String getName() {
163 return "Firemaking";
164 }
165
166 @Override
167 public Item destructItem() {
168 return item;
169 }
170}
static final double FIREMAKING_MODIFICATION
Definition Config.java:298
static void onReward(Player player, int item, int chance)
Definition Pets.java:70
DestructionSkillAction(Mob mob, Optional< Position > position, boolean instant)
synchronized final void cancel()
Definition Task.java:147
Task(boolean instant, int delay)
Definition Task.java:75
static void schedule(Task task)
Definition World.java:284
void addExperience(int id, double experience)
static void createGlobal(Player player, Item item)
boolean containsObject(int height, GameObject object)
Definition Region.java:205