Improved superglass make behavior (bushtail)
This commit is contained in:
-123
@@ -1,123 +0,0 @@
|
|||||||
package core.game.node.entity.skill.magic.lunar;
|
|
||||||
|
|
||||||
import core.game.node.entity.skill.Skills;
|
|
||||||
import core.game.node.entity.skill.magic.MagicSpell;
|
|
||||||
import core.game.node.entity.skill.magic.Runes;
|
|
||||||
import core.game.node.Node;
|
|
||||||
import core.game.node.entity.Entity;
|
|
||||||
import core.game.node.entity.combat.equipment.SpellType;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.node.entity.player.link.audio.Audio;
|
|
||||||
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
|
|
||||||
import core.game.node.item.Item;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.game.world.update.flag.context.Graphics;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
import core.tools.RandomFunction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The super glass make spell.
|
|
||||||
* @author 'Vexia
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class SuperglassMakeSpell extends MagicSpell {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the animation of this spell.
|
|
||||||
*/
|
|
||||||
private static final Animation ANIMATION = Animation.create(4413);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the graphics of this spell.
|
|
||||||
*/
|
|
||||||
private static final Graphics GRAPHIC = new Graphics(729, 120);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the bucket of sand item.
|
|
||||||
*/
|
|
||||||
private static final Item BUCKET_OF_SAND = new Item(1783);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the molten glass item.
|
|
||||||
*/
|
|
||||||
private static final Item MOLTEN_GLASS = new Item(1775);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The set of items to be used with sand.
|
|
||||||
*/
|
|
||||||
private static final Item[] SETS = new Item[] { new Item(1781), new Item(401), new Item(10978) };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code SuperglassMakeSpell} {@code Object}.
|
|
||||||
*/
|
|
||||||
public SuperglassMakeSpell() {
|
|
||||||
super(SpellBook.LUNAR, 77, 78, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.FIRE_RUNE.getId(), 6), new Item(Runes.AIR_RUNE.getId(), 10) });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
|
|
||||||
SpellBook.LUNAR.register(25, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean cast(Entity entity, Node target) {
|
|
||||||
final Player player = ((Player) entity);
|
|
||||||
int setIndex = getSetIndex(player);
|
|
||||||
int sand = player.getInventory().getAmount(BUCKET_OF_SAND);
|
|
||||||
if (setIndex == -1) {
|
|
||||||
player.getPacketDispatch().sendMessage("You don't have the required ingredients.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!super.meetsRequirements(player, true, true)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
player.lock(4);
|
|
||||||
player.graphics(GRAPHIC);
|
|
||||||
player.animate(ANIMATION);
|
|
||||||
player.getAudioManager().send(2896, 1, 1);
|
|
||||||
for (int i = 0; i < sand; i++) {
|
|
||||||
if (hasSet(player, setIndex)) {
|
|
||||||
if (player.getInventory().remove(BUCKET_OF_SAND, SETS[setIndex])) {
|
|
||||||
player.getInventory().add(MOLTEN_GLASS);
|
|
||||||
// https://runescape.wiki/w/Superglass_Make?oldid=1970761
|
|
||||||
// "On average, each set will produce 1.30 pieces of molten glass"
|
|
||||||
if(RandomFunction.randomDouble(1.0) < 0.3) {
|
|
||||||
player.getInventory().add(MOLTEN_GLASS);
|
|
||||||
}
|
|
||||||
player.getSkills().addExperience(Skills.CRAFTING, 10, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the player has the set.
|
|
||||||
* @param player the player.
|
|
||||||
* @param index the index.
|
|
||||||
* @return {@code True} if so.
|
|
||||||
*/
|
|
||||||
public boolean hasSet(final Player player, final int index) {
|
|
||||||
return player.getInventory().containsItem(BUCKET_OF_SAND) && player.getInventory().containsItem(SETS[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the set index.
|
|
||||||
* @param player the player.
|
|
||||||
* @return the index.s
|
|
||||||
*/
|
|
||||||
public int getSetIndex(final Player player) {
|
|
||||||
if (!player.getInventory().containsItem(BUCKET_OF_SAND)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < SETS.length; i++) {
|
|
||||||
if (player.getInventory().containsItem(SETS[i])) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package rs09.game.node.entity.skill.magic
|
||||||
|
|
||||||
|
import core.game.world.update.flag.context.Animation
|
||||||
|
import core.game.world.update.flag.context.Graphics
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
|
val BAKE_PIE_ANIM = Animation(4413)
|
||||||
|
val BAKE_PIE_GFX = Graphics(746,75)
|
||||||
|
val STATSPY_ANIM = Animation(6293)
|
||||||
|
val STATSPY_GFX = Graphics(1059)
|
||||||
|
val CURE_PLANT_ANIM = Animation(4409)
|
||||||
|
val CURE_PLANT_GFX = Graphics(742,100)
|
||||||
|
val NPC_CONTACT_ANIM = Animation(4413)
|
||||||
|
val NPC_CONTACT_GFX = Graphics(730,130)
|
||||||
|
val PLANK_MAKE_ANIM = Animation(6298)
|
||||||
|
val PLANK_MAKE_GFX = Graphics(1063, 120)
|
||||||
|
val STRING_JEWELLERY_ANIM = Animation(4412)
|
||||||
|
val STRING_JEWELLERY_GFX = Graphics(728, 100)
|
||||||
|
val SUPERGLASS_MAKE_ANIM = Animation(4413)
|
||||||
|
val SUPERGLASS_MAKE_GFX = Graphics(729, 120)
|
||||||
|
|
||||||
|
|
||||||
|
enum class JewelleryString(val unstrung: Int, val strung: Int) {
|
||||||
|
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
|
||||||
|
SAPPHIRE(Items.SAPPHIRE_AMULET_1675, Items.SAPPHIRE_AMULET_1694),
|
||||||
|
EMERALD(Items.EMERALD_AMULET_1677, Items.EMERALD_AMULET_1696),
|
||||||
|
RUBY(Items.RUBY_AMULET_1679, Items.RUBY_AMULET_1698),
|
||||||
|
DIAMOND(Items.DIAMOND_AMULET_1681, Items.DIAMOND_AMULET_1700),
|
||||||
|
DRAGONSTONE(Items.DRAGONSTONE_AMMY_1683, Items.DRAGONSTONE_AMMY_1702),
|
||||||
|
ONYX(Items.ONYX_AMULET_6579, Items.ONYX_AMULET_6581),
|
||||||
|
SALVE(Items.SALVE_SHARD_4082, Items.SALVE_AMULET_4081),
|
||||||
|
HOLY(Items.UNSTRUNG_SYMBOL_1714, Items.UNBLESSED_SYMBOL_1716),
|
||||||
|
UNHOLY(Items.UNSTRUNG_EMBLEM_1720, Items.UNPOWERED_SYMBOL_1722);
|
||||||
|
companion object {
|
||||||
|
val productOfString = values().associate { it.unstrung to it.strung }
|
||||||
|
fun forId(id : Int) : Int {
|
||||||
|
return productOfString[id]!!
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unstrungContains(id: Int): Boolean {
|
||||||
|
return productOfString.contains(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,27 +15,14 @@ import core.game.world.map.Location
|
|||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.game.world.update.flag.context.Animation
|
import core.game.world.update.flag.context.Animation
|
||||||
import core.game.world.update.flag.context.Graphics
|
import core.game.world.update.flag.context.Graphics
|
||||||
|
import core.tools.RandomFunction
|
||||||
import org.rs09.consts.Components
|
import org.rs09.consts.Components
|
||||||
import org.rs09.consts.Items
|
import org.rs09.consts.Items
|
||||||
import rs09.game.node.entity.skill.farming.FarmingPatch
|
import rs09.game.node.entity.skill.farming.FarmingPatch
|
||||||
import rs09.game.node.entity.skill.magic.LunarListeners.JewelleryString.Companion.productOfString
|
|
||||||
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
|
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
|
||||||
import rs09.game.system.config.NPCConfigParser
|
import rs09.game.system.config.NPCConfigParser
|
||||||
import java.util.Deque
|
|
||||||
|
|
||||||
class LunarListeners : SpellListener("lunar") {
|
class LunarListeners : SpellListener("lunar") {
|
||||||
private val BAKE_PIE_ANIM = Animation(4413)
|
|
||||||
private val BAKE_PIE_GFX = Graphics(746,75)
|
|
||||||
private val STATSPY_ANIM = Animation(6293)
|
|
||||||
private val STATSPY_GFX = Graphics(1059)
|
|
||||||
private val CURE_PLANT_ANIM = Animation(4409)
|
|
||||||
private val CURE_PLANT_GFX = Graphics(742,100)
|
|
||||||
private val NPC_CONTACT_ANIM = Animation(4413)
|
|
||||||
private val NPC_CONTACT_GFX = Graphics(730,130)
|
|
||||||
private val PLANK_MAKE_ANIM = Animation(6298)
|
|
||||||
private val PLANK_MAKE_GFX = Graphics(1063, 120)
|
|
||||||
private val STRING_JEWELLERY_ANIM = Animation(4412)
|
|
||||||
private val STRING_JEWELLERY_GFX = Graphics(728, 100)
|
|
||||||
|
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
|
|
||||||
@@ -166,8 +153,14 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCast(Lunar.STRING_JEWELLERY, NONE) { player, _ ->
|
onCast(Lunar.STRING_JEWELLERY, NONE) { player, _ ->
|
||||||
|
requires(player, 80, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.EARTH_RUNE_557, 10), Item(Items.WATER_RUNE_555, 5)))
|
||||||
stringJewellery(player)
|
stringJewellery(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCast(Lunar.SUPERGLASS_MAKE, NONE) {player, _ ->
|
||||||
|
requires(player, 77, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.FIRE_RUNE_554, 6), Item(Items.AIR_RUNE_556, 10)))
|
||||||
|
superglassMake(player)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun plankMake(player: Player, item: Item) {
|
private fun plankMake(player: Player, item: Item) {
|
||||||
@@ -336,8 +329,6 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
playerJewellery.add(item)
|
playerJewellery.add(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
player.pulseManager.run(object : Pulse() {
|
player.pulseManager.run(object : Pulse() {
|
||||||
var counter = 0
|
var counter = 0
|
||||||
override fun pulse(): Boolean {
|
override fun pulse(): Boolean {
|
||||||
@@ -353,6 +344,7 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
rewardXP(player, Skills.CRAFTING, 4.0)
|
rewardXP(player, Skills.CRAFTING, 4.0)
|
||||||
addXP(player, 83.0)
|
addXP(player, 83.0)
|
||||||
playerJewellery.remove(item)
|
playerJewellery.remove(item)
|
||||||
|
if(playerJewellery.isNotEmpty()) removeRunes(player,false) else removeRunes(player,true)
|
||||||
}
|
}
|
||||||
counter++
|
counter++
|
||||||
return playerJewellery.isEmpty()
|
return playerJewellery.isEmpty()
|
||||||
@@ -360,27 +352,45 @@ class LunarListeners : SpellListener("lunar") {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum class JewelleryString(val unstrung : Int, val strung : Int) {
|
private fun superglassMake(player: Player) {
|
||||||
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
|
val GLASSWEED = hashSetOf(Items.SODA_ASH_1781, Items.SEAWEED_401, Items.SWAMP_WEED_10978)
|
||||||
SAPPHIRE(Items.SAPPHIRE_AMULET_1675, Items.SAPPHIRE_AMULET_1694),
|
val inv = player.inventory.toArray()
|
||||||
EMERALD(Items.EMERALD_AMULET_1677, Items.EMERALD_AMULET_1696),
|
var playerWeed: Int = amountInInventory(player, Items.SODA_ASH_1781) + amountInInventory(player, Items.SEAWEED_401) + amountInInventory(player, Items.SWAMP_WEED_10978)
|
||||||
RUBY(Items.RUBY_AMULET_1679, Items.RUBY_AMULET_1698),
|
var playerSand: Int = amountInInventory(player, Items.BUCKET_OF_SAND_1783)
|
||||||
DIAMOND(Items.DIAMOND_AMULET_1681, Items.DIAMOND_AMULET_1700),
|
var index: Int = 0
|
||||||
DRAGONSTONE(Items.DRAGONSTONE_AMMY_1683, Items.DRAGONSTONE_AMMY_1702),
|
|
||||||
ONYX(Items.ONYX_AMULET_6579, Items.ONYX_AMULET_6581),
|
|
||||||
SALVE(Items.SALVE_SHARD_4082, Items.SALVE_AMULET_4081),
|
|
||||||
HOLY(Items.UNSTRUNG_SYMBOL_1714, Items.UNBLESSED_SYMBOL_1716),
|
|
||||||
UNHOLY(Items.UNSTRUNG_EMBLEM_1720, Items.UNPOWERED_SYMBOL_1722);
|
|
||||||
companion object {
|
|
||||||
val productOfString = values().associate { it.unstrung to it.strung }
|
|
||||||
fun forId(id : Int) : Int {
|
|
||||||
return productOfString[id]!!
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unstrungContains(id : Int) : Boolean {
|
fun addMolten(): Boolean {
|
||||||
return productOfString.contains(id)
|
if(RandomFunction.randomDouble(1.0) < 0.3) {
|
||||||
|
if(addItem(player, Items.MOLTEN_GLASS_1775, 2)) return true
|
||||||
|
} else {
|
||||||
|
if(addItem(player, Items.MOLTEN_GLASS_1775)) return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
val size = minOf(playerSand, playerWeed)
|
||||||
|
|
||||||
|
if(index != size && size != 0) {
|
||||||
|
for (item in inv) {
|
||||||
|
if (item == null) continue
|
||||||
|
if (index == size) break
|
||||||
|
if (GLASSWEED.contains(item.id)) {
|
||||||
|
if (removeItem(player, item) && removeItem(player, Items.BUCKET_OF_SAND_1783) && addMolten()) {
|
||||||
|
index++
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (playerWeed == 0 || playerSand == 0 || size == 0) {
|
||||||
|
sendMessage(player, "You lack the required ingredients.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index == size && size != 0) {
|
||||||
|
removeRunes(player, true)
|
||||||
|
visualizeSpell(player, SUPERGLASS_MAKE_ANIM, SUPERGLASS_MAKE_GFX, 2896)
|
||||||
|
rewardXP(player, Skills.CRAFTING, 10.0)
|
||||||
|
addXP(player, 78.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ object Lunar {
|
|||||||
const val CATHERBY_TELEPORT = 21
|
const val CATHERBY_TELEPORT = 21
|
||||||
const val STRING_JEWELLERY = 22
|
const val STRING_JEWELLERY = 22
|
||||||
const val WATERBIRTH_TELEPORT = 24
|
const val WATERBIRTH_TELEPORT = 24
|
||||||
|
const val SUPERGLASS_MAKE = 25
|
||||||
const val ICE_PLATEAU_TELEPORT = 28
|
const val ICE_PLATEAU_TELEPORT = 28
|
||||||
const val OURANIA_TELEPORT = 31
|
const val OURANIA_TELEPORT = 31
|
||||||
const val CURE_PLANT = 32
|
const val CURE_PLANT = 32
|
||||||
|
|||||||
Reference in New Issue
Block a user