Fixed ice spell casts allowing frozen victim movement for 1 tick

Fixed ice barrage animations
Players who get successfully frozen by an ice spell now receive the message "You have been frozen!"
This commit is contained in:
dam
2025-11-27 14:04:25 +02:00
committed by Ryan
parent 5533a2f78a
commit 1765f3a3b6
2 changed files with 210 additions and 209 deletions
@@ -1,162 +1,160 @@
package content.global.skill.magic.ancient; package content.global.skill.magic.ancient;
import java.util.List; import java.util.List;
import core.game.node.entity.combat.spell.Runes; import core.game.node.entity.combat.spell.Runes;
import core.game.node.Node; import core.game.node.Node;
import core.game.node.entity.Entity; import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState; import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.spell.CombatSpell; import core.game.node.entity.combat.spell.CombatSpell;
import core.game.node.entity.combat.spell.SpellType; import core.game.node.entity.combat.spell.SpellType;
import core.game.node.entity.impl.Projectile; import core.game.node.entity.impl.Projectile;
import core.game.node.entity.impl.Animator.Priority; import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item; import core.game.node.item.Item;
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.plugin.Initializable; import core.plugin.Initializable;
import core.plugin.Plugin; import core.plugin.Plugin;
import org.rs09.consts.Sounds; import org.rs09.consts.Sounds;
import static core.api.ContentAPIKt.*; import static core.api.ContentAPIKt.*;
/** /**
* Handles the Ice spells from the Ancient spellbook. * Handles the Ice spells from the Ancient spellbook.
* @author Emperor * @author Emperor
* @version 1.0 * @version 1.0
*/ */
@Initializable @Initializable
public final class IceSpells extends CombatSpell { public final class IceSpells extends CombatSpell {
/** /**
* The barrage orb GFX. * The barrage orb GFX.
*/ */
private static final Graphics BARRAGE_ORB = new Graphics(1677, 96); //119 private static final Graphics BARRAGE_ORB = new Graphics(1677, 96); //119
/** /**
* The projectile for Ice rush. * The projectile for Ice rush.
*/ */
private static final Projectile RUSH_PROJECTILE = Projectile.create((Entity) null, null, 360, 40, 36, 52, 75, 15, 11); private static final Projectile RUSH_PROJECTILE = Projectile.create((Entity) null, null, 360, 40, 36, 52, 75, 15, 11);
/** /**
* The end graphic for Ice rush. * The end graphic for Ice rush.
*/ */
private static final Graphics RUSH_END = new Graphics(361, 96); private static final Graphics RUSH_END = new Graphics(361, 96);
/** /**
* The projectile for Ice barrage. * The projectile for Ice barrage.
*/ */
private static final Projectile BURST_PROJECTILE = Projectile.create((Entity) null, null, 362, 40, 36, 52, 75, 15, 11); private static final Projectile BURST_PROJECTILE = Projectile.create((Entity) null, null, 362, 40, 36, 52, 75, 15, 11);
/** /**
* The end graphic for Ice barrage. * The end graphic for Ice barrage.
*/ */
private static final Graphics BURST_END = new Graphics(363, 0); private static final Graphics BURST_END = new Graphics(363, 0);
/** /**
* The start graphic for Ice rush. * The start graphic for Ice rush.
*/ */
private static final Graphics BLITZ_START = new Graphics(366, 96); private static final Graphics BLITZ_START = new Graphics(366, 96);
/** /**
* The end graphic for Ice rush. * The end graphic for Ice rush.
*/ */
private static final Graphics BLITZ_END = new Graphics(367, 96); private static final Graphics BLITZ_END = new Graphics(367, 96);
/** /**
* The projectile for Ice barrage. * The projectile for Ice barrage.
*/ */
private static final Projectile BARRAGE_PROJECTILE = Projectile.create((Entity) null, null, 368, 40, 36, 52, 75, 15, 11); private static final Projectile BARRAGE_PROJECTILE = Projectile.create((Entity) null, null, 368, 40, 36, 52, 75, 15, 11);
/** /**
* The end graphic for Ice barrage. * The end graphic for Ice barrage.
*/ */
private static final Graphics BARRAGE_END = new Graphics(369, 0); private static final Graphics BARRAGE_END = new Graphics(369, 0);
/** /**
* Constructs a new {@code IceSpells} {@code Object}. * Constructs a new {@code IceSpells} {@code Object}.
*/ */
public IceSpells() { public IceSpells() {
/* /*
* empty. * empty.
*/ */
} }
/** /**
* Constructs a new {@code IceSpells} {@Code Object} * Constructs a new {@code IceSpells} {@Code Object}
* @param type The spell type. * @param type The spell type.
* @param impactSound The impact sound id. * @param impactSound The impact sound id.
* @param anim The animation. * @param anim The animation.
* @param start The start graphics. * @param start The start graphics.
* @param projectile The projectile. * @param projectile The projectile.
* @param end The end graphics. * @param end The end graphics.
*/ */
private IceSpells(SpellType type, int level, double baseExperience, int impactSound, Animation anim, Graphics start, Projectile projectile, Graphics end, Item... runes) { private IceSpells(SpellType type, int level, double baseExperience, int impactSound, Animation anim, Graphics start, Projectile projectile, Graphics end, Item... runes) {
super(type, SpellBook.ANCIENT, level, baseExperience, Sounds.ICE_CAST_171, impactSound, anim, start, projectile, end, runes); super(type, SpellBook.ANCIENT, level, baseExperience, Sounds.ICE_CAST_171, impactSound, anim, start, projectile, end, runes);
} }
@Override @Override
public void visualize(Entity entity, Node target) { public void visualize(Entity entity, Node target) {
entity.graphics(graphic); entity.graphics(graphic);
if (projectile != null) { if (projectile != null) {
projectile.transform(entity, (Entity) target, false, 58, 10).send(); projectile.transform(entity, (Entity) target, false, 58, 10).send();
} }
entity.animate(animation); entity.animate(animation);
playGlobalAudio(entity.getLocation(), audio.id, 20); playGlobalAudio(entity.getLocation(), audio.id, 20);
} }
@Override @Override
public void visualizeImpact(Entity entity, Entity target, BattleState state) { public void visualizeImpact(Entity entity, Entity target, BattleState state) {
if (state.isFrozen()) { if (state.isFrozen()) {
playGlobalAudio(target.getLocation(), impactAudio, 20); playGlobalAudio(target.getLocation(), impactAudio, 20);
target.graphics(BARRAGE_ORB); target.graphics(BARRAGE_ORB);
return; return;
} }
super.visualizeImpact(entity, target, state); super.visualizeImpact(entity, target, state);
} }
@Override @Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable { public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.ANCIENT.register(0, new IceSpells(SpellType.RUSH, 58, 34.0, Sounds.ICE_RUSH_IMPACT_173, new Animation(1978, Priority.HIGH), null, RUSH_PROJECTILE, RUSH_END, Runes.DEATH_RUNE.getItem(2), Runes.CHAOS_RUNE.getItem(2), Runes.WATER_RUNE.getItem(2))); SpellBook.ANCIENT.register(0, new IceSpells(SpellType.RUSH, 58, 34.0, Sounds.ICE_RUSH_IMPACT_173, new Animation(1978, Priority.HIGH), null, RUSH_PROJECTILE, RUSH_END, Runes.DEATH_RUNE.getItem(2), Runes.CHAOS_RUNE.getItem(2), Runes.WATER_RUNE.getItem(2)));
SpellBook.ANCIENT.register(2, new IceSpells(SpellType.BURST, 70, 40.0, Sounds.ICE_BURST_IMPACT_170, new Animation(1979, Priority.HIGH), null, BURST_PROJECTILE, BURST_END, Runes.DEATH_RUNE.getItem(2), Runes.CHAOS_RUNE.getItem(4), Runes.WATER_RUNE.getItem(4))); SpellBook.ANCIENT.register(2, new IceSpells(SpellType.BURST, 70, 40.0, Sounds.ICE_BURST_IMPACT_170, new Animation(1979, Priority.HIGH), null, BURST_PROJECTILE, BURST_END, Runes.DEATH_RUNE.getItem(2), Runes.CHAOS_RUNE.getItem(4), Runes.WATER_RUNE.getItem(4)));
SpellBook.ANCIENT.register(1, new IceSpells(SpellType.BLITZ, 82, 46.0, Sounds.ICE_BLITZ_IMPACT_169, new Animation(1978, Priority.HIGH), BLITZ_START, null, BLITZ_END, Runes.BLOOD_RUNE.getItem(2), Runes.DEATH_RUNE.getItem(2), Runes.WATER_RUNE.getItem(3))); SpellBook.ANCIENT.register(1, new IceSpells(SpellType.BLITZ, 82, 46.0, Sounds.ICE_BLITZ_IMPACT_169, new Animation(1978, Priority.HIGH), BLITZ_START, null, BLITZ_END, Runes.BLOOD_RUNE.getItem(2), Runes.DEATH_RUNE.getItem(2), Runes.WATER_RUNE.getItem(3)));
SpellBook.ANCIENT.register(3, new IceSpells(SpellType.BARRAGE, 94, 52.0, Sounds.ICE_BARRAGE_IMPACT_168, new Animation(1979, Priority.HIGH), null, BARRAGE_PROJECTILE, BARRAGE_END, Runes.BLOOD_RUNE.getItem(2), Runes.DEATH_RUNE.getItem(4), Runes.WATER_RUNE.getItem(6))); SpellBook.ANCIENT.register(3, new IceSpells(SpellType.BARRAGE, 94, 52.0, Sounds.ICE_BARRAGE_IMPACT_168, new Animation(1979, Priority.HIGH), null, BARRAGE_PROJECTILE, BARRAGE_END, Runes.BLOOD_RUNE.getItem(2), Runes.DEATH_RUNE.getItem(4), Runes.WATER_RUNE.getItem(6)));
return this; return this;
} }
@Override @Override
public void fireEffect(Entity entity, Entity victim, BattleState state) { public void fireEffect(Entity entity, Entity victim, BattleState state) {
if (state.getEstimatedHit() == -1) { if (state.getEstimatedHit() == -1) {
return; return;
} }
int ticks = (1 + (type.ordinal() - SpellType.RUSH.ordinal())) * 8; int ticks = (type.ordinal() - 4) * 8;
if (state.getEstimatedHit() > -1) { if (hasTimerActive(victim, "frozen") || hasTimerActive(victim, "frozen:immunity")) {
if (!hasTimerActive(victim, "frozen:immunity")) { if (type == SpellType.BARRAGE) { state.setFrozen(true); }
registerTimer(victim, spawnTimer("frozen", ticks, true)); return;
} else if (type == SpellType.BARRAGE) { }
state.setFrozen(true); registerTimer(victim, spawnTimer("frozen", ticks, true));
} }
}
} @Override
public BattleState[] getTargets(Entity entity, Entity target) {
@Override if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
public BattleState[] getTargets(Entity entity, Entity target) { return super.getTargets(entity, target);
if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) { }
return super.getTargets(entity, target); List<Entity> list = getMultihitTargets(entity, target, 9);
} BattleState[] targets = new BattleState[list.size()];
List<Entity> list = getMultihitTargets(entity, target, 9); int index = 0;
BattleState[] targets = new BattleState[list.size()]; for (Entity e : list) {
int index = 0; targets[index++] = new BattleState(entity, e);
for (Entity e : list) { }
targets[index++] = new BattleState(entity, e); return targets;
} }
return targets;
} @Override
public int getMaximumImpact(Entity entity, Entity victim, BattleState state) {
@Override return getType().getImpactAmount(entity, victim, 4);
public int getMaximumImpact(Entity entity, Entity victim, BattleState state) { }
return getType().getImpactAmount(entity, victim, 4);
} }
}
@@ -1,47 +1,50 @@
package core.game.system.timer.impl package core.game.system.timer.impl
import core.game.system.timer.* import core.game.system.timer.*
import core.api.* import core.api.*
import core.game.node.entity.Entity import core.game.node.entity.Entity
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.world.repository.Repository import core.game.world.repository.Repository
import org.json.simple.* import org.json.simple.*
class Frozen : PersistTimer (1, "frozen", flags = arrayOf(TimerFlag.ClearOnDeath)) { class Frozen : PersistTimer (1, "frozen", flags = arrayOf(TimerFlag.ClearOnDeath)) {
var shouldApplyImmunity = false var shouldApplyImmunity = false
override fun save (root: JSONObject, entity: Entity) { override fun save (root: JSONObject, entity: Entity) {
root["ticksLeft"] = (nextExecution - getWorldTicks()).toString() root["ticksLeft"] = (nextExecution - getWorldTicks()).toString()
root["applyImmunity"] = shouldApplyImmunity root["applyImmunity"] = shouldApplyImmunity
} }
override fun parse (root: JSONObject, entity: Entity) { override fun parse (root: JSONObject, entity: Entity) {
runInterval = root["ticksLeft"].toString().toInt() runInterval = root["ticksLeft"].toString().toInt()
shouldApplyImmunity = root["applyImmunity"] as? Boolean ?: false shouldApplyImmunity = root["applyImmunity"] as? Boolean ?: false
} }
override fun beforeRegister (entity: Entity) { override fun beforeRegister (entity: Entity) {
if (hasTimerActive<FrozenImmunity>(entity)) { if (hasTimerActive<FrozenImmunity>(entity)) {
removeTimer(entity, this) removeTimer(entity, this)
return return
} }
if (hasTimerActive<Frozen>(entity)) { if (hasTimerActive<Frozen>(entity)) {
removeTimer(entity, this) removeTimer(entity, this)
return return
} }
} if (entity is Player) {
sendMessage(entity as Player, "You have been frozen!")
override fun run (entity: Entity) : Boolean { }
if (shouldApplyImmunity) { }
registerTimer (entity, spawnTimer<FrozenImmunity>(7))
} else (entity as? Player)?.debug ("Can't apply immunity") override fun run (entity: Entity) : Boolean {
return false if (shouldApplyImmunity) {
} registerTimer (entity, spawnTimer<FrozenImmunity>(7))
} else (entity as? Player)?.debug ("Can't apply immunity")
override fun getTimer (vararg args: Any) : RSTimer { return false
val inst = Frozen() }
inst.runInterval = args.getOrNull(0) as? Int ?: 10
inst.shouldApplyImmunity = args.getOrNull(1) as? Boolean ?: false override fun getTimer (vararg args: Any) : RSTimer {
return inst val inst = Frozen()
} inst.runInterval = args.getOrNull(0) as? Int ?: 10
} inst.shouldApplyImmunity = args.getOrNull(1) as? Boolean ?: false
return inst
}
}