Merge branch 'fix-rainbow-fish' into 'master'

Fly fishing rainbow fish now consumes stripy feathers instead of normal feathers.

See merge request 2009scape/2009scape!252
This commit is contained in:
Ceikry
2021-09-11 01:51:56 +00:00
2 changed files with 49 additions and 23 deletions
@@ -1,5 +1,6 @@
package core.game.node.entity.skill.fishing; package core.game.node.entity.skill.fishing;
import core.game.container.Container;
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.item.Item; import core.game.node.item.Item;
@@ -17,18 +18,18 @@ public enum FishingOption {
CRAYFISH_CAGE(new Item(13431), 1, Animation.create(619), null, "cage", Fish.CRAYFISH), CRAYFISH_CAGE(new Item(13431), 1, Animation.create(619), null, "cage", Fish.CRAYFISH),
SMALL_NET(new Item(303), 1, Animation.create(621), null, "net", Fish.SHRIMP, Fish.ANCHOVIE), SMALL_NET(new Item(303), 1, Animation.create(621), null, "net", Fish.SHRIMP, Fish.ANCHOVIE),
BAIT(new Item(307), 5, Animation.create(622), new Item(313), "bait", Fish.SARDINE, Fish.HERRING), BAIT(new Item(307), 5, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.SARDINE, Fish.HERRING),
LURE(new Item(309), 20, new Animation(622), new Item(314), "lure", Fish.TROUT, Fish.SALMON, Fish.RAINBOW_FISH), LURE(new Item(309), 20, new Animation(622), new Item[]{new Item(Items.FEATHER_314), new Item(Items.STRIPY_FEATHER_10087)}, "lure", Fish.TROUT, Fish.SALMON, Fish.RAINBOW_FISH),
L_BAIT(new Item(307), 25, Animation.create(622), new Item(313), "bait", Fish.PIKE), L_BAIT(new Item(307), 25, Animation.create(622), new Item[]{new Item(313)}, "bait", Fish.PIKE),
CAGE(new Item(301), 40, Animation.create(619), null, "cage", Fish.LOBSTER), CAGE(new Item(301), 40, Animation.create(619), null, "cage", Fish.LOBSTER),
HARPOON(new Item(311), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH), HARPOON(new Item(311), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH),
BARB_HARPOON(new Item(10129), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH), BARB_HARPOON(new Item(10129), 35, Animation.create(618), null, "harpoon", Fish.TUNA, Fish.SWORDFISH),
BIG_NET(new Item(305), 16, Animation.create(620), null, "net", Fish.MACKEREL, Fish.COD, Fish.BASS, Fish.SEAWEED), BIG_NET(new Item(305), 16, Animation.create(620), null, "net", Fish.MACKEREL, Fish.COD, Fish.BASS, Fish.SEAWEED),
N_HARPOON(new Item(311), 76, Animation.create(618), null, "harpoon", Fish.SHARK), N_HARPOON(new Item(311), 76, Animation.create(618), null, "harpoon", Fish.SHARK),
H_NET(new Item(303), 1, Animation.create(621), null, "net", Fish.MONKFISH), H_NET(new Item(303), 1, Animation.create(621), null, "net", Fish.MONKFISH),
C_CAGE(new Item(301), 85, Animation.create(619), new Item(14943), "cage", Fish.DARK_CRAB), C_CAGE(new Item(301), 85, Animation.create(619), new Item[]{new Item(14943)}, "cage", Fish.DARK_CRAB),
KBWANJI_NET(new Item(Items.SMALL_FISHING_NET_303), 5, Animation.create(621), null, "net", Fish.KARAMBWANJI), KBWANJI_NET(new Item(Items.SMALL_FISHING_NET_303), 5, Animation.create(621), null, "net", Fish.KARAMBWANJI),
KARAMBWAN_VES(new Item(Items.KARAMBWAN_VESSEL_3157), 65, Animation.create(1193), new Item(Items.RAW_KARAMBWANJI_3150), "fish", Fish.KARAMBWAN); KARAMBWAN_VES(new Item(Items.KARAMBWAN_VESSEL_3157), 65, Animation.create(1193), new Item[]{new Item(Items.RAW_KARAMBWANJI_3150)}, "fish", Fish.KARAMBWAN);
public static HashMap<String,FishingOption> nameMap = new HashMap<>(); public static HashMap<String,FishingOption> nameMap = new HashMap<>();
static{ static{
@@ -58,7 +59,7 @@ public enum FishingOption {
/** /**
* The bait. * The bait.
*/ */
private final Item bait; private final Item[] bait;
/** /**
* The option name. * The option name.
@@ -77,7 +78,7 @@ public enum FishingOption {
* @param animation The animation. * @param animation The animation.
* @param fish The fish to catch. * @param fish The fish to catch.
*/ */
private FishingOption(Item tool, int level, Animation animation, Item bait, String name, Fish... fish) { private FishingOption(Item tool, int level, Animation animation, Item[] bait, String name, Fish... fish) {
this.tool = tool; this.tool = tool;
this.level = level; this.level = level;
this.animation = animation; this.animation = animation;
@@ -105,7 +106,7 @@ public enum FishingOption {
return Fish.RAINBOW_FISH; return Fish.RAINBOW_FISH;
} }
Fish reward = fish[RandomFunction.randomize(fish.length)]; Fish reward = fish[RandomFunction.randomize(fish.length)];
if (reward.getLevel() > player.getSkills().getLevel(Skills.FISHING) || (reward == Fish.RAINBOW_FISH && !player.getInventory().contains(100887, 1))) { if (reward.getLevel() > player.getSkills().getLevel(Skills.FISHING) || (reward == Fish.RAINBOW_FISH && !player.getInventory().contains(10087, 1))) {
reward = fish[0]; reward = fish[0];
} }
return reward; return reward;
@@ -146,13 +147,40 @@ public enum FishingOption {
return animation; return animation;
} }
/** public String getBaitName() {
* Gets the bait. if(bait != null && bait.length > 0) {
* @return The bait. return bait[0].getName();
*/ } else {
public Item getBait() { return "null";
return bait; }
}
}
public boolean hasBait(Container inventory) {
if(bait == null) {
return true;
} else {
boolean any_bait = false;
for(Item b : bait) {
any_bait = any_bait || inventory.containsItem(b);
}
return any_bait;
}
}
public boolean removeBait(Container inventory) {
if(bait == null) {
return true;
} else {
// Remove more specific bait (later in the list) first.
for(int i = bait.length; i > 0; i--) {
if(inventory.remove(bait[i-1])) {
return true;
}
}
return false;
}
}
/** /**
* Gets the name. * Gets the name.
@@ -170,4 +198,4 @@ public enum FishingOption {
return fish; return fish;
} }
} }
@@ -3,6 +3,7 @@ package rs09.game.node.entity.skill.gather.fishing
import core.game.content.global.SkillingPets import core.game.content.global.SkillingPets
import core.game.content.quest.tutorials.tutorialisland.TutorialSession import core.game.content.quest.tutorials.tutorialisland.TutorialSession
import core.game.content.quest.tutorials.tutorialisland.TutorialStage import core.game.content.quest.tutorials.tutorialisland.TutorialStage
import core.game.container.Container
import core.game.node.entity.npc.NPC import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType import core.game.node.entity.player.link.diary.DiaryType
@@ -64,8 +65,8 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
stop() stop()
return false return false
} }
if (option.bait != null && !player.inventory.containsItem(option.bait)) { if (!option.hasBait(player.inventory)) {
player.dialogueInterpreter.sendDialogue("You don't have any " + option.bait.name.toLowerCase() + "s left.") player.dialogueInterpreter.sendDialogue("You don't have any " + option.getBaitName().toLowerCase() + "s left.")
stop() stop()
return false return false
} }
@@ -113,10 +114,7 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
forager.handlePassiveAction() forager.handlePassiveAction()
} }
if (success()) { if (success()) {
if (if (player.inventory.hasSpaceFor(fish!!.item) && option!!.bait != null) player.inventory.remove( if (player.inventory.hasSpaceFor(fish!!.item) && option!!.removeBait(player.inventory)) {
option.bait
) else true
) {
if (player.skillTasks.hasTask()) { if (player.skillTasks.hasTask()) {
updateSkillTask() updateSkillTask()
} }
@@ -447,4 +445,4 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
fish = option.getRandomFish(player) fish = option.getRandomFish(player)
} }
} }
} }