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); ARROW_SHAFT.setAmount(15);
player.getPacketDispatch().sendMessage("You attach feathers to 15 arrow shafts."); player.getPacketDispatch().sendMessage("You attach feathers to 15 arrow shafts.");
} else { } else {
int amount = featherAmount > shaftAmount ? shaftAmount : featherAmount; int amount = Math.min(featherAmount, shaftAmount);
feather.setAmount(amount); feather.setAmount(amount);
ARROW_SHAFT.setAmount(amount); ARROW_SHAFT.setAmount(amount);
player.getPacketDispatch().sendMessage(amount == 1 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) { public StringPulse(Player player, Item node, final Fletching.String bow, int amount) {
super(player, node); super(player, node);
setDelay(bow.string == 1777 ? 9 : 7);
this.bow = bow; this.bow = bow;
this.amount = amount; 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.player.Player
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.SkillPulse
import core.game.node.entity.skill.fletching.Fletching; import core.game.node.entity.skill.Skills
import core.game.node.entity.player.Player; import core.game.node.entity.skill.fletching.Fletching
import core.game.node.item.Item; import core.game.node.item.Item
/** /**
* Represents the skill pulse of attaching limbs. * Represents the skill pulse of attaching limbs.
* @author Ceikry * @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))
}
/** override fun animate() {
* Represents the limbs. player.animate(limb.animation)
*/ }
private final Fletching.Limb limb;
/** override fun reward(): Boolean {
* Represents the amount. if (delay == 1) {
*/ super.setDelay(6)
private int amount; 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
}
/** override fun message(type: Int) {}
* 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) {
}
}
@@ -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 package rs09.game.node.entity.skill.gather
import core.game.node.Node
import core.game.node.entity.npc.NPC 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 core.game.node.entity.skill.gather.woodcutting.WoodcuttingSkillPulse
import org.rs09.consts.NPCs import org.rs09.consts.NPCs
import rs09.game.content.dialogue.KjallakOnChopDialogue import rs09.game.content.dialogue.KjallakOnChopDialogue
import rs09.game.interaction.InteractionListener import rs09.game.interaction.InteractionListener
import rs09.game.node.entity.skill.gather.mining.MiningSkillPulse import rs09.game.node.entity.skill.gather.mining.MiningSkillPulse
class GatheringSkillOptionPlugin : InteractionListener() { class GatheringSkillOptionListeners : InteractionListener() {
val ETCETERIA_REGION = 10300 val ETCETERIA_REGION = 10300
@@ -25,5 +29,19 @@ class GatheringSkillOptionPlugin : InteractionListener() {
player.pulseManager.run(MiningSkillPulse(player, node.asObject())) player.pulseManager.run(MiningSkillPulse(player, node.asObject()))
return@on true 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.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.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
import core.game.node.entity.player.link.skillertasks.SkillTasks; import core.game.node.entity.player.link.skillertasks.SkillTasks
import core.game.node.entity.skill.SkillPulse; import core.game.node.entity.skill.SkillPulse
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills
import core.game.node.entity.skill.summoning.familiar.Forager; import core.game.node.entity.skill.fishing.Fish
import core.game.node.item.Item; import core.game.node.entity.skill.fishing.FishingOption
import core.game.system.task.Pulse; import core.game.node.entity.skill.summoning.familiar.Forager
import core.game.world.map.Location; import core.game.node.item.Item
import core.game.world.map.path.Pathfinder; import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation; import core.game.world.map.Location
import core.tools.RandomFunction; import core.game.world.map.path.Pathfinder
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks; import core.game.world.update.flag.context.Animation
import rs09.game.world.GameWorld; import core.tools.RandomFunction
import rs09.game.node.entity.player.info.stats.STATS_BASE
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_BASE; import rs09.game.node.entity.player.info.stats.STATS_FISH
import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_FISH; import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
import static rs09.tools.stringtools.StringToolsKt.colorize; 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. * Handles a fishing pulse.
* *
* @author Ceikry * @author Ceikry
*/ */
public final class FishingPulse extends SkillPulse<NPC> { class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?) : SkillPulse<NPC?>(player, npc) {
/**
* Represents the fishing option.
*/
private final FishingOption option;
/** /**
* Represents the fish type. * Represents the fish type.
*/ */
private Fish fish; private var fish: Fish? = null
/** /**
* Represents the base location the npc was at. * Represents the base location the npc was at.
*/ */
private final Location location; private val location: Location = npc.location
/** override fun start() {
* Constructs a new {@code FishingPulse} {@code Object}. if (TutorialSession.getExtension(player).stage == 12) {
* TutorialStage.load(player, 13, false)
* @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);
} }
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 override fun checkRequirements(): Boolean {
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() {
if (option == null) { if (option == null) {
return false; return false
} }
player.debug(String.valueOf(player.getInventory().containsItem(option.getTool()))); player.debug(player.inventory.containsItem(option.tool).toString())
if (!player.getInventory().containsItem(option.getTool()) && !hasBarbTail()) { if (!player.inventory.containsItem(option.tool) && !hasBarbTail()) {
//System.out.println(isBareHanded(player)); //System.out.println(isBareHanded(player));
player.getDialogueInterpreter().sendDialogue("You need a " + option.getTool().getName().toLowerCase() + " to catch these fish."); player.dialogueInterpreter.sendDialogue("You need a " + option.tool.name.toLowerCase() + " to catch these fish.")
stop(); stop()
return false; return false
} }
if (option.getBait() != null && !player.getInventory().containsItem(option.getBait())) { if (option.bait != null && !player.inventory.containsItem(option.bait)) {
player.getDialogueInterpreter().sendDialogue("You don't have any " + option.getBait().getName().toLowerCase() + "s left."); player.dialogueInterpreter.sendDialogue("You don't have any " + option.bait.name.toLowerCase() + "s left.")
stop(); stop()
return false; return false
} }
if (player.getSkills().getLevel(Skills.FISHING) < fish.getLevel()) { if (player.skills.getLevel(Skills.FISHING) < fish!!.level) {
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()); 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(); stop()
return false; return false
} }
if (player.getInventory().freeSlots() == 0) { if (player.inventory.freeSlots() == 0) {
player.getDialogueInterpreter().sendDialogue("You don't have enough space in your inventory."); player.dialogueInterpreter.sendDialogue("You don't have enough space in your inventory.")
stop(); stop()
return false; return false
} }
if (location != node.getLocation() || !node.isActive() || node.isInvisible()) { if (location !== node!!.location || !node!!.isActive || node!!.isInvisible) {
stop(); stop()
return false; return false
} }
return true; return true
} }
@Override override fun animate() {
public void animate() {
if (isBareHanded(player)) { if (isBareHanded(player)) {
player.animate(new Animation(6709)); player.animate(Animation(6709))
GameWorld.getPulser().submit(new Pulse(1) { Pulser.submit(object : Pulse(1) {
int counter = 0; var counter = 0
override fun pulse(): Boolean {
@Override when (counter++) {
public boolean pulse() { 5 -> getCatchAnimationAndLoot(player)
switch (counter++) {
case 5:
getCatchAnimationAndLoot(player);
break;
} }
return false; return false
} }
}); })
} else { } else {
player.animate(option.getAnimation()); player.animate(option!!.animation)
} }
} }
@Override override fun reward(): Boolean {
public boolean reward() { if (delay == 1) {
if (getDelay() == 1) { super.setDelay(5)
super.setDelay(5); return false
return false;
} }
if (player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar() instanceof Forager) { if (player.familiarManager.hasFamiliar() && player.familiarManager.familiar is Forager) {
final Forager forager = (Forager) player.getFamiliarManager().getFamiliar(); val forager = player.familiarManager.familiar as Forager
forager.handlePassiveAction(); forager.handlePassiveAction()
} }
if (success()) { if (success()) {
if ((player.getInventory().hasSpaceFor(fish.getItem()) && option.getBait() != null) ? player.getInventory().remove(option.getBait()) : true) { if (if (player.inventory.hasSpaceFor(fish!!.item) && option!!.bait != null) player.inventory.remove(
option.bait
if (player.getSkillTasks().hasTask()) { ) else true
updateSkillTask(); ) {
if (player.skillTasks.hasTask()) {
updateSkillTask()
} }
updateDiary(); updateDiary()
SkillingPets.checkPetDrop(player, SkillingPets.HERON)
SkillingPets.checkPetDrop(player, SkillingPets.HERON); val item = fish!!.item
final Item item = fish.getItem(); if (isActive(SkillcapePerks.GREAT_AIM, player) && RandomFunction.random(100) <= 5) {
if(SkillcapePerks.isActive(SkillcapePerks.GREAT_AIM,player) && RandomFunction.random(100) <= 5){ player.inventory.add(item)
player.getInventory().add(item); player.sendMessage(colorize("%RYour expert aim catches you a second fish."))
player.sendMessage(colorize("%RYour expert aim catches you a second fish."));
} }
player.getInventory().add(item); player.inventory.add(item)
int fishCaught = player.getAttribute(STATS_BASE + ":" + STATS_FISH,0); var fishCaught = player.getAttribute(STATS_BASE + ":" + STATS_FISH, 0)
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_FISH,++fishCaught); player.setAttribute("/save:$STATS_BASE:$STATS_FISH", ++fishCaught)
player.getSkills().addExperience(Skills.FISHING, fish.getExperience(), true); player.skills.addExperience(Skills.FISHING, fish!!.experience, true)
message(2); message(2)
if (TutorialSession.getExtension(player).getStage() == 13) { if (TutorialSession.getExtension(player).stage == 13) {
TutorialStage.load(player, 14, false); TutorialStage.load(player, 14, false)
stop(); stop()
return true; return true
} }
fish = option.getRandomFish(player); fish = option!!.getRandomFish(player)
} }
} }
return player.getInventory().freeSlots() == 0; return player.inventory.freeSlots() == 0
} }
public void updateDiary() { fun updateDiary() {
switch (fish) { when (fish) {
case MACKEREL: Fish.MACKEREL -> {
if (player.getViewport().getRegion().getId() == 11317) { if (player.viewport.region.id == 11317) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 11); player.achievementDiaryManager.finishTask(player, DiaryType.SEERS_VILLAGE, 0, 11)
} }
case BASS: if (player.viewport.region.id == 11317
if (player.getViewport().getRegion().getId() == 11317 && !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 1, 11)
&& !player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 1, 11)) { ) {
player.setAttribute("/save:diary:seers:bass-caught", true); player.setAttribute("/save:diary:seers:bass-caught", true)
} }
case SHARK: if (player.viewport.region.id == 11317
if (player.getViewport().getRegion().getId() == 11317 && !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)
&& !player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 7)) { ) {
player.setAttribute("/save:diary:seers:caught-shark", 1 + player.getAttribute("diary:seers:caught-shark", 0)); player.setAttribute(
"/save:diary:seers:caught-shark",
1 + player.getAttribute("diary:seers:caught-shark", 0)
)
if (player.getAttribute("diary:seers:caught-shark", 0) >= 5) { 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
// Catch some shrimp in the Fishing spot to the east of<br><br>Lumbridge Swamp if (player.location.withinDistance(Location.create(3241, 3149, 0))) {
if (player.getLocation().withinDistance(Location.create(3241, 3149, 0))) { player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 0, 13)
player.getAchievementDiaryManager().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 // Catch a trout in the river to the east of Barbarian Village
if (player.getLocation().withinDistance(Location.create(3105, 3431, 0))) { if (player.location.withinDistance(Location.create(3105, 3431, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 0, 16); 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 // Use the Fishing spots north of the banana plantation
if (node.getId() == 333 && player.getZoneMonitor().isInZone("karamja") if (node!!.id == 333 && player.zoneMonitor.isInZone("karamja")
&& player.getLocation().withinDistance(new Location(2924, 3178, 0), 10)) { && player.location.withinDistance(Location(2924, 3178, 0), 10)
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 0, 6); ) {
player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 0, 6)
} }
} }
public void updateSkillTask() { fun updateSkillTask() {
switch (fish) { when (fish) {
case ANCHOVIE: Fish.ANCHOVIE -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FANCHOVIES1); player.skillTasks.decreaseTask(player, SkillTasks.FANCHOVIES1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FANCHOVIES2); player.skillTasks.decreaseTask(player, SkillTasks.FANCHOVIES2)
break; }
case HERRING: Fish.HERRING -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FHERRING1); player.skillTasks.decreaseTask(player, SkillTasks.FHERRING1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FHERRING2); player.skillTasks.decreaseTask(player, SkillTasks.FHERRING2)
break; }
case LOBSTER: Fish.LOBSTER -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FLOBSTER1); player.skillTasks.decreaseTask(player, SkillTasks.FLOBSTER1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FLOBSTER2); player.skillTasks.decreaseTask(player, SkillTasks.FLOBSTER2)
break; }
case SALMON: Fish.SALMON -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FSALMON1); player.skillTasks.decreaseTask(player, SkillTasks.FSALMON1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FSALMON2); player.skillTasks.decreaseTask(player, SkillTasks.FSALMON2)
break; }
case SHARK: Fish.SHARK -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK1); player.skillTasks.decreaseTask(player, SkillTasks.FSHARK1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK2); player.skillTasks.decreaseTask(player, SkillTasks.FSHARK2)
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHARK3); player.skillTasks.decreaseTask(player, SkillTasks.FSHARK3)
break; }
case SHRIMP: Fish.SHRIMP -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHRIMP1); player.skillTasks.decreaseTask(player, SkillTasks.FSHRIMP1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FSHRIMP2); player.skillTasks.decreaseTask(player, SkillTasks.FSHRIMP2)
break; }
case SWORDFISH: Fish.SWORDFISH -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FSWORD1); player.skillTasks.decreaseTask(player, SkillTasks.FSWORD1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FSWORD2); player.skillTasks.decreaseTask(player, SkillTasks.FSWORD2)
break; }
case TROUT: Fish.TROUT -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FTROUT1); player.skillTasks.decreaseTask(player, SkillTasks.FTROUT1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FTROUT2); player.skillTasks.decreaseTask(player, SkillTasks.FTROUT2)
break; }
case TUNA: Fish.TUNA -> {
player.getSkillTasks().decreaseTask(player, SkillTasks.FTUNA1); player.skillTasks.decreaseTask(player, SkillTasks.FTUNA1)
player.getSkillTasks().decreaseTask(player, SkillTasks.FTUNA2); player.skillTasks.decreaseTask(player, SkillTasks.FTUNA2)
break; }
} }
} }
private boolean isBareHanded(Player p) { private fun isBareHanded(p: Player): Boolean {
if (option == FishingOption.HARPOON) { if (option == FishingOption.HARPOON) {
if (checkFish(p) > 0 && !(player.getInventory().containsItem(option.getTool()) || player.getEquipment().containsItem(option.getTool()))) { if (checkFish(p) > 0 && !(player.inventory.containsItem(
return true; option.tool
) || player.equipment.containsItem(option.tool))
) {
return true
} }
if (checkFish(p) > 2 && !(player.getInventory().containsItem(option.getTool()) || player.getEquipment().containsItem(option.getTool()))) { if (checkFish(p) > 2 && !(player.inventory.containsItem(
return true; option.tool
) || player.equipment.containsItem(option.tool))
) {
return true
} }
} }
return false; return false
} }
private int getCatchAnimationAndLoot(Player p) { private fun getCatchAnimationAndLoot(p: Player): Int {
int fishingFor = checkFish(p); val fishingFor = checkFish(p)
switch (node.getId()) { when (node!!.id) {
case 324: 324 -> when (fishingFor) {
switch (fishingFor) { 1 -> {
case 1: p.animate(Animation(6710))
p.animate(new Animation(6710)); p.skills.addExperience(Skills.FISHING, 80.0)
p.getSkills().addExperience(Skills.FISHING, 80); p.skills.addExperience(Skills.STRENGTH, 8.0)
p.getSkills().addExperience(Skills.STRENGTH, 8); p.inventory.add(Item(359))
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));
}
} }
break; 2, 3 -> if (RandomFunction.random(1) == 1) {
case 313: p.animate(Animation(6710))
p.animate(new Animation(6705)); p.skills.addExperience(Skills.FISHING, 80.0)
p.getSkills().addExperience(Skills.FISHING, 110); p.skills.addExperience(Skills.STRENGTH, 8.0)
p.getSkills().addExperience(Skills.STRENGTH, 11); p.inventory.add(Item(359))
p.getInventory().add(new Item(383)); } else {
break; p.animate(Animation(6707))
} p.skills.addExperience(Skills.FISHING, 100.0)
return 0; p.skills.addExperience(Skills.STRENGTH, 10.0)
} p.inventory.add(Item(371))
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;
} }
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. * 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 (option == FishingOption.HARPOON) {
if (player.getInventory().containsItem(FishingOption.BARB_HARPOON.getTool()) || player.getEquipment().containsItem(FishingOption.BARB_HARPOON.getTool())) { if (player.inventory.containsItem(FishingOption.BARB_HARPOON.tool) || player.equipment.containsItem(
return true; FishingOption.BARB_HARPOON.tool
)
) {
return true
} }
} }
return false; return false
} }
@Override override fun message(type: Int) {
public void message(int type) { when (type) {
switch (type) { 0 -> player.packetDispatch.sendMessage(option!!.startMessage)
case 0: 2 -> {
player.getPacketDispatch().sendMessage(option.getStartMessage()); player.packetDispatch.sendMessage(
break; if (fish == Fish.ANCHOVIE || fish == Fish.SHRIMP) "You catch some " + fish!!.item.name.toLowerCase()
case 2: .replace("raw", "")
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() + "."); .trim { it <= ' ' } + "." else "You catch a " + fish!!.item.name.toLowerCase()
if (player.getInventory().freeSlots() == 0) { .replace("raw", "").trim { it <= ' ' } + ".")
player.getDialogueInterpreter().sendDialogue("You don't have enough space in your inventory."); if (player.inventory.freeSlots() == 0) {
stop(); player.dialogueInterpreter.sendDialogue("You don't have enough space in your inventory.")
stop()
} }
break; }
} }
} }
/** /**
* Method used to check if the catch was a success. * Method used to check if the catch was a success.
* *
* @return <code>True</code> if so. * @return `True` if so.
*/ */
private boolean success() { private fun success(): Boolean {
if (getDelay() == 1) { if (delay == 1) {
return false; 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 core.game.node.item.Item
import rs09.game.interaction.InteractionListener 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.npc.NPC
import core.game.node.entity.player.Player 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.player.Player
import core.game.node.entity.skill.Skills 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.NodeUsageEvent
import core.game.interaction.UseWithHandler 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.node.entity.npc.NPC
import core.game.world.map.Location import core.game.world.map.Location
@@ -7,8 +7,8 @@ import core.plugin.CorePluginTypes.Managers
import core.plugin.Initializable import core.plugin.Initializable
import core.plugin.Plugin import core.plugin.Plugin
import core.tools.RandomFunction import core.tools.RandomFunction
import rs09.game.node.entity.skill.fishing.barbfishing.SpotManager.Companion.locations import rs09.game.node.entity.skill.gather.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.usedLocations
@Initializable @Initializable
/** /**
@@ -1,13 +1,13 @@
package rs09.game.system.config package rs09.game.system.config
import rs09.ServerConstants
import core.game.content.global.shop.Shop import core.game.content.global.shop.Shop
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
import rs09.game.system.SystemLogger
import org.json.simple.JSONArray import org.json.simple.JSONArray
import org.json.simple.JSONObject import org.json.simple.JSONObject
import org.json.simple.parser.JSONParser import org.json.simple.parser.JSONParser
import rs09.ServerConstants
import rs09.game.system.SystemLogger
import java.io.FileReader import java.io.FileReader
class ShopParser{ class ShopParser{
@@ -29,7 +29,7 @@ class ShopParser{
reader = FileReader(ServerConstants.CONFIG_PATH + "shops.json") reader = FileReader(ServerConstants.CONFIG_PATH + "shops.json")
val configlist = parser.parse(reader) as JSONArray val configlist = parser.parse(reader) as JSONArray
for(config in configlist){ for(config in configlist){
var shop: Shop? = null var shop: Shop?
val e = config as JSONObject val e = config as JSONObject
val id = e["id"].toString().toInt() val id = e["id"].toString().toInt()
val title = e["title"].toString() val title = e["title"].toString()