Moved most fletching option handlers and use with handlers to FletchingListeners.kt

This commit is contained in:
Ceikry
2021-03-13 17:29:39 -06:00
parent c2a3496b31
commit 154d570569
18 changed files with 563 additions and 819 deletions
@@ -1,102 +0,0 @@
package core.game.content.dialogue;
import core.plugin.Initializable;
import core.game.node.entity.skill.fletching.items.grapple.GrapplePulse;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.RunScript;
import core.game.node.item.Item;
import core.net.packet.PacketRepository;
import core.net.packet.context.ChildPositionContext;
import core.net.packet.out.RepositionChild;
/**
* Represents the dialogue used to create a mith grapple.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class MithGrappleDialogue extends DialoguePlugin {
/**
* Represents the mith grapple tip.
*/
private static final Item MITH_GRAPPLE = new Item(9418);
/**
* Represents the first item used.
*/
private Item first;
/**
* Represents the second item used.
*/
private Item second;
/**
* Constructs a new {@code MithGrappleDialogue} {@code Object}.
*/
public MithGrappleDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code MithGrappleDialogue} {@code Object}.
* @param player the player.
*/
public MithGrappleDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new MithGrappleDialogue(player);
}
@Override
public boolean open(Object... args) {
first = (Item) args[0];
second = (Item) args[1];
player.getInterfaceManager().openChatbox(309);
player.getPacketDispatch().sendString("<br><br><br><br>Mith Grapple", 309, 6);
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 215, 26));
player.getPacketDispatch().sendItemZoomOnInterface(MITH_GRAPPLE.getId(), 175, 309, 2);
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
player.getInterfaceManager().closeChatbox();
int amount = 0;
switch (buttonId) {
case 6:
amount = 1;
break;
case 5:
amount = 5;
break;
case 4:
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
int ammount = (int) value;
player.getPulseManager().run(new GrapplePulse(player, first, ammount));
return false;
}
});
player.getDialogueInterpreter().sendInput(false, "Enter the amount");
return true;
case 3:
amount = player.getInventory().getAmount(second);
break;
}
player.getPulseManager().run(new GrapplePulse(player, first, amount));
return true;
}
@Override
public int[] getIds() {
return new int[] { 903213 };
}
}
@@ -1,50 +0,0 @@
package core.game.node.entity.skill.fishing;
import core.cache.def.impl.NPCDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the plugin used to start fishing.
* @author Ceikry
* @version 1.2
*/
@Initializable
public final class FishingOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.setOptionHandler("net", this);
NPCDefinition.setOptionHandler("bait", this);
NPCDefinition.setOptionHandler("lure", this);
NPCDefinition.setOptionHandler("cage", this);
NPCDefinition.setOptionHandler("harpoon", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
NPC npc = (NPC) node;
FishingSpot spot = FishingSpot.forId(npc.getId());
if (spot == null) {
return false;
}
FishingOption opt = spot.getOptionByName(option);
if (opt == null) {
return false;
}
player.getPulseManager().run(new FishingPulse(player, npc, opt));
return true;
}
@Override
public Location getDestination(Node node, Node n) {
return null;
}
}
@@ -1,114 +0,0 @@
package core.game.node.entity.skill.fletching;
import core.plugin.Initializable;
import rs09.game.content.dialogue.SkillDialogueHandler;
import rs09.game.content.dialogue.SkillDialogueHandler.SkillDialogue;
import core.game.node.entity.skill.fletching.items.arrow.ArrowHeadPulse;
import core.game.node.entity.skill.fletching.items.arrow.HeadlessArrowPulse;
import core.game.interaction.NodeUsageEvent;
import core.game.interaction.UseWithHandler;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.net.packet.PacketRepository;
import core.net.packet.context.ChildPositionContext;
import core.net.packet.out.RepositionChild;
import core.plugin.Plugin;
/**
* Represents the plugin used to create arrows.
* @author Angle
*/
@Initializable
public class ArrowCreatePlugin extends UseWithHandler {
/**
* Represents the headless arrow item.
*/
private static final Item HEADLESS_ARROW = new Item(53);
/**
* Constructs a new {@code ArrowCreatePlugin} {@code Object}.
*/
public ArrowCreatePlugin() {
super(314, 53, 52);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
// Feathers plus colored feathers
addHandler(314, ITEM_TYPE, this);
addHandler(10087, ITEM_TYPE, this);
addHandler(10088, ITEM_TYPE, this);
addHandler(10089, ITEM_TYPE, this);
addHandler(10090, ITEM_TYPE, this);
addHandler(10091, ITEM_TYPE, this);
// Headless Arrows
addHandler(53, ITEM_TYPE, this);
// Arrow heads
for (Fletching.ArrowHeads head : Fletching.ArrowHeads.values()) {
addHandler(head.unfinished, ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(final NodeUsageEvent event) {
event.getPlayer().debug("Trying to handle: " + event.getUsedItem() + " with " + event.getUsedWith());
final Player player = event.getPlayer();
// If the player uses a feather on headless arrows, do headless arrow crafting
final int itemId = event.getUsedItem().getId();
final int otherId = event.getUsedWith().getId();
final boolean hasFeather = (itemId == 314 || (itemId >= 10087 && itemId <= 10091)) || (otherId == 314 || (otherId >= 10087 && otherId <= 10091));
final boolean hasShaft = (itemId == 52 || otherId == 52);
// If the item used was feathers and the target was arrow shafts
if (hasFeather && hasShaft) {
// Creating headless arrows
final int featherId = itemId == 52 ? otherId : itemId;
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, HEADLESS_ARROW) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new HeadlessArrowPulse(player, event.getUsedItem(), new Item(featherId), amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(HEADLESS_ARROW);
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
// Otherwise, fletch normally
boolean firstIsHead = Fletching.isArrowHead(itemId);
if (!firstIsHead && !Fletching.isArrowHead(otherId)) {
return false;
} else if (hasFeather || hasShaft) {
// Disallow crafting feathers with arrowheads or shafts with arrowheads.
// It will fail anyway but this makes sure
// that the gui doesn't pop up on the client.
return true;
}
final Fletching.ArrowHeads head = Fletching.arrowHeadMap.get(firstIsHead ? itemId : otherId);
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, head.getFinished()) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new ArrowHeadPulse(player, event.getUsedItem(), head, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(head.getUnfinished());
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
}
@@ -1,62 +0,0 @@
package core.game.node.entity.skill.fletching;
import rs09.game.content.dialogue.SkillDialogueHandler;
import core.game.node.entity.skill.fletching.items.crossbow.LimbPulse;
import core.game.interaction.NodeUsageEvent;
import core.game.interaction.UseWithHandler;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.net.packet.PacketRepository;
import core.net.packet.context.ChildPositionContext;
import core.net.packet.out.RepositionChild;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the plugin used to make a crossbow.
* @author Ceikry
*/
@Initializable
public class MakeCrossbowPlugin extends UseWithHandler {
Fletching.Limb limb;
Item whichItem;
/**
* Constructs a new {@code StringcrossbowPlugin} {@code Object}.
*/
public MakeCrossbowPlugin() {
super(9420, 9423, 9422, 9425, 9427, 9429, 9431);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Fletching.Limb l : Fletching.Limb.values()) {
addHandler(new Item(l.stock).getId(), ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
limb = Fletching.limbMap.get(event.getBaseItem().getId());
whichItem = (Item)event.getUsedWith();
if(limb == null){
limb = Fletching.limbMap.get(event.getUsed().getId());
whichItem = (Item)event.getUsed();
}
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogueHandler.SkillDialogue.ONE_OPTION, new Item(limb.product)) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new LimbPulse(player, whichItem, limb, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(whichItem);
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 210, 10));
return true;
}
}
@@ -1,69 +0,0 @@
package core.game.node.entity.skill.fletching;
import core.game.node.entity.skill.Skills;
import core.game.interaction.NodeUsageEvent;
import core.game.interaction.UseWithHandler;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the plugin used to make a mithril grapple.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class MithGrapplePlugin extends UseWithHandler {
/**
* Represents the rope grapple.
*/
private static final Item ROPE_GRAPPLE = new Item(9419);
/**
* Represents the mith grapple.
*/
private static final Item MITH_GRAPPLE = new Item(9418);
/**
* Represents the rope item.
*/
private static final Item ROPE = new Item(954);
/**
* Constructs a new {@code MithGrapplePlugin} {@code Object}.
*/
public MithGrapplePlugin() {
super(9416, 954);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(9142, ITEM_TYPE, this);
addHandler(9418, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
final Item first = event.getUsedItem();
final Item second = event.getBaseItem();
if (first.getId() == 9418 && second.getId() != 954) {
return false;
} else if (first.getId() == 9418 && second.getId() == 954) {
if (player.getInventory().remove(ROPE) && player.getInventory().remove(MITH_GRAPPLE)) {
player.getInventory().add(ROPE_GRAPPLE);
}
return true;
}
if (player.getSkills().getLevel(Skills.FLETCHING) < 59) {
player.getDialogueInterpreter().sendDialogue("You need a fletching level of 59 in order to do that.");
return true;
}
player.getDialogueInterpreter().open(903213, first, second);
return true;
}
}
@@ -1,65 +0,0 @@
package core.game.node.entity.skill.fletching;
import core.plugin.Initializable;
import rs09.game.content.dialogue.SkillDialogueHandler;
import core.game.node.entity.skill.fletching.items.bow.StringPulse;
import core.game.interaction.NodeUsageEvent;
import core.game.interaction.UseWithHandler;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.net.packet.PacketRepository;
import core.net.packet.context.ChildPositionContext;
import core.net.packet.out.RepositionChild;
import core.plugin.Plugin;
/**
* Represents the plugin used to string a bow.
* @author Ceikry
* @version 2.0
*/
@Initializable
public final class StringbowPlugin extends UseWithHandler {
Fletching.String string;
/**
* Constructs a new {@code StringbowPlugin} {@code Object}.
*/
public StringbowPlugin() {
super(1777, 9438);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
for (Fletching.String bw : Fletching.String.values()) {
addHandler(bw.unfinished, ITEM_TYPE, this);
}
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
Fletching.String string = Fletching.stringMap.get(event.getUsedItem().getId());
if(string == null){
string = Fletching.stringMap.get(event.getUsedWith().getId());
}
final Fletching.String bow = string;
if(!(player.getInventory().containsItem(new Item(bow.string)))){
player.getDialogueInterpreter().sendDialogue("That's not the correct type of string.");
return true;
}
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogueHandler.SkillDialogue.ONE_OPTION, new Item(bow.product)) {
@Override
public void create(final int amount, int index) {
player.getPulseManager().run(new StringPulse(player, event.getUsedItem(), bow, amount));
}
@Override
public int getAll(int index) {
return player.getInventory().getAmount(event.getUsedItem());
}
};
handler.open();
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 309, 2, 215, 10));
return true;
}
}
@@ -94,7 +94,7 @@ public final class HeadlessArrowPulse extends SkillPulse<Item> {
ARROW_SHAFT.setAmount(15);
player.getPacketDispatch().sendMessage("You attach feathers to 15 arrow shafts.");
} else {
int amount = featherAmount > shaftAmount ? shaftAmount : featherAmount;
int amount = Math.min(featherAmount, shaftAmount);
feather.setAmount(amount);
ARROW_SHAFT.setAmount(amount);
player.getPacketDispatch().sendMessage(amount == 1
@@ -33,7 +33,6 @@ public class StringPulse extends SkillPulse<Item> {
*/
public StringPulse(Player player, Item node, final Fletching.String bow, int amount) {
super(player, node);
setDelay(bow.string == 1777 ? 9 : 7);
this.bow = bow;
this.amount = amount;
}
@@ -1,79 +1,52 @@
package core.game.node.entity.skill.fletching.items.crossbow;
package core.game.node.entity.skill.fletching.items.crossbow
import core.game.node.entity.skill.SkillPulse;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.fletching.Fletching;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.node.entity.player.Player
import core.game.node.entity.skill.SkillPulse
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.fletching.Fletching
import core.game.node.item.Item
/**
* Represents the skill pulse of attaching limbs.
* @author Ceikry
*/
public class LimbPulse extends SkillPulse<Item> {
class LimbPulse(player: Player?, node: Item, private val limb: Fletching.Limb ,private var amount: Int) : SkillPulse<Item?>(player, node) {
override fun checkRequirements(): Boolean {
if (player.skills.getLevel(Skills.FLETCHING) < limb.level) {
player.dialogueInterpreter.sendDialogue("You need a fletching level of " + limb.level + " to attach these limbs.")
return false
}
if (!player.inventory.containsItem(Item(limb.limb))) {
player.dialogueInterpreter.sendDialogue("That's not the correct limb to attach.")
return false
}
if(!player.inventory.containsItem(Item(limb.stock))){
player.dialogueInterpreter.sendDialogue("That's not the correct stock for that limb.")
return false
}
return player.inventory.containsItem(Item(limb.stock))
}
/**
* Represents the limbs.
*/
private final Fletching.Limb limb;
override fun animate() {
player.animate(limb.animation)
}
/**
* Represents the amount.
*/
private int amount;
override fun reward(): Boolean {
if (delay == 1) {
super.setDelay(6)
return false
}
if (player.inventory.remove(Item(limb.stock), Item(limb.limb))) {
player.inventory.add(Item(limb.product))
player.skills.addExperience(Skills.FLETCHING, limb.experience, true)
player.packetDispatch.sendMessage("You attach the metal limbs to the stock.")
}
if (!player.inventory.containsItem(Item(limb.limb))) {
return true
}
amount--
return amount == 0
}
/**
* Constructs a new {@code StringcrossbowPlugin.java} {@code Object}.
* @param player the player.
* @param node the node.
*/
public LimbPulse(Player player, Item node, final Fletching.Limb limb, int amount) {
super(player, node);
this.limb = limb;
this.amount = amount;
}
@Override
public boolean checkRequirements() {
if (player.getSkills().getLevel(Skills.FLETCHING) < limb.level) {
player.getDialogueInterpreter().sendDialogue("You need a fletching level of " + limb.level + " to attach these limbs.");
return false;
}
if (!player.getInventory().containsItem(new Item(limb.limb))) {
player.getDialogueInterpreter().sendDialogue("That's not the correct limb to attach.");
return false;
}
if (!player.getInventory().containsItem(new Item(limb.stock))) {
return false;
}
return true;
}
@Override
public void animate() {
player.animate(limb.animation);
}
@Override
public boolean reward() {
if (getDelay() == 1) {
super.setDelay(6);
return false;
}
if (player.getInventory().remove(new Item(limb.stock), new Item(limb.limb))) {
player.getInventory().add(new Item(limb.product));
player.getSkills().addExperience(Skills.FLETCHING, limb.experience, true);
player.getPacketDispatch().sendMessage("You attach the metal limbs to the stock.");
}
if (!player.getInventory().containsItem(new Item(limb.limb))) {
return true;
}
amount--;
return amount == 0;
}
@Override
public void message(int type) {
}
}
override fun message(type: Int) {}
}
@@ -0,0 +1,133 @@
package rs09.game.node.entity.skill.fletching
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.fletching.Fletching
import core.game.node.entity.skill.fletching.items.arrow.ArrowHeadPulse
import core.game.node.entity.skill.fletching.items.arrow.HeadlessArrowPulse
import core.game.node.entity.skill.fletching.items.bow.StringPulse
import core.game.node.entity.skill.fletching.items.crossbow.LimbPulse
import core.game.node.item.Item
import core.net.packet.PacketRepository
import core.net.packet.context.ChildPositionContext
import core.net.packet.out.RepositionChild
import org.rs09.consts.Items
import rs09.game.content.dialogue.SkillDialogueHandler
import rs09.game.interaction.InteractionListener
class FletchingListeners : InteractionListener() {
val LIMBIDs = Fletching.Limb.values().map(Fletching.Limb::limb).toIntArray()
val STOCKIDs = Fletching.Limb.values().map(Fletching.Limb::stock).toIntArray()
val MITHRIL_BOLT = Items.MITHRIL_BOLTS_9142
val MITH_GRAPPLE_TIP = Items.MITH_GRAPPLE_TIP_9416
val ROPE = Items.ROPE_954
val MITH_GRAPPLE = Items.MITH_GRAPPLE_9418
val ROPE_GRAPPLE = Items.MITH_GRAPPLE_9419
val ARROW_SHAFT = Items.ARROW_SHAFT_52
val FLETCHED_SHAFT = Items.HEADLESS_ARROW_53
val UNFINISHED_ARROWS = Fletching.ArrowHeads.values().map(Fletching.ArrowHeads::unfinished).toIntArray()
val FEATHERS = intArrayOf(314,10087,10088,10089,10090,10091)
val UNSTRUNG_BOWS = Fletching.String.values().map(Fletching.String::unfinished).toIntArray()
val STRINGS = intArrayOf(Items.BOW_STRING_1777,Items.SINEW_9436)
override fun defineListeners() {
onUseWith(ITEM,STRINGS,*UNSTRUNG_BOWS){player,string,bow ->
val enum = Fletching.stringMap[bow.id] ?: return@onUseWith false
if(enum.string != string.id){
player.sendMessage("That's not the right kind of string for this.")
return@onUseWith true
}
val handler: SkillDialogueHandler =
object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, Item(enum.product)) {
override fun create(amount: Int, index: Int) {
player.pulseManager.run(StringPulse(player, string.asItem(), enum, amount))
}
override fun getAll(index: Int): Int {
return player.inventory.getAmount(string.asItem())
}
}
handler.open()
PacketRepository.send(RepositionChild::class.java, ChildPositionContext(player, 309, 2, 215, 10))
return@onUseWith true
}
onUseWith(ITEM,ARROW_SHAFT,*FEATHERS){player,shaft,feather ->
val handler: SkillDialogueHandler =
object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, Item(FLETCHED_SHAFT)) {
override fun create(amount: Int, index: Int) {
player.pulseManager.run(HeadlessArrowPulse(player, shaft.asItem(), Item(feather.id), amount))
}
override fun getAll(index: Int): Int {
return player.inventory.getAmount(FLETCHED_SHAFT)
}
}
handler.open()
PacketRepository.send(RepositionChild::class.java, ChildPositionContext(player, 309, 2, 210, 10))
return@onUseWith true
}
onUseWith(ITEM,FLETCHED_SHAFT,*UNFINISHED_ARROWS){player,shaft,unfinished ->
val head = Fletching.arrowHeadMap[unfinished.id] ?: return@onUseWith false
val handler: SkillDialogueHandler =
object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, head.getFinished()) {
override fun create(amount: Int, index: Int) {
player.pulseManager.run(ArrowHeadPulse(player, shaft.asItem(), head, amount))
}
override fun getAll(index: Int): Int {
return player.inventory.getAmount(head.getUnfinished())
}
}
handler.open()
PacketRepository.send(RepositionChild::class.java, ChildPositionContext(player, 309, 2, 210, 10))
return@onUseWith true
}
onUseWith(ITEM,MITHRIL_BOLT,MITH_GRAPPLE_TIP){player,bolt,tip ->
if(player.skills.getLevel(Skills.FLETCHING) < 59){
player.sendMessage("You need a fletching level of 59 to make this.")
return@onUseWith true
}
if(player.inventory.remove(bolt.asItem(),tip.asItem())){
player.inventory.add(Item(MITH_GRAPPLE))
}
return@onUseWith true
}
onUseWith(ITEM,ROPE,MITH_GRAPPLE){player,rope,grapple ->
if(player.skills.getLevel(Skills.FLETCHING) < 59){
player.sendMessage("You need a fletching level of 59 to make this.")
return@onUseWith true
}
if(player.inventory.remove(rope.asItem(),grapple.asItem())){
player.inventory.add(Item(ROPE_GRAPPLE))
}
return@onUseWith true
}
onUseWith(ITEM,LIMBIDs,*STOCKIDs){player, limb, stock ->
val limbEnum = Fletching.limbMap[stock.id] ?: return@onUseWith false
if(limbEnum.limb != limb.id){
player.sendMessage("That's not the right limb to attach to that stock.")
return@onUseWith true
}
val handler: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, Item(limbEnum.product)){
override fun create(amount: Int, index: Int) {
player.pulseManager.run(LimbPulse(player, stock.asItem(), limbEnum, amount))
}
override fun getAll(index: Int): Int {
return player.inventory.getAmount(stock.asItem())
}
}
handler.open()
PacketRepository.send(RepositionChild::class.java, ChildPositionContext(player, 309, 2, 210, 10))
return@onUseWith true
}
}
}
@@ -1,13 +1,17 @@
package rs09.game.node.entity.skill.gather
import core.game.node.Node
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import rs09.game.node.entity.skill.gather.fishing.FishingPulse
import core.game.node.entity.skill.fishing.FishingSpot
import core.game.node.entity.skill.gather.woodcutting.WoodcuttingSkillPulse
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.KjallakOnChopDialogue
import rs09.game.interaction.InteractionListener
import rs09.game.node.entity.skill.gather.mining.MiningSkillPulse
class GatheringSkillOptionPlugin : InteractionListener() {
class GatheringSkillOptionListeners : InteractionListener() {
val ETCETERIA_REGION = 10300
@@ -25,5 +29,19 @@ class GatheringSkillOptionPlugin : InteractionListener() {
player.pulseManager.run(MiningSkillPulse(player, node.asObject()))
return@on true
}
on(NPC,"net"){player,node -> return@on fish(player,node,"net")}
on(NPC,"lure"){player,node -> return@on fish(player,node,"lure")}
on(NPC,"bait"){player,node -> return@on fish(player,node,"bait")}
on(NPC,"harpoon"){player,node -> return@on fish(player,node,"harpoon")}
on(NPC,"cage"){player,node -> return@on fish(player,node,"cage")}
}
fun fish(player: Player, node: Node, opt: String): Boolean{
val npc = node as NPC
val spot = FishingSpot.forId(npc.id) ?: return false
val op = spot.getOptionByName(opt) ?: return false
player.pulseManager.run(FishingPulse(player, npc, op))
return true
}
}
@@ -1,367 +1,450 @@
package core.game.node.entity.skill.fishing;
package rs09.game.node.entity.skill.gather.fishing
import core.game.content.global.SkillingPets;
import core.game.content.quest.tutorials.tutorialisland.TutorialSession;
import core.game.content.quest.tutorials.tutorialisland.TutorialStage;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.node.entity.player.link.skillertasks.SkillTasks;
import core.game.node.entity.skill.SkillPulse;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.summoning.familiar.Forager;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import core.game.world.map.Location;
import core.game.world.map.path.Pathfinder;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks;
import rs09.game.world.GameWorld;
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_BASE;
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_FISH;
import static rs09.tools.stringtools.StringToolsKt.colorize;
import core.game.content.global.SkillingPets
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.player.link.skillertasks.SkillTasks
import core.game.node.entity.skill.SkillPulse
import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.fishing.Fish
import core.game.node.entity.skill.fishing.FishingOption
import core.game.node.entity.skill.summoning.familiar.Forager
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.path.Pathfinder
import core.game.world.update.flag.context.Animation
import core.tools.RandomFunction
import rs09.game.node.entity.player.info.stats.STATS_BASE
import rs09.game.node.entity.player.info.stats.STATS_FISH
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.Companion.isActive
import rs09.game.world.GameWorld.Pulser
import rs09.tools.stringtools.colorize
/**
* Handles a fishing pulse.
*
* @author Ceikry
*/
public final class FishingPulse extends SkillPulse<NPC> {
/**
* Represents the fishing option.
*/
private final FishingOption option;
class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?) : SkillPulse<NPC?>(player, npc) {
/**
* Represents the fish type.
*/
private Fish fish;
private var fish: Fish? = null
/**
* Represents the base location the npc was at.
*/
private final Location location;
private val location: Location = npc.location
/**
* Constructs a new {@code FishingPulse} {@code Object}.
*
* @param player the player.
* @param npc the fishing spot NPC.
* @param option The fishing option.
*/
public FishingPulse(final Player player, final NPC npc, final FishingOption option) {
super(player, npc);
this.option = option;
this.location = npc.getLocation();
if (option != null) {
this.fish = option.getRandomFish(player);
override fun start() {
if (TutorialSession.getExtension(player).stage == 12) {
TutorialStage.load(player, 13, false)
}
if (player.familiarManager.hasFamiliar() && player.familiarManager.familiar is Forager) {
val forager = player.familiarManager.familiar as Forager
val dest = player.location.transform(player.direction)
Pathfinder.find(forager.location, dest).walk(forager)
}
super.start()
}
@Override
public void start() {
if (TutorialSession.getExtension(player).getStage() == 12) {
TutorialStage.load(player, 13, false);
}
if (player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar() instanceof Forager) {
final Forager forager = (Forager) player.getFamiliarManager().getFamiliar();
Location dest = player.getLocation().transform(player.getDirection());
Pathfinder.find(forager.getLocation(), dest).walk(forager);
}
super.start();
}
@Override
public boolean checkRequirements() {
override fun checkRequirements(): Boolean {
if (option == null) {
return false;
return false
}
player.debug(String.valueOf(player.getInventory().containsItem(option.getTool())));
if (!player.getInventory().containsItem(option.getTool()) && !hasBarbTail()) {
player.debug(player.inventory.containsItem(option.tool).toString())
if (!player.inventory.containsItem(option.tool) && !hasBarbTail()) {
//System.out.println(isBareHanded(player));
player.getDialogueInterpreter().sendDialogue("You need a " + option.getTool().getName().toLowerCase() + " to catch these fish.");
stop();
return false;
player.dialogueInterpreter.sendDialogue("You need a " + option.tool.name.toLowerCase() + " to catch these fish.")
stop()
return false
}
if (option.getBait() != null && !player.getInventory().containsItem(option.getBait())) {
player.getDialogueInterpreter().sendDialogue("You don't have any " + option.getBait().getName().toLowerCase() + "s left.");
stop();
return false;
if (option.bait != null && !player.inventory.containsItem(option.bait)) {
player.dialogueInterpreter.sendDialogue("You don't have any " + option.bait.name.toLowerCase() + "s left.")
stop()
return false
}
if (player.getSkills().getLevel(Skills.FISHING) < fish.getLevel()) {
player.getDialogueInterpreter().sendDialogue("You need a fishing level of " + fish.getLevel() + " to catch " + (fish == Fish.SHRIMP || fish == Fish.ANCHOVIE ? "" : "a") + " " + fish.getItem().getName().toLowerCase() + ".".trim());
stop();
return false;
if (player.skills.getLevel(Skills.FISHING) < fish!!.level) {
player.dialogueInterpreter.sendDialogue("You need a fishing level of " + fish!!.level + " to catch " + (if (fish == Fish.SHRIMP || fish == Fish.ANCHOVIE) "" else "a") + " " + fish!!.item.name.toLowerCase() + ".".trim { it <= ' ' })
stop()
return false
}
if (player.getInventory().freeSlots() == 0) {
player.getDialogueInterpreter().sendDialogue("You don't have enough space in your inventory.");
stop();
return false;
if (player.inventory.freeSlots() == 0) {
player.dialogueInterpreter.sendDialogue("You don't have enough space in your inventory.")
stop()
return false
}
if (location != node.getLocation() || !node.isActive() || node.isInvisible()) {
stop();
return false;
if (location !== node!!.location || !node!!.isActive || node!!.isInvisible) {
stop()
return false
}
return true;
return true
}
@Override
public void animate() {
override fun animate() {
if (isBareHanded(player)) {
player.animate(new Animation(6709));
GameWorld.getPulser().submit(new Pulse(1) {
int counter = 0;
@Override
public boolean pulse() {
switch (counter++) {
case 5:
getCatchAnimationAndLoot(player);
break;
player.animate(Animation(6709))
Pulser.submit(object : Pulse(1) {
var counter = 0
override fun pulse(): Boolean {
when (counter++) {
5 -> getCatchAnimationAndLoot(player)
}
return false;
return false
}
});
})
} else {
player.animate(option.getAnimation());
player.animate(option!!.animation)
}
}
@Override
public boolean reward() {
if (getDelay() == 1) {
super.setDelay(5);
return false;
override fun reward(): Boolean {
if (delay == 1) {
super.setDelay(5)
return false
}
if (player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar() instanceof Forager) {
final Forager forager = (Forager) player.getFamiliarManager().getFamiliar();
forager.handlePassiveAction();
if (player.familiarManager.hasFamiliar() && player.familiarManager.familiar is Forager) {
val forager = player.familiarManager.familiar as Forager
forager.handlePassiveAction()
}
if (success()) {
if ((player.getInventory().hasSpaceFor(fish.getItem()) && option.getBait() != null) ? player.getInventory().remove(option.getBait()) : true) {
if (player.getSkillTasks().hasTask()) {
updateSkillTask();
if (if (player.inventory.hasSpaceFor(fish!!.item) && option!!.bait != null) player.inventory.remove(
option.bait
) else true
) {
if (player.skillTasks.hasTask()) {
updateSkillTask()
}
updateDiary();
SkillingPets.checkPetDrop(player, SkillingPets.HERON);
final Item item = fish.getItem();
if(SkillcapePerks.isActive(SkillcapePerks.GREAT_AIM,player) && RandomFunction.random(100) <= 5){
player.getInventory().add(item);
player.sendMessage(colorize("%RYour expert aim catches you a second fish."));
updateDiary()
SkillingPets.checkPetDrop(player, SkillingPets.HERON)
val item = fish!!.item
if (isActive(SkillcapePerks.GREAT_AIM, player) && RandomFunction.random(100) <= 5) {
player.inventory.add(item)
player.sendMessage(colorize("%RYour expert aim catches you a second fish."))
}
player.getInventory().add(item);
int fishCaught = player.getAttribute(STATS_BASE + ":" + STATS_FISH,0);
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_FISH,++fishCaught);
player.getSkills().addExperience(Skills.FISHING, fish.getExperience(), true);
message(2);
if (TutorialSession.getExtension(player).getStage() == 13) {
TutorialStage.load(player, 14, false);
stop();
return true;
player.inventory.add(item)
var fishCaught = player.getAttribute(STATS_BASE + ":" + STATS_FISH, 0)
player.setAttribute("/save:$STATS_BASE:$STATS_FISH", ++fishCaught)
player.skills.addExperience(Skills.FISHING, fish!!.experience, true)
message(2)
if (TutorialSession.getExtension(player).stage == 13) {
TutorialStage.load(player, 14, false)
stop()
return true
}
fish = option.getRandomFish(player);
fish = option!!.getRandomFish(player)
}
}
return player.getInventory().freeSlots() == 0;
return player.inventory.freeSlots() == 0
}
public void updateDiary() {
switch (fish) {
case MACKEREL:
if (player.getViewport().getRegion().getId() == 11317) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 11);
fun updateDiary() {
when (fish) {
Fish.MACKEREL -> {
if (player.viewport.region.id == 11317) {
player.achievementDiaryManager.finishTask(player, DiaryType.SEERS_VILLAGE, 0, 11)
}
case BASS:
if (player.getViewport().getRegion().getId() == 11317
&& !player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 1, 11)) {
player.setAttribute("/save:diary:seers:bass-caught", true);
if (player.viewport.region.id == 11317
&& !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 1, 11)
) {
player.setAttribute("/save:diary:seers:bass-caught", true)
}
case SHARK:
if (player.getViewport().getRegion().getId() == 11317
&& !player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)) {
player.setAttribute("/save:diary:seers:caught-shark", 1 + player.getAttribute("diary:seers:caught-shark", 0));
if (player.viewport.region.id == 11317
&& !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)
) {
player.setAttribute(
"/save:diary:seers:caught-shark",
1 + player.getAttribute("diary:seers:caught-shark", 0)
)
if (player.getAttribute("diary:seers:caught-shark", 0) >= 5) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 2, 7);
player.achievementDiaryManager.finishTask(player, DiaryType.SEERS_VILLAGE, 2, 7)
}
}
case SHRIMP:
// Catch some shrimp in the Fishing spot to the east of<br><br>Lumbridge Swamp
if (player.getLocation().withinDistance(Location.create(3241, 3149, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 13);
// Catch some shrimp in the Fishing spot to the east of<br><br>Lumbridge Swamp
if (player.location.withinDistance(Location.create(3241, 3149, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 13)
}
// Catch a pike in the river to the east of Lumbridge Castle
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 4)
}
// Catch a salmon in the river to the east of Lumbridge Castle
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
case PIKE:
// Catch a pike in the river to the east of Lumbridge Castle
if (player.getLocation().withinDistance(Location.create(3240, 3247, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 4);
}
case SALMON:
// Catch a salmon in the river to the east of Lumbridge Castle
if (player.getLocation().withinDistance(Location.create(3240, 3247, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 2, 9);
}
case TROUT:
// Catch a trout in the river to the east of Barbarian Village
if (player.getLocation().withinDistance(Location.create(3105, 3431, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 0, 16);
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.BASS -> {
if (player.viewport.region.id == 11317
&& !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 1, 11)
) {
player.setAttribute("/save:diary:seers:bass-caught", true)
}
if (player.viewport.region.id == 11317
&& !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)
) {
player.setAttribute(
"/save:diary:seers:caught-shark",
1 + player.getAttribute("diary:seers:caught-shark", 0)
)
if (player.getAttribute("diary:seers:caught-shark", 0) >= 5) {
player.achievementDiaryManager.finishTask(player, DiaryType.SEERS_VILLAGE, 2, 7)
}
}
if (player.location.withinDistance(Location.create(3241, 3149, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 13)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 4)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.SHARK -> {
if (player.viewport.region.id == 11317
&& !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)
) {
player.setAttribute(
"/save:diary:seers:caught-shark",
1 + player.getAttribute("diary:seers:caught-shark", 0)
)
if (player.getAttribute("diary:seers:caught-shark", 0) >= 5) {
player.achievementDiaryManager.finishTask(player, DiaryType.SEERS_VILLAGE, 2, 7)
}
}
if (player.location.withinDistance(Location.create(3241, 3149, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 13)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 4)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.SHRIMP -> {
if (player.location.withinDistance(Location.create(3241, 3149, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 13)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 4)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.PIKE -> {
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 4)
}
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.SALMON -> {
if (player.location.withinDistance(Location.create(3240, 3247, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 9)
}
if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
Fish.TROUT -> if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 0, 16)
}
}
// Use the Fishing spots north of the banana plantation
if (node.getId() == 333 && player.getZoneMonitor().isInZone("karamja")
&& player.getLocation().withinDistance(new Location(2924, 3178, 0), 10)) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 0, 6);
if (node!!.id == 333 && player.zoneMonitor.isInZone("karamja")
&& player.location.withinDistance(Location(2924, 3178, 0), 10)
) {
player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 0, 6)
}
}
public void updateSkillTask() {
switch (fish) {
case ANCHOVIE:
player.getSkillTasks().decreaseTask(player, SkillTasks.FANCHOVIES1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FANCHOVIES2);
break;
case HERRING:
player.getSkillTasks().decreaseTask(player, SkillTasks.FHERRING1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FHERRING2);
break;
case LOBSTER:
player.getSkillTasks().decreaseTask(player, SkillTasks.FLOBSTER1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FLOBSTER2);
break;
case SALMON:
player.getSkillTasks().decreaseTask(player, SkillTasks.FSALMON1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FSALMON2);
break;
case SHARK:
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK2);
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK3);
break;
case SHRIMP:
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHRIMP1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHRIMP2);
break;
case SWORDFISH:
player.getSkillTasks().decreaseTask(player, SkillTasks.FSWORD1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FSWORD2);
break;
case TROUT:
player.getSkillTasks().decreaseTask(player, SkillTasks.FTROUT1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FTROUT2);
break;
case TUNA:
player.getSkillTasks().decreaseTask(player, SkillTasks.FTUNA1);
player.getSkillTasks().decreaseTask(player, SkillTasks.FTUNA2);
break;
fun updateSkillTask() {
when (fish) {
Fish.ANCHOVIE -> {
player.skillTasks.decreaseTask(player, SkillTasks.FANCHOVIES1)
player.skillTasks.decreaseTask(player, SkillTasks.FANCHOVIES2)
}
Fish.HERRING -> {
player.skillTasks.decreaseTask(player, SkillTasks.FHERRING1)
player.skillTasks.decreaseTask(player, SkillTasks.FHERRING2)
}
Fish.LOBSTER -> {
player.skillTasks.decreaseTask(player, SkillTasks.FLOBSTER1)
player.skillTasks.decreaseTask(player, SkillTasks.FLOBSTER2)
}
Fish.SALMON -> {
player.skillTasks.decreaseTask(player, SkillTasks.FSALMON1)
player.skillTasks.decreaseTask(player, SkillTasks.FSALMON2)
}
Fish.SHARK -> {
player.skillTasks.decreaseTask(player, SkillTasks.FSHARK1)
player.skillTasks.decreaseTask(player, SkillTasks.FSHARK2)
player.skillTasks.decreaseTask(player, SkillTasks.FSHARK3)
}
Fish.SHRIMP -> {
player.skillTasks.decreaseTask(player, SkillTasks.FSHRIMP1)
player.skillTasks.decreaseTask(player, SkillTasks.FSHRIMP2)
}
Fish.SWORDFISH -> {
player.skillTasks.decreaseTask(player, SkillTasks.FSWORD1)
player.skillTasks.decreaseTask(player, SkillTasks.FSWORD2)
}
Fish.TROUT -> {
player.skillTasks.decreaseTask(player, SkillTasks.FTROUT1)
player.skillTasks.decreaseTask(player, SkillTasks.FTROUT2)
}
Fish.TUNA -> {
player.skillTasks.decreaseTask(player, SkillTasks.FTUNA1)
player.skillTasks.decreaseTask(player, SkillTasks.FTUNA2)
}
}
}
private boolean isBareHanded(Player p) {
private fun isBareHanded(p: Player): Boolean {
if (option == FishingOption.HARPOON) {
if (checkFish(p) > 0 && !(player.getInventory().containsItem(option.getTool()) || player.getEquipment().containsItem(option.getTool()))) {
return true;
if (checkFish(p) > 0 && !(player.inventory.containsItem(
option.tool
) || player.equipment.containsItem(option.tool))
) {
return true
}
if (checkFish(p) > 2 && !(player.getInventory().containsItem(option.getTool()) || player.getEquipment().containsItem(option.getTool()))) {
return true;
if (checkFish(p) > 2 && !(player.inventory.containsItem(
option.tool
) || player.equipment.containsItem(option.tool))
) {
return true
}
}
return false;
return false
}
private int getCatchAnimationAndLoot(Player p) {
int fishingFor = checkFish(p);
switch (node.getId()) {
case 324:
switch (fishingFor) {
case 1:
p.animate(new Animation(6710));
p.getSkills().addExperience(Skills.FISHING, 80);
p.getSkills().addExperience(Skills.STRENGTH, 8);
p.getInventory().add(new Item(359));
break;
case 2:
case 3:
if (RandomFunction.random(1) == 1) {
p.animate(new Animation(6710));
p.getSkills().addExperience(Skills.FISHING, 80);
p.getSkills().addExperience(Skills.STRENGTH, 8);
p.getInventory().add(new Item(359));
} else {
p.animate(new Animation(6707));
p.getSkills().addExperience(Skills.FISHING, 100);
p.getSkills().addExperience(Skills.STRENGTH, 10);
p.getInventory().add(new Item(371));
}
private fun getCatchAnimationAndLoot(p: Player): Int {
val fishingFor = checkFish(p)
when (node!!.id) {
324 -> when (fishingFor) {
1 -> {
p.animate(Animation(6710))
p.skills.addExperience(Skills.FISHING, 80.0)
p.skills.addExperience(Skills.STRENGTH, 8.0)
p.inventory.add(Item(359))
}
break;
case 313:
p.animate(new Animation(6705));
p.getSkills().addExperience(Skills.FISHING, 110);
p.getSkills().addExperience(Skills.STRENGTH, 11);
p.getInventory().add(new Item(383));
break;
}
return 0;
}
public static int checkFish(Player p) {
if (p.getSkills().getLevel(Skills.FISHING) >= 55 && p.getSkills().getLevel(Skills.STRENGTH) >= 35) {
if (p.getSkills().getLevel(Skills.FISHING) >= 70 && p.getSkills().getLevel(Skills.STRENGTH) >= 50) {
if (p.getSkills().getLevel(Skills.FISHING) >= 96 && p.getSkills().getLevel(Skills.STRENGTH) >= 76) {
return 3;
2, 3 -> if (RandomFunction.random(1) == 1) {
p.animate(Animation(6710))
p.skills.addExperience(Skills.FISHING, 80.0)
p.skills.addExperience(Skills.STRENGTH, 8.0)
p.inventory.add(Item(359))
} else {
p.animate(Animation(6707))
p.skills.addExperience(Skills.FISHING, 100.0)
p.skills.addExperience(Skills.STRENGTH, 10.0)
p.inventory.add(Item(371))
}
return 2;
}
return 1;
313 -> {
p.animate(Animation(6705))
p.skills.addExperience(Skills.FISHING, 110.0)
p.skills.addExperience(Skills.STRENGTH, 11.0)
p.inventory.add(Item(383))
}
}
return 0;
return 0
}
/**
* Checks if they have the barb tail harpoon.
*
* @return {@code True} if so.
* @return `True` if so.
*/
private boolean hasBarbTail() {
private fun hasBarbTail(): Boolean {
if (option == FishingOption.HARPOON) {
if (player.getInventory().containsItem(FishingOption.BARB_HARPOON.getTool()) || player.getEquipment().containsItem(FishingOption.BARB_HARPOON.getTool())) {
return true;
if (player.inventory.containsItem(FishingOption.BARB_HARPOON.tool) || player.equipment.containsItem(
FishingOption.BARB_HARPOON.tool
)
) {
return true
}
}
return false;
return false
}
@Override
public void message(int type) {
switch (type) {
case 0:
player.getPacketDispatch().sendMessage(option.getStartMessage());
break;
case 2:
player.getPacketDispatch().sendMessage(fish == Fish.ANCHOVIE || fish == Fish.SHRIMP ? "You catch some " + fish.getItem().getName().toLowerCase().replace("raw", "").trim() + "." : "You catch a " + fish.getItem().getName().toLowerCase().replace("raw", "").trim() + ".");
if (player.getInventory().freeSlots() == 0) {
player.getDialogueInterpreter().sendDialogue("You don't have enough space in your inventory.");
stop();
override fun message(type: Int) {
when (type) {
0 -> player.packetDispatch.sendMessage(option!!.startMessage)
2 -> {
player.packetDispatch.sendMessage(
if (fish == Fish.ANCHOVIE || fish == Fish.SHRIMP) "You catch some " + fish!!.item.name.toLowerCase()
.replace("raw", "")
.trim { it <= ' ' } + "." else "You catch a " + fish!!.item.name.toLowerCase()
.replace("raw", "").trim { it <= ' ' } + ".")
if (player.inventory.freeSlots() == 0) {
player.dialogueInterpreter.sendDialogue("You don't have enough space in your inventory.")
stop()
}
break;
}
}
}
/**
* Method used to check if the catch was a success.
*
* @return <code>True</code> if so.
* @return `True` if so.
*/
private boolean success() {
if (getDelay() == 1) {
return false;
private fun success(): Boolean {
if (delay == 1) {
return false
}
val level = 1 + player.skills.getLevel(Skills.FISHING) + player.familiarManager.getBoost(Skills.FISHING)
val hostRatio = Math.random() * fish!!.level
val clientRatio = Math.random() * (level * 1.25 - fish!!.level)
return hostRatio < clientRatio
}
companion object {
fun checkFish(p: Player): Int {
return if (p.skills.getLevel(Skills.FISHING) >= 55 && p.skills.getLevel(Skills.STRENGTH) >= 35) {
if (p.skills.getLevel(Skills.FISHING) >= 70 && p.skills.getLevel(Skills.STRENGTH) >= 50) {
if (p.skills.getLevel(Skills.FISHING) >= 96 && p.skills.getLevel(Skills.STRENGTH) >= 76) {
3
} else 2
} else 1
} else 0
}
}
/**
* Constructs a new `FishingPulse` `Object`.
*
* @param player the player.
* @param npc the fishing spot NPC.
* @param option The fishing option.
*/
init {
if (option != null) {
fish = option.getRandomFish(player)
}
int level = 1 + player.getSkills().getLevel(Skills.FISHING) + player.getFamiliarManager().getBoost(Skills.FISHING);
double hostRatio = Math.random() * fish.getLevel();
double clientRatio = Math.random() * ((level * 1.25 - fish.getLevel()));
return hostRatio < clientRatio;
}
}
@@ -1,4 +1,4 @@
package rs09.game.node.entity.skill.fishing.barbfishing
package rs09.game.node.entity.skill.gather.fishing.barbfishing
import core.game.node.item.Item
import rs09.game.interaction.InteractionListener
@@ -1,4 +1,4 @@
package rs09.game.node.entity.skill.fishing.barbfishing
package rs09.game.node.entity.skill.gather.fishing.barbfishing
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
@@ -1,4 +1,4 @@
package rs09.game.node.entity.skill.fishing.barbfishing
package rs09.game.node.entity.skill.gather.fishing.barbfishing
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
@@ -1,4 +1,4 @@
package rs09.game.node.entity.skill.fishing.barbfishing
package rs09.game.node.entity.skill.gather.fishing.barbfishing
import core.game.interaction.NodeUsageEvent
import core.game.interaction.UseWithHandler
@@ -1,4 +1,4 @@
package rs09.game.node.entity.skill.fishing.barbfishing
package rs09.game.node.entity.skill.gather.fishing.barbfishing
import core.game.node.entity.npc.NPC
import core.game.world.map.Location
@@ -7,8 +7,8 @@ import core.plugin.CorePluginTypes.Managers
import core.plugin.Initializable
import core.plugin.Plugin
import core.tools.RandomFunction
import rs09.game.node.entity.skill.fishing.barbfishing.SpotManager.Companion.locations
import rs09.game.node.entity.skill.fishing.barbfishing.SpotManager.Companion.usedLocations
import rs09.game.node.entity.skill.gather.fishing.barbfishing.SpotManager.Companion.locations
import rs09.game.node.entity.skill.gather.fishing.barbfishing.SpotManager.Companion.usedLocations
@Initializable
/**
@@ -1,13 +1,13 @@
package rs09.game.system.config
import rs09.ServerConstants
import core.game.content.global.shop.Shop
import core.game.node.entity.player.Player
import core.game.node.item.Item
import rs09.game.system.SystemLogger
import org.json.simple.JSONArray
import org.json.simple.JSONObject
import org.json.simple.parser.JSONParser
import rs09.ServerConstants
import rs09.game.system.SystemLogger
import java.io.FileReader
class ShopParser{
@@ -29,7 +29,7 @@ class ShopParser{
reader = FileReader(ServerConstants.CONFIG_PATH + "shops.json")
val configlist = parser.parse(reader) as JSONArray
for(config in configlist){
var shop: Shop? = null
var shop: Shop?
val e = config as JSONObject
val id = e["id"].toString().toInt()
val title = e["title"].toString()