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:
Ceikry
2023-01-26 13:59:28 +00:00
committed by Ryan
parent e4b799c44a
commit a100affda2
3156 changed files with 24205 additions and 30585 deletions
@@ -0,0 +1,104 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.entity.skill.Skills;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the dream magic spell.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class DreamSpell extends MagicSpell {
/**
* Represents the starting animation.
*/
private static final Animation START = Animation.create(6295);
/**
* Represents the dreaming animation.
*/
private static final Animation DREAMING = Animation.create(6296);
/**
* Represents the end animation.
*/
private static final Animation END = Animation.create(6297);
/**
* Represents the graphics of this spell.
*/
private static final Graphics GRAPHIC = new Graphics(1056);
/**
* Constructs a new {@code CureOtherSpell} {@code Object}.
*/
public DreamSpell() {
super(SpellBook.LUNAR, 79, 82, null, null, null, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 1), new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.BODY_RUNE.getId(), 5) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(10, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player p = (Player) entity;
if (p.getSkills().getLifepoints() == p.getSkills().getStaticLevel(Skills.HITPOINTS)) {
p.getPacketDispatch().sendMessage("You have no need to cast this spell since your hitpoints are already full.");
return false;
}
if (!meetsRequirements(entity, true, true)) {
return false;
}
p.animate(START);
p.lock();
GameWorld.getPulser().submit(new Pulse(4, p) {
@Override
public boolean pulse() {
p.animate(DREAMING);
p.graphics(GRAPHIC);
p.unlock();
return true;
}
});
p.getPulseManager().run(new Pulse(18, p) {
@Override
public boolean pulse() {
p.graphics(GRAPHIC);
p.getSkills().heal(1);
if (p.getSkills().getLifepoints() == p.getSkills().getStaticLevel(Skills.HITPOINTS)) {
stop();
return true;
}
return false;
}
@Override
public void stop() {
super.stop();
p.graphics(new Graphics(-1));
p.animate(END);
}
});
return true;
}
}
@@ -0,0 +1,84 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.ImpactHandler.HitsplatType;
import core.game.node.entity.combat.spell.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;
/**
* Represents the energy transfer spell.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class EnergyTransferSpell extends MagicSpell {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(4411);
/**
* Repesents the graphic, next spells of this spell.
*/
private static final Graphics GRAPHICS = new Graphics(738, 90);
/**
* Constructs a new {@code EnergyTransferSpell} {@code Object}.
*/
public EnergyTransferSpell() {
super(SpellBook.LUNAR, 91, 100, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 3), new Item(Runes.LAW_RUNE.getId(), 2), new Item(Runes.NATURE_RUNE.getId(), 1) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(5, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
if (!(target instanceof Player)) {
return false;
}
final Player player = ((Player) entity);
if (!super.meetsRequirements(player, true, true)) {
return false;
}
final Player o = ((Player) target);
int hp = (int) Math.floor(player.getSkills().getLifepoints() * 0.10);
int run = hp;
if (run > (100 - o.getSettings().getRunEnergy())) {
run = (int) (100 - o.getSettings().getRunEnergy());
}
if (run < 0) {
run = 0;
}
o.getSettings().updateRunEnergy(-run);
player.getImpactHandler().manualHit(player, hp, HitsplatType.NORMAL, 2);
int energy = 100;
energy -= o.getSettings().getSpecialEnergy();
if (energy < 0) {
energy = 0;
}
if (energy > player.getSettings().getSpecialEnergy()) {
energy = player.getSettings().getSpecialEnergy();
}
o.getSettings().setSpecialEnergy(o.getSettings().getSpecialEnergy() + energy);
player.getSettings().setSpecialEnergy(player.getSettings().getSpecialEnergy() - energy);
player.animate(ANIMATION);
player.getAudioManager().send(new Audio (2885), true);
o.graphics(GRAPHICS);
return true;
}
}
@@ -0,0 +1,143 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.ImpactHandler.HitsplatType;
import core.game.node.entity.combat.spell.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.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Plugin;
import java.util.Iterator;
import java.util.List;
/**
* Represents the healing spell.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class HealSpell extends MagicSpell {
/**
* Represents the animation for this spell.
*/
private static final Animation ANIMATION = new Animation(4411);
/**
* Represents the graphics of this spell.
*/
private static final Graphics GRAPHICS = new Graphics(738, 90);
/**
* Represents the animation used for the group heal.
*/
private static final Animation ANIMATION_G = new Animation(1979);
/**
* Represents the graphics used for the group heal.
*/
private static final Graphics GRAPHICS_G = new Graphics(734, 90);
/**
* Constructs a new {@code HealSpell} {@code Object}.
*/
public HealSpell() {
/**
* empty.
*/
}
/**
* Constructs a new {@code HealSpell} {@code Object}.
*/
public HealSpell(int level, int experience, Item[] runes) {
super(SpellBook.LUNAR, level, experience, null, null, null, runes);
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(29, new HealSpell(92, 101, new Item[] { new Item(Runes.BLOOD_RUNE.getId(), 1), new Item(Runes.LAW_RUNE.getId(), 3), new Item(Runes.ASTRAL_RUNE.getId(), 3) }));
SpellBook.LUNAR.register(30, new HealSpell(92, 101, new Item[] { new Item(Runes.BLOOD_RUNE.getId(), 3), new Item(Runes.LAW_RUNE.getId(), 6), new Item(Runes.ASTRAL_RUNE.getId(), 4) }));
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = (Player) entity;
boolean group = getSpellId() == 30;
int eleven = (int) (player.getSkills().getStaticLevel(Skills.HITPOINTS) * 0.11);
if (player.getSkills().getLifepoints() < eleven) {
player.sendMessage("You need at least 11 percent of your original hitpoints in order to do this.");
return false;
}
if (!group) {
if (!(target instanceof Player)) {
return false;
}
final Player o = (Player) target;
player.face(o);
if (!o.isActive() || o.getLocks().isInteractionLocked()) {
player.getPacketDispatch().sendMessage("This player is busy.");
return false;
}
if (!o.getSettings().isAcceptAid()) {
player.getPacketDispatch().sendMessage("The player is not accepting any aid.");
return false;
}
if (o.getSkills().getLifepoints() == o.getSkills().getLevel(Skills.HITPOINTS)) {
player.getPacketDispatch().sendMessage("The player already has full hitpoints.");
return false;
}
if (!super.meetsRequirements(player, true, true)) {
return false;
}
int transfer = (int) (player.getSkills().getLifepoints() * 0.75);
player.getImpactHandler().manualHit(player, transfer, null);
o.getSkills().heal(transfer);
player.animate(ANIMATION);
player.getAudioManager().send(new Audio(2895), true);
o.getAudioManager().send(new Audio(2892), true);
o.graphics(GRAPHICS);
} else {
List<Player> players = RegionManager.getLocalPlayers(player, 1);
if (!super.meetsRequirements(player, true, true)) {
return false;
}
int percentage = (int) Math.ceil(player.getSkills().getLifepoints() * 0.75);
for (Iterator<Player> it = players.iterator(); it.hasNext();) {
Player p = it.next();
if (p == player || !p.getSettings().isAcceptAid() || !p.isActive() || p.getSkills().getLifepoints() == p.getSkills().getMaximumLifepoints()) {
it.remove();
}
}
if (players.isEmpty()) {
player.getPacketDispatch().sendMessage("There are no players around to replenish.");
return false;
}
if (percentage < 1) {
player.getPacketDispatch().sendMessage("You don't have enough hitpoints left to cast this spell.");
return false;
}
player.getImpactHandler().manualHit(player, percentage, HitsplatType.NORMAL);
player.animate(ANIMATION_G);
player.getAudioManager().send(new Audio(2894), true);
for (Player p : players) {
p.getAudioManager().send(new Audio(2892), true);
p.graphics(GRAPHICS_G);
p.getSkills().heal(percentage);
}
}
return true;
}
}
@@ -0,0 +1,90 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
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;
/**
* Represents the humidify spell.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class HumidifySpell extends MagicSpell {
/**
* Represents the animation of this graphics.
*/
private static final Animation ANIMATION = new Animation(6294);
/**
* Repesents the graphick, next spells of this spell.
*/
private static final Graphics GRAPHIC = new Graphics(1061);
/**
* Represents the empty vessels.
*/
private static final int[] EMPTY = { 229, 1831, 1829, 1827, 1825, 1925, 1923, 1935, 5331, 5332, 5333, 5334, 5335, 5337, 5338, 5339, 6667, 7688, 731, 1980, 434 };
/**
* Represents the full vessels.
*/
private static final int[] FULL = { 227, 1823, 1823, 1823, 1823, 1929, 1921, 1937, 5340, 5340, 5340, 5340, 5340, 5340, 5340, 5340, 6668, 7690, 732, 4458, 1761 };
/**
* Constructs a new {@code CureOtherSpell} {@code Object}.
*/
public HumidifySpell() {
super(SpellBook.LUNAR, 68, 65, ANIMATION, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 1), new Item(Runes.WATER_RUNE.getId(), 3), new Item(Runes.FIRE_RUNE.getId(), 1) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(7, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
Player p = (Player) entity;
boolean good = false;
for (int i = 0; i < EMPTY.length; i++) {
if (p.getInventory().contains(EMPTY[i], 1)) {
good = true;
break;
}
}
if (!good) {
p.sendMessage("You need something which holds water in order to do this spell.");
return false;
}
if (!super.meetsRequirements(p, true, true)) {
return false;
}
p.lock(ANIMATION.getDuration() + 1);
p.animate(ANIMATION);
p.graphics(GRAPHIC);
p.getAudioManager().send(3614);
for (int k = 0; k < 28; k++) {
for (int i = 0; i < 21; i++) {
if (p.getInventory().contains(EMPTY[i], 1)) {
if (p.getInventory().remove(new Item(EMPTY[i]))) {
p.getInventory().add(new Item(FULL[i]));
}
}
}
}
return true;
}
}
@@ -0,0 +1,97 @@
package content.global.skill.magic.lunar;
import core.cache.def.impl.ItemDefinition;
import core.plugin.Initializable;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
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.Plugin;
/**
* Represents the hunter kit spell.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class HunterKitSpell extends MagicSpell {
/**
* Represents the hunter kit.
*/
private static final Item KIT = new Item(11159);
/**
* Represents the animation of this graphics.
*/
private static final Animation ANIMATION = new Animation(6303);
/**
* Repesents the graphick, next spells of this spell.
*/
private static final Graphics GRAPHIC = new Graphics(1074);
/**
* Constructs a new {@code CureOtherSpell} {@code Object}.
*/
public HunterKitSpell() {
super(SpellBook.LUNAR, 71, 70, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 2) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(8, this);
ItemDefinition.forId(KIT.getId()).getHandlers().put("option:open", new OptionHandler() {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
if (player.getInventory().freeSlots() < 7) {
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
return true;
}
if (player.getInventory().remove((Item) node)) {
player.getInventory().add(new Item[] { new Item(10150), new Item(10010), new Item(10006), new Item(10031), new Item(10029), new Item(596), new Item(10008) });
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
});
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
Player p = (Player) entity;
if (p.getInventory().freeSlots() == 0) {
p.getPacketDispatch().sendMessage("Not enough inventory space!");
return false;
}
if (!meetsRequirements(entity, true, true)) {
return false;
}
if (p.getInventory().add(KIT)) {
p.lock(5);
p.animate(ANIMATION);
p.graphics(GRAPHIC);
p.getAudioManager().send(3615, 1, 1);
}
return true;
}
}
@@ -0,0 +1,55 @@
package content.global.skill.magic.lunar
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.Items
// Animations
val BAKE_PIE_ANIM = Animation(4413)
val STATSPY_ANIM = Animation(6293)
val CURE_PLANT_ANIM = Animation(4409)
val NPC_CONTACT_ANIM = Animation(4413)
val PLANK_MAKE_ANIM = Animation(6298)
val STRING_JEWELLERY_ANIM = Animation(4412)
val SUPERGLASS_MAKE_ANIM = Animation(4413)
val FERTILE_SOIL_ANIM = Animation(724)
val CURE_ME_ANIM = Animation(4411)
val CURE_GROUP_ANIM = Animation(4409)
val CURE_OTHER_ANIM = Animation(4411)
// Graphics
val BAKE_PIE_GFX = Graphics(746,75)
val STATSPY_GFX = Graphics(1059)
val CURE_PLANT_GFX = Graphics(742,100)
val NPC_CONTACT_GFX = Graphics(730,130)
val PLANK_MAKE_GFX = Graphics(1063, 120)
val STRING_JEWELLERY_GFX = Graphics(728, 100)
val SUPERGLASS_MAKE_GFX = Graphics(729, 120)
val FERTILE_SOIL_GFX = Graphics(141, 96)
val CURE_ME_GFX = Graphics(731, 90)
val CURE_GROUP_GFX = Graphics(751, 130)
val CURE_OTHER_GFX = Graphics(738, 130)
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)
}
}
}
@@ -0,0 +1,536 @@
package content.global.skill.magic.lunar
import content.global.skill.cooking.CookableItems
import content.global.skill.farming.CompostBins
import content.global.skill.farming.CompostType
import content.global.skill.farming.FarmingPatch
import content.global.skill.magic.SpellListener
import content.global.skill.magic.spellconsts.Lunar
import core.api.*
import core.game.component.Component
import core.game.node.Node
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.TeleportManager
import core.game.node.entity.player.link.audio.Audio
import core.game.node.entity.skill.Skills
import core.game.node.entity.state.EntityState
import core.game.node.item.Item
import core.game.node.scenery.Scenery
import core.game.system.command.Privilege
import core.game.system.config.NPCConfigParser
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.repository.Repository
import core.tools.RandomFunction
import org.rs09.consts.Components
import org.rs09.consts.Items
class LunarListeners : SpellListener("lunar"), Commands {
override fun defineListeners() {
onCast(Lunar.HOME_TELEPORT, NONE) { player, _ ->
requires(player)
sendTeleport(player,0.0, Location.create(2100, 3914, 0))
}
onCast(Lunar.MOONCLAN_TELEPORT, NONE) { player, _ ->
requires(player,69, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,2)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,66.0, Location.create(2111, 3916, 0))
}
onCast(Lunar.MOONCLAN_GR_TELEPORT, NONE) { player, _ ->
requires(player,70, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,4)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,67.0,"Moonclan Island",Location.create(2111, 3916, 0))
}
onCast(Lunar.OURANIA_TELEPORT, NONE) { player, _ ->
requires(player,71, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,1), Item(Items.EARTH_RUNE_557,6)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,69.0, Location.create(2469, 3247, 0))
}
onCast(Lunar.WATERBIRTH_TELEPORT, NONE){ player, _ ->
requires(player,72, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563), Item(Items.WATER_RUNE_555)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,71.0, Location.create(2527, 3739, 0))
}
onCast(Lunar.WATERBIRTH_GR_TELEPORT, NONE) { player, _ ->
requires(player,73, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563), Item(Items.WATER_RUNE_555,5)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,72.0,"Waterbirth Island", Location.create(2527, 3739, 0))
}
onCast(Lunar.BARBARIAN_TELEPORT, NONE) { player, _ ->
requires(player,75, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.FIRE_RUNE_554,3)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,76.0, Location.create(2544, 3572, 0))
}
onCast(Lunar.BARBARIAN_GR_TELEPORT, NONE) { player, _ ->
requires(player,77, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.FIRE_RUNE_554,6)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,77.0,"Barbarian Outpost", Location.create(2544, 3572, 0))
}
onCast(Lunar.KHAZARD_TELEPORT, NONE) { player, _ ->
requires(player,78, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.WATER_RUNE_555,4)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,80.0, Location.create(2656, 3157, 0))
}
onCast(Lunar.KHAZARD_GR_TELEPORT, NONE) { player, _ ->
requires(player,79, arrayOf(Item(Items.ASTRAL_RUNE_9075,2), Item(Items.LAW_RUNE_563,2), Item(Items.WATER_RUNE_555,8)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,81.0, "Port Khazard", Location.create(2656, 3157, 0))
}
onCast(Lunar.FISHING_GUILD_TELEPORT, NONE) { player, _ ->
requires(player,85, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,10)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,89.0, Location.create(2611, 3393, 0))
}
onCast(Lunar.FISHING_GUILD_GR_TELEPORT, NONE) { player, _ ->
requires(player,86, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,14)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,90.0,"Fishing Guild", Location.create(2611, 3393, 0))
}
onCast(Lunar.CATHERBY_TELEPORT, NONE) { player, _ ->
requires(player,87, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,10)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,92.0, Location.create(2804, 3433, 0))
}
onCast(Lunar.CATHERBY_GR_TELEPORT, NONE) { player, _ ->
requires(player,88, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,15)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,93.0,"Catherby", Location.create(2804, 3433, 0))
}
onCast(Lunar.ICE_PLATEAU_TELEPORT, NONE) { player, _ ->
requires(player,89, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,8)))
player.getAudioManager().send(Audio(200), true)
sendTeleport(player,96.0, Location.create(2972, 3873, 0))
}
onCast(Lunar.ICE_PLATEAU_GR_TELEPORT, NONE) { player, _ ->
requires(player,90, arrayOf(Item(Items.ASTRAL_RUNE_9075,3), Item(Items.LAW_RUNE_563,3), Item(Items.WATER_RUNE_555,16)))
player.getAudioManager().send(Audio(200), true)
sendGroupTeleport(player,99.0, "Ice Plateau", Location.create(2972, 3873, 0))
}
onCast(Lunar.BAKE_PIE, NONE) { player, _ ->
requires(player,65, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.FIRE_RUNE_554,5), Item(Items.WATER_RUNE_555,4)))
bakePie(player)
}
onCast(Lunar.MONSTER_EXAMINE, NPC) { player, node ->
requires(player,66, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.MIND_RUNE_558), Item(Items.COSMIC_RUNE_564)))
examineMonster(player,node!!.asNpc())
}
onCast(Lunar.CURE_PLANT, OBJECT) { player, node ->
requires(player,66, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.EARTH_RUNE_557,8)))
curePlant(player,node!!.asScenery())
}
onCast(Lunar.NPC_CONTACT, NONE) { player, _ ->
requires(player,67, arrayOf(Item(Items.ASTRAL_RUNE_9075), Item(Items.COSMIC_RUNE_564), Item(Items.AIR_RUNE_556,2)))
player.interfaceManager.open(Component(429))
player.setAttribute("contact-caller"){
removeRunes(player)
addXP(player,63.0)
setDelay(player,false)
visualizeSpell(player, NPC_CONTACT_ANIM, NPC_CONTACT_GFX,3618)
}
}
onCast(Lunar.PLANK_MAKE, ITEM) { player, node ->
requires(player, 86, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.NATURE_RUNE_561, 1), Item(Items.EARTH_RUNE_557, 15)))
plankMake(player, node!!.asItem())
}
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)
}
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)
}
onCast(Lunar.FERTILE_SOIL, OBJECT) { player, node ->
node?.let { fertileSoil(player, node.asScenery()) }
}
onCast(Lunar.CURE_ME, NONE) { player, _ ->
cureMe(player)
}
onCast(Lunar.CURE_GROUP, NONE) { player, _ ->
cureGroup(player)
}
onCast(Lunar.CURE_OTHER, PLAYER) { player, node ->
node?.let { cureOther(player, node) }
}
}
// Lunar spellbook-related debug commands
override fun defineCommands() {
define("poison", privilege = Privilege.ADMIN) { player, strings ->
if(strings.size == 3) {
var dmg = strings[2].toIntOrNull()
val p = Repository.getPlayerByName(strings[1])
if(p == null) {
sendMessage(player, "Player ${strings[1]} does not exist.")
return@define
}
if(dmg != null) {
p?.let { addState(it, EntityState.POISONED, false, (dmg * 10 + 8), player) }
} else {
sendMessage(player, "Damage must be an integer. Format:")
sendMessage(player, "::poison username damage")
}
} else {
sendMessage(player, "Invalid arguments provided. Format:")
sendMessage(player, "::poison username damage")
}
}
}
private fun plankMake(player: Player, item: Item) {
val plankType = PlankType.getForLog(item)
if (plankType == null) {
sendMessage(player, "You need to use this spell on logs.")
return
}
if (!removeItem(player, Item(Items.COINS_995, plankType.price))) {
sendMessage(player, "You need ${plankType.price} coins to convert that log into a plank.")
return
}
lock(player, 3)
setDelay(player, false)
visualizeSpell(player, PLANK_MAKE_ANIM, PLANK_MAKE_GFX, 3617)
removeRunes(player)
replaceSlot(player, item.slot, plankType.plank)
addXP(player, 90.0)
showMagicTab(player)
}
enum class PlankType (val log: Item, val plank: Item, val price: Int) {
WOOD(Item(1511), Item(960), 70),
OAK(Item(1521), Item(8778), 175),
TEAK(Item(6333), Item(8780), 350),
MAHOGANY(Item(6332), Item(8782), 1050);
companion object {
fun getForLog(item: Item): PlankType? {
for (plankType in values()) {
if (plankType.log.id == item.id) {
return plankType
}
}
return null
}
}
}
fun curePlant(player: Player, obj: Scenery){
val fPatch = FarmingPatch.forObject(obj)
if(fPatch == null){
player.sendMessage("You attempt to cast Cure Plant on ${obj.definition.name}!")
player.sendMessage("Nothing interesting happens.")
return
}
val patch = fPatch.getPatchFor(player)
if(!patch.isDiseased && !patch.isWeedy()){
player.sendMessage("It is growing just fine.")
return
}
if(patch.isWeedy()){
player.sendMessage("The weeds are healthy enough already.")
return
}
if(patch.isDead){
player.sendMessage("It says 'Cure' not 'Resurrect'. Although death may arise from disease, it is not in itself a disease and hence cannot be cured. So there.")
return
}
if(patch.isGrown()){
player.sendMessage("That's not diseased.")
return
}
patch.cureDisease()
removeRunes(player)
addXP(player,60.0)
visualizeSpell(player, CURE_PLANT_ANIM, CURE_PLANT_GFX)
setDelay(player,false)
}
private fun examineMonster(player: Player, npc: NPC){
if(!npc.location.withinDistance(player.location)){
player.sendMessage("You must get closer to use this spell.")
return
}
player.faceLocation(npc.location)
visualizeSpell(player, STATSPY_ANIM, STATSPY_GFX,3620)
removeRunes(player)
addXP(player,66.0)
setDelay(player,false)
player.interfaceManager.openSingleTab(Component(Components.DREAM_MONSTER_STAT_522))
player.packetDispatch.sendString("Monster name : " + npc.definition.name,Components.DREAM_MONSTER_STAT_522,0)
player.packetDispatch.sendString("Combat Level : ${npc.definition.combatLevel}",Components.DREAM_MONSTER_STAT_522,1)
player.packetDispatch.sendString("Hitpoints : ${npc.definition.handlers.get(NPCConfigParser.LIFEPOINTS) ?: 0}",Components.DREAM_MONSTER_STAT_522,2)
player.packetDispatch.sendString("Max hit : ${npc.getSwingHandler(false).calculateHit(npc,player,1.0)}",Components.DREAM_MONSTER_STAT_522,3)
val poisonStatus = if(npc.definition.handlers.getOrDefault(NPCConfigParser.POISON_IMMUNE,false) == true){
"This creature is immune to poison."
} else "This creature is not immune to poison."
player.packetDispatch.sendString(poisonStatus,Components.DREAM_MONSTER_STAT_522,4)
}
private fun bakePie(player: Player){
val playerPies = ArrayList<Item>()
for(item in player.inventory.toArray()){
if(item == null) continue
val pie = CookableItems.forId(item.id) ?: continue
if(!pie.name.lowercase().contains("pie")) continue
if(player.skills.getLevel(Skills.COOKING) < pie.level) continue
playerPies.add(item)
}
if(playerPies.isEmpty()){
player.sendMessage("You have no pies which you have the level to cook.")
return
}
player.pulseManager.run(object : Pulse(){
var counter = 0
override fun pulse(): Boolean {
if(playerPies.isEmpty()) return true
if(counter == 0) delay = BAKE_PIE_ANIM.definition.durationTicks + 1
val item = playerPies.get(0)
val pie = CookableItems.forId(item.id)
visualizeSpell(player, BAKE_PIE_ANIM, BAKE_PIE_GFX, 2879)
addXP(player,60.0)
player.skills.addExperience(Skills.COOKING,pie.experience)
setDelay(player,false)
player.inventory.remove(item)
player.inventory.add(Item(pie.cooked))
playerPies.remove(item)
if(playerPies.isNotEmpty()) removeRunes(player,false) else removeRunes(player,true)
return false
}
})
}
private fun sendTeleport(player: Player, xp: Double, loc: Location){
if(player.locks.isTeleportLocked){
player.sendMessage("A magical force prevents you from teleporting.")
return
}
if(player.teleporter.send(loc,TeleportManager.TeleportType.LUNAR)) {
addXP(player, xp)
removeRunes(player)
setDelay(player, true)
}
}
private fun sendGroupTeleport(player: Player, xp: Double, destName: String, loc: Location){
RegionManager.getLocalPlayers(player,1).forEach {
if(it == player) return@forEach
if(it.locks.isTeleportLocked) return@forEach
if(!it.isActive) return@forEach
if(!it.settings.isAcceptAid) return@forEach
if(it.ironmanManager.isIronman) return@forEach
it.setAttribute("t-o_location",loc)
it.interfaceManager.open(Component(Components.TELEPORT_OTHER_326))
it.packetDispatch.sendString(player.username,Components.TELEPORT_OTHER_326,1)
it.packetDispatch.sendString(destName,Components.TELEPORT_OTHER_326,3)
}
sendTeleport(player,xp,loc)
}
private fun stringJewellery(player: Player) {
val playerJewellery = ArrayDeque<Item>()
for(item in player.inventory.toArray()) {
if(item == null) continue
if(!JewelleryString.unstrungContains(item.id)) continue
playerJewellery.add(item)
}
player.pulseManager.run(object : Pulse() {
var counter = 0
override fun pulse(): Boolean {
removeAttribute(player, "spell:runes")
requires(player, 80, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.EARTH_RUNE_557, 10), Item(Items.WATER_RUNE_555, 5)))
if(counter == 0) delay = animationDuration(STRING_JEWELLERY_ANIM) + 1
val item = playerJewellery[0]
val strung = JewelleryString.forId(item.id)
setDelay(player,false)
if(removeItem(player, item) && addItem(player, strung)) {
removeRunes(player, true)
visualizeSpell(player, STRING_JEWELLERY_ANIM, STRING_JEWELLERY_GFX, 2903)
rewardXP(player, Skills.CRAFTING, 4.0)
addXP(player, 83.0)
playerJewellery.remove(item)
if(playerJewellery.isNotEmpty()) removeRunes(player,false) else removeRunes(player,true)
}
counter++
return playerJewellery.isEmpty()
}
})
}
private fun superglassMake(player: Player) {
val GLASSWEED = hashSetOf(Items.SODA_ASH_1781, Items.SEAWEED_401, Items.SWAMP_WEED_10978)
val inv = player.inventory.toArray()
var playerWeed: Int = amountInInventory(player, Items.SODA_ASH_1781) + amountInInventory(player, Items.SEAWEED_401) + amountInInventory(player, Items.SWAMP_WEED_10978)
var playerSand: Int = amountInInventory(player, Items.BUCKET_OF_SAND_1783)
var index: Int = 0
fun addMolten(): Boolean {
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)
}
}
private fun fertileSoil(player: Player, target: Scenery) {
if (CompostBins.forObjectID(target.id) != null) {
sendMessage(player, "No, that would be silly.")
return
}
val fPatch = FarmingPatch.forObject(target)
if(fPatch == null) {
sendMessage(player, "Um... I don't want to fertilize that!")
return
}
val patch = fPatch.getPatchFor(player)
if (patch.isGrown()) {
sendMessage(player, "Composting isn't going to make it get any bigger.")
return
}
if (patch.isFertilized()) {
sendMessage(player, "This patch has already been composted.")
return
}
requires(player, 83, arrayOf(Item(Items.ASTRAL_RUNE_9075, 3), Item(Items.NATURE_RUNE_561, 2), Item(Items.EARTH_RUNE_557, 15)))
removeRunes(player, true)
visualizeSpell(player, FERTILE_SOIL_ANIM, FERTILE_SOIL_GFX, 2891)
patch.compost = CompostType.SUPER
sendMessage(player, "You fertilize the soil.")
addXP(player, 87.0)
}
private fun cureMe(player: Player) {
if(!hasState(player, EntityState.POISONED)) {
sendMessage(player, "You are not poisoned.")
return
}
requires(player, 71, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.LAW_RUNE_563, 1), Item(Items.COSMIC_RUNE_564, 2)))
removeRunes(player, true)
visualizeSpell(player, CURE_ME_ANIM, CURE_ME_GFX, 2880)
removeState(player, EntityState.POISONED)
addXP(player, 69.0)
playAudio(player, Audio(2900))
sendMessage(player, "You have been cured of poison.")
}
private fun cureGroup(player: Player) {
requires(player, 74, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.LAW_RUNE_563, 2), Item(Items.COSMIC_RUNE_564, 2)))
removeRunes(player, true)
visualizeSpell(player, CURE_GROUP_ANIM, CURE_GROUP_GFX, 2882)
removeState(player, EntityState.POISONED)
for(acct in RegionManager.getLocalPlayers(player, 1)) {
if(!acct.isActive || acct.locks.isInteractionLocked) {
continue
}
if(!acct.settings.isAcceptAid) {
continue
}
removeState(acct, EntityState.POISONED)
sendMessage(acct, "You have been cured of poison.")
playAudio(acct, Audio(2889), true)
visualize(acct, -1, CURE_GROUP_GFX)
}
addXP(player, 74.0)
}
private fun cureOther(player: Player, target: Node) {
if(!isPlayer(target)) {
sendMessage(player, "You can only cast this spell on other players.")
return
}
val p = target.asPlayer()
if(!p.isActive || p.locks.isInteractionLocked) {
sendMessage(player, "This player is busy.")
return
}
if(!p.settings.isAcceptAid) {
sendMessage(player, "This player is not accepting any aid.")
return
}
if(!hasState(p, EntityState.POISONED)) {
sendMessage(player, "This player is not poisoned.")
return
}
requires(player, 68, arrayOf(Item(Items.ASTRAL_RUNE_9075, 1), Item(Items.LAW_RUNE_563), Item(Items.EARTH_RUNE_557, 10)))
player.face(p)
visualizeSpell(player, CURE_OTHER_ANIM, CURE_OTHER_GFX, 2886)
visualize(p, -1, CURE_OTHER_GFX)
playAudio(p, Audio(2889), true)
removeRunes(player, true)
removeState(p, EntityState.POISONED)
sendMessage(p, "You have been cured of poison.")
addXP(player, 65.0)
}
}
@@ -0,0 +1,68 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.plugin.Initializable;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Plugin;
/**
* The magic imbue spell.
* @author 'Vexia
*/
@Initializable
public class MagicImbueSpell extends MagicSpell {
/**
* The graphic.
*/
private static final Graphics GRAPHIC = new Graphics(141, 96);
/**
* The animation.
*/
private static final Animation ANIMATION = new Animation(722);
/**
* Constructs a new {@code StatRestoreSpell} {@code Object}.
*/
public MagicImbueSpell() {
super(SpellBook.LUNAR, 82, 86, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.FIRE_RUNE.getId(), 7), new Item(Runes.WATER_RUNE.getId(), 7) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(13, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = ((Player) entity);
if (player == null) {
return false;
}
if (player.getAttribute("spell:imbue", 0) > GameWorld.getTicks()) {
player.sendMessage("You already have this activated.");
return false;
}
if (!super.meetsRequirements(player, true, true)) {
return false;
}
player.setAttribute("spell:imbue", GameWorld.getTicks() + 20);
player.lock(ANIMATION.getDuration() + 1);
player.graphics(GRAPHIC);
player.animate(ANIMATION);
player.getAudioManager().send(2888, 1, 1);
player.getPacketDispatch().sendMessage("You are charged to combine runes!");
return true;
}
}
@@ -0,0 +1,84 @@
package content.global.skill.magic.lunar;
import core.game.component.Component;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import core.game.world.GameWorld;
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 spellbook swap spell.
* @author 'Vexia
*/
@Initializable
public class SpellbookSwapSpell extends MagicSpell {
/**
* Represents the animation of this spell.
*/
private final Animation ANIMATION = new Animation(6299);
/**
* Represents the graphics of this spell.
*/
private final Graphics GRAPHIC = new Graphics(1062);
/**
* Constructs a new {@code SpellbookSwapSpell} {@code Object}.
*/
public SpellbookSwapSpell() {
super(SpellBook.LUNAR, 96, 130, null, null, null, new Item[] { new Item(Runes.LAW_RUNE.getId(), 1), new Item(Runes.COSMIC_RUNE.getId(), 2), new Item(Runes.ASTRAL_RUNE.getId(), 3) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(12, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = (Player) entity;
if (!super.meetsRequirements(player, true, true)) {
return false;
}
player.lock(9);
player.animate(ANIMATION);
player.graphics(GRAPHIC);
player.getDialogueInterpreter().open(3264731);
final int id = RandomFunction.random(1, 500000);
player.setAttribute("spell:swap", id);
GameWorld.getPulser().submit(new Pulse(20, player) {
@Override
public boolean pulse() {
if (player.getAttribute("spell:swap", 0) == id) {
removeTemporarySpell(player);
}
return true;
}
});
return true;
}
/**
* Method used to remove the temp spell swap.
* @param player the player.
*/
public static void removeTemporarySpell(final Player player) {
player.removeAttribute("spell:swap");
player.getSpellBookManager().setSpellBook(SpellBook.LUNAR);
player.getInterfaceManager().openTab(new Component(SpellBook.LUNAR.getInterfaceId()));
}
}
@@ -0,0 +1,96 @@
package content.global.skill.magic.lunar;
import content.data.consumables.Consumables;
import core.game.consumable.Potion;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.audio.Audio;
import core.game.bots.AIPlayer;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.map.RegionManager;
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 java.util.List;
@Initializable
public final class StatBoostSpell extends MagicSpell {
private static final Animation ANIMATION = new Animation(4413);
private static final Graphics GRAPHICS = new Graphics(733, 130);
public static final int VIAL = 229;
public StatBoostSpell() {
super(SpellBook.LUNAR, 84, 88, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 3), new Item(Runes.EARTH_RUNE.getId(), 12), new Item(Runes.WATER_RUNE.getId(), 10) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(26, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = ((Player) entity);
Item item = ((Item) target);
final Potion potion = (Potion) Consumables.getConsumableById(item.getId());
player.getInterfaceManager().setViewedTab(6);
if (potion == null) {
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
return false;
}
if (!item.getDefinition().isTradeable() || item.getName().toLowerCase().contains("restore") || item.getName().toLowerCase().contains("zamorak") || item.getName().toLowerCase().contains("saradomin") || item.getName().toLowerCase().contains("combat")) {
player.getPacketDispatch().sendMessage("You can't cast this spell on that item.");
return false;
}
List<Player> pl = RegionManager.getLocalPlayers(player, 1);
int plSize = pl.size() - 1;
int doses = potion.getDose(item);
if (plSize > doses) {
player.getPacketDispatch().sendMessage("You don't have enough doses.");
return false;
}
if (doses > plSize) {
doses = plSize;
}
if (pl.size() == 0) {
return false;
}
if (!super.meetsRequirements(player, true, false)) {
return false;
}
int size = 1;
for (Player players : pl) {
Player o = (Player) players;
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
continue;
}
if (!o.getSettings().isAcceptAid() && !(o instanceof AIPlayer)) {
continue;
}
o.graphics(GRAPHICS);
o.getAudioManager().send(new Audio (2902), true);
potion.getEffect().activate(o);
size++;
}
if (size == 1) {
player.getPacketDispatch().sendMessage("There is nobody around that has accept aid on to share the potion with you.");
return false;
}
super.meetsRequirements(player, true, true);
potion.getEffect().activate(player);
player.getAudioManager().send(new Audio (2901), true);
player.animate(ANIMATION);
player.graphics(GRAPHICS);
player.getInventory().remove(item);
player.getInventory().add(new Item(potion.getIds()[size - 1]));
return true;
}
}
@@ -0,0 +1,108 @@
package content.global.skill.magic.lunar;
import content.data.consumables.Consumables;
import core.game.consumable.Potion;
import core.plugin.Initializable;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.audio.Audio;
import core.game.bots.AIPlayer;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Plugin;
import java.util.List;
@Initializable
public class StatRestoreSpell extends MagicSpell {
private static final Animation ANIMATION = new Animation(4413);
private static final Graphics GRAPHICS = new Graphics(733, 130);
private static final int[] IDS = new int[] { 2434, 139, 141, 143, 2430, 127, 129, 131, 3024, 3026, 3028, 3030 };
public StatRestoreSpell() {
super(SpellBook.LUNAR, 81, 84, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 10), new Item(Runes.WATER_RUNE.getId(), 10) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(27, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = ((Player) entity);
Item item = ((Item) target);
final Potion potion = (Potion) Consumables.getConsumableById(item.getId());
player.getInterfaceManager().setViewedTab(6);
if (potion == null) {
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
return false;
}
if (!item.getDefinition().isTradeable() || !isRestore(item.getId())) {
player.getPacketDispatch().sendMessage("You can't cast this spell on that item.");
return false;
}
List<Player> pl = RegionManager.getLocalPlayers(player, 1);
int plSize = pl.size() - 1;
int doses = potion.getDose(item);
if (plSize > doses) {
player.getPacketDispatch().sendMessage("You don't have enough doses.");
return false;
}
if (doses > plSize) {
doses = plSize;
}
if (pl.size() == 0) {
return false;
}
if (!super.meetsRequirements(player, true, false)) {
return false;
}
int size = 1;
for (Player players : pl) {
Player o = (Player) players;
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
continue;
}
if (!o.getSettings().isAcceptAid() && !(o instanceof AIPlayer)) {
continue;
}
o.graphics(GRAPHICS);
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
potion.getEffect().activate(o);
size++;
}
if (size == 1) {
player.getPacketDispatch().sendMessage("There is nobody around that has accept aid on to share the potion with you.");
return false;
}
super.meetsRequirements(player, true, true);
potion.getEffect().activate(player);
player.getAudioManager().send(new Audio (2899), true);
player.animate(ANIMATION);
player.graphics(GRAPHICS);
player.getInventory().remove(item);
player.getInventory().add(new Item(potion.getIds()[size - 1]));
return true;
}
private boolean isRestore(int id) {
for (int i : IDS) {
if (i == id) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,97 @@
package content.global.skill.magic.lunar;
import core.game.component.CloseEvent;
import core.game.component.Component;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
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.Plugin;
/**
* The stat spy spell.
* @author 'Vexia
*/
@Initializable
public final class StatSpySpell extends MagicSpell {
/**
* Represents the animation of this spell.
*/
private final static Animation ANIMATION = new Animation(6293);
/**
* Repesents the graphics of this spell.
*/
private static final Graphics GRAPHIC = new Graphics(734, 120);
/**
* Represents the graphics.
*/
private static final Graphics EYE = new Graphics(1059);
/**
* Represents the component.
*/
private static final Component COMPONENT = new Component(523);
/**
* Represents the array of skills.
*/
private static int[][] SKILLS = { { Skills.ATTACK, 1, 2 }, { Skills.HITPOINTS, 5, 6 }, { Skills.MINING, 9, 10 }, { Skills.STRENGTH, 13, 14 }, { Skills.AGILITY, 17, 18 }, { Skills.SMITHING, 21, 22 }, { Skills.DEFENCE, 25, 26 }, { Skills.HERBLORE, 29, 30 }, { Skills.FISHING, 33, 34 }, { Skills.RANGE, 37, 38 }, { Skills.THIEVING, 41, 42 }, { Skills.COOKING, 45, 46 }, { Skills.PRAYER, 49, 50 }, { Skills.CRAFTING, 53, 54 }, { Skills.FIREMAKING, 57, 58 }, { Skills.MAGIC, 61, 62 }, { Skills.FLETCHING, 65, 66 }, { Skills.WOODCUTTING, 69, 70 }, { Skills.RUNECRAFTING, 73, 74 }, { Skills.SLAYER, 77, 78 }, { Skills.FARMING, 81, 82 }, { Skills.CONSTRUCTION, 85, 86 }, { Skills.HUNTER, 89, 90 }, { Skills.SUMMONING, 93, 94 } };
/**
* Constructs a new {@code CureOtherSpell} {@code Object}.
*/
public StatSpySpell() {
super(SpellBook.LUNAR, 75, 76, ANIMATION, null, null, new Item[] { new Item(Runes.COSMIC_RUNE.getId(), 2), new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.BODY_RUNE.getId(), 5) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(9, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = ((Player) entity);
if (!(target instanceof Player)) {
player.getPacketDispatch().sendMessage("You can only cast this spell on players.");
return false;
}
if (super.meetsRequirements(player, true, true)) {
final Player o = ((Player) target);
player.animate(ANIMATION);
player.face(o);
player.getAudioManager().send(3620);
COMPONENT.setCloseEvent(new CloseEvent() {
@Override
public boolean close(Player player, Component c) {
player.getInterfaceManager().restoreTabs();
return true;
}
});
player.graphics(EYE);
o.graphics(GRAPHIC);
player.getAudioManager().send(3621);
for (int[] element : SKILLS) {
player.getPacketDispatch().sendString("" + o.getSkills().getLevel(element[0]) + "", 523, element[1]);
player.getPacketDispatch().sendString("" + o.getSkills().getStaticLevel(element[0]) + "", 523, element[2]);
}
player.getPacketDispatch().sendString((o.getUsername()), 523, 99);
player.getInterfaceManager().openSingleTab(COMPONENT);
return true;
}
return true;
}
}
@@ -0,0 +1,88 @@
package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Handles the vengeance (other) spell.
* @author Emperor
*/
@Initializable
public final class VengeanceSpell extends MagicSpell {
/**
* Constructs a new {@code VengeanceSpell} {@code Object}.
*/
public VengeanceSpell() {
/*
* empty.
*/
}
/**
* Constructs a new {@code VengeanceSpell} {@code Object}.
* @param level The level required.
* @param experience The experience gained from casting this spell.
* @param anim The cast animation.
* @param graphic The graphics.
* @param runes The runes required.
*/
public VengeanceSpell(int level, double experience, Animation anim, Graphics graphic, Item... runes) {
super(SpellBook.LUNAR, level, experience, anim, graphic, null, runes);
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
// Vengeance other
SpellBook.LUNAR.register(19, new VengeanceSpell(93, 78, Animation.create(4411), new Graphics(725, 96), Runes.ASTRAL_RUNE.getItem(3), Runes.DEATH_RUNE.getItem(2), Runes.EARTH_RUNE.getItem(10)));
// Vengeance
SpellBook.LUNAR.register(14, new VengeanceSpell(94, 112, Animation.create(4410), new Graphics(726, 96), Runes.ASTRAL_RUNE.getItem(4), Runes.DEATH_RUNE.getItem(2), Runes.EARTH_RUNE.getItem(10)));
return this;
}
@Override
public void visualize(Entity entity, Node target) {
entity.animate(animation);
((Entity) target).graphics(graphic);
}
@Override
public boolean cast(Entity entity, Node target) {
int ticks = GameWorld.getTicks();
boolean vengOther = spellId == 19;
if (entity.getAttribute("vengeance_delay", -1) > ticks) {
((Player) entity).getPacketDispatch().sendMessage("You can only cast vengeance spells once every 30 seconds.");
return false;
}
if (vengOther && (target == null || !(target instanceof Player))) {
return false;
}
Player p = (Player) (vengOther ? target : entity);
if (vengOther) {
if (!p.getSettings().isAcceptAid()) {
((Player) entity).getPacketDispatch().sendMessage("The player is not accepting any aid.");
return false;
}
}
if (!meetsRequirements(entity, true, true)) {
return false;
}
visualize(entity, p);
entity.setAttribute("vengeance_delay", ticks + 50);
p.setAttribute("vengeance", true);
p.getAudioManager().send(vengOther ? 2908 : 2907);
return true;
}
}