Repository reorganisation
Unified kotlin and java into just src/main Unified the rs09 and core packages Took all content out of the core package, and placed it into the new content package Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import content.global.skill.crafting.jewellery.JewelleryCrafting;
|
||||
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.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to string an amulet.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class AmuletStringingPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AmuletStringingPlugin} {@code Object}.
|
||||
*/
|
||||
public AmuletStringingPlugin() {
|
||||
super(1673, 1675, 1677, 1679, 1681, 1683, 6579);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1759, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final JewelleryCrafting.JewelleryItem data = JewelleryCrafting.JewelleryItem.forProduct(event.getUsedItem().getId() == 6579 ? 6579 : ((Item) event.getUsedWith()).getId());
|
||||
if (data == null) {
|
||||
return true;
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < data.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + data.getLevel() + " to do that.");
|
||||
return true;
|
||||
}
|
||||
if (player.getInventory().remove(event.getUsedItem(), event.getBaseItem())) {
|
||||
player.getInventory().add(new Item(data == JewelleryCrafting.JewelleryItem.ONYX_AMULET ? 6581 : data.getSendItem() + 19));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
/**
|
||||
* Represents a battlestave.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum BattleStaves {
|
||||
WATER(571, 1395, 54, 100, 215, 149),
|
||||
EARTH(575, 1399, 58, 112.5, 29415, 151),
|
||||
FIRE(569, 1393, 62, 125, 2153, 152),
|
||||
AIR(573, 1397, 66, 137.5, 2152, 150);
|
||||
|
||||
/**
|
||||
* The obelisk used.
|
||||
*/
|
||||
private final int obelisk;
|
||||
|
||||
/**
|
||||
* The product made.
|
||||
*/
|
||||
private final int product;
|
||||
|
||||
/**
|
||||
* The level needed to make the staff.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* The exp gained.
|
||||
*/
|
||||
private final double exp;
|
||||
|
||||
/**
|
||||
* The object id.
|
||||
*/
|
||||
private final int objectId;
|
||||
|
||||
/**
|
||||
* The graphic id.
|
||||
*/
|
||||
private final int graphicId;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BattleStaves} {@Code Object}
|
||||
* @param obelisk the obelisk.
|
||||
* @param product the product.
|
||||
* @param level the lever.
|
||||
* @param exp the experience.
|
||||
* @param objectId the id.
|
||||
* @param graphicId the id.
|
||||
*/
|
||||
BattleStaves(int obelisk, int product, int level, double exp, final int objectId, final int graphicId) {
|
||||
this.obelisk = obelisk;
|
||||
this.product = product;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
this.objectId = objectId;
|
||||
this.graphicId = graphicId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a battle stave by the id.
|
||||
* @param id the id.
|
||||
* @return the object.
|
||||
*/
|
||||
public static BattleStaves forId(int id) {
|
||||
for (BattleStaves staff : BattleStaves.values()) {
|
||||
if (staff.getObelisk() == id) {
|
||||
return staff;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the obelisk.
|
||||
* @return The obelisk.
|
||||
*/
|
||||
public int getObelisk() {
|
||||
return obelisk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return The product.
|
||||
*/
|
||||
public int getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the objectId.
|
||||
* @return The objectId.
|
||||
*/
|
||||
public int getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graphicId.
|
||||
* @return The graphicId.
|
||||
*/
|
||||
public int getGraphicId() {
|
||||
return graphicId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exp.
|
||||
* @return The exp.
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
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 battle stave making plugin used for zaff.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class BattlestaveMakePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the original staff item.
|
||||
*/
|
||||
private static final Item STAFF = new Item(1391, 1);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BattlestaveMakePlugin} {@code Object}.
|
||||
*/
|
||||
public BattlestaveMakePlugin() {
|
||||
super(STAFF.getId(), 573, 571, 575, 569);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(573, ITEM_TYPE, this);
|
||||
addHandler(571, ITEM_TYPE, this);
|
||||
addHandler(575, ITEM_TYPE, this);
|
||||
addHandler(569, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (event.getUsedItem().getId() != STAFF.getId()) {
|
||||
return false;
|
||||
}
|
||||
int id = event.getUsedItem().getId() == STAFF.getId() ? event.getUsedWith().getId() : event.getUsedItem().getId();
|
||||
final BattleStaves staff = BattleStaves.forId(id);
|
||||
if (staff == null)
|
||||
return true;
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < staff.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + staff.getLevel() + " to make this.");
|
||||
return true;
|
||||
}
|
||||
player.getInventory().remove(STAFF);
|
||||
player.getInventory().remove(new Item(staff.getObelisk(), 1));
|
||||
player.getInventory().add(new Item(staff.getProduct(), 1));
|
||||
player.getSkills().addExperience(Skills.CRAFTING, staff.getExp(), true);
|
||||
// Craft an air battlestaff
|
||||
if (staff == BattleStaves.AIR) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 2, 6);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import content.global.skill.crafting.limestone.ChiselLimestonePulse;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The plugin that starts the chisel limestone cutting pulse.
|
||||
* @author Jamix77
|
||||
*/
|
||||
@Initializable
|
||||
public final class ChiselLimestonePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GemCutPlugin} {@Code Object}
|
||||
*/
|
||||
public ChiselLimestonePlugin() {
|
||||
super(3211);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1755, ITEM_TYPE, this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
player.getPulseManager().run(new ChiselLimestonePulse(player, new Item(3211)));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import content.global.skill.crafting.gem.GemCutPulse;
|
||||
import core.game.dialogue.SkillDialogueHandler;
|
||||
import core.game.dialogue.SkillDialogueHandler.SkillDialogue;
|
||||
import content.global.skill.crafting.gem.Gems;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to cut a gem.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class GemCutPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GemCutPlugin} {@Code Object}
|
||||
*/
|
||||
public GemCutPlugin() {
|
||||
super(1623, 1621, 1619, 1617, 1631, 6571, 1625, 1627, 1629, 6571);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1755, ITEM_TYPE, this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Gems gem = Gems.forId(event.getUsedItem().getId() == 1755 ? event.getBaseItem() : event.getUsedItem());
|
||||
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, gem.getGem()) {
|
||||
@Override
|
||||
public void create(final int amount, int index) {
|
||||
player.getPulseManager().run(new GemCutPulse(player, gem.getUncut(), amount, gem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(gem.getUncut());
|
||||
}
|
||||
|
||||
};
|
||||
if (player.getInventory().getAmount(gem.getUncut()) == 1) {
|
||||
handler.create(0, 1);
|
||||
} else {
|
||||
handler.open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
/**
|
||||
* Represents the glass product.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum GlassProduct {
|
||||
|
||||
VIAL(38, 229, 1, 33, 35), ORB(39, 567, 1, 46, 52.5), BEER(40, 1919, 1, 1, 17.5), CANDLE(41, 4527, 1, 4, 19), OIL_LAMP(42, 4525, 1, 12, 25), FISHBOWL(44, 6667, 1, 42, 42.5), LANTERN_LENS(43, 4542, 1, 49, 55), LIGHT_ORB(45, 10973, 1, 87, 70);
|
||||
|
||||
/**
|
||||
* Represents the button pressed.
|
||||
*/
|
||||
private final int buttonId;
|
||||
|
||||
/**
|
||||
* Represents the product.
|
||||
*/
|
||||
private final int product;
|
||||
|
||||
/**
|
||||
* Represents the amount.
|
||||
*/
|
||||
private final int amount;
|
||||
|
||||
/**
|
||||
* Represents the level needed.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the experience gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GlassDefinitions.java} {@Code Object}
|
||||
* @param buttonId the button id.
|
||||
* @param result the product.
|
||||
* @param amount the amount.
|
||||
* @param level the level.
|
||||
* @param experience the exp.
|
||||
*/
|
||||
private GlassProduct(int buttonId, int result, int amount, int level, double experience) {
|
||||
this.buttonId = buttonId;
|
||||
this.product = result;
|
||||
this.amount = amount;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the buttonId.
|
||||
* @return The buttonId.
|
||||
*/
|
||||
public int getButtonId() {
|
||||
return buttonId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return The product.
|
||||
*/
|
||||
public int getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount.
|
||||
* @return The amount.
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience.
|
||||
* @return The experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the glass product by the id.
|
||||
* @param id the id.
|
||||
* @return the product.
|
||||
*/
|
||||
public static GlassProduct forId(int id) {
|
||||
for (GlassProduct def : GlassProduct.values()) {
|
||||
if (def.getButtonId() == id) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import content.global.skill.crafting.jewellery.JewelleryCrafting;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to craft jewellery.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class JewelleryCraftPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the ids to use for this plugin.
|
||||
*/
|
||||
private static final int[] IDS = new int[] { 4304, 6189, 11010, 11666, 12100, 12809, 18497, 26814, 30021, 30510, 36956, 37651 };
|
||||
|
||||
/**
|
||||
* Constructs a new {@code JewelleryCraftPlugin} {@code Object}.
|
||||
*/
|
||||
public JewelleryCraftPlugin() {
|
||||
super(2357);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (int i : IDS) {
|
||||
addHandler(i, OBJECT_TYPE, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
JewelleryCrafting.open(event.getPlayer());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.component.Component;
|
||||
import core.game.dialogue.DialoguePlugin;
|
||||
import kotlin.Unit;
|
||||
import content.global.skill.crafting.armour.DragonCraftPulse;
|
||||
import content.global.skill.crafting.armour.HardCraftPulse;
|
||||
import content.global.skill.crafting.armour.LeatherCrafting;
|
||||
import content.global.skill.crafting.armour.LeatherCrafting.DragonHide;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* Represents the dialogue plugin used for leather crafting.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class LeatherCraftDialogue extends DialoguePlugin {
|
||||
|
||||
/**
|
||||
* Represents the type.
|
||||
*/
|
||||
private String type = "";
|
||||
|
||||
/**
|
||||
* Represents the leather.
|
||||
*/
|
||||
private int leather;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LeatherCraftDialogue} {@code Object}.
|
||||
*/
|
||||
public LeatherCraftDialogue() {
|
||||
/**
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LeatherCraftDialogue} {@code Object}.
|
||||
* @param player the player.
|
||||
*/
|
||||
public LeatherCraftDialogue(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialoguePlugin newInstance(Player player) {
|
||||
return new LeatherCraftDialogue(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open(Object... args) {
|
||||
Component component = new Component(304);
|
||||
type = (String) args[0];
|
||||
if (type.equals("hard")) {
|
||||
player.getInterfaceManager().openChatbox(309);
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(1131, 150, 309, 2);
|
||||
player.getPacketDispatch().sendString("<br><br><br><br>" + "Heardleather body", 309, 6);
|
||||
} else {
|
||||
/** dragon */
|
||||
leather = (int) args[1];
|
||||
player.getInterfaceManager().openChatbox(component);
|
||||
int index[] = new int[3];
|
||||
if (leather == LeatherCrafting.GREEN_LEATHER) {
|
||||
index[0] = DragonHide.GREEN_D_HIDE_BODY.getProduct();
|
||||
index[1] = DragonHide.GREEN_D_HIDE_VAMBS.getProduct();
|
||||
index[2] = DragonHide.GREEN_D_HIDE_CHAPS.getProduct();
|
||||
}
|
||||
if (leather == LeatherCrafting.BLUE_LEATHER) {
|
||||
index[0] = DragonHide.BLUE_D_HIDE_BODY.getProduct();
|
||||
index[1] = DragonHide.BLUE_D_HIDE_VAMBS.getProduct();
|
||||
index[2] = DragonHide.BLUE_D_HIDE_CHAPS.getProduct();
|
||||
}
|
||||
if (leather == LeatherCrafting.RED_LEATHER) {
|
||||
index[0] = DragonHide.RED_D_HIDE_BODY.getProduct();
|
||||
index[1] = DragonHide.RED_D_HIDE_VAMBS.getProduct();
|
||||
index[2] = DragonHide.RED_D_HIDE_CHAPS.getProduct();
|
||||
}
|
||||
if (leather == LeatherCrafting.BLACK_LEATHER) {
|
||||
index[0] = DragonHide.BLACK_D_HIDE_BODY.getProduct();
|
||||
index[1] = DragonHide.BLACK_D_HIDE_VAMBS.getProduct();
|
||||
index[2] = DragonHide.BLACK_D_HIDE_CHAPS.getProduct();
|
||||
}
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(index[0], 175, 304, 2);
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(index[1], 175, 304, 3);
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(index[2], 165, 304, 4);
|
||||
player.getPacketDispatch().sendString("<br><br><br><br>" + ItemDefinition.forId(index[0]).getName(), 304, 8);
|
||||
player.getPacketDispatch().sendString("<br><br><br><br>" + ItemDefinition.forId(index[1]).getName(), 304, 11);
|
||||
player.getPacketDispatch().sendString("<br><br><br><br>" + ItemDefinition.forId(index[2]).getName(), 304, 16);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(int interfaceId, int buttonId) {
|
||||
player.getInterfaceManager().closeChatbox();
|
||||
int amt = 0;
|
||||
switch (type) {
|
||||
case "hard":
|
||||
switch (buttonId) {
|
||||
case 6:
|
||||
amt = 1;
|
||||
break;
|
||||
case 4:
|
||||
amt = 5;
|
||||
break;
|
||||
case 3:
|
||||
sendInputDialogue(player, true, "Enter the amount:", (value) -> {
|
||||
player.getPulseManager().run(new HardCraftPulse(player, null, (int) value));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
return true;
|
||||
case 2:
|
||||
amt = player.getInventory().getAmount(new Item(LeatherCrafting.HARD_LEATHER));
|
||||
break;
|
||||
}
|
||||
player.getPulseManager().run(new HardCraftPulse(player, null, amt));
|
||||
break;
|
||||
case "dragon":
|
||||
int index = 0;
|
||||
if (buttonId > 3 && buttonId < 8) {
|
||||
index = 1;
|
||||
}
|
||||
if (buttonId > 7 && buttonId < 12) {
|
||||
index = 2;
|
||||
}
|
||||
if (buttonId > 11 && buttonId < 16) {
|
||||
index = 3;
|
||||
}
|
||||
DragonHide hide = null;
|
||||
if (index == 1) {
|
||||
switch (leather) {
|
||||
case LeatherCrafting.GREEN_LEATHER:
|
||||
hide = DragonHide.GREEN_D_HIDE_BODY;
|
||||
break;
|
||||
case LeatherCrafting.BLUE_LEATHER:
|
||||
hide = DragonHide.BLUE_D_HIDE_BODY;
|
||||
break;
|
||||
case LeatherCrafting.RED_LEATHER:
|
||||
hide = DragonHide.RED_D_HIDE_BODY;
|
||||
break;
|
||||
case LeatherCrafting.BLACK_LEATHER:
|
||||
hide = DragonHide.BLACK_D_HIDE_BODY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == 2) {
|
||||
switch (leather) {
|
||||
case LeatherCrafting.GREEN_LEATHER:
|
||||
hide = DragonHide.GREEN_D_HIDE_VAMBS;
|
||||
break;
|
||||
case LeatherCrafting.BLUE_LEATHER:
|
||||
hide = DragonHide.BLUE_D_HIDE_VAMBS;
|
||||
break;
|
||||
case LeatherCrafting.RED_LEATHER:
|
||||
hide = DragonHide.RED_D_HIDE_VAMBS;
|
||||
break;
|
||||
case LeatherCrafting.BLACK_LEATHER:
|
||||
hide = DragonHide.BLACK_D_HIDE_VAMBS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == 3) {
|
||||
switch (leather) {
|
||||
case LeatherCrafting.GREEN_LEATHER:
|
||||
hide = DragonHide.GREEN_D_HIDE_CHAPS;
|
||||
break;
|
||||
case LeatherCrafting.BLUE_LEATHER:
|
||||
hide = DragonHide.BLUE_D_HIDE_CHAPS;
|
||||
break;
|
||||
case LeatherCrafting.RED_LEATHER:
|
||||
hide = DragonHide.RED_D_HIDE_CHAPS;
|
||||
break;
|
||||
case LeatherCrafting.BLACK_LEATHER:
|
||||
hide = DragonHide.BLACK_D_HIDE_CHAPS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (buttonId) {
|
||||
case 7:
|
||||
case 11:
|
||||
case 15:
|
||||
amt = 1;
|
||||
break;
|
||||
case 6:
|
||||
case 10:
|
||||
case 14:
|
||||
amt = 5;
|
||||
break;
|
||||
case 5:
|
||||
case 9:
|
||||
case 13:
|
||||
amt = 10;
|
||||
break;
|
||||
case 4:
|
||||
case 8:
|
||||
case 12:
|
||||
final DragonHide hidee = hide;
|
||||
if (hidee == null) {
|
||||
return false;
|
||||
}
|
||||
sendInputDialogue(player, true, "Enter the amount:", (value) -> {
|
||||
player.getPulseManager().run(new DragonCraftPulse(player, null, hidee, (int) value));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (hide == null) {
|
||||
return false;
|
||||
}
|
||||
player.getPulseManager().run(new DragonCraftPulse(player, null, hide, amt));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 48923 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
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.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to make molten glass.
|
||||
* @author Vexia
|
||||
* @author Splinter
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class MoltenGlassMakePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MoltenGlassMakePlugin} {@code Object}.
|
||||
*/
|
||||
public MoltenGlassMakePlugin() {
|
||||
super(1783, 1781);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(4304, OBJECT_TYPE, this);
|
||||
addHandler(6189, OBJECT_TYPE, this);
|
||||
addHandler(9390, OBJECT_TYPE, this);
|
||||
addHandler(11010, OBJECT_TYPE, this);
|
||||
addHandler(11666, OBJECT_TYPE, this);
|
||||
addHandler(12100, OBJECT_TYPE, this);
|
||||
addHandler(12809, OBJECT_TYPE, this);
|
||||
addHandler(18497, OBJECT_TYPE, this);
|
||||
addHandler(26814, OBJECT_TYPE, this);
|
||||
addHandler(30021, OBJECT_TYPE, this);
|
||||
addHandler(30510, OBJECT_TYPE, this);
|
||||
addHandler(36956, OBJECT_TYPE, this);
|
||||
addHandler(37651, OBJECT_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
event.getPlayer().getPulseManager().run(new MoltenGlassPulse(event.getPlayer(), event.getUsedItem()));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the pulse for molten glass making via a furnace
|
||||
* @author Splinter
|
||||
*/
|
||||
public static class MoltenGlassPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the bucket of sand item.
|
||||
*/
|
||||
private static final Item BUCKET_OF_SAND = new Item(1783);
|
||||
|
||||
/**
|
||||
* Represents the soda ash item.
|
||||
*/
|
||||
private static final Item SODA_ASH = new Item(1781);
|
||||
|
||||
/**
|
||||
* Represents the molten glass item.
|
||||
*/
|
||||
private static final Item MOLTEN_GLASS = new Item(1775);
|
||||
|
||||
/**
|
||||
* Represents the bucket item.
|
||||
*/
|
||||
private static final Item BUCKET = new Item(1925);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MoltenGlassPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
*/
|
||||
public MoltenGlassPulse(Player player, Item node) {
|
||||
super(player, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getInventory().contains(1783, 1) && player.getInventory().contains(1781, 1)) {
|
||||
return true;
|
||||
}
|
||||
player.sendMessage("You need at least one heap of soda ash and one bucket of sand to do this.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
player.animate(Animation.create(899));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (getDelay() == 1) {
|
||||
super.setDelay(3);
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(BUCKET_OF_SAND, SODA_ASH)) {
|
||||
player.lock(3);
|
||||
player.getInventory().add(MOLTEN_GLASS, BUCKET);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, 20, true);
|
||||
player.sendMessage("You heat the sand and soda ash in the furnace to make glass.");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import content.global.skill.crafting.pottery.FirePotteryPulse;
|
||||
import content.global.skill.crafting.pottery.PotteryItem;
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.dialogue.SkillDialogueHandler;
|
||||
import core.game.dialogue.SkillDialogueHandler.SkillDialogue;
|
||||
import content.global.skill.crafting.pottery.PotteryPulse;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.OptionHandler;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to handle pottery actions.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class PotteryPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the soft clay item.
|
||||
*/
|
||||
private static final Item SOFT_CLAY = new Item(1761);
|
||||
|
||||
/**
|
||||
* Represents the oven ids.
|
||||
*/
|
||||
private static final int[] OVENS = new int[] { 2643, 4308, 11601, 34802 };
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PotteryPlugin} {@code Object}.
|
||||
*/
|
||||
public PotteryPlugin() {
|
||||
super(1761);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
new FireOvenPlugin().newInstance(arg);
|
||||
addHandler(2642, OBJECT_TYPE, this);
|
||||
addHandler(2643, OBJECT_TYPE, this);
|
||||
addHandler(4308, OBJECT_TYPE, this);
|
||||
addHandler(4310, OBJECT_TYPE, this);
|
||||
addHandler(20375, OBJECT_TYPE, this);
|
||||
addHandler(34801, OBJECT_TYPE, this);
|
||||
addHandler(34802, OBJECT_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getPottery(false)) {
|
||||
|
||||
@Override
|
||||
public void create(final int amount, int index) {
|
||||
player.getPulseManager().run(new PotteryPulse(player, event.getUsedItem(), amount, PotteryItem.values()[index]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(SOFT_CLAY);
|
||||
}
|
||||
|
||||
}.open();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pottery items.
|
||||
* @param finished if not.
|
||||
* @return the items.
|
||||
*/
|
||||
private Item[] getPottery(boolean finished) {
|
||||
final Item[] items = new Item[PotteryItem.values().length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = finished ? PotteryItem.values()[i].getProduct() : PotteryItem.values()[i].getUnfinished();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the fire oven plugin.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public class FireOvenPlugin extends OptionHandler {
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (int id : OVENS) {
|
||||
SceneryDefinition.forId(id).getHandlers().put("option:fire", this);
|
||||
}
|
||||
new FireUseHandler().newInstance(arg);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final Player player, Node node, String option) {
|
||||
getSkillHandler(player).open();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the fire use with handler.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class FireUseHandler extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code FireUseHandler} {@code Object}.
|
||||
*/
|
||||
public FireUseHandler() {
|
||||
super(1787, 1789, 1791, 5352, 4438);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(2643, OBJECT_TYPE, this);
|
||||
addHandler(4308, OBJECT_TYPE, this);
|
||||
addHandler(11601, OBJECT_TYPE, this);
|
||||
addHandler(34802, OBJECT_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
getSkillHandler(player).open();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill handler dialogue.
|
||||
* @param player the player.
|
||||
* @return the dialogue handler.
|
||||
*/
|
||||
public SkillDialogueHandler getSkillHandler(final Player player) {
|
||||
return new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getPottery(true)) {
|
||||
|
||||
@Override
|
||||
public void create(final int amount, final int index) {
|
||||
player.getPulseManager().run(new FirePotteryPulse(player, PotteryItem.values()[index].getUnfinished(), PotteryItem.values()[index], amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(PotteryItem.values()[index].getUnfinished());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import content.global.skill.crafting.armour.SnakeSkin;
|
||||
import content.global.skill.crafting.armour.SnakeSkinPulse;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.dialogue.SkillDialogueHandler;
|
||||
import core.game.dialogue.SkillDialogueHandler.SkillDialogue;
|
||||
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.Plugin;
|
||||
|
||||
/**
|
||||
* Handles snake skin plugin.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public class SnakeSkinPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code SnakeSkinPlugin} {@Code Object}
|
||||
*/
|
||||
public SnakeSkinPlugin() {
|
||||
super(1733);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(6289, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
new SkillDialogueHandler(player, SkillDialogue.FIVE_OPTION, (Object[]) getSkins()) {
|
||||
|
||||
@Override
|
||||
public void create(final int amount, int index) {
|
||||
player.getPulseManager().run(new SnakeSkinPulse(player, event.getUsedItem(), amount, SnakeSkin.values()[index]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(new Item(6289));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Item item) {
|
||||
return item.getId() == 6328 ? "Boots" : item.getId() == 6330 ? "Vambs" : item.getId() == 6326 ? "Bandana" : item.getId() == 6324 ? "Chaps" : "Body";
|
||||
}
|
||||
|
||||
}.open();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skins.
|
||||
* @return the item.
|
||||
*/
|
||||
public Item[] getSkins() {
|
||||
Item[] items = new Item[SnakeSkin.values().length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = SnakeSkin.values()[i].getProduct();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
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.Plugin;
|
||||
|
||||
/**
|
||||
* Handles the crafting of a snelm helmet.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public class SnelmCraftPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* The snelm data.
|
||||
*/
|
||||
private static final int[][] DATA = new int[][] { { 3345, 3327 }, { 3355, 3337 },// blamish
|
||||
{ 3349, 3341 }, { 3341, 3359 },// ochre
|
||||
{ 3347, 3329 }, { 3357, 3339 },// blood
|
||||
{ 3351, 3333 }, { 3361, 3343 },// blue
|
||||
{ 3353, 3335 },// bark
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code SnelmCraftPlugin} {@Code Object}
|
||||
*/
|
||||
public SnelmCraftPlugin() {
|
||||
super(1755);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (int i = 0; i < DATA.length; i++) {
|
||||
for (int k = 0; k < DATA[i].length; k++) {
|
||||
addHandler(DATA[i][0], ITEM_TYPE, this);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
int[] snelm = null;
|
||||
for (int i = 0; i < DATA.length; i++) {
|
||||
for (int k = 0; k < DATA[i].length; k++) {
|
||||
if (DATA[i][0] == event.getUsedItem().getId()) {
|
||||
snelm = DATA[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (snelm == null) {
|
||||
return false;
|
||||
}
|
||||
player.lock(1);
|
||||
player.getPulseManager().run(new SnelmCraftPulse(player, event.getUsedItem(), snelm));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the crafting of a snelm helmet.
|
||||
* @author Vexia
|
||||
*/
|
||||
public static final class SnelmCraftPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* The snelm data.
|
||||
*/
|
||||
private final int[] data;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code SnelmCraftPulse} {@Code Object}
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
*/
|
||||
public SnelmCraftPulse(Player player, Item node, int[] data) {
|
||||
super(player, node);
|
||||
this.setDelay(1);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getStaticLevel(Skills.CRAFTING) < 15) {
|
||||
player.sendMessage("You need a Crafting level of at least 15 in order to do this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
player.sendMessage("You craft the shell into a helmet.");
|
||||
player.getInventory().replace(new Item(data[1]), node.getSlot());
|
||||
player.getSkills().addExperience(Skills.CRAFTING, 32.5, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* The Stitch Crafting Plugin
|
||||
* @author SonicForce41
|
||||
*/
|
||||
@Initializable
|
||||
public class StitchCraftPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StitchCraftPlugin.java} {@Code Object}
|
||||
*/
|
||||
public StitchCraftPlugin() {
|
||||
super(1741);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method handles the actions for this Plugin
|
||||
*/
|
||||
@Override
|
||||
public boolean handle(NodeUsageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
int itemId = event.getUsedItem().getId();
|
||||
player.getAttributes().put("leatherId", itemId);
|
||||
player.getInterfaceManager().open(new Component(154));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns the instance for plugin
|
||||
*/
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1733, ITEM_TYPE, this);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.plugin.Initializable;
|
||||
import core.game.dialogue.SkillDialogueHandler;
|
||||
import core.game.dialogue.SkillDialogueHandler.SkillDialogue;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
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.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the studded body plugin.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class StuddedArmourPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the steel studs item.
|
||||
*/
|
||||
private static final Item STEEL_STUDS = new Item(2370);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StuddedBodyPlugin} {@code Object}.
|
||||
*/
|
||||
public StuddedArmourPlugin() {
|
||||
super(2370);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (StuddedArmour armour : StuddedArmour.values()) {
|
||||
addHandler(armour.getItem().getId(), ITEM_TYPE, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final StuddedArmour armour = StuddedArmour.forItem(event.getBaseItem());
|
||||
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, armour.getStudded()) {
|
||||
|
||||
@Override
|
||||
public void create(int amount, int index) {
|
||||
player.getPulseManager().run(new StudArmourPulse(player, event.getBaseItem(), armour, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(STEEL_STUDS);
|
||||
}
|
||||
|
||||
};
|
||||
if (player.getInventory().getAmount(armour.getItem()) == 1) {
|
||||
handler.create(1, 0);
|
||||
} else {
|
||||
handler.open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a studded armour.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum StuddedArmour {
|
||||
CHAPS(new Item(1095), new Item(1097), 18, 27), BODY(new Item(1129), new Item(1133), 14, 25);
|
||||
|
||||
/**
|
||||
* Represents the unstudded item.
|
||||
*/
|
||||
private final Item item;
|
||||
|
||||
/**
|
||||
* Represents the studded item.
|
||||
*/
|
||||
private final Item studded;
|
||||
|
||||
/**
|
||||
* Represents the level needed.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the experience gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StuddedArmour} {@code Object}.
|
||||
* @param item the item.
|
||||
* @param studded the studded item.
|
||||
* @param level the level.
|
||||
* @param experience the experience.
|
||||
*/
|
||||
private StuddedArmour(Item item, Item studded, int level, double experience) {
|
||||
this.item = item;
|
||||
this.studded = studded;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the studded armour for the item.
|
||||
* @param item the item.
|
||||
* @return the studden armour.
|
||||
*/
|
||||
public static StuddedArmour forItem(final Item item) {
|
||||
for (StuddedArmour armour : values()) {
|
||||
if (armour.getItem().getId() == item.getId()) {
|
||||
return armour;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
* @return The item.
|
||||
*/
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the studded.
|
||||
* @return The studded.
|
||||
*/
|
||||
public Item getStudded() {
|
||||
return studded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience.
|
||||
* @return The experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the skill pulse used to stud armour.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public static final class StudArmourPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(1249);
|
||||
|
||||
/**
|
||||
* Represents the armour being studded.
|
||||
*/
|
||||
private final StuddedArmour armour;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StudArmourPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param armour the armour.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public StudArmourPulse(Player player, Item node, final StuddedArmour armour, final int amount) {
|
||||
super(player, node);
|
||||
this.armour = armour;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < armour.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + armour.getLevel() + " to do this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(STEEL_STUDS)) {
|
||||
player.getPacketDispatch().sendMessage("You need studs in order to make studded armour.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(armour.getItem())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(armour.getItem(), STEEL_STUDS)) {
|
||||
player.getInventory().add(armour.getStudded());
|
||||
player.getSkills().addExperience(Skills.CRAFTING, armour.getExperience(), true);
|
||||
player.getPacketDispatch().sendMessage("You make a " + armour.getStudded().getName().toLowerCase() + ".");
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(int type) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
player.getPacketDispatch().sendMessage("You use the studs with the " + node.getName().toLowerCase() + ".");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.component.Component;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* Represents a tanning product.
|
||||
* @author Vexia
|
||||
* @version 1.1
|
||||
*/
|
||||
public enum TanningProduct {
|
||||
SOFT_LEATHER(1, 1739, 1741),
|
||||
HARD_LEATHER(2, 1739, 1743),
|
||||
SNAKESKIN(3, 6287, 6289),
|
||||
SNAKESKIN2(4, 6287, 6289),
|
||||
GREEN_DHIDE(5, 1753, 1745),
|
||||
BLUEDHIDE(6, 1751, 2505),
|
||||
REDDHIDE(7, 1749, 2507),
|
||||
BLACKDHIDE(8, 1747, 2509);
|
||||
|
||||
/**
|
||||
* The button.
|
||||
*/
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* The item needed.
|
||||
*/
|
||||
private final int item;
|
||||
|
||||
/**
|
||||
* The product.
|
||||
*/
|
||||
private final int product;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code TanningProduct} {@Code Object}
|
||||
* @param button the button.
|
||||
* @param item the item.
|
||||
* @param product the product.
|
||||
*/
|
||||
TanningProduct(int button, int item, int product) {
|
||||
this.button = button;
|
||||
this.item = item;
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the button.
|
||||
*/
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item.
|
||||
*/
|
||||
public int getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the product.
|
||||
*/
|
||||
public int getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product by the id.
|
||||
* @param id the id.
|
||||
* @return the product.
|
||||
*/
|
||||
public static TanningProduct forId(int id) {
|
||||
for (TanningProduct def : TanningProduct.values()) {
|
||||
if (def.getButton() == id) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product by the id.
|
||||
* @param id the id.
|
||||
* @return te product.
|
||||
*/
|
||||
public static TanningProduct forItemId(int id) {
|
||||
for (TanningProduct def : TanningProduct.values()) {
|
||||
if (def.getItem() == id) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to open the tanning interface.
|
||||
*/
|
||||
public static void open(final Player player, final int npc) {
|
||||
player.getInterfaceManager().open(new Component(324));
|
||||
//Removed all the string modification that was here earlier -- it seems the client automatically does it now.
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to tan the hide.
|
||||
* @param player the player.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public static void tan(final Player player, int amount, TanningProduct def) {
|
||||
if (amount > player.getInventory().getAmount(new Item(def.getItem()))) {
|
||||
amount = player.getInventory().getAmount(new Item(def.getItem()));
|
||||
}
|
||||
int coins = 0;
|
||||
if (def == SOFT_LEATHER) {
|
||||
coins = 1;
|
||||
} else if (def == HARD_LEATHER) {
|
||||
coins = 3;
|
||||
} else if (def == SNAKESKIN) {
|
||||
coins = 20;
|
||||
} else if (def == SNAKESKIN2) {
|
||||
coins = 15;
|
||||
} else {
|
||||
coins = 20;
|
||||
}
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
if (!player.getInventory().contains(def.getItem(), amount)) {
|
||||
player.getPacketDispatch().sendMessage("You don't have any " + ItemDefinition.forId(def.getItem()).getName().toLowerCase() + " to tan.");
|
||||
return;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
if (!player.getInventory().contains(995, coins * amount)) {
|
||||
player.getPacketDispatch().sendMessage("You don't have enough coins to tan that many.");
|
||||
return;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(995, coins * amount)) && player.getInventory().remove(new Item(def.getItem(), amount))) {
|
||||
player.getInventory().add(new Item(def.getProduct(), amount));
|
||||
if (amount > 1) {
|
||||
player.getPacketDispatch().sendMessage("The tanner tans " + amount + " " + ItemDefinition.forId(def.getItem()).getName().toLowerCase() + "s for you.");
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("The tanner tans your " + ItemDefinition.forId(def.getItem()).getName().toLowerCase() + ".");
|
||||
}
|
||||
if (def == SOFT_LEATHER) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 2);
|
||||
}
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("You don't have enough coins to tan that many.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package content.global.skill.crafting;
|
||||
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.world.map.Location;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.dialogue.SkillDialogueHandler;
|
||||
import core.game.dialogue.SkillDialogueHandler.SkillDialogue;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.interaction.OptionHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Plugin;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents the plugin used for weaving.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class WeaveOptionPlugin extends OptionHandler {
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
SceneryDefinition.setOptionHandler("weave", this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final Player player, final Node node, String option) {
|
||||
new SkillDialogueHandler(player, SkillDialogue.THREE_OPTION, WeavingItem.SACK.getProduct(), WeavingItem.BASKET.getProduct(), WeavingItem.CLOTH.getProduct()) {
|
||||
@Override
|
||||
public void create(int amount, int index) {
|
||||
player.getPulseManager().run(new WeavePulse(player, (Scenery) node, WeavingItem.values()[index], amount));
|
||||
}
|
||||
}.open();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the weaving pulse.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public static final class WeavePulse extends SkillPulse<Scenery> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(2270);
|
||||
|
||||
/**
|
||||
* Represents the weaving item.
|
||||
*/
|
||||
private final WeavingItem type;
|
||||
|
||||
/**
|
||||
* Represents the amount.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code WeavePulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public WeavePulse(Player player, Scenery node, final WeavingItem type, final int amount) {
|
||||
super(player, node);
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a Crafting level of at least " + type.getLevel() + " in order to do this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(type.getRequired())) {
|
||||
player.getPacketDispatch().sendMessage("You need " + type.getRequired().getAmount() + " " + type.getRequired().getName().toLowerCase().replace("ball", "balls") + "" + (type == WeavingItem.SACK ? "s" : type == WeavingItem.CLOTH ? "" : "es") + " to weave " + (StringUtils.isPlusN(type.getProduct().getName().toLowerCase()) ? "an" : "a") + " " + type.getProduct().getName().toLowerCase() + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(type.getRequired())) {
|
||||
player.getInventory().add(type.getProduct());
|
||||
player.getSkills().addExperience(Skills.CRAFTING, type.getExperience(), true);
|
||||
player.getPacketDispatch().sendMessage("You weave the "
|
||||
+ type.getRequired().getName().toLowerCase().replace("ball", "balls")
|
||||
+ "" + (type == WeavingItem.SACK ? "s" : type == WeavingItem.CLOTH ? "" : "es")
|
||||
+ " into " + (StringUtils.isPlusN(type.getProduct().getName().toLowerCase()) ? "an" : "a")
|
||||
+ " " + type.getProduct().getName().toLowerCase() + ".");
|
||||
if (type == WeavingItem.BASKET && node.getId() == 8717 && player.getLocation().withinDistance(new Location(3039,3287,0))
|
||||
&& !player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).isComplete(1,0)) {
|
||||
player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).updateTask(player,1,0, true);
|
||||
}
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a weaving item.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum WeavingItem {
|
||||
SACK(new Item(5418), new Item(5931, 4), 21, 38),
|
||||
BASKET(new Item(5376), new Item(5933, 6), 36, 56),
|
||||
CLOTH(new Item(3224), new Item(1759, 4), 10, 12);
|
||||
|
||||
/**
|
||||
* Represents the product.
|
||||
*/
|
||||
private final Item product;
|
||||
|
||||
/**
|
||||
* Represents the required required.
|
||||
*/
|
||||
private final Item required;
|
||||
|
||||
/**
|
||||
* Represents the level needed.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the experience gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code WeavingItem} {@code Object}.
|
||||
* @param product the product.
|
||||
* @param level the level.
|
||||
* @param required the required.
|
||||
* @param experience the experience.
|
||||
*/
|
||||
private WeavingItem(Item product, final Item required, int level, double experience) {
|
||||
this.product = product;
|
||||
this.required = required;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return The product.
|
||||
*/
|
||||
public Item getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the required.
|
||||
* @return The required
|
||||
*/
|
||||
public Item getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience.
|
||||
* @return The experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import content.global.skill.crafting.armour.LeatherCrafting.DragonHide;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents a pulse used to craft dragon armour.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class DragonCraftPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(1249);
|
||||
|
||||
/**
|
||||
* Represents the dragon hide type.
|
||||
*/
|
||||
private DragonHide hide;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code DragonCraftPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public DragonCraftPulse(Player player, Item node, DragonHide hide, int amount) {
|
||||
super(player, node);
|
||||
this.hide = hide;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < hide.getLevel()) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a crafting level of " + hide.getLevel() + " to make " + ItemDefinition.forId(hide.getProduct()).getName() + ".");
|
||||
amount = 0;
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.NEEDLE, 1)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a needle to make this.");
|
||||
amount = 0;
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(LeatherCrafting.THREAD)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need thread to make this.");
|
||||
amount = 0;
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(hide.getLeather(), hide.getAmount())) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need " + hide.getAmount() + " " + ItemDefinition.forId(hide.getLeather()).getName().toLowerCase() + " to make this.");
|
||||
amount = 0;
|
||||
return false;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(hide.getLeather(), hide.getAmount()))) {
|
||||
if (hide.name().contains("VAMBS")) {
|
||||
player.getPacketDispatch().sendMessage("You make a pair of " + ItemDefinition.forId(hide.getProduct()).getName().toLowerCase() + "'s.");
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("You make " + (StringUtils.isPlusN(ItemDefinition.forId(hide.getProduct()).getName().toLowerCase()) ? "an" : "a") + " " + ItemDefinition.forId(hide.getProduct()).getName().toLowerCase() + ".");
|
||||
}
|
||||
Item item = new Item(hide.getProduct());
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, hide.getExperience(), true);
|
||||
LeatherCrafting.decayThread(player);
|
||||
if (LeatherCrafting.isLastThread(player)) {
|
||||
LeatherCrafting.removeThread(player);
|
||||
}
|
||||
amount--;
|
||||
}
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(int type) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to craft hard leather.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class HardCraftPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(1249);
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code HardCraftPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public HardCraftPulse(Player player, Item node, int amount) {
|
||||
super(player, node);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 28) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a crafting level of " + 28 + " to make a hardleather body.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.NEEDLE, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.HARD_LEATHER, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(LeatherCrafting.THREAD)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need thread to make this.");
|
||||
return false;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(LeatherCrafting.HARD_LEATHER))) {
|
||||
Item item = new Item(1131);
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, 35, true);
|
||||
LeatherCrafting.decayThread(player);
|
||||
if (LeatherCrafting.isLastThread(player)) {
|
||||
LeatherCrafting.removeThread(player);
|
||||
}
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* Represents a useful class for leather crafting related information.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class LeatherCrafting {
|
||||
|
||||
/**
|
||||
* Constant of a needle id.
|
||||
*/
|
||||
public static final int NEEDLE = 1733;
|
||||
|
||||
/**
|
||||
* Constant of a thread id.
|
||||
*/
|
||||
public static final Item THREAD = new Item(1734, 1);
|
||||
|
||||
/**
|
||||
* Constant of a needle id.
|
||||
*/
|
||||
public static final int LEATHER = 1741;
|
||||
|
||||
/**
|
||||
* Constant of a thread id.
|
||||
*/
|
||||
public static final int HARD_LEATHER = 1743;
|
||||
|
||||
/**
|
||||
* The constants of leather id's related to dragon hides.
|
||||
*/
|
||||
public static final int GREEN_LEATHER = 1745, BLUE_LEATHER = 2505, RED_LEATHER = 2507, BLACK_LEATHER = 2509;
|
||||
|
||||
/**
|
||||
* The leather interface component.
|
||||
*/
|
||||
private static final Component COMPONENT = new Component(154);
|
||||
|
||||
/**
|
||||
* Checks if its the last thrad.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public static boolean isLastThread(final Player player) {
|
||||
final Item thread = getThread(player);
|
||||
if (thread == null) {
|
||||
return false;
|
||||
}
|
||||
int charge = thread.getCharge();
|
||||
return charge >= 1004;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to decay thread.
|
||||
*/
|
||||
public static void decayThread(final Player player) {
|
||||
final Item thread = getThread(player);
|
||||
if (thread == null) {
|
||||
return;
|
||||
}
|
||||
int charge = thread.getCharge();
|
||||
thread.setCharge(charge + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to remove thread.
|
||||
* @param player the player.
|
||||
*/
|
||||
public static void removeThread(final Player player) {
|
||||
if (player.getInventory().remove(THREAD)) {
|
||||
player.getPacketDispatch().sendMessage("You use a reel of your thread.");
|
||||
Item thread = getThread(player);
|
||||
if (thread != null) {
|
||||
thread.setCharge(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the thread.
|
||||
* @param player the player.
|
||||
* @return the item.
|
||||
*/
|
||||
public static Item getThread(final Player player) {
|
||||
return player.getInventory().get(player.getInventory().getSlot(THREAD));
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the dragon hide crafting data.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum DragonHide {
|
||||
GREEN_D_HIDE_VAMBS(1745, 1, 1065, 57, 62),
|
||||
GREEN_D_HIDE_CHAPS(1745, 2, 1099, 60, 124),
|
||||
GREEN_D_HIDE_BODY(1745, 3, 1135, 63, 186),
|
||||
BLUE_D_HIDE_VAMBS(2505, 1, 2487, 66, 70),
|
||||
BLUE_D_HIDE_CHAPS(2505, 2, 2493, 68, 140),
|
||||
BLUE_D_HIDE_BODY(2505, 3, 2499, 71, 210),
|
||||
RED_D_HIDE_VAMBS(2507, 1, 2489, 73, 78),
|
||||
RED_D_HIDE_CHAPS(2507, 2, 2495, 75, 156),
|
||||
RED_D_HIDE_BODY(2507, 3, 2501, 77, 234),
|
||||
BLACK_D_HIDE_VAMBS(2509, 1, 2491, 79, 86),
|
||||
BLACK_D_HIDE_CHAPS(2509, 2, 2497, 82, 172),
|
||||
BLACK_D_HIDE_BODY(2509, 3, 2503, 84, 258);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LeatherCrafting.java} {@code Object}.
|
||||
* @param leather the leather required.
|
||||
* @param amount the amount of leather needed.
|
||||
* @param product the product item.
|
||||
* @param level the level required.
|
||||
* @param experience the experience.
|
||||
*/
|
||||
DragonHide(int leather, int amount, int product, int level, double experience) {
|
||||
this.leather = leather;
|
||||
this.amount = amount;
|
||||
this.product = product;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* The leather id.
|
||||
*/
|
||||
private final int leather;
|
||||
|
||||
/**
|
||||
* The leather amount required.
|
||||
*/
|
||||
private final int amount;
|
||||
|
||||
/**
|
||||
* The product.
|
||||
*/
|
||||
private final int product;
|
||||
|
||||
/**
|
||||
* The required level.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* The experiences gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* @return the leather.
|
||||
*/
|
||||
public int getLeather() {
|
||||
return leather;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount.
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the product.
|
||||
*/
|
||||
public int getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to return the type for the leather.
|
||||
* @param leather the leather.
|
||||
* @return the hide.
|
||||
*/
|
||||
public static DragonHide forLeather(int leather) {
|
||||
for (DragonHide hide : DragonHide.values()) {
|
||||
if (hide.getLeather() == leather) {
|
||||
return hide;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an enumeration of soft leather crafting values.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum SoftLeather {
|
||||
ARMOUR(28, 14, 25, new Item(1129)),
|
||||
GLOVES(29, 1, 13.8, new Item(1059)),
|
||||
BOOTS(30, 7, 16.3, new Item(1061)),
|
||||
VAMBRACES(31, 11, 22, new Item(1063)),
|
||||
CHAPS(32, 18, 27, new Item(1095)),
|
||||
COIF(33, 38, 37, new Item(1169)),
|
||||
COWL(34, 9, 18.5, new Item(1167));
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Soft} {@code Object}.
|
||||
* @param level the level.
|
||||
* @param experience the experience.
|
||||
* @param product the product.
|
||||
*/
|
||||
SoftLeather(int button, int level, double experience, Item product) {
|
||||
this.button = button;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
/**
|
||||
* The button.
|
||||
*/
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* The level required.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* The experience gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* The product.
|
||||
*/
|
||||
private final Item product;
|
||||
|
||||
/**
|
||||
* Method used to open the crafting interface.
|
||||
* @param player the player.
|
||||
*/
|
||||
public static void open(final Player player) {
|
||||
player.getInterfaceManager().open(COMPONENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the product.
|
||||
*/
|
||||
public Item getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the button.
|
||||
*/
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to get the value by the id.
|
||||
*/
|
||||
public static SoftLeather forButton(int button) {
|
||||
for (SoftLeather soft : SoftLeather.values()) {
|
||||
if (soft.getButton() == button) {
|
||||
return soft;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* A snake skin.
|
||||
* @author Vexia
|
||||
*/
|
||||
public enum SnakeSkin {
|
||||
SNAKESKIN_BOOT(new Item(6328), 45, 30, 6), SNAKESKIN_VAMBRACES(new Item(6330), 47, 35, 8), SNAKESKIN_BANDANA(new Item(6326), 48, 45, 5), SNAKESKIN_CHAPS(new Item(6324), 51, 50, 12), SNAKESKIN_BODY(new Item(6322), 53, 55, 15);
|
||||
|
||||
/**
|
||||
* The item product.
|
||||
*/
|
||||
private final Item product;
|
||||
|
||||
/**
|
||||
* The level.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* The experience.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* The required amount of snakeskins.
|
||||
*/
|
||||
private final int requiredAmount;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code SnakeSkin} {@Code Object}
|
||||
* @param product the product.
|
||||
* @param level the level.
|
||||
* @param experience the exp.
|
||||
* @param requiredAmount the required amount.
|
||||
*/
|
||||
private SnakeSkin(Item product, int level, double experience, int requiredAmount) {
|
||||
this.product = product;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
this.requiredAmount = requiredAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return the product
|
||||
*/
|
||||
public Item getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return the level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience.
|
||||
* @return the experience
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the requiredAmount.
|
||||
* @return the requiredAmount
|
||||
*/
|
||||
public int getRequiredAmount() {
|
||||
return requiredAmount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to craft snake skin.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class SnakeSkinPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(1249);
|
||||
|
||||
/**
|
||||
* The snake skin.
|
||||
*/
|
||||
private final SnakeSkin skin;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code HardCraftPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public SnakeSkinPulse(Player player, Item node, int amount, SnakeSkin skin) {
|
||||
super(player, node);
|
||||
this.amount = amount;
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < skin.getLevel()) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a crafting level of " + skin.getLevel() + " to make this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.NEEDLE, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(LeatherCrafting.THREAD)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need thread to make this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(6289, skin.getRequiredAmount())) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need " + skin.getRequiredAmount() + " snakeskins in order to do this.");
|
||||
return false;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(6289, skin.getRequiredAmount()))) {
|
||||
Item item = skin.getProduct();
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, skin.getExperience(), true);
|
||||
LeatherCrafting.decayThread(player);
|
||||
if (LeatherCrafting.isLastThread(player)) {
|
||||
LeatherCrafting.removeThread(player);
|
||||
}
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package content.global.skill.crafting.armour;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents a pulse used to craft soft leather.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class SoftCraftPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(1249);
|
||||
|
||||
/**
|
||||
* Represents the leather to use.
|
||||
*/
|
||||
private LeatherCrafting.SoftLeather soft;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SoftCraftPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param leather the soft.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public SoftCraftPulse(Player player, Item node, LeatherCrafting.SoftLeather leather, int amount) {
|
||||
super(player, node);
|
||||
this.soft = leather;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < soft.getLevel()) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need a crafting level of " + soft.getLevel() + " to make " + (StringUtils.isPlusN(soft.getProduct().getName()) ? "an" : "a" + " " + soft.getProduct().getName()).toLowerCase() + ".");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.NEEDLE, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(LeatherCrafting.LEATHER, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(LeatherCrafting.THREAD)) {
|
||||
player.getDialogueInterpreter().sendDialogue("You need thread to make this.");
|
||||
amount = 0;
|
||||
return false;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(LeatherCrafting.LEATHER))) {
|
||||
if (soft == LeatherCrafting.SoftLeather.GLOVES || soft == LeatherCrafting.SoftLeather.BOOTS || soft == LeatherCrafting.SoftLeather.VAMBRACES) {
|
||||
player.getPacketDispatch().sendMessage("You make a pair of " + soft.getProduct().getName().toLowerCase() + ".");
|
||||
} else {
|
||||
player.getPacketDispatch().sendMessage("You make " + (StringUtils.isPlusN(soft.getProduct().getName()) ? "an " : "a ") + soft.getProduct().getName().toLowerCase() + ".");
|
||||
}
|
||||
Item item = soft.getProduct();
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, soft.getExperience(), true);
|
||||
LeatherCrafting.decayThread(player);
|
||||
if (LeatherCrafting.isLastThread(player)) {
|
||||
LeatherCrafting.removeThread(player);
|
||||
}
|
||||
|
||||
if (soft == LeatherCrafting.SoftLeather.GLOVES) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 3);
|
||||
}
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package content.global.skill.crafting.gem;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to cut a gem.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class GemCutPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the chisel item.
|
||||
*/
|
||||
private static final Item CHISEL = new Item(1755);
|
||||
|
||||
/**
|
||||
* Represents the gem to cut.
|
||||
*/
|
||||
private final Gems gem;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GemCuttingPulse} {@Code Object}
|
||||
* @param player the player.
|
||||
* @param item the item cut.
|
||||
*/
|
||||
public GemCutPulse(Player player, Item item, int ammount, final Gems gem) {
|
||||
super(player, item);
|
||||
this.amount = ammount;
|
||||
this.gem = gem;
|
||||
this.resetAnimation = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (!player.getInventory().containsItem(CHISEL)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(gem.getUncut())) {
|
||||
return false;
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < gem.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + gem.getLevel() + " to craft this gem.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0 || ticks < 1) {
|
||||
player.getAudioManager().send(2586);
|
||||
player.animate(gem.getAnimation());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (player.getInventory().remove(gem.getUncut())) {
|
||||
final Item item = gem.getGem();
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, gem.getExp(), true);
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package content.global.skill.crafting.gem;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents a gem enumeration.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum Gems {
|
||||
SAPPHIRE(new Item(1623), new Item(1607), 20, new Animation(888), 50),
|
||||
EMERALD(new Item(1621), new Item(1605), 27, new Animation(889), 67),
|
||||
RUBY(new Item(1619), new Item(1603), 34, new Animation(887), 85),
|
||||
DIAMOND(new Item(1617), new Item(1601), 43, new Animation(886), 107.5),
|
||||
DRAGONSTONE(new Item(1631), new Item(1615), 55, new Animation(885), 137.5),
|
||||
ONYX(new Item(6571), new Item(6573), 67, new Animation(2717), 168),
|
||||
OPAL(new Item(1625), new Item(1609), 1, new Animation(890), 10),
|
||||
JADE(new Item(1627), new Item(1611), 13, new Animation(891), 20),
|
||||
RED_TOPAZ(new Item(1629), new Item(1613), 16, new Animation(892), 25);
|
||||
|
||||
/**
|
||||
* Represents the raw gem.
|
||||
*/
|
||||
private final Item uncut;
|
||||
|
||||
/**
|
||||
* Represents the gem cut.
|
||||
*/
|
||||
private final Item gem;
|
||||
|
||||
/**
|
||||
* Represents the level needed.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the animation used.
|
||||
*/
|
||||
private final Animation animation;
|
||||
|
||||
/**
|
||||
* Represents the experience gained.
|
||||
*/
|
||||
private final double exp;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Gems} {@code Object}.
|
||||
* @param uncut the uncut.
|
||||
* @param gem the gem.
|
||||
* @param level the level.
|
||||
* @param animation the animation.
|
||||
* @param exp the exp.
|
||||
*/
|
||||
private Gems(Item uncut, Item gem, int level, Animation animation, double exp) {
|
||||
this.uncut = uncut;
|
||||
this.gem = gem;
|
||||
this.level = level;
|
||||
this.animation = animation;
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gem by the id.
|
||||
* @return the gem.
|
||||
*/
|
||||
public static Gems forId(final Item item) {
|
||||
for (Gems gem : Gems.values()) {
|
||||
if (gem.getUncut().getId() == item.getId()) {
|
||||
return gem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the uncut.
|
||||
* @return The uncut.
|
||||
*/
|
||||
public Item getUncut() {
|
||||
return uncut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gem.
|
||||
* @return The gem.
|
||||
*/
|
||||
public Item getGem() {
|
||||
return gem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the animation.
|
||||
* @return The animation.
|
||||
*/
|
||||
public Animation getAnimation() {
|
||||
return animation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exp.
|
||||
* @return The exp.
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package content.global.skill.crafting.jewellery;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.component.Component;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Represents a useful class for jewellery crafting information.
|
||||
* @author Ceikry
|
||||
*/
|
||||
public class JewelleryCrafting {
|
||||
|
||||
/**
|
||||
* Represents constants of useful items.
|
||||
*/
|
||||
public static final int RING_MOULD = 1592, AMULET_MOULD = 1595, NECKLACE_MOULD = 1597, BRACELET_MOULD = 11065, GOLD_BAR = 2357, SAPPHIRE = 1607, EMERALD = 1605, RUBY = 1603, DIAMOND = 1601, DRAGONSTONE = 1615, ONYX = 6573;
|
||||
|
||||
/**
|
||||
* Represents the anum of jewellery data.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum JewelleryItem {
|
||||
//Ring
|
||||
GOLD_RING(5, 15, 19, 1635, GOLD_BAR),
|
||||
SAPPIRE_RING(20, 40, 21, 1637, SAPPHIRE, GOLD_BAR),
|
||||
EMERALD_RING(27, 55, 23, 1639, EMERALD, GOLD_BAR),
|
||||
RUBY_RING(34, 70, 25, 1641, RUBY, GOLD_BAR),
|
||||
DIAMOND_RING(43, 85, 27, 1643, DIAMOND, GOLD_BAR),
|
||||
DRAGONSTONE_RING(55, 100, 29, 1645, DRAGONSTONE, GOLD_BAR),
|
||||
ONYX_RING(67, 115, 31, 6575, 6573, GOLD_BAR),
|
||||
|
||||
//Necklaces
|
||||
GOLD_NECKLACE(6, 20, 41, 1654, 2357),
|
||||
SAPPHIRE_NECKLACE(22, 55, 43, 1656, 1607, 2357),
|
||||
EMERALD_NECKLACE(29, 60, 45, 1658, 1605, 2357),
|
||||
RUBY_NECKLACE(40, 75, 47, 1660, 1603, 2357),
|
||||
DIAMOND_NECKLACE(56, 90, 49, 1662, 1601, 2357),
|
||||
DRAGONSTONE_NECKLACE(72, 105, 51, 1664, 1615, 2357),
|
||||
ONYX_NECKLACE(82, 120, 53, 6577, 6573, 2357),
|
||||
SLAYER_RING(75, 15, 34, 13281, 4155, GOLD_BAR),
|
||||
|
||||
|
||||
//Amulet
|
||||
GOLD_AMULET(8, 30, 60, 1673, 2357),
|
||||
SAPPHIRE_AMULET(24, 63, 62, 1675, 1607, 2357),
|
||||
EMERALD_AMULET(31, 70, 64, 1677, 1605, 2357),
|
||||
RUBY_AMULET(50, 85, 66, 1679, 1603, 2357),
|
||||
DIAMOND_AMULET(70, 100, 68, 1681, 1601, 2357),
|
||||
DRAGONSTONE_AMULET(80, 150, 70, 1683, 1615, 2357),
|
||||
ONYX_AMULET(90, 165, 72, 6579, 6573, 2357),
|
||||
|
||||
//Bracelet
|
||||
GOLD_BRACELET(7, 25, 79, 11069, 2357),
|
||||
SAPPHIRE_BRACELET(23, 60, 81, 11072, 1607, 2357),
|
||||
EMERALD_BRACELET(30, 65, 83, 11076, 1605, 2357),
|
||||
RUBY_BRACELET(42, 80, 85, 11085, 1603, 2357),
|
||||
DIAMOND_BRACELET(58, 95, 87, 11092, 1601, 2357),
|
||||
DRAGONSTONE_BRACELET(74, 110, 89, 11115, 1615, 2357),
|
||||
ONYX_BRACELET(84, 125, 91, 11130, 6573, 2357);
|
||||
|
||||
public static HashMap<Integer, JewelleryItem> productMap = new HashMap<>();
|
||||
static{
|
||||
JewelleryItem[] jewelleryArray = JewelleryItem.values();
|
||||
for (JewelleryItem jewelleryItem : jewelleryArray) {
|
||||
productMap.putIfAbsent(jewelleryItem.sendItem, jewelleryItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the item ids.
|
||||
*/
|
||||
private final int[] items;
|
||||
|
||||
/**
|
||||
* Represents the send item.
|
||||
*/
|
||||
private final int sendItem;
|
||||
|
||||
/**
|
||||
* Represents the component id.
|
||||
*/
|
||||
private final int componentId;
|
||||
|
||||
/**
|
||||
* Represents the level.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the experience gained.
|
||||
*/
|
||||
private final double experience;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Jewellery.java} {@code Object}.
|
||||
* @param level the level.
|
||||
* @param experience the experience.
|
||||
*/
|
||||
JewelleryItem(int level, int experience, int componentId, int sendItem, int... items) {
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
this.componentId = componentId;
|
||||
this.sendItem = sendItem;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the jewellery by the product.
|
||||
* @param id the id.
|
||||
* @return the jewellery.
|
||||
*/
|
||||
public static JewelleryItem forProduct(int id) {
|
||||
return productMap.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the items.
|
||||
* @return The items.
|
||||
*/
|
||||
public int[] getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sendItem.
|
||||
* @return The sendItem.
|
||||
*/
|
||||
public int getSendItem() {
|
||||
return sendItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the componentId.
|
||||
* @return The componentId.
|
||||
*/
|
||||
public int getComponentId() {
|
||||
return componentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the experience.
|
||||
* @return The experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to open the jewellery crafting interface.
|
||||
* @param player the player.
|
||||
*/
|
||||
public static void open(final Player player) {
|
||||
player.getInterfaceManager().open(new Component(446));
|
||||
if (player.getInventory().contains(RING_MOULD, 1)) {
|
||||
player.getPacketDispatch().sendInterfaceConfig(446, 14, true);
|
||||
/** hides the mould and text. */
|
||||
}
|
||||
if (player.getInventory().contains(NECKLACE_MOULD, 1)) {
|
||||
player.getPacketDispatch().sendInterfaceConfig(446, 36, true);
|
||||
/** hides the mould and text. */
|
||||
}
|
||||
if (player.getInventory().contains(AMULET_MOULD, 1)) {
|
||||
player.getPacketDispatch().sendInterfaceConfig(446, 55, true);
|
||||
/** hides the mould and text. */
|
||||
}
|
||||
if (player.getInventory().contains(BRACELET_MOULD, 1)) {
|
||||
player.getPacketDispatch().sendInterfaceConfig(446, 74, true);
|
||||
/** hides the mould and text. */
|
||||
}
|
||||
for (JewelleryItem data : JewelleryItem.values()) {
|
||||
int length = 0;
|
||||
for (int i = 0; i < data.items.length; i++) {
|
||||
if (player.getInventory().contains(data.getItems()[i], 1)) {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
if (!player.getInventory().contains(mouldFor(data.name()), 1)) {
|
||||
length--;
|
||||
}
|
||||
if (length == data.getItems().length && player.getSkills().getLevel(Skills.CRAFTING) >= data.getLevel()) {
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(data.getSendItem(), 170, 446, data.getComponentId());
|
||||
} else {
|
||||
String name = ItemDefinition.forId(data.getSendItem()).getName().toLowerCase();
|
||||
if (name.contains("amulet") && player.getInventory().contains(mouldFor(data.name()), 1)) {
|
||||
for (int i = 0; i < data.items.length; i++) {
|
||||
if (!player.getInventory().contains(data.getItems()[i], 1)) {
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(1685, 220, 446, data.getComponentId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name.contains("ring") && !player.getInventory().contains(RING_MOULD, 1)) {
|
||||
continue;
|
||||
}
|
||||
if (name.contains("necklace") && !player.getInventory().contains(NECKLACE_MOULD, 1)) {
|
||||
continue;
|
||||
}
|
||||
if (data == JewelleryItem.DRAGONSTONE_AMULET && !player.getInventory().contains(AMULET_MOULD, 1)) {
|
||||
continue;
|
||||
}
|
||||
if (name.contains("amulet") && !player.getInventory().contains(AMULET_MOULD, 1)) {
|
||||
continue;
|
||||
}
|
||||
if (name.contains("bracelet") && !player.getInventory().contains(BRACELET_MOULD, 1)) {
|
||||
continue;
|
||||
}
|
||||
player.getPacketDispatch().sendItemZoomOnInterface(name.contains("ring") ? 1647 : name.contains("necklace") ? 1666 : name.contains("amulet") || name.contains("ammy") ? 1685 : name.contains("bracelet") ? 11067 : -1, 1, 446, data.getComponentId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the making of a jewellery.
|
||||
* @param player the player.
|
||||
* @param data the data.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public static final void make(final Player player, JewelleryItem data, int amount) {
|
||||
int length = 0;
|
||||
int amt = 0;
|
||||
if (data.name().contains("GOLD")) {
|
||||
amt = player.getInventory().getAmount(new Item(GOLD_BAR));
|
||||
} else {
|
||||
int first = player.getInventory().getAmount(new Item(data.getItems()[0]));
|
||||
int second = player.getInventory().getAmount(new Item(data.getItems()[1]));
|
||||
if (first == second) {
|
||||
amt = first;
|
||||
} else if (first > second) {
|
||||
amt = second;
|
||||
} else {
|
||||
amt = first;
|
||||
}
|
||||
}
|
||||
if (amount > amt) {
|
||||
amount = amt;
|
||||
}
|
||||
for (int i = 0; i < data.items.length; i++) {
|
||||
if (player.getInventory().contains(data.getItems()[i], amount)) {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
if (length != data.getItems().length) {
|
||||
player.getPacketDispatch().sendMessage("You don't have the required items to make this item.");
|
||||
return;
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < data.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + data.getLevel() + " to craft this.");
|
||||
return;
|
||||
}
|
||||
Item items[] = new Item[data.items.length];
|
||||
int index = 0;
|
||||
for (int i = 0; i < data.items.length; i++) {
|
||||
items[index] = new Item(data.items[i], 1 * amount);
|
||||
index++;
|
||||
}
|
||||
player.getInterfaceManager().close();
|
||||
player.getPulseManager().run(new JewelleryPulse(player, null, data, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mould id for the name.
|
||||
* @param name the name.
|
||||
* @return the mould id.
|
||||
*/
|
||||
public static int mouldFor(String name) {
|
||||
name = name.toLowerCase();
|
||||
if (name.contains("ring")) {
|
||||
return RING_MOULD;
|
||||
}
|
||||
if (name.contains("necklace")) {
|
||||
return NECKLACE_MOULD;
|
||||
}
|
||||
if (name.contains("amulet")) {
|
||||
return AMULET_MOULD;
|
||||
}
|
||||
if (name.contains("bracelet")) {
|
||||
return BRACELET_MOULD;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package content.global.skill.crafting.jewellery;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to craft jewllery.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class JewelleryPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(3243);
|
||||
|
||||
/**
|
||||
* Represents the data of jewellery.
|
||||
*/
|
||||
private JewelleryCrafting.JewelleryItem type;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code CraftJewellery.java} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
*/
|
||||
public JewelleryPulse(Player player, Item node, JewelleryCrafting.JewelleryItem data, int amount) {
|
||||
super(player, node);
|
||||
this.type = data;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(getItems())) {
|
||||
final Item item = new Item(type.getSendItem());
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, type.getExperience(), true);
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the items to remove.
|
||||
* @return the items.
|
||||
*/
|
||||
private Item[] getItems() {
|
||||
Item items[] = new Item[type.getItems().length];
|
||||
int index = 0;
|
||||
for (int i = 0; i < type.getItems().length; i++) {
|
||||
items[index] = new Item(type.getItems()[i], 1);
|
||||
index++;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package content.global.skill.crafting.leather
|
||||
|
||||
import core.api.Container
|
||||
import core.api.*
|
||||
import core.game.interaction.NodeUsageEvent
|
||||
import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import org.rs09.consts.Items
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
/**
|
||||
* Handles attaching Kebbit Claws to Vambraces
|
||||
* to create "Spiky Vambraces"
|
||||
* @author downthecrop
|
||||
*/
|
||||
|
||||
@Initializable
|
||||
class SpikyVambraces: UseWithHandler(Items.KEBBIT_CLAWS_10113) {
|
||||
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
addHandler(Items.LEATHER_VAMBRACES_1063, ITEM_TYPE, this)
|
||||
addHandler(Items.GREEN_DHIDE_VAMB_1065, ITEM_TYPE, this)
|
||||
addHandler(Items.BLUE_DHIDE_VAMB_2487, ITEM_TYPE, this)
|
||||
addHandler(Items.RED_DHIDE_VAMB_2489, ITEM_TYPE, this)
|
||||
addHandler(Items.BLACK_DHIDE_VAMB_2491, ITEM_TYPE, this)
|
||||
return this
|
||||
}
|
||||
override fun handle(event: NodeUsageEvent?): Boolean {
|
||||
event ?: return false
|
||||
val vamb = event.usedWith.id
|
||||
val player = event.player
|
||||
when(vamb){
|
||||
Items.LEATHER_VAMBRACES_1063 -> {
|
||||
craftVamb(player,vamb,Items.SPIKY_VAMBRACES_10077,"leather")
|
||||
}
|
||||
Items.GREEN_DHIDE_VAMB_1065 -> {
|
||||
craftVamb(player,vamb,Items.GREEN_SPIKY_VAMBS_10079,"green dragonhide")
|
||||
}
|
||||
Items.BLUE_DHIDE_VAMB_2487 -> {
|
||||
craftVamb(player,vamb,Items.BLUE_SPIKY_VAMBS_10081,"blue dragonhide")
|
||||
}
|
||||
Items.RED_DHIDE_VAMB_2489 -> {
|
||||
craftVamb(player,vamb,Items.RED_SPIKY_VAMBS_10083,"red dragonhide")
|
||||
}
|
||||
Items.BLACK_DHIDE_VAMB_2491 -> {
|
||||
craftVamb(player,vamb,Items.BLACK_SPIKY_VAMBS_10085,"black dragonhide")
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun craftVamb(player: Player, vamb: Int, product: Int, vambLeather: String){
|
||||
if (player.skills.getLevel(Skills.CRAFTING) >= 32){
|
||||
if (removeItem(player,vamb,Container.INVENTORY) &&
|
||||
removeItem(player,Items.KEBBIT_CLAWS_10113,Container.INVENTORY)
|
||||
) {
|
||||
addItem(player,product)
|
||||
player.skills.addExperience(Skills.CRAFTING,6.0)
|
||||
sendMessage(player, "You carefully attach the sharp claws to the $vambLeather vambraces.")
|
||||
}
|
||||
}
|
||||
else{
|
||||
sendMessage(player,"You need a crafting level of 32 to craft this.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package content.global.skill.crafting.lightsources
|
||||
|
||||
import core.game.interaction.NodeUsageEvent
|
||||
import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
/**
|
||||
* Handles the combining of items to craft lanterns
|
||||
* @author Ceikry
|
||||
*/
|
||||
@Initializable
|
||||
class LanternCrafting : UseWithHandler(36,38,4525,4542,1607){
|
||||
/**
|
||||
* For candle lanterns -> Glassblowing produces 4527
|
||||
* 4527 + white candle = 4529
|
||||
* 4527 + black candle = 4532
|
||||
*
|
||||
* For oil lanterns -> Glassblowing produces 4525
|
||||
* 4525 + 4540 (oil lantern frame) = 4535 (empty oil lantern)
|
||||
*
|
||||
* For Bullseye lanterns -> Smithing produces 4544 (bullseye lantern (unf))
|
||||
* 4544 + Lens(4542) -> 4546
|
||||
* 4544 + Sapphire(1607) -> 4700 (Sapphire lantern)
|
||||
*/
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
addHandler(4527, ITEM_TYPE, this) //Empty candle lantern
|
||||
addHandler(4540, ITEM_TYPE,this) //oil lantern frame
|
||||
addHandler(4544, ITEM_TYPE,this) //Bullseye lantern(unf)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(event: NodeUsageEvent?): Boolean {
|
||||
event ?: return false //if event is null don't execute
|
||||
val used = event.used
|
||||
return when(used.id){
|
||||
4527 -> craftCandleLantern(event.player,event)
|
||||
4540 -> craftOilLantern(event.player,event)
|
||||
4544 -> craftBullseyeLantern(event.player,event)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun craftCandleLantern(player: Player, event: NodeUsageEvent): Boolean{
|
||||
return when(event.usedWith.id){
|
||||
36,38 -> {
|
||||
removeEventItems(player,event)
|
||||
player.inventory.add( if(event.usedWith.id == 36) Item(4529) else Item(4532))
|
||||
player.sendMessage("You place the unlit candle inside the lantern.")
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun craftOilLantern(player: Player, event: NodeUsageEvent): Boolean {
|
||||
return when(event.usedWith.id){
|
||||
4525 -> {
|
||||
removeEventItems(player,event)
|
||||
player.inventory.add(Item(4535))
|
||||
player.sendMessage("You place the oil lamp inside its metal frame.")
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun craftBullseyeLantern(player: Player,event: NodeUsageEvent): Boolean{
|
||||
return when(event.usedWith.id){
|
||||
4542 -> {
|
||||
removeEventItems(player,event)
|
||||
player.inventory.add( Item(4546) )
|
||||
player.sendMessage("You fashion the lens onto the lantern.")
|
||||
true
|
||||
}
|
||||
1607 -> {
|
||||
if(player.skills.getLevel(Skills.CRAFTING) >= 20){
|
||||
removeEventItems(player,event)
|
||||
player.inventory.add(Item(4700))
|
||||
player.sendMessage("You fashion the gem into a lens and fit it onto the lantern.")
|
||||
} else {
|
||||
player.sendMessage("You require a crafting level of 20 to use a gem as a lens.")
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeEventItems(player: Player, event: NodeUsageEvent){
|
||||
player.inventory.remove(event.used.asItem())
|
||||
player.inventory.remove(event.usedWith.asItem())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package content.global.skill.crafting.lightsources
|
||||
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.game.container.Container
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.SystemLogger
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
|
||||
/**
|
||||
* Extinguishes light sources
|
||||
* @author Ceikry
|
||||
*/
|
||||
@Initializable
|
||||
class LightSourceExtinguisher : OptionHandler(){
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
ItemDefinition.setOptionHandler("extinguish",this)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
|
||||
node ?: return false
|
||||
player ?: return false
|
||||
|
||||
val lightSource = LightSources.forId(node.id)
|
||||
|
||||
lightSource ?: return false.also { SystemLogger.logWarn(this::class.java, "UNHANDLED EXTINGUISH OPTION: ID = ${node.id}") }
|
||||
|
||||
player.inventory.replace(node.asItem(), Item(lightSource.fullID))
|
||||
return true
|
||||
}
|
||||
|
||||
fun Container.replace(item: Item, with: Item){
|
||||
if(remove(item)) {
|
||||
add(with)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package content.global.skill.crafting.lightsources
|
||||
|
||||
import core.game.container.Container
|
||||
import core.game.interaction.NodeUsageEvent
|
||||
import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
/**
|
||||
* Method used to light various light sources
|
||||
* @author Ceikry
|
||||
*/
|
||||
@Initializable
|
||||
class LightSourceLighter : UseWithHandler(590,36,38){
|
||||
/**
|
||||
* For Candles:
|
||||
* 36 + tinderbox = 33
|
||||
* 38 + tinderbox = 32
|
||||
*
|
||||
* For torches:
|
||||
* 596 + tinderbox = 594
|
||||
*
|
||||
* For Candle lanterns:
|
||||
* 4529 + tinderbox = 4531
|
||||
* 4532 + tinderbox = 4534
|
||||
* Required Level: 4 Firemaking
|
||||
*
|
||||
* For oil lamps:
|
||||
* 4522 + tinderbox = 4524
|
||||
* Required Level: 12 Firemaking
|
||||
*
|
||||
* For oil lanterns:
|
||||
* 4537 + tinderbox = 4539
|
||||
* Required Level: 26 Firemaking
|
||||
*
|
||||
* For bullseye lanterns:
|
||||
* 4548 + tinderbox = 4550
|
||||
* 4701 + tinderbox = 4702
|
||||
* 9064 + tinderbox = 9065
|
||||
* Required Level: 49 Firemaking
|
||||
*/
|
||||
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
addHandler(590, ITEM_TYPE, this)
|
||||
addHandler(596, ITEM_TYPE, this)
|
||||
addHandler(4529, ITEM_TYPE, this)
|
||||
addHandler(4532, ITEM_TYPE, this)
|
||||
addHandler(4522, ITEM_TYPE, this)
|
||||
addHandler(4537, ITEM_TYPE, this)
|
||||
addHandler(4548, ITEM_TYPE, this)
|
||||
addHandler(4701, ITEM_TYPE, this)
|
||||
addHandler(9064, ITEM_TYPE, this)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(event: NodeUsageEvent?): Boolean {
|
||||
event ?: return false
|
||||
val inventory = event.player.inventory
|
||||
val used = if(event.used.id == 590) event.usedWith.asItem() else event.used.asItem() //compensation for bad two-way use with handler shit
|
||||
|
||||
val lightSource = LightSources.forId(used.id)
|
||||
|
||||
lightSource ?: return false
|
||||
|
||||
if(!light(event.player,used,lightSource)){
|
||||
event.player.sendMessage("You need a Firemaking level of at least ${lightSource.levelRequired} to light this.")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun Container.replace(item: Item, with: Item){
|
||||
if(remove(item)) {
|
||||
add(with)
|
||||
}
|
||||
}
|
||||
|
||||
fun light(player: Player, item: Item, lightSource: LightSources): Boolean{
|
||||
val requiredLevel = lightSource.levelRequired
|
||||
val playerLevel = player.skills.getLevel(Skills.FIREMAKING)
|
||||
|
||||
if(playerLevel < requiredLevel) return false
|
||||
|
||||
player.inventory.replace(item,Item(lightSource.litID))
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package content.global.skill.crafting.lightsources
|
||||
|
||||
enum class LightSources(val emptyID: Int, val fullID: Int, val litID: Int, val levelRequired: Int, val openFlame: Boolean) {
|
||||
WHITE_CANDLE(0,36,33,0,true),
|
||||
BLACK_CANDLE(0,38,32,0,true),
|
||||
TORCH(0,596,594,0,true),
|
||||
WHITE_CANDLE_LANTERN(4527,4529,4531,4,true),
|
||||
BLACK_CANDLE_LANTERN(4527,4532,4534,4,true),
|
||||
OIL_LAMP(4525,4522,4524,12,true),
|
||||
OIL_LANTERN(4535,4537,4539,26,false),
|
||||
BULLSEYE_LANTERN(4546,4548,4550,49,false),
|
||||
SAPPHIRE_LANTERN(0,4701,4702,49,false),
|
||||
MINING_HELMET(0,5014,5013,65,false),
|
||||
EMERALD_LANTERN(0,9064,9065,49,false);
|
||||
|
||||
companion object {
|
||||
fun forId(id: Int): LightSources? {
|
||||
return when (id) {
|
||||
36, 33 -> WHITE_CANDLE
|
||||
38, 32 -> BLACK_CANDLE
|
||||
596, 594 -> TORCH
|
||||
4529, 4531 -> WHITE_CANDLE_LANTERN
|
||||
4532, 4534 -> BLACK_CANDLE_LANTERN
|
||||
4522, 4524 -> OIL_LAMP
|
||||
4537, 4539 -> OIL_LANTERN
|
||||
4548, 4550 -> BULLSEYE_LANTERN
|
||||
4701, 4702 -> SAPPHIRE_LANTERN
|
||||
5014, 5013 -> MINING_HELMET
|
||||
9064, 9065 -> EMERALD_LANTERN
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package content.global.skill.crafting.limestone;
|
||||
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
*
|
||||
* The skill pulse for chiseling a limestone into a limestone brick.
|
||||
*
|
||||
* @author Jamix77
|
||||
*
|
||||
*/
|
||||
public class ChiselLimestonePulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the chisel item.
|
||||
*/
|
||||
private static final Item CHISEL = new Item(1755);
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
public ChiselLimestonePulse(Player player, Item node) {
|
||||
super(player, node);
|
||||
this.resetAnimation= false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (!player.getInventory().containsItem(CHISEL)) {
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(new Item(3211))) {
|
||||
return false;
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 12) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of 12 to make limestone bricks.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0 || ticks < 1) {
|
||||
player.getAudioManager().send(2586);
|
||||
player.animate(Animation.create(4470));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 2 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(3211))) {
|
||||
|
||||
player.getInventory().add(new Item(3420));
|
||||
|
||||
player.getSkills().addExperience(Skills.CRAFTING, 6, true);
|
||||
}
|
||||
return !player.getInventory().containsItem(new Item(3211));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package content.global.skill.crafting.pottery;
|
||||
|
||||
import core.game.world.map.Location;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to fire pottery.
|
||||
*
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class FirePotteryPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(899);
|
||||
|
||||
/**
|
||||
* Represents the pottery item.
|
||||
*/
|
||||
private final PotteryItem pottery;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code FirePotteryPulse} {@code Object}.
|
||||
*
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param pottery the pottery.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public FirePotteryPulse(Player player, Item node, final PotteryItem pottery, final int amount) {
|
||||
super(player, node);
|
||||
this.pottery = pottery;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < pottery.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + pottery.getLevel() + " in order to do this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().containsItem(pottery.getUnfinished())) {
|
||||
player.getPacketDispatch().sendMessage("You need a " + pottery.name().toLowerCase() + "in order to do this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(pottery.getUnfinished())) {
|
||||
final Item item = pottery.getProduct();
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, pottery.getFireExp(), true);
|
||||
player.getPacketDispatch().sendMessage("You put the " + pottery.getUnfinished().getName().toLowerCase() + " in the oven.");
|
||||
player.getPacketDispatch().sendMessage("You remove a " + pottery.getProduct().getName().toLowerCase() + " from the oven.");
|
||||
|
||||
// Spin a bowl on the pottery wheel and fire it in the oven in<br><br>Barbarian Village
|
||||
if (pottery == PotteryItem.BOWL
|
||||
&& player.getLocation().withinDistance(Location.create(3085,3408,0))
|
||||
&& player.getAttribute("diary:varrock:spun-bowl", false)) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 0, 9);
|
||||
}
|
||||
|
||||
// Fire a pot in the kiln in the Barbarian Village potter's<br><br>house
|
||||
if (pottery == PotteryItem.POT && player.getLocation().withinDistance(Location.create(3085,3408,0))) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 7);
|
||||
}
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package content.global.skill.crafting.pottery;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
|
||||
/**
|
||||
* Represents a pottery item definition.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum PotteryItem {
|
||||
POT(new Item(1787), new Item(1931), 1, 6.3, 6.3), DISH(new Item(1789), new Item(2313), 7, 15, 10), BOWL(new Item(1791), new Item(1923), 8, 18, 15), PLANT(new Item(5352), new Item(5350), 19, 20, 17.5), LID(new Item(4438), new Item(4440), 25, 20, 20);
|
||||
|
||||
/**
|
||||
* Represents the unfinished product.
|
||||
*/
|
||||
private final Item unfinished;
|
||||
|
||||
/**
|
||||
* Represents the product.
|
||||
*/
|
||||
private final Item product;
|
||||
|
||||
/**
|
||||
* Represents the level required.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* Represents the exp given.
|
||||
*/
|
||||
private final double exp;
|
||||
|
||||
/**
|
||||
* Represents the fire exp.
|
||||
*/
|
||||
private final double fireExp;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PotteryItem} {@code Object}.
|
||||
* @param unfinished the unfinished.
|
||||
* @param product the product.
|
||||
* @param level the level.
|
||||
* @param exp the exp.
|
||||
* @param fireExp the fire experience.
|
||||
*/
|
||||
private PotteryItem(Item unfinished, Item product, int level, double exp, double fireExp) {
|
||||
this.unfinished = unfinished;
|
||||
this.product = product;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
this.fireExp = fireExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pottery item by the id.
|
||||
* @param id the id.
|
||||
* @return the item.
|
||||
*/
|
||||
public static PotteryItem forId(int id) {
|
||||
for (PotteryItem def : PotteryItem.values()) {
|
||||
if (def.getUnfinished().getId() == id) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unfinished.
|
||||
* @return The unfinished.
|
||||
*/
|
||||
public Item getUnfinished() {
|
||||
return unfinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return The product.
|
||||
*/
|
||||
public Item getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exp.
|
||||
* @return The exp.
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fireExp.
|
||||
* @return The fireExp.
|
||||
*/
|
||||
public double getFireExp() {
|
||||
return fireExp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package content.global.skill.crafting.pottery;
|
||||
|
||||
import core.game.world.map.Location;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents the skill pulse of the pottery unfired items.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class PotteryPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = Animation.create(896);
|
||||
|
||||
/**
|
||||
* Represnets the soft clay item.
|
||||
*/
|
||||
private static final Item SOFT_CLAY = new Item(1761);
|
||||
|
||||
/**
|
||||
* Represents the pottery item to make.
|
||||
*/
|
||||
private final PotteryItem pottery;
|
||||
|
||||
/**
|
||||
* Represents the amount to make.
|
||||
*/
|
||||
private int amount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PotteryPulse} {@code Object}.
|
||||
* @param player the player.
|
||||
* @param node the node.
|
||||
* @param amount the amount.
|
||||
* @param pottery the pottery.
|
||||
*/
|
||||
public PotteryPulse(Player player, Item node, int amount, final PotteryItem pottery) {
|
||||
super(player, node);
|
||||
this.pottery = pottery;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
if (!player.getInventory().contains(1761, 1)) {
|
||||
player.getPacketDispatch().sendMessage("You need soft clay in order to do this.");
|
||||
return false;
|
||||
}
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < pottery.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + pottery.getLevel() + " to make this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
if (++ticks % 5 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(SOFT_CLAY)) {
|
||||
if (pottery == PotteryItem.BOWL && player.getLocation().withinDistance(Location.create(3086,3410,0))) {
|
||||
player.setAttribute("/save:diary:varrock:spun-bowl", true);
|
||||
}
|
||||
final Item item = pottery.getUnfinished();
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, pottery.getExp(), true);
|
||||
player.getPacketDispatch().sendMessage("You make the soft clay into " + (StringUtils.isPlusN(pottery.getUnfinished().getName()) ? "an" : "a") + " " + pottery.getUnfinished().getName().toLowerCase() + ".");
|
||||
}
|
||||
amount--;
|
||||
return amount < 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package content.global.skill.crafting.silver
|
||||
|
||||
import core.api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import org.rs09.consts.Components
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Scenery
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InterfaceListener
|
||||
|
||||
import core.game.node.scenery.Scenery as CoreScenery
|
||||
|
||||
/**
|
||||
* Handles silver crafting interface interactions
|
||||
* as well as silver -> furnace use-with interaction.
|
||||
*
|
||||
* @author vddCore
|
||||
*/
|
||||
class SilverCraftingListener : InterfaceListener, InteractionListener {
|
||||
companion object {
|
||||
private const val OP_MAKE_ONE = 155
|
||||
private const val OP_MAKE_FIVE = 196
|
||||
private const val OP_MAKE_ALL = 124
|
||||
private const val OP_MAKE_X = 199
|
||||
|
||||
private val FURNACES = intArrayOf(
|
||||
Scenery.FURNACE_2966, Scenery.FURNACE_3044, Scenery.FURNACE_3294, Scenery.FURNACE_4304,
|
||||
Scenery.FURNACE_6189, Scenery.FURNACE_11009, Scenery.FURNACE_11010, Scenery.FURNACE_11666,
|
||||
Scenery.FURNACE_12100, Scenery.FURNACE_12809, Scenery.FURNACE_18497, Scenery.FURNACE_18525,
|
||||
Scenery.FURNACE_18526, Scenery.FURNACE_21879, Scenery.FURNACE_22721, Scenery.FURNACE_26814,
|
||||
Scenery.FURNACE_28433, Scenery.FURNACE_28434, Scenery.FURNACE_30021, Scenery.FURNACE_30510,
|
||||
Scenery.FURNACE_36956, Scenery.FURNACE_37651
|
||||
)
|
||||
|
||||
private const val ATTRIBUTE_FURNACE_ID = "crafting:silver:furnace_id"
|
||||
}
|
||||
|
||||
override fun defineInterfaceListeners() {
|
||||
onOpen(Components.CRAFTING_SILVER_CASTING_438) { player, _ ->
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 17, Items.HOLY_SYMBOL_1718)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 24, Items.UNHOLY_SYMBOL_1724)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 31, Items.SILVER_SICKLE_2961)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 38, Items.CONDUCTOR_4201)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 45, Items.TIARA_5525)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 53, Items.SILVTHRILL_ROD_7637)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 60, Items.DEMONIC_SIGIL_6748)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 67, Items.SILVER_BOLTS_UNF_9382)
|
||||
sendItemOnInterface(player, Components.CRAFTING_SILVER_CASTING_438, 74, Items.SILVTHRIL_CHAIN_13154)
|
||||
|
||||
return@onOpen true
|
||||
}
|
||||
|
||||
on(Components.CRAFTING_SILVER_CASTING_438) { player, _, opcode, buttonID, _, _ ->
|
||||
val product = SilverProduct.forButtonID(buttonID) ?: return@on true
|
||||
|
||||
if (!inInventory(player, product.requiredItemId)) {
|
||||
sendMessage(
|
||||
player,
|
||||
"You need a ${itemDefinition(product.requiredItemId).name.lowercase()} to make this item."
|
||||
)
|
||||
return@on true
|
||||
}
|
||||
|
||||
if (product == SilverProduct.SILVTHRILL_ROD || product == SilverProduct.SILVTHRIL_CHAIN) {
|
||||
sendMessage(player, "You can't do that yet.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
if (!hasLevelDyn(player, Skills.CRAFTING, product.minimumLevel)) {
|
||||
sendMessage(player, "You need a Crafting level of ${product.minimumLevel} to make this.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
when (opcode) {
|
||||
OP_MAKE_ONE -> make(player, product, 1)
|
||||
OP_MAKE_FIVE -> make(player, product, 5)
|
||||
OP_MAKE_ALL -> make(player, product, amountInInventory(player, Items.SILVER_BAR_2355))
|
||||
OP_MAKE_X -> sendInputDialogue(player, InputType.AMOUNT, "Enter the amount:") { value ->
|
||||
make(player, product, Integer.parseInt(value.toString()))
|
||||
}
|
||||
else -> return@on true
|
||||
}
|
||||
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.SCENERY, Items.SILVER_BAR_2355, *FURNACES) { player, _, with ->
|
||||
setAttribute(player, ATTRIBUTE_FURNACE_ID, with)
|
||||
openInterface(player, Components.CRAFTING_SILVER_CASTING_438)
|
||||
return@onUseWith true
|
||||
}
|
||||
}
|
||||
|
||||
private fun make(player: Player, product: SilverProduct, amount: Int) {
|
||||
closeInterface(player)
|
||||
|
||||
submitIndividualPulse(
|
||||
player,
|
||||
SilverCraftingPulse(
|
||||
player,
|
||||
product,
|
||||
getAttribute(player, ATTRIBUTE_FURNACE_ID, CoreScenery(-1, -1, 0)),
|
||||
amount
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package content.global.skill.crafting.silver
|
||||
|
||||
import core.api.*
|
||||
import core.game.event.ResourceProducedEvent
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.scenery.Scenery
|
||||
import core.game.system.task.Pulse
|
||||
import org.rs09.consts.Animations
|
||||
import org.rs09.consts.Items
|
||||
|
||||
/**
|
||||
* Handles tick-based silver crafting logic.
|
||||
*
|
||||
* @author vddCore
|
||||
*/
|
||||
class SilverCraftingPulse(
|
||||
private val player: Player,
|
||||
private val product: SilverProduct,
|
||||
private val furnace: Scenery,
|
||||
private var amount: Int
|
||||
) : Pulse() {
|
||||
override fun pulse(): Boolean {
|
||||
if (amount < 1) return true
|
||||
|
||||
if (!inInventory(player, product.requiredItemId) || !inInventory(player, Items.SILVER_BAR_2355)) {
|
||||
return true
|
||||
}
|
||||
|
||||
animate(player, Animations.HUMAN_FURNACE_SMELTING_3243)
|
||||
|
||||
if (removeItem(player, Items.SILVER_BAR_2355, Container.INVENTORY)) {
|
||||
addItem(player, product.producedItemId, product.amountProduced)
|
||||
rewardXP(player, Skills.CRAFTING, product.xpReward)
|
||||
|
||||
player.dispatch(
|
||||
ResourceProducedEvent(
|
||||
product.producedItemId,
|
||||
product.amountProduced,
|
||||
furnace,
|
||||
Items.SILVER_BAR_2355
|
||||
)
|
||||
)
|
||||
} else return true
|
||||
|
||||
amount--
|
||||
delay = 5
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package content.global.skill.crafting.silver
|
||||
|
||||
import org.rs09.consts.Items
|
||||
|
||||
private const val BUTTON_UNBLESSED = 16
|
||||
private const val BUTTON_UNHOLY = 23
|
||||
private const val BUTTON_SICKLE = 30
|
||||
private const val BUTTON_TIARA = 44
|
||||
private const val BUTTON_DEMONIC_SIGIL = 59
|
||||
private const val BUTTON_SILVTHRIL_CHAIN = 73
|
||||
private const val BUTTON_LIGHTNING_ROD = 37
|
||||
private const val BUTTON_SILVTHRILL_ROD = 52
|
||||
private const val BUTTON_CROSSBOW_BOLTS = 66
|
||||
|
||||
/**
|
||||
* Provides silver crafting product definitions.
|
||||
*
|
||||
* @author vddCore
|
||||
*/
|
||||
enum class SilverProduct(
|
||||
val buttonId: Int,
|
||||
val requiredItemId: Int,
|
||||
val producedItemId: Int,
|
||||
val amountProduced: Int,
|
||||
val minimumLevel: Int,
|
||||
val xpReward: Double,
|
||||
val strungId: Int
|
||||
) {
|
||||
HOLY(BUTTON_UNBLESSED, Items.HOLY_MOULD_1599, Items.UNSTRUNG_SYMBOL_1714, 1, 16, 50.0, Items.UNBLESSED_SYMBOL_1716),
|
||||
UNHOLY(BUTTON_UNHOLY, Items.UNHOLY_MOULD_1594, Items.UNSTRUNG_EMBLEM_1720, 1, 17, 50.0, Items.UNHOLY_SYMBOL_1724),
|
||||
SICKLE(BUTTON_SICKLE, Items.SICKLE_MOULD_2976, Items.SILVER_SICKLE_2961, 1, 18, 50.0, -1),
|
||||
TIARA(BUTTON_TIARA, Items.TIARA_MOULD_5523, Items.TIARA_5525, 1, 23, 52.5, -1),
|
||||
SILVTHRIL_CHAIN(BUTTON_SILVTHRIL_CHAIN, Items.CHAIN_LINK_MOULD_13153, Items.SILVTHRIL_CHAIN_13154, 1, 47, 100.0, -1),
|
||||
LIGHTNING_ROD(BUTTON_LIGHTNING_ROD, Items.CONDUCTOR_MOULD_4200, Items.CONDUCTOR_4201, 1, 20, 50.0, -1),
|
||||
SILVTHRILL_ROD(BUTTON_SILVTHRILL_ROD, Items.ROD_CLAY_MOULD_7649, Items.SILVTHRILL_ROD_7637, 1, 25, 55.0, -1),
|
||||
CROSSBOW_BOLTS(BUTTON_CROSSBOW_BOLTS, Items.BOLT_MOULD_9434, Items.SILVER_BOLTS_UNF_9382, 10, 21, 50.0, -1);
|
||||
|
||||
companion object {
|
||||
private val BUTTON_MAP = HashMap<Int, SilverProduct>()
|
||||
private val PRODUCT_MAP = HashMap<Int, SilverProduct>()
|
||||
|
||||
init {
|
||||
for (product in SilverProduct.values()) {
|
||||
BUTTON_MAP[product.buttonId] = product
|
||||
}
|
||||
|
||||
for (product in SilverProduct.values()) {
|
||||
PRODUCT_MAP[product.producedItemId] = product
|
||||
}
|
||||
}
|
||||
|
||||
fun forButtonID(buttonId: Int): SilverProduct? = BUTTON_MAP[buttonId]
|
||||
fun forProductID(productId: Int): SilverProduct? = PRODUCT_MAP[productId]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package content.global.skill.crafting.silver
|
||||
|
||||
import core.api.addItem
|
||||
import core.api.removeItem
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import org.rs09.consts.Items
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.IntType
|
||||
|
||||
/**
|
||||
* Handles ball of wool <-> stringable silver items interaction.
|
||||
*
|
||||
* @author vddCore
|
||||
*/
|
||||
class SilverStringingListener : InteractionListener {
|
||||
companion object {
|
||||
private val STRINGABLE_PRODUCTS = intArrayOf(
|
||||
Items.UNSTRUNG_SYMBOL_1714,
|
||||
Items.UNSTRUNG_EMBLEM_1720
|
||||
)
|
||||
}
|
||||
|
||||
private fun stringSilverProduct(player: Player, used: Node, with: Node): Boolean {
|
||||
SilverProduct.forProductID(with.id)?.let {
|
||||
if (removeItem(player, with.id) && removeItem(player, used.id)) {
|
||||
addItem(player, it.strungId)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.ITEM, Items.BALL_OF_WOOL_1759, *STRINGABLE_PRODUCTS, handler = ::stringSilverProduct)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package content.global.skill.crafting.spinning;
|
||||
|
||||
/**
|
||||
* Represents an item to be spinned.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum SpinningItem {
|
||||
WOOL(19, 1737, 1759, 1, 2.5), FLAX(17, 1779, 1777, 10, 15), ROOT(23, 6051, 6038, 19, 30), ROOT1(23, 6043, 6038, 19, 30), ROOT2(23, 6045, 6038, 19, 30), ROOT3(23, 6047, 6038, 19, 30), ROOT4(23, 6049, 6038, 19, 30), ROOT5(23, 6053, 6038, 19, 30), SINEW(27, 9436, 9438, 10, 15), TREE_ROOTS(31, 6043, 9438, 10, 15), YACK(35, 10814, 954, 30, 25);
|
||||
|
||||
/**
|
||||
* The button id.
|
||||
*/
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* The needed item.
|
||||
*/
|
||||
private final int need;
|
||||
|
||||
/**
|
||||
* The product.
|
||||
*/
|
||||
private final int product;
|
||||
|
||||
/**
|
||||
* The level required.
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
/**
|
||||
* The exp gained.
|
||||
*/
|
||||
private final double exp;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SpinningItem} {@code Object}.
|
||||
* @param button the button.
|
||||
* @param need the needed item id.
|
||||
* @param product the product.
|
||||
* @param level the level.
|
||||
* @param exp the exp.
|
||||
*/
|
||||
SpinningItem(int button, int need, int product, int level, double exp) {
|
||||
this.button = button;
|
||||
this.need = need;
|
||||
this.product = product;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spinning item.
|
||||
* @param id the id.
|
||||
* @return the item.
|
||||
*/
|
||||
public static SpinningItem forId(int id) {
|
||||
for (SpinningItem spin : SpinningItem.values()) {
|
||||
if (spin.button == id) {
|
||||
return spin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the button.
|
||||
* @return The button.
|
||||
*/
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the need.
|
||||
* @return The need.
|
||||
*/
|
||||
public int getNeed() {
|
||||
return need;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product.
|
||||
* @return The product.
|
||||
*/
|
||||
public int getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level.
|
||||
* @return The level.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exp.
|
||||
* @return The exp.
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package content.global.skill.crafting.spinning;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.node.entity.skill.SkillPulse;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the pulse used to spin an item.
|
||||
*
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class SpinningPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(896);
|
||||
|
||||
/**
|
||||
* Represents the type of spinning item.
|
||||
*/
|
||||
private final SpinningItem type;
|
||||
|
||||
/**
|
||||
* Represents the amount to spin.
|
||||
*/
|
||||
private int ammount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SpinningPulse.java} {@Code Object}
|
||||
*
|
||||
* @param player
|
||||
* @param node
|
||||
*/
|
||||
public SpinningPulse(Player player, Item node, int ammount, SpinningItem def) {
|
||||
super(player, node);
|
||||
this.type = def;
|
||||
this.ammount = ammount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
player.getInterfaceManager().close();
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + type.getLevel() + " to make this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(type.getNeed(), 1)) {
|
||||
player.getPacketDispatch().sendMessage("You need " + ItemDefinition.forId(type.getNeed()).getName() + " to do this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
int tickThreshhold = 4;
|
||||
if (player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(2)
|
||||
&& player.getLocation().withinDistance(Location.create(2711,3471,1))
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
|
||||
tickThreshhold = 2;
|
||||
}
|
||||
if (++ticks % tickThreshhold != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(type.getNeed(), 1))) {
|
||||
final Item item = new Item(type.getProduct(), 1);
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, type.getExp(), true);
|
||||
|
||||
// Seers achievement diary
|
||||
if (player.getViewport().getRegion().getId() == 10806
|
||||
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0, 4)) {
|
||||
if (player.getAttribute("diary:seers:bowstrings-spun", 0) >= 4) {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", 5);
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 4);
|
||||
} else {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", player.getAttribute("diary:seers:bowstrings-spun", 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ammount--;
|
||||
return ammount < 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(int type) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user