Rewrote molten glass blowing
Fixed animations Timing has been corrected, now takes 2 ticks instead of 3
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package content.global.bots
|
||||
|
||||
import content.global.handlers.iface.GlassInterface
|
||||
import content.global.skill.crafting.glass.GlassCraftingPulse
|
||||
import content.global.skill.crafting.glass.GlassProduct
|
||||
import core.game.bots.Script
|
||||
import core.game.bots.SkillingBotAssembler
|
||||
import core.game.node.entity.skill.Skills
|
||||
import content.global.skill.crafting.GlassProduct
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import core.game.bots.SkillingBotAssembler
|
||||
import core.game.bots.Script
|
||||
|
||||
class GlassBlowingBankstander : Script(){
|
||||
var state = State.BLOWING
|
||||
@@ -17,7 +17,7 @@ class GlassBlowingBankstander : Script(){
|
||||
State.BLOWING -> {
|
||||
bot.inventory.add(Item(Items.GLASSBLOWING_PIPE_1785))
|
||||
bot.inventory.add(Item(Items.MOLTEN_GLASS_1775,27))
|
||||
GlassInterface.make(bot, GlassProduct.ORB,27)
|
||||
bot.pulseManager.run(GlassCraftingPulse(bot, GlassProduct.ORB, 27))
|
||||
State.BANKING
|
||||
}
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
package content.global.handlers.iface;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
import core.game.component.Component;
|
||||
import core.game.component.ComponentDefinition;
|
||||
import core.game.component.ComponentPlugin;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import content.global.skill.crafting.GlassProduct;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import kotlin.Unit;
|
||||
import org.rs09.consts.Sounds;
|
||||
|
||||
/**
|
||||
* Represents the glass making interface plugin.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public final class GlassInterface extends ComponentPlugin {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(884);
|
||||
|
||||
/**
|
||||
* Represents the molten glass item.
|
||||
*/
|
||||
private static final Item MOLTEN_GLASS = new Item(1775);
|
||||
|
||||
/**
|
||||
* Represents the soda ash item.
|
||||
*/
|
||||
private static final Item SODA_ASH = new Item(1781, 1);
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ComponentDefinition.put(542, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final Player p, Component component, int opcode, int button, int slot, int itemId) {
|
||||
final GlassProduct def = GlassProduct.forId(button);
|
||||
if (def == null) {
|
||||
return true;
|
||||
}
|
||||
if (!p.getInventory().contains(1785, 1)) {
|
||||
p.getPacketDispatch().sendMessage("You need a glassblowing pipe to do this.");
|
||||
return true;
|
||||
}
|
||||
if (!p.getInventory().contains(1775, 1)) {
|
||||
p.getPacketDispatch().sendMessage("You need molten glass to do this.");
|
||||
return true;
|
||||
}
|
||||
if (p.getSkills().getLevel(Skills.CRAFTING) < def.getLevel()) {
|
||||
p.getPacketDispatch().sendMessage("You need a crafting level of " + def.getLevel() + " to make this.");
|
||||
return true;
|
||||
}
|
||||
int real = -1;
|
||||
switch (opcode) {
|
||||
case 230:
|
||||
real = 1;
|
||||
break;
|
||||
case 205:
|
||||
real = 5;
|
||||
break;
|
||||
case 127:
|
||||
real = p.getInventory().getAmount(MOLTEN_GLASS);
|
||||
break;
|
||||
case 211:
|
||||
sendInputDialogue(p, true, "Enter the amount:", (value) -> {
|
||||
make(p, def, (int) value);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (opcode == 211) {
|
||||
return true;
|
||||
}
|
||||
make(p, def, real);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to make a glass product.
|
||||
* @param player the player.
|
||||
* @param glass the glass.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public static void make(final Player player, final GlassProduct glass, final int amount) {
|
||||
player.getInterfaceManager().close();
|
||||
player.animate(ANIMATION);
|
||||
player.getPulseManager().clear();
|
||||
player.getPulseManager().run(new Pulse(2, player) {
|
||||
int amt = amount;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (!player.getInventory().contains(1775, 1) || amt == 0) {
|
||||
return true;
|
||||
}
|
||||
player.animate(ANIMATION);
|
||||
playAudio(player, Sounds.GLASSBLOWING_2724);
|
||||
player.getInventory().remove(MOLTEN_GLASS);
|
||||
player.getInventory().add(new Item(glass.getProduct(), 1));
|
||||
player.getSkills().addExperience(Skills.CRAFTING, glass.getExperience(), true);
|
||||
player.getPacketDispatch().sendMessage("You make a " + new Item(glass.getProduct()).getName().toLowerCase().replace("unpowered", "").trim() + ".");
|
||||
amt--;
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package content.global.handlers.item.withitem;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import content.global.skill.crafting.GlassProduct;
|
||||
import core.game.interaction.NodeUsageEvent;
|
||||
import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents the plugin used to make glass.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
@Initializable
|
||||
public class MakeGlassInterfacePlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MakeGlassInterfacePlugin} {@code Object}.
|
||||
*/
|
||||
public MakeGlassInterfacePlugin() {
|
||||
super(1775);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1785, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
event.getPlayer().getInterfaceManager().open(new Component(542));
|
||||
final Player player = event.getPlayer();
|
||||
switch (GlassProduct.BEER) {
|
||||
case BEER:
|
||||
break;
|
||||
case CANDLE:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 4)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Candle lantern</col>", 542, 25);
|
||||
break;
|
||||
case FISHBOWL:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 42)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Fish Bowl</col>", 542, 28);
|
||||
break;
|
||||
case LANTERN_LENS:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 49)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Lantern lens</col>", 542, 27);
|
||||
break;
|
||||
case OIL_LAMP:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 12)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Oil lamp</col>", 542, 26);
|
||||
break;
|
||||
case ORB:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 46)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Unpowered orb</col>", 542, 23);
|
||||
break;
|
||||
case VIAL:
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < 33)
|
||||
player.getPacketDispatch().sendString("<col=FF8000>Vial</col>", 542, 22);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
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,69 @@
|
||||
package content.global.skill.crafting.glass
|
||||
|
||||
import core.api.*
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.InterfaceListener
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import org.rs09.consts.Components
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class GlassCraftingListener : InteractionListener, InterfaceListener {
|
||||
|
||||
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 const val GLASS_BLOWING_PIPE = Items.GLASSBLOWING_PIPE_1785
|
||||
private const val MOLTEN_GLASS = Items.MOLTEN_GLASS_1775
|
||||
private const val GLASS_BLOWING_INTERFACE = Components.CRAFTING_GLASS_542
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.ITEM, GLASS_BLOWING_PIPE, MOLTEN_GLASS) { player, _, _ ->
|
||||
openInterface(player, GLASS_BLOWING_INTERFACE)
|
||||
return@onUseWith true
|
||||
}
|
||||
}
|
||||
|
||||
override fun defineInterfaceListeners() {
|
||||
on(GLASS_BLOWING_INTERFACE) { player, _, opcode, buttonID, _, _ ->
|
||||
val product = GlassProduct.forButtonID(buttonID) ?: return@on true
|
||||
|
||||
if (!inInventory(player, GLASS_BLOWING_PIPE)) {
|
||||
sendMessage(player, "You need a glassblowing pipe to do this.")
|
||||
return@on true
|
||||
}
|
||||
|
||||
if (!inInventory(player, MOLTEN_GLASS)) {
|
||||
sendMessage(player, "You need molten glass to do this.")
|
||||
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, MOLTEN_GLASS))
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
private fun make(player: Player, product: GlassProduct, amount: Int) {
|
||||
closeInterface(player)
|
||||
submitIndividualPulse(player, GlassCraftingPulse(player, product, amount))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package content.global.skill.crafting.glass
|
||||
|
||||
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.system.task.Pulse
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Sounds
|
||||
|
||||
class GlassCraftingPulse(
|
||||
private val player: Player,
|
||||
private val product: GlassProduct,
|
||||
private var amount: Int
|
||||
) : Pulse() {
|
||||
|
||||
override fun pulse(): Boolean {
|
||||
if (amount < 1) return true
|
||||
|
||||
if (!inInventory(player, Items.GLASSBLOWING_PIPE_1785) || !inInventory(player, Items.MOLTEN_GLASS_1775)) {
|
||||
return true
|
||||
}
|
||||
|
||||
//Animation is updated on 2 June 2009 - https://runescape.wiki/w/Update:Patch_Notes_(2_June_2009)
|
||||
animate(player, 884)
|
||||
playAudio(player, Sounds.GLASSBLOWING_2724)
|
||||
if (product.producedItemId in intArrayOf(Items.UNPOWERED_ORB_567, Items.OIL_LAMP_4525)) {
|
||||
sendMessage(player, "You make an ${product.name.lowercase().replace("_", " ")}.")
|
||||
|
||||
} else sendMessage(player, "You make a ${product.name.lowercase().replace("_", " ")}.")
|
||||
|
||||
if (removeItem(player, Items.MOLTEN_GLASS_1775)) {
|
||||
addItem(player, product.producedItemId, product.amount)
|
||||
rewardXP(player, Skills.CRAFTING, product.experience)
|
||||
player.dispatch(ResourceProducedEvent(product.producedItemId, product.amount, player))
|
||||
|
||||
} else return true
|
||||
|
||||
amount--
|
||||
delay = 3
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package content.global.skill.crafting.glass
|
||||
|
||||
import core.api.*
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import org.rs09.consts.Items
|
||||
import kotlin.math.min
|
||||
|
||||
class GlassMakeListener : InteractionListener {
|
||||
|
||||
companion object{
|
||||
private const val SODA_ASH = Items.SODA_ASH_1781
|
||||
private const val BUCKET_OF_SAND = Items.BUCKET_OF_SAND_1783
|
||||
private const val MOLTEN_GLASS = Items.MOLTEN_GLASS_1775
|
||||
private val INPUTS = intArrayOf(SODA_ASH, BUCKET_OF_SAND)
|
||||
private val FURNACES = intArrayOf(4304, 6189, 9390, 11010, 11666, 12100, 12809, 18497, 26814, 30021, 30510, 36956, 37651)
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.SCENERY, INPUTS, *FURNACES){ player, _, _ ->
|
||||
|
||||
if (!inInventory(player, SODA_ASH, 1) || !inInventory(player, BUCKET_OF_SAND, 1)) {
|
||||
sendMessage(player, "You need at least one heap of soda ash and one bucket of sand to do this.")
|
||||
return@onUseWith true
|
||||
}
|
||||
|
||||
sendSkillDialogue(player) {
|
||||
withItems(MOLTEN_GLASS)
|
||||
create { id, amount ->
|
||||
submitIndividualPulse(player, GlassMakePulse(player, id, amount))
|
||||
}
|
||||
calculateMaxAmount { _ ->
|
||||
min(amountInInventory(player, SODA_ASH), amountInInventory(player, BUCKET_OF_SAND))
|
||||
}
|
||||
}
|
||||
|
||||
return@onUseWith true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package content.global.skill.crafting.glass
|
||||
|
||||
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.system.task.Pulse
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class GlassMakePulse(
|
||||
private val player: Player,
|
||||
private val product: Int,
|
||||
private var amount: Int
|
||||
) : Pulse() {
|
||||
|
||||
override fun pulse(): Boolean {
|
||||
if (amount < 1) return true
|
||||
|
||||
if (!inInventory(player, Items.SODA_ASH_1781) || !inInventory(player, Items.BUCKET_OF_SAND_1783)) {
|
||||
return true
|
||||
}
|
||||
|
||||
animate(player, 3243)
|
||||
//Audio unknown (2725?)
|
||||
sendMessage(player, "You heat the sand and soda ash in the furnace to make glass.")
|
||||
|
||||
if (removeItem(player, Items.SODA_ASH_1781) && removeItem(player, Items.BUCKET_OF_SAND_1783)) {
|
||||
addItem(player, Items.EMPTY_BUCKET_3727)
|
||||
addItem(player, Items.MOLTEN_GLASS_1775)
|
||||
rewardXP(player, Skills.CRAFTING, 20.0)
|
||||
player.dispatch(ResourceProducedEvent(product, amount, player))
|
||||
|
||||
} else return true
|
||||
|
||||
amount--
|
||||
delay = 2
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package content.global.skill.crafting.glass
|
||||
|
||||
enum class GlassProduct (
|
||||
val buttonId: Int,
|
||||
val producedItemId: Int,
|
||||
val amount: Int,
|
||||
val minimumLevel: Int,
|
||||
val experience: Double
|
||||
) {
|
||||
VIAL(38, 229, 1, 33, 35.0),
|
||||
ORB(39, 567, 1, 46, 52.5),
|
||||
BEER_GLASS(40, 1919, 1, 1, 17.5),
|
||||
CANDLE_LANTERN(41, 4527, 1, 4, 19.0),
|
||||
OIL_LAMP(42, 4525, 1, 12, 25.0),
|
||||
LANTERN_LENS(43, 4542, 1, 49, 55.0),
|
||||
FISHBOWL(44, 6667, 1, 42, 42.5),
|
||||
LIGHT_ORB(45, 10973, 1, 87, 70.0);
|
||||
|
||||
companion object {
|
||||
private val BUTTON_MAP = HashMap<Int, GlassProduct>()
|
||||
private val PRODUCT_MAP = HashMap<Int, GlassProduct>()
|
||||
|
||||
init {
|
||||
for (product in GlassProduct.values()) {
|
||||
BUTTON_MAP[product.buttonId] = product
|
||||
}
|
||||
|
||||
for (product in GlassProduct.values()) {
|
||||
PRODUCT_MAP[product.producedItemId] = product
|
||||
}
|
||||
}
|
||||
|
||||
fun forButtonID(buttonId: Int): GlassProduct? = BUTTON_MAP[buttonId]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user