Fix bugs in multihit

This commit is contained in:
Player Name 2026-07-27 11:13:04 +02:00
parent 4716a0b74d
commit e91bf716a4
10 changed files with 15 additions and 14 deletions

View file

@ -55,14 +55,15 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler {
return -1;
}
List<Entity> targetCandidates = findMultihitTargets(victim.getLocation(), entity, victim, entity.getSwingHandler(false), CombatStyle.RANGE);
boolean accurate = isAccurateImpact(entity, victim, CombatStyle.RANGE);
List<Entity> targetCandidates = findMultihitTargets(victim.getLocation(), entity, victim, CombatStyle.RANGE);
BattleState[] targets = new BattleState[targetCandidates.size()];
int count = 0;
for (Entity e : targetCandidates) {
BattleState s = targets[count++] = new BattleState(entity, e);
s.setStyle(CombatStyle.RANGE);
int hit = 0;
if (isAccurateImpact(entity, e, CombatStyle.RANGE)) {
if (accurate) {
hit = RandomFunction.random(calculateHit(entity, e, 1.0) + 1);
}
s.setEstimatedHit(hit);

View file

@ -76,7 +76,7 @@ public final class PowerstabSpecialHandler extends MeleeSwingHandler implements
if (!multi) {
return super.swing(entity, victim, state);
}
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, entity.getSwingHandler(false), CombatStyle.MELEE);
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, CombatStyle.MELEE);
BattleState[] targets = new BattleState[list.size()];
int count = 0;
for (Entity e : list) {

View file

@ -77,7 +77,7 @@ public final class SpearWallSpecialHandler extends MeleeSwingHandler implements
if (!multi) {
return super.swing(entity, victim, state);
}
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, entity.getSwingHandler(false), CombatStyle.MELEE);
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, CombatStyle.MELEE);
BattleState[] targets = new BattleState[list.size()];
int count = 0;
for (Entity e : list) {

View file

@ -101,7 +101,7 @@ public final class SweepSpecialHandler extends MeleeSwingHandler implements Plug
Direction dir = Direction.getDirection(x - entity.getLocation().getX(), y - entity.getLocation().getY());
List<BattleState> l = new ArrayList<>(20);
l.add(new BattleState(entity, victim));
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, entity.getSwingHandler(false), CombatStyle.MELEE);
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, CombatStyle.MELEE);
for (Entity n : list) {
if (n == victim) {
continue;

View file

@ -121,7 +121,7 @@ public final class BloodSpells extends CombatSpell {
return super.getTargets(entity, target);
}
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, entity.getSwingHandler(false), CombatStyle.MAGIC);
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, CombatStyle.MAGIC);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -146,7 +146,7 @@ public final class IceSpells extends CombatSpell {
return super.getTargets(entity, target);
}
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, entity.getSwingHandler(false), CombatStyle.MAGIC);
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, CombatStyle.MAGIC);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -160,7 +160,7 @@ public final class MiasmicSpells extends CombatSpell {
return super.getTargets(entity, target);
}
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, entity.getSwingHandler(false), CombatStyle.MAGIC);
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, CombatStyle.MAGIC);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -117,7 +117,7 @@ public final class ShadowSpells extends CombatSpell {
return super.getTargets(entity, target);
}
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, entity.getSwingHandler(false), CombatStyle.MAGIC);
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, CombatStyle.MAGIC);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -125,7 +125,7 @@ public final class SmokeSpells extends CombatSpell {
return super.getTargets(entity, target);
}
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, entity.getSwingHandler(false), CombatStyle.MAGIC);
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, target, CombatStyle.MAGIC);
BattleState[] targets = new BattleState[list.size()];
int index = 0;
for (Entity e : list) {

View file

@ -8,8 +8,8 @@ import core.game.world.map.Location
import core.game.world.map.RegionManager.getLocalEntities
import core.game.world.map.zone.impl.WildernessZone
fun findMultihitTargets(center: Location, entity: Entity, victim: Entity, swingHandler: CombatSwingHandler, combatStyle: CombatStyle): List<Entity> {
val targetCandidates = getLocalEntities(center, 1).filter { it != entity && swingHandler.canSwing(entity, it) != InteractionType.NO_INTERACT && it.isAttackable(entity, combatStyle, false) }
fun findMultihitTargets(center: Location, attacker: Entity, victim: Entity, combatStyle: CombatStyle): List<Entity> {
val targetCandidates = getLocalEntities(center, 1).filter { it != attacker && it.isAttackable(attacker, combatStyle, false) }
val targets: List<Entity>?
if (victim is Player) {
val players = targetCandidates.filterIsInstance<Player>()
@ -17,7 +17,7 @@ fun findMultihitTargets(center: Location, entity: Entity, victim: Entity, swingH
if (entity !is Familiar) {
return false
}
return entity.owner in players
return entity.owner in players && WildernessZone.getInstance().continueAttack(attacker, entity.owner, combatStyle, false)
}
targets = targetCandidates.filter { it is Player || isFamiliarOf(it, players) }
} else {
@ -28,7 +28,7 @@ fun findMultihitTargets(center: Location, entity: Entity, victim: Entity, swingH
}
for (npc in npcs) {
if (npc is Familiar && npc.owner == entity) {
return WildernessZone.getInstance().continueAttack(entity, entity, combatStyle, false)
return WildernessZone.getInstance().continueAttack(attacker, entity, combatStyle, false)
}
}
return false