From 9c42c7e4c986611b5fce6d383bbae09942ffdd0d Mon Sep 17 00:00:00 2001 From: Player Name Date: Wed, 15 Jul 2026 08:00:36 +0200 Subject: [PATCH] Improve lunar group spells --- .../global/skill/magic/lunar/HealSpell.java | 2 +- .../skill/magic/lunar/LunarListeners.kt | 12 ++++----- .../skill/magic/lunar/StatBoostSpell.java | 26 ++++++++++--------- .../skill/magic/lunar/StatRestoreSpell.java | 26 ++++++++++--------- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Server/src/main/content/global/skill/magic/lunar/HealSpell.java b/Server/src/main/content/global/skill/magic/lunar/HealSpell.java index e7db4f75c..8485e6e06 100644 --- a/Server/src/main/content/global/skill/magic/lunar/HealSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/HealSpell.java @@ -118,7 +118,7 @@ public final class HealSpell extends MagicSpell { List players = RegionManager.getLocalPlayers(player.getLocation(), 1); for (Iterator it = players.iterator(); it.hasNext();) { Player p = it.next(); - if (p.getName() == player.getName() || !p.getSettings().isAcceptAid() || !p.isActive() || p.getSkills().getLifepoints() == p.getSkills().getMaximumLifepoints()) { + if (p == player || !p.getSettings().isAcceptAid() || !p.isActive() || p.getSkills().getLifepoints() == p.getSkills().getMaximumLifepoints()) { it.remove(); } } diff --git a/Server/src/main/content/global/skill/magic/lunar/LunarListeners.kt b/Server/src/main/content/global/skill/magic/lunar/LunarListeners.kt index c32a4b69d..3bbfa2881 100644 --- a/Server/src/main/content/global/skill/magic/lunar/LunarListeners.kt +++ b/Server/src/main/content/global/skill/magic/lunar/LunarListeners.kt @@ -497,16 +497,16 @@ class LunarListeners : SpellListener("lunar"), Commands { removeRunes(player, true) visualizeSpell(player, Animations.LUNAR_SPELLBOOK_CURE_GROUP_4409, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_GROUP_2882) curePoison(player) - for (player in RegionManager.getLocalPlayers(player.location, 1)) { - if (!player.isActive || player.locks.isInteractionLocked) { + for (otherPlayer in RegionManager.getLocalPlayers(player.location, 1)) { + if (otherPlayer == player || !otherPlayer.isActive || otherPlayer.locks.isInteractionLocked) { continue } - if (!player.settings.isAcceptAid) { + if (!otherPlayer.settings.isAcceptAid) { continue } - curePoison(player) - sendMessage(player, "You have been cured of poison.") - visualizeSpell(player, -1, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_OTHER_INDIVIDUAL_2889) + curePoison(otherPlayer) + sendMessage(otherPlayer, "You have been cured of poison.") + visualizeSpell(otherPlayer, -1, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_OTHER_INDIVIDUAL_2889) } addXP(player, 74.0) } diff --git a/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java b/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java index b58529e77..b1af331fd 100644 --- a/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java @@ -16,6 +16,7 @@ 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 org.rs09.consts.Items; import org.rs09.consts.Sounds; import java.util.List; @@ -63,7 +64,7 @@ public final class StatBoostSpell extends MagicSpell { int size = 0; for (Player o : pl) { if (size >= doses) break; - if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) { + if (!o.isActive() || o.getLocks().isInteractionLocked()) { continue; } if (!o.getSettings().isAcceptAid() && !(o instanceof AIPlayer)) { @@ -79,17 +80,18 @@ public final class StatBoostSpell extends MagicSpell { return false; } super.meetsRequirements(player, true, true); - potion.getEffect().activate(player); - playGlobalAudio(player.getLocation(), Sounds.LUNAR_STRENGTH_SHARE_2901); - player.animate(ANIMATION); - player.graphics(GRAPHICS); - player.getInventory().remove(item); - int newIndex = (potion.getIds().length - doses) + size; - if (newIndex > potion.getIds().length - 1) { - player.getInventory().add(new Item(229)); - return true; - } - player.getInventory().add(new Item(potion.getIds()[newIndex])); + if (player.getInventory().remove(item)) { + potion.getEffect().activate(player); + playGlobalAudio(player.getLocation(), Sounds.LUNAR_STRENGTH_SHARE_2901); + player.animate(ANIMATION); + player.graphics(GRAPHICS); + int newIndex = (potion.getIds().length - doses) + size; + if (newIndex > potion.getIds().length - 1) { + player.getInventory().add(new Item(Items.VIAL_229)); + return true; + } + player.getInventory().add(new Item(potion.getIds()[newIndex])); + } return true; } } diff --git a/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java b/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java index b7aa4d15c..505d3921d 100644 --- a/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java @@ -16,6 +16,7 @@ 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 org.rs09.consts.Items; import org.rs09.consts.Sounds; import java.util.List; @@ -45,22 +46,22 @@ public class StatRestoreSpell extends MagicSpell { Item item = ((Item) target); player.getInterfaceManager().setViewedTab(6); - if (Consumables.getConsumableById(item.getId()) == null) { + if (Consumables.getConsumableById(item.getId()) == null) { player.getPacketDispatch().sendMessage("You can only cast this spell on a potion."); - return false; - } + return false; + } final Potion potion = (Potion) Consumables.getConsumableById(item.getId()).getConsumable(); if (potion == null) { - player.getPacketDispatch().sendMessage("You can only cast this spell on a potion."); + player.getPacketDispatch().sendMessage("You can only cast this spell on a potion."); return false; } if (!item.getDefinition().isTradeable() || !isRestore(potion)) { player.getPacketDispatch().sendMessage("You can't cast this spell on that item."); return false; } - List pl = RegionManager.getLocalPlayers(player.getLocation(), 2); + List pl = RegionManager.getLocalPlayers(player.getLocation(), 1); int doses = potion.getDose(item); if (pl.isEmpty()) { return false; @@ -90,13 +91,14 @@ public class StatRestoreSpell extends MagicSpell { playGlobalAudio(player.getLocation(), Sounds.LUNAR_STAT_SHARE_2899); player.animate(ANIMATION); player.graphics(GRAPHICS); - player.getInventory().remove(item); - int newIndex = (potion.getIds().length - doses) + size; - if (newIndex > potion.getIds().length - 1) { - player.getInventory().add(new Item(229)); - return true; - } - player.getInventory().add(new Item(potion.getIds()[newIndex])); + if (player.getInventory().remove(item)) { + int newIndex = (potion.getIds().length - doses) + size; + if (newIndex > potion.getIds().length - 1) { + player.getInventory().add(new Item(Items.VIAL_229)); + return true; + } + player.getInventory().add(new Item(potion.getIds()[newIndex])); + } return true; }