mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 11:25:11 -06:00
Multihit fix only chinchompas discriminate players and npcs
This commit is contained in:
parent
eca8597147
commit
8316d934e9
10 changed files with 21 additions and 27 deletions
|
|
@ -13,7 +13,7 @@ import core.tools.RandomFunction;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static core.game.node.entity.combat.MultihitTargetsKt.findMultihitTargets;
|
||||
import static core.game.node.entity.combat.MultihitTargetsKt.findMultihitTargetsForChinchompa;
|
||||
|
||||
/**
|
||||
* Handles a combat swing using red chinchompas.
|
||||
|
|
@ -56,7 +56,7 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler {
|
|||
}
|
||||
|
||||
boolean accurate = isAccurateImpact(entity, victim, CombatStyle.RANGE);
|
||||
List<Entity> targetCandidates = findMultihitTargets(victim.getLocation(), entity, victim, CombatStyle.RANGE);
|
||||
List<Entity> targetCandidates = findMultihitTargetsForChinchompa(victim.getLocation(), entity, victim);
|
||||
BattleState[] targets = new BattleState[targetCandidates.size()];
|
||||
int count = 0;
|
||||
for (Entity e : targetCandidates) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ import java.util.List;
|
|||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.BattleState;
|
||||
import core.game.node.entity.combat.CombatStyle;
|
||||
import core.game.node.entity.combat.InteractionType;
|
||||
import core.game.node.entity.combat.MeleeSwingHandler;
|
||||
import core.game.node.entity.impl.Animator.Priority;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
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;
|
||||
|
|
@ -76,7 +73,7 @@ public final class PowerstabSpecialHandler extends MeleeSwingHandler implements
|
|||
if (!multi) {
|
||||
return super.swing(entity, victim, state);
|
||||
}
|
||||
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, CombatStyle.MELEE);
|
||||
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, CombatStyle.MELEE);
|
||||
BattleState[] targets = new BattleState[list.size()];
|
||||
int count = 0;
|
||||
for (Entity e : list) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ import java.util.List;
|
|||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.BattleState;
|
||||
import core.game.node.entity.combat.CombatStyle;
|
||||
import core.game.node.entity.combat.InteractionType;
|
||||
import core.game.node.entity.combat.MeleeSwingHandler;
|
||||
import core.game.node.entity.impl.Animator.Priority;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
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;
|
||||
|
|
@ -77,7 +74,7 @@ public final class SpearWallSpecialHandler extends MeleeSwingHandler implements
|
|||
if (!multi) {
|
||||
return super.swing(entity, victim, state);
|
||||
}
|
||||
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, victim, CombatStyle.MELEE);
|
||||
List<Entity> list = findMultihitTargets(entity.getLocation(), entity, CombatStyle.MELEE);
|
||||
BattleState[] targets = new BattleState[list.size()];
|
||||
int count = 0;
|
||||
for (Entity e : list) {
|
||||
|
|
|
|||
|
|
@ -2,21 +2,16 @@ package content.global.handlers.item.equipment.special;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import core.game.world.repository.Repository;
|
||||
import core.plugin.Initializable;
|
||||
import content.global.skill.summoning.familiar.Familiar;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.BattleState;
|
||||
import core.game.node.entity.combat.CombatStyle;
|
||||
import core.game.node.entity.combat.MeleeSwingHandler;
|
||||
import core.game.node.entity.impl.Animator.Priority;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
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;
|
||||
|
|
@ -101,7 +96,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(vl, entity, victim, null);
|
||||
List<Entity> list = findMultihitTargets(vl, entity, null);
|
||||
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, CombatStyle.MAGIC);
|
||||
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, 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, CombatStyle.MAGIC);
|
||||
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, 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, CombatStyle.MAGIC);
|
||||
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, 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, CombatStyle.MAGIC);
|
||||
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, 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, CombatStyle.MAGIC);
|
||||
List<Entity> list = MultihitTargetsKt.findMultihitTargets(target.getLocation(), entity, CombatStyle.MAGIC);
|
||||
BattleState[] targets = new BattleState[list.size()];
|
||||
int index = 0;
|
||||
for (Entity e : list) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import core.game.world.map.Location
|
|||
import core.game.world.map.RegionManager.getLocalEntities
|
||||
import core.game.world.map.zone.impl.WildernessZone
|
||||
|
||||
fun isAttackable(victim: Entity, attacker: Entity, combatStyle: CombatStyle?, wilderness: Boolean): Boolean {
|
||||
private fun isAttackable(victim: Entity, attacker: Entity, combatStyle: CombatStyle?, wilderness: Boolean): Boolean {
|
||||
if (combatStyle == null) {
|
||||
return true
|
||||
}
|
||||
|
|
@ -18,8 +18,13 @@ fun isAttackable(victim: Entity, attacker: Entity, combatStyle: CombatStyle?, wi
|
|||
return victim.isAttackable(attacker, combatStyle, false)
|
||||
}
|
||||
|
||||
fun findMultihitTargets(center: Location, attacker: Entity, victim: Entity, combatStyle: CombatStyle?): List<Entity> {
|
||||
val targetCandidates = getLocalEntities(center, 1).filter { it != attacker && isAttackable(it, attacker, combatStyle, false) }
|
||||
fun findMultihitTargets(center: Location, attacker: Entity, combatStyle: CombatStyle?): List<Entity> {
|
||||
val targets = getLocalEntities(center, 1).filter { it != attacker && isAttackable(it, attacker, combatStyle, false) }
|
||||
return targets.take(9)
|
||||
}
|
||||
|
||||
fun findMultihitTargetsForChinchompa(center: Location, attacker: Entity, victim: Entity): List<Entity> {
|
||||
val targetCandidates = getLocalEntities(center, 1).filter { it != attacker && isAttackable(it, attacker, CombatStyle.RANGE, false) }
|
||||
val targets: List<Entity>?
|
||||
if (victim is Player) {
|
||||
val players = targetCandidates.filterIsInstance<Player>()
|
||||
|
|
@ -27,9 +32,9 @@ fun findMultihitTargets(center: Location, attacker: Entity, victim: Entity, comb
|
|||
if (entity !is Familiar) {
|
||||
return false
|
||||
}
|
||||
return entity.owner in players && isAttackable(entity.owner, attacker, combatStyle, true)
|
||||
return entity.owner in players && isAttackable(entity.owner, attacker, CombatStyle.RANGE, true)
|
||||
}
|
||||
targets = targetCandidates.filter { (it is Player && isAttackable(attacker, it, combatStyle, true)) || isFamiliarOf(it, players) }
|
||||
targets = targetCandidates.filter { (it is Player && isAttackable(attacker, it, CombatStyle.RANGE, true)) || isFamiliarOf(it, players) }
|
||||
} else {
|
||||
val npcs = targetCandidates.filterIsInstance<NPC>()
|
||||
fun isOwnerOf(entity: Entity, npcs: List<NPC>): Boolean {
|
||||
|
|
@ -38,7 +43,7 @@ fun findMultihitTargets(center: Location, attacker: Entity, victim: Entity, comb
|
|||
}
|
||||
for (npc in npcs) {
|
||||
if (npc is Familiar && npc.owner == entity) {
|
||||
return isAttackable(entity, attacker, combatStyle, true)
|
||||
return isAttackable(entity, attacker, CombatStyle.RANGE, true)
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue