RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
FishingAction.java
1package com.osroyale.content.skill.impl.fishing;
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.game.Animation;
10import com.osroyale.game.action.Action;
11import com.osroyale.game.action.policy.WalkablePolicy;
12import com.osroyale.game.world.entity.mob.player.Player;
13import com.osroyale.game.world.entity.skill.Skill;
14import com.osroyale.game.world.items.Item;
15import com.osroyale.game.world.items.ItemDefinition;
16import com.osroyale.util.RandomUtils;
17import com.osroyale.util.Utility;
18
22public class FishingAction extends Action<Player> {
23 private final FishingTool tool;
24 private final Fishable[] fishing;
25
26 FishingAction(Player player, FishingTool tool, Fishable[] fishing) {
27 super(player, 6, false);
28 this.tool = tool;
29 this.fishing = fishing;
30 }
31
32 private boolean fish(Player player, Fishable[] fishing) {
33 if (fishing == null)
34 return false;
35
36 Fishable[] fish = new Fishable[5];
37
38 byte c = 0;
39
40 for (Fishable aFishing : fishing) {
41 if (Fishing.canFish(player, aFishing, false)) {
42 fish[c] = aFishing;
43 c = (byte) (c + 1);
44 }
45 }
46 if (c == 0) {
47 return false;
48 }
49
50 Fishable f = fish[Utility.random(c)];
51
52 if (player.inventory.getFreeSlots() == 0) {
53 player.dialogueFactory.sendStatement("You can't carry anymore fish.").execute();
54 player.animate(Animation.RESET, true);
55 return false;
56 }
57
58 if (Fishing.success(player, f)) {
59 if (f.getBaitRequired() != -1) {
60 player.inventory.remove(new Item(f.getBaitRequired(), 1));
61 if (!player.inventory.contains(f.getBaitRequired(), 1)) {
62 player.dialogueFactory.sendStatement("You have run out of bait.").execute();
63 player.animate(Animation.RESET, true);
64 return false;
65 }
66 }
67
68 boolean infernalHarpoon = player.equipment.contains(21031) && Utility.random(3) == 0 && (f.equals(Fishable.SWORD_FISH) || f.equals(Fishable.SWORD_FISH2) || f.equals(Fishable.SWORD_FISH) || f.equals(Fishable.TUNA) || f.equals(Fishable.TUNA2) || f.equals(Fishable.SHARK));
69
70 int id = f.getRawFishId();
71 String name = ItemDefinition.get(id).getName();
72 if(!infernalHarpoon)
73 player.inventory.add(new Item(id, 1));
74 else {
75 double xp = f.equals(Fishable.SWORD_FISH) || f.equals(Fishable.SWORD_FISH2) ? 70 : f.equals(Fishable.TUNA) || f.equals(Fishable.TUNA2) ? 50 : 105;
77 }
78
79 player.skills.addExperience(Skill.FISHING, f.getExperience() * Config.FISHING_MODIFICATION);
80
81 player.message(true, "You manage to catch a " + name + ".");
82 RandomEventHandler.trigger(player);
83 player.playerAssistant.activateSkilling(1);
84 Pets.onReward(player, PetData.HERON.getItem(), 7500);
85
86 if (player.prestige.hasPerk(PrestigePerk.MASTERBAIRTER) && RandomUtils.success(.15)) {
87 player.inventory.addOrDrop(new Item(id, 1));
88 }
89
90 if (id == 383) {
91 player.forClan(channel -> channel.activateTask(ClanTaskKey.SHARK, player.getName()));
92 } else if (id == 11934) {
93 player.forClan(channel -> channel.activateTask(ClanTaskKey.DARK_CRAB, player.getName()));
94 }
95 }
96 return true;
97 }
98
99 @Override
100 protected boolean canSchedule() {
101 return !getMob().skills.get(Skill.FISHING).isDoingSkill();
102 }
103
104 @Override
105 protected void onSchedule() {
106 getMob().animate(tool.getAnimationId());
107 }
108
109 @Override
110 public void execute() {
111 if (!getMob().skills.get(Skill.FISHING).isDoingSkill()) {
112 cancel();
113 return;
114 }
115
116 getMob().animate(tool.getAnimationId());
117
118 if (!fish(getMob(), fishing)) {
119 cancel();
120 }
121 }
122
123 @Override
124 protected void onCancel(boolean logout) {
125 getMob().resetFace();
126 getMob().skills.get(Skill.FISHING).setDoingSkill(false);
127 }
128
129 @Override
133
134 @Override
135 public String getName() {
136 return "fishing-action";
137 }
138}
static final double COOKING_MODIFICATION
Definition Config.java:292
static final double FISHING_MODIFICATION
Definition Config.java:334
final DialogueFactory sendStatement(String... lines)
static void onReward(Player player, int item, int chance)
Definition Pets.java:70
Action(T mob, int delay, boolean instant)
Definition Action.java:24
synchronized final void cancel()
Definition Task.java:147
void addExperience(int id, double experience)