mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Fixed multihit spells incorrectly targeting familiars
Fixed multihit spells incorrectly being limited to exclusively players or exclusively NPCs per cast
This commit is contained in:
parent
3dd189d0f3
commit
2ba1174678
1 changed files with 34 additions and 17 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package core.game.node.entity.combat.spell;
|
package core.game.node.entity.combat.spell;
|
||||||
|
|
||||||
|
import content.global.skill.summoning.familiar.Familiar;
|
||||||
import core.game.node.entity.combat.BattleState;
|
import core.game.node.entity.combat.BattleState;
|
||||||
import core.game.node.entity.combat.CombatStyle;
|
import core.game.node.entity.combat.CombatStyle;
|
||||||
import core.game.node.entity.combat.InteractionType;
|
import core.game.node.entity.combat.InteractionType;
|
||||||
|
|
@ -13,6 +14,7 @@ import core.game.node.entity.player.link.SpellBookManager;
|
||||||
import core.game.node.entity.player.link.audio.Audio;
|
import core.game.node.entity.player.link.audio.Audio;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
import core.game.world.map.RegionManager;
|
import core.game.world.map.RegionManager;
|
||||||
|
import core.game.world.map.zone.impl.WildernessZone;
|
||||||
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 org.rs09.consts.Sounds;
|
import org.rs09.consts.Sounds;
|
||||||
|
|
@ -106,27 +108,42 @@ public abstract class CombatSpell extends MagicSpell {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of possible targets for a multihitting spell.
|
* Gets a list of valid targets for a multihitting spell.
|
||||||
* @param entity The caster of the spell.
|
* @param entity The caster of the spell.
|
||||||
* @param target The victim.
|
* @param target The primary victim.
|
||||||
* @param max The max amount of victims.
|
* @param max The maximum number of extra victims that may be hit.
|
||||||
* @return The list of targets.
|
* @return The list of targets (the primary target is always at index 0).
|
||||||
*/
|
*/
|
||||||
public List<Entity> getMultihitTargets(Entity entity, Entity target, int max) {
|
public List<Entity> getMultihitTargets(Entity entity, Entity target, int max) {
|
||||||
List<Entity> list = new ArrayList<>(20);
|
List<Entity> victims = new ArrayList<>(20);
|
||||||
list.add(target);
|
victims.add(target);
|
||||||
boolean npc = target instanceof NPC;
|
|
||||||
for (Entity e : npc ? RegionManager.getSurroundingNPCs(target) : RegionManager.getSurroundingPlayers(target)) {
|
List<Entity> surrounding = new ArrayList<>();
|
||||||
if (e != target && e != entity && CombatStyle.MAGIC.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT) {
|
surrounding.addAll(RegionManager.getSurroundingPlayers(target));
|
||||||
list.add(e);
|
surrounding.addAll(RegionManager.getSurroundingNPCs(target));
|
||||||
|
|
||||||
|
for (Entity e : surrounding) {
|
||||||
|
if (e == target || e == entity) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (CombatStyle.MAGIC.getSwingHandler().canSwing(entity, e) == InteractionType.NO_INTERACT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (e instanceof Familiar) {
|
||||||
|
Player owner = ((Familiar) e).getOwner();
|
||||||
|
if (owner != entity && WildernessZone.getInstance().continueAttack(entity, owner, CombatStyle.MAGIC, true)) {
|
||||||
|
victims.add(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
victims.add(e);
|
||||||
}
|
}
|
||||||
if (--max < 1) {
|
if (--max < 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return victims;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visualizes the impact.
|
* Visualizes the impact.
|
||||||
|
|
@ -235,4 +252,4 @@ public abstract class CombatSpell extends MagicSpell {
|
||||||
return SPLASH_GRAPHIC;
|
return SPLASH_GRAPHIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue