multihit wip

This commit is contained in:
Player Name 2026-07-27 09:04:19 +02:00
parent 917827ce8d
commit eb3c64d61a
7 changed files with 21 additions and 22 deletions

View file

@ -118,7 +118,7 @@ public final class BloodSpells extends CombatSpell {
if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
return super.getTargets(entity, target);
}
List<Entity> list = getMultihitTargets(entity, target, 9);
List<Entity> list = getMultihitTargets(entity, target);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -143,7 +143,7 @@ public final class IceSpells extends CombatSpell {
if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
return super.getTargets(entity, target);
}
List<Entity> list = getMultihitTargets(entity, target, 9);
List<Entity> list = getMultihitTargets(entity, target);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -157,7 +157,7 @@ public final class MiasmicSpells extends CombatSpell {
|| !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
return super.getTargets(entity, target);
}
List<Entity> list = getMultihitTargets(entity, target, 9);
List<Entity> list = getMultihitTargets(entity, target);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -115,7 +115,7 @@ public final class ShadowSpells extends CombatSpell {
if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
return super.getTargets(entity, target);
}
List<Entity> list = getMultihitTargets(entity, target, 9);
List<Entity> list = getMultihitTargets(entity, target);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -123,7 +123,7 @@ public final class SmokeSpells extends CombatSpell {
if (animation.getId() == 1978 || !entity.getProperties().isMultiZone() || !target.getProperties().isMultiZone()) {
return super.getTargets(entity, target);
}
List<Entity> list = getMultihitTargets(entity, target, 9);
List<Entity> list = getMultihitTargets(entity, target);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -20,7 +20,7 @@ import static core.api.ContentAPIKt.*;
* @author Emperor
*/
public final class PestControlSession {
private static STRANGE_PHANTOM_OBJECT_THAT_SHARES_A_TILE_WITH_A_BARRICADE = 25636;
private static int STRANGE_PHANTOM_OBJECT_THAT_SHARES_A_TILE_WITH_A_BARRICADE = 25636;
/**
* The barricade object offsets.
@ -31,7 +31,7 @@ public final class PestControlSession {
* The object ids of non-attackable barricades/gates.
*/
public static final int[] INVALID_OBJECT_IDS = {14230, 14231, 14232, // Barricades
14245, 14246, 14247, 14248, // Gates
14245, 14246, 14247, 14248 // Gates
};
/**

View file

@ -111,17 +111,19 @@ public abstract class CombatSpell extends MagicSpell {
/**
* Gets a list of valid targets for a multihitting spell.
* @param entity The caster of the spell.
* @param target The primary victim.
* @param max The maximum number of extra victims that may be hit.
* @param victim The primary victim.
* @return The list of targets (the primary target is always at index 0).
*/
public List<Entity> getMultihitTargets(Entity entity, Entity target, int max) {
List<Entity> victims = new ArrayList<>(max+1);
victims.add(target);
List<Entity> surrounding = RegionManager.getLocalEntities(target.getLocation(), 1);
for (Entity e : surrounding) {
if (e == target || e == entity) {
public List<Entity> getMultihitTargets(Entity entity, Entity victim) {
// https://oldschool.runescape.wiki/w/Chinchompa - shit source but it's better than what was here before
List<? extends Entity> targetCandidates;
if (victim instanceof Player) {
targetCandidates = RegionManager.getSurroundingPlayers(victim, 9);
} else {
targetCandidates = RegionManager.getSurroundingNPCs(victim, 11);
}
for (Entity e : targetCandidates) {
if (e == victim || e == entity) {
continue;
}
if (CombatStyle.MAGIC.getSwingHandler().canSwing(entity, e) == InteractionType.NO_INTERACT || !e.isAttackable(entity, CombatStyle.MAGIC, false)) {
@ -130,16 +132,13 @@ public abstract class CombatSpell extends MagicSpell {
if (e instanceof Familiar) {
Player owner = ((Familiar) e).getOwner();
if (owner != entity && WildernessZone.getInstance().continueAttack(entity, owner, CombatStyle.MAGIC, true)) {
victims.add(e);
targetCandidates.add(e);
}
} else {
victims.add(e);
}
if (--max < 1) {
break;
targetCandidates.add(e);
}
}
return victims;
return targetCandidates;
}
/**