mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-26 12:55:11 -06:00
Fix bugs in multihit
This commit is contained in:
parent
4716a0b74d
commit
e91bf716a4
10 changed files with 15 additions and 14 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue