RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.fishing.Fishing Class Reference

Handles the fishing skill. More...

Inheritance diagram for com.runehive.content.skill.impl.fishing.Fishing:
Collaboration diagram for com.runehive.content.skill.impl.fishing.Fishing:

Public Member Functions

 Fishing (int level, double experience)
void start (Player player, Fishable[] fishing, int option)
Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
double addExperience (double amount)
 Adds experiences to this skill by the given amount.
void addLevel (int amount)
 Adds levels to this skill by the given amount.
void divideExperience (double amount)
 Divides the current experience of this skill by a given amount.
void divideLevel (double amount)
 Divides the current level of this skill by a given amount.
double getExperience ()
 Gets the skill experience.
int getLevel ()
 Gets the current skill level.
int getMaxLevel ()
 Gets the maximum skill level.
int getRoundedExperience ()
 Gets the floor experience.
int getSkill ()
 Gets the skill id.
boolean isDoingSkill ()
double modifyExperience (Function< Double, Double > function)
 Modifies the current experience with a given function.
double modifyExperience (Function< Double, Double > function, int lowerBounds, int upperBounds)
 Modifies the current experience with a given function.
void modifyLevel (Function< Integer, Integer > function)
 Modifies the current level with a given function.
void modifyLevel (Function< Integer, Integer > function, int lowerBounds, int upperBounds)
 Modifies the current level with a given function.
void multiplyExperience (double amount)
 Multiplies the current experience of this skill by a given amount.
void multiplyLevel (double amount)
 Multiplies the current level of this skill by a given amount.
boolean onEvent (Player player, InteractionEvent interactionEvent)
void removeExperience (double amount)
 Removes experiences from this skill by the given amount.
void removeLevel (int amount)
 Removes levels from this skill by the given amount.
boolean reqLevel (int level)
 Determines if your level is greater than or equal to level.
void setDoingSkill (boolean doingSkill)
void setExperience (double experience)
 Sets the experience for this skill.
void setLevel (int level)
 Sets the level for this skill.
void setMaxLevel (int maxLevel)
 Sets the maximum level for this skill.
 Skill (int skill, int level, double experience)
 Constructs a new Skill.
String toString ()

Static Public Member Functions

static double getBonus (Player player)
static boolean success (Player player, Fishable fish)
Static Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
static Function< Integer, Integer > add (int amount)
 Creates a function that adds a number by an amount.
static Function< Integer, Integer > divide (double amount)
 Creates a function that divides a number by an amount.
static final int getExperienceForLevel (int level)
 Gets the experience for a given level.
static final byte getLevelForExperience (double experience)
 Gets the level for a given experience amount.
static String getName (int skill)
 Gets the name for a skill id.
static Function< Integer, Integer > multiply (double amount)
 Creates a function that multiplies a number by an amount.
static Function< Integer, Integer > subtract (int amount)
 Creates a function that subtracts a number by an amount.

Protected Member Functions

boolean clickNpc (Player player, NpcInteractionEvent event)
Protected Member Functions inherited from com.runehive.game.world.entity.skill.Skill
boolean clickButton (Player player, ClickButtonInteractionEvent event)
boolean clickItem (Player player, ItemInteractionEvent event)
boolean clickObject (Player player, ObjectInteractionEvent event)
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
double modifier ()
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Static Package Functions

static boolean canFish (Player player, Fishable fish, boolean message)

Static Private Member Functions

static boolean hasFishingItems (Player player, Fishable fish, boolean message)

Additional Inherited Members

Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
transient final Stopwatch stopwatch = Stopwatch.start()
Static Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
static final int AGILITY = 16
 The agility skill id.
static final int ATTACK = 0
 The attack skill id.
static final int CONSTRUCTION = 21
 The construction skill id.
static final int COOKING = 7
 The cooking skill id.
static final int CRAFTING = 12
 The crafting skill id.
static final int DEFENCE = 1
 The defence skill id.
static final int FARMING = 19
 The farming skill id.
static final int FIREMAKING = 11
 The firemaking skill id.
static final int FISHING = 10
 The fishing skill id.
static final int FLETCHING = 9
 The fletching skill id.
static final int HERBLORE = 15
 The herblore skill id.
static final int HITPOINTS = 3
 The hitpoints skill id.
static final int HUNTER = 22
 The hunter skill id.
static final int[][] INTERFACE_DATA
 Skill tab string data.
static final int MAGIC = 6
 The magic skill id.
static final int MINING = 14
 The mining skill id.
static final int PRAYER = 5
 The prayer skill id.
static final int RANGED = 4
 The ranged skill id.
static final int RUNECRAFTING = 20
 The runecrafting skill id.
static final int SKILL_COUNT = 23
 The amount of available skills.
static final int SLAYER = 18
 The slayer skill id.
static final int SMITHING = 13
 The smithing skill id.
static final int STRENGTH = 2
 The strength skill id.
static final int THIEVING = 17
 The thieving skill id.
static final int TOTAL_SKILL_LEVEL = 99 * SKILL_COUNT
 The total skill amount.
static final int WOODCUTTING = 8
 The woodcutting skill id.

Detailed Description

Handles the fishing skill.

Author
Daniel

Definition at line 17 of file Fishing.java.

Constructor & Destructor Documentation

◆ Fishing()

com.runehive.content.skill.impl.fishing.Fishing.Fishing ( int level,
double experience )

Definition at line 19 of file Fishing.java.

19 {
20 super(Skill.FISHING, level, experience);
21 }

References com.runehive.game.world.entity.skill.Skill.experience, com.runehive.game.world.entity.skill.Skill.level, and com.runehive.game.world.entity.skill.Skill.Skill().

Here is the call graph for this function:

Member Function Documentation

◆ canFish()

boolean com.runehive.content.skill.impl.fishing.Fishing.canFish ( Player player,
Fishable fish,
boolean message )
staticpackage

Definition at line 41 of file Fishing.java.

41 {
42 if (player.skills.get(Skill.FISHING).getLevel() < fish.getRequiredLevel()) {
43 if (message) player.message("You need a fishing level of " + fish.getRequiredLevel() + " to fish here.");
44 return false;
45 }
46 return hasFishingItems(player, fish, message);
47 }

References com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.game.world.entity.skill.Skill.getLevel(), com.runehive.content.skill.impl.fishing.Fishable.getRequiredLevel(), hasFishingItems(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by clickNpc(), and com.runehive.content.skill.impl.fishing.FishingAction.fish().

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

◆ clickNpc()

boolean com.runehive.content.skill.impl.fishing.Fishing.clickNpc ( Player player,
NpcInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 87 of file Fishing.java.

87 {
88 Npc npc = event.getNpc();
89 int opcode = event.getOpcode();
90 FishingSpot spot = FishingSpot.forId(npc.id);
91
92 if (spot == null) {
93 return false;
94 }
95 if (player.skills.get(Skill.FISHING).isDoingSkill()) {
96 return true;
97 }
98
99 int amount = 0;
100 Fishable[] fish;
101 Fishable[] fishable = new Fishable[3];
102
103 switch (opcode) {
104 case 0:
105 fish = spot.getFirstOption();
106 for (int i = 0; i < fish.length; i++) {
107 if (canFish(player, fish[i], i == 0)) {
108 fishable[i] = fish[i];
109 amount++;
110 }
111 }
112 break;
113 case 1:
114 fish = spot.getSecondOption();
115 for (int i = 0; i < fish.length; i++) {
116 if (canFish(player, fish[i], i == 0)) {
117 fishable[i] = fish[i];
118 amount++;
119 }
120 }
121 }
122
123 if (amount == 0)
124 return true;
125
126 Fishable[] fishing = new Fishable[amount];
127 System.arraycopy(fishable, 0, fishing, 0, amount);
128 start(player, fishing, 0);
129 return true;
130 }

References canFish(), com.runehive.content.skill.impl.fishing.FishingSpot.forId(), com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.content.skill.impl.fishing.FishingSpot.getFirstOption(), com.runehive.game.world.entity.mob.Mob.getNpc(), com.runehive.content.skill.impl.fishing.FishingSpot.getSecondOption(), com.runehive.game.world.entity.mob.Mob.id, com.runehive.game.world.entity.skill.Skill.isDoingSkill(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and start().

Here is the call graph for this function:

◆ getBonus()

double com.runehive.content.skill.impl.fishing.Fishing.getBonus ( Player player)
static

Definition at line 22 of file Fishing.java.

22 {
23 double bonus = 0;
24 if(player.equipment.getId(0) == 13258)
25 bonus += 0.4;
26 if(player.equipment.getId(4) == 13259)
27 bonus += 0.8;
28 if(player.equipment.getId(7) == 13260)
29 bonus += 0.6;
30 if(player.equipment.getId(10) == 13261)
31 bonus += 0.2;
32
33 if(player.equipment.containsAll(13258, 13259, 13260, 13261))
34 bonus = 2.5;
35
36 return bonus;
37 }

References com.runehive.game.world.items.containers.ItemContainer.containsAll(), com.runehive.game.world.entity.mob.player.Player.equipment, and com.runehive.game.world.items.containers.ItemContainer.getId().

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

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

◆ hasFishingItems()

boolean com.runehive.content.skill.impl.fishing.Fishing.hasFishingItems ( Player player,
Fishable fish,
boolean message )
staticprivate

Definition at line 49 of file Fishing.java.

49 {
50 int tool = fish.getToolId();
51 int bait = fish.getBaitRequired();
52 boolean hasDragonHarpoon;
53 if (tool == 311) {
54 hasDragonHarpoon = player.inventory.contains(new Item(21028, 1));
55 if (!player.inventory.contains(new Item(tool, 1)) && !hasDragonHarpoon) {
56 String name = ItemDefinition.get(tool).getName();
57 player.message("You need " + Utility.getAOrAn(name) + " " + name + " to fish here.");
58 return false;
59 }
60 } else {
61 if (!player.inventory.contains(new Item(tool, 1)) && message) {
62 String name = ItemDefinition.get(tool).getName();
63 player.message("You need " + Utility.getAOrAn(name) + " " + name + " to fish here.");
64 return false;
65 }
66 }
67 if (bait > -1 && !player.inventory.contains(new Item(bait, 1))) {
68 String name = ItemDefinition.get(bait).getName();
69 if (message) {
70 player.message("You need " + Utility.getAOrAn(name) + " " + name + " to fish here.");
71 }
72 return false;
73 }
74 return true;
75 }

References com.runehive.game.world.items.containers.ItemContainer.contains(), com.runehive.game.world.items.ItemDefinition.get(), com.runehive.util.Utility.getAOrAn(), com.runehive.content.skill.impl.fishing.Fishable.getBaitRequired(), com.runehive.game.world.items.ItemDefinition.getName(), com.runehive.content.skill.impl.fishing.Fishable.getToolId(), com.runehive.game.world.entity.mob.player.Player.inventory, and com.runehive.game.world.entity.mob.player.Player.message().

Referenced by canFish(), and start().

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

◆ start()

void com.runehive.content.skill.impl.fishing.Fishing.start ( Player player,
Fishable[] fishing,
int option )

Definition at line 132 of file Fishing.java.

132 {
133 if (fishing == null || fishing[option] == null || fishing[option].getToolId() == -1) {
134 return;
135 }
136
137 FishingTool tool = FishingTool.forId(fishing[option].getToolId());
138
139 if (!hasFishingItems(player, fishing[option], true)) {
140 return;
141 }
142
143 player.action.execute(new FishingAction(player, tool, fishing));
144 player.skills.get(Skill.FISHING).setDoingSkill(true);
145 }

References com.runehive.game.world.entity.mob.Mob.action, com.runehive.game.action.ActionManager.execute(), com.runehive.content.skill.impl.fishing.FishingTool.forId(), com.runehive.game.world.entity.skill.SkillManager.get(), hasFishingItems(), com.runehive.game.world.entity.skill.Skill.setDoingSkill(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by clickNpc().

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

◆ success()

boolean com.runehive.content.skill.impl.fishing.Fishing.success ( Player player,
Fishable fish )
static

Definition at line 77 of file Fishing.java.

77 {
78 var usingDragonHarpoon = (player.inventory.contains(new Item(21028, 1))
79 || player.equipment.contains(new Item(21028, 1))) && player.skills.get(Skill.FISHING).getLevel() > 60;
80 if (usingDragonHarpoon && (fish.getToolId() == 311 || fish.getToolId() == 21028)) {
81 return SkillRepository.isSuccess(player, Skill.FISHING, fish.getRequiredLevel(), true);
82 }
83 return SkillRepository.isSuccess(player, Skill.FISHING, fish.getRequiredLevel(), false);
84 }

References com.runehive.game.world.items.containers.equipment.Equipment.contains(), com.runehive.game.world.items.containers.ItemContainer.contains(), com.runehive.game.world.entity.mob.player.Player.equipment, com.runehive.game.world.entity.skill.SkillManager.get(), com.runehive.game.world.entity.skill.Skill.getLevel(), com.runehive.content.skill.impl.fishing.Fishable.getRequiredLevel(), com.runehive.content.skill.impl.fishing.Fishable.getToolId(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.content.skill.SkillRepository.isSuccess(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by com.runehive.content.skill.impl.fishing.FishingAction.fish().

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

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