Rewrote dream spell

Fixed healing rate of dream
Added sound to dream spell
This commit is contained in:
GregF 2024-11-14 11:51:34 +00:00 committed by Ryan
parent 53dc169774
commit 1da53c448d
3 changed files with 38 additions and 110 deletions

View file

@ -1,104 +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.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;
}
}

View file

@ -9,6 +9,7 @@ import content.global.skill.magic.spellconsts.Lunar
import core.api.*
import core.game.component.CloseEvent
import core.game.component.Component
import core.game.interaction.QueueStrength
import core.game.node.Node
import core.game.node.entity.combat.ImpactHandler
import core.game.node.entity.npc.NPC
@ -169,9 +170,10 @@ class LunarListeners : SpellListener("lunar"), Commands {
}
// Level 79
/**
* Dream
*/
onCast(Lunar.DREAM, NONE) { player, _ ->
requires(player, 79, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.BODY_RUNE_559, 5), Item(Items.COSMIC_RUNE_564, 1)))
dream(player)
}
// Level 80
onCast(Lunar.STRING_JEWELLERY, NONE) { player, _ ->
@ -576,9 +578,38 @@ class LunarListeners : SpellListener("lunar"), Commands {
}
// Level 79
/**
* Dream
*/
private fun dream(player: Player) {
if(player.skills.lifepoints >= getStatLevel(player, Skills.HITPOINTS)) {
sendMessage(player, "You have no need to cast this spell since your hitpoints are already full.")
return
}
animate(player, Animations.LUNAR_SPELLBOOK_DREAM_START_6295)
delayEntity(player, 4)
queueScript(player, 4, QueueStrength.WEAK) { stage: Int ->
when(stage) {
0 -> {
animate(player, Animations.LUNAR_SPELLBOOK_DREAM_MID_6296)
sendGraphics(Graphics.LUNAR_SPELLBOOK_DREAM_1056, player.location)
playAudio(player, Sounds.LUNAR_SLEEP_3619)
return@queueScript delayScript(player, 5)
}
else -> {
sendGraphics(Graphics.LUNAR_SPELLBOOK_DREAM_1056, player.location)
// This heals 2 HP every min. Naturally you heal 1 for a total of 3
// The script steps every 5 ticks and we want 50 ticks before a heal
if (stage.mod(10) == 0){
heal(player, 1)
if(player.skills.lifepoints >= getStatLevel(player, Skills.HITPOINTS)) {
animate(player, Animations.LUNAR_SPELLBOOK_DREAM_END_6297)
return@queueScript stopExecuting(player)
}
}
return@queueScript delayScript(player, 5)
}
}
}
}
private fun stringJewellery(player: Player) {
val playerJewellery = ArrayDeque<Item>()

View file

@ -296,6 +296,7 @@ class CombatPulse(
}
setVictim(victim)
entity.onAttack(victim as Entity?)
victim.scripts.removeWeakScripts()
if (!isAttacking)
entity.pulseManager.run(this)