Converted lunar spellbook energy transfer to kotlin
This commit is contained in:
@@ -1,84 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@ val FERTILE_SOIL_ANIM = Animation(724)
|
|||||||
val CURE_ME_ANIM = Animation(4411)
|
val CURE_ME_ANIM = Animation(4411)
|
||||||
val CURE_GROUP_ANIM = Animation(4409)
|
val CURE_GROUP_ANIM = Animation(4409)
|
||||||
val CURE_OTHER_ANIM = Animation(4411)
|
val CURE_OTHER_ANIM = Animation(4411)
|
||||||
|
val ENERGY_TRANSFER_ANIM = Animation(4411)
|
||||||
|
|
||||||
|
|
||||||
// Graphics
|
// Graphics
|
||||||
@@ -30,6 +31,7 @@ val FERTILE_SOIL_GFX = Graphics(141, 96)
|
|||||||
val CURE_ME_GFX = Graphics(731, 90)
|
val CURE_ME_GFX = Graphics(731, 90)
|
||||||
val CURE_GROUP_GFX = Graphics(751, 130)
|
val CURE_GROUP_GFX = Graphics(751, 130)
|
||||||
val CURE_OTHER_GFX = Graphics(738, 130)
|
val CURE_OTHER_GFX = Graphics(738, 130)
|
||||||
|
val ENERGY_TRANSFER_GFX = Graphics(738, 90)
|
||||||
|
|
||||||
enum class JewelleryString(val unstrung: Int, val strung: Int) {
|
enum class JewelleryString(val unstrung: Int, val strung: Int) {
|
||||||
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
|
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import content.global.skill.magic.spellconsts.Lunar
|
|||||||
import core.api.*
|
import core.api.*
|
||||||
import core.game.component.Component
|
import core.game.component.Component
|
||||||
import core.game.node.Node
|
import core.game.node.Node
|
||||||
|
import core.game.node.entity.combat.ImpactHandler
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.entity.player.link.TeleportManager
|
import core.game.node.entity.player.link.TeleportManager
|
||||||
@@ -26,6 +27,7 @@ import core.game.world.repository.Repository
|
|||||||
import core.tools.RandomFunction
|
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 kotlin.math.floor
|
||||||
|
|
||||||
class LunarListeners : SpellListener("lunar"), Commands {
|
class LunarListeners : SpellListener("lunar"), Commands {
|
||||||
|
|
||||||
@@ -182,6 +184,10 @@ class LunarListeners : SpellListener("lunar"), Commands {
|
|||||||
onCast(Lunar.CURE_OTHER, PLAYER) { player, node ->
|
onCast(Lunar.CURE_OTHER, PLAYER) { player, node ->
|
||||||
node?.let { cureOther(player, node) }
|
node?.let { cureOther(player, node) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCast(Lunar.ENERGY_TRANSFER, PLAYER) { player, node ->
|
||||||
|
node?.let { energyTransfer(player, node) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lunar spellbook-related debug commands
|
// Lunar spellbook-related debug commands
|
||||||
@@ -528,6 +534,53 @@ class LunarListeners : SpellListener("lunar"), Commands {
|
|||||||
sendMessage(p, "You have been cured of poison.")
|
sendMessage(p, "You have been cured of poison.")
|
||||||
addXP(player, 65.0)
|
addXP(player, 65.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun energyTransfer(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(10 >= player.skills.lifepoints) {
|
||||||
|
sendMessage(player, "You need more hitpoints to cast this spell.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requires(player, 91, arrayOf(Item(Items.ASTRAL_RUNE_9075, 3), Item(Items.LAW_RUNE_563, 2), Item(Items.NATURE_RUNE_561, 1)))
|
||||||
|
player.face(p)
|
||||||
|
visualizeSpell(player, ENERGY_TRANSFER_ANIM, ENERGY_TRANSFER_GFX, 2885)
|
||||||
|
visualize(p, -1, CURE_OTHER_GFX)
|
||||||
|
val hp = floor(player.skills.lifepoints * 0.10)
|
||||||
|
var r = hp
|
||||||
|
if(r > (100 - p.settings.runEnergy)) {
|
||||||
|
r = (100 - p.settings.runEnergy)
|
||||||
|
}
|
||||||
|
if(r < 0) {
|
||||||
|
r = 0.0
|
||||||
|
}
|
||||||
|
p.settings.runEnergy += r
|
||||||
|
player.settings.runEnergy -= r
|
||||||
|
impact(player, hp.toInt(), ImpactHandler.HitsplatType.NORMAL)
|
||||||
|
var e = 100
|
||||||
|
e -= p.settings.specialEnergy
|
||||||
|
if(e < 0) {
|
||||||
|
e = 0
|
||||||
|
}
|
||||||
|
if(e > player.settings.specialEnergy) {
|
||||||
|
e = player.settings.specialEnergy
|
||||||
|
}
|
||||||
|
p.settings.specialEnergy += e
|
||||||
|
player.settings.specialEnergy -= e
|
||||||
|
removeRunes(player, true)
|
||||||
|
addXP(player, 100.0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user