mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 19:35:10 -06:00
barrage debugging
This commit is contained in:
parent
7c4b0f19dd
commit
1a48009b85
2 changed files with 32 additions and 1 deletions
|
|
@ -121,7 +121,7 @@ public abstract class CombatSpell extends MagicSpell {
|
|||
List<Entity> victims = new ArrayList<>(20);
|
||||
victims.add(target);
|
||||
|
||||
List<Entity> surrounding = RegionManager.getLocalEntities(target.getLocation(), 1);
|
||||
List<Entity> surrounding = RegionManager.getLocalEntitiesIce(target.getLocation(), 1);
|
||||
for (Entity e : surrounding) {
|
||||
if (e == target || e == entity) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -453,6 +453,37 @@ object RegionManager {
|
|||
@JvmStatic fun getSurroundingNPCs(npc: Entity, maximum: Int): List<NPC> = getLocalEntities<NPC>(npc.location, 1, maximum, null)
|
||||
@JvmStatic fun getLocalPlayersBoundingBox(location: Location, maximum: Int): List<Player> = getLocalEntities<Player>(location, 1, maximum, null)
|
||||
|
||||
@JvmStatic fun getLocalEntitiesIce(location: Location, distance: Int): List<Entity> {
|
||||
val maximum = 0
|
||||
val ignore = null
|
||||
|
||||
val entities: MutableList<Entity> = ArrayList(20)
|
||||
for (cx in (location.absChunkX - 0)..(location.absChunkX + 0)) {
|
||||
for (cy in (location.absChunkY - 0)..(location.absChunkY + 0)) {
|
||||
println("cx = $cx, cy = $cy, loc = $location, cx shl 3 = ${cx shl 3}, cy shl 3 = ${cy shl 3}")
|
||||
val loc = Location(cx shl 3, cy shl 3, location.z)
|
||||
println("Grabbing chunk at $cx,$cy, which is location $loc")
|
||||
val chunk = Location(cx shl 3, cy shl 3, location.z).chunk
|
||||
if (Entity::class.java.isAssignableFrom(Player::class.java)) {
|
||||
println("adding players, of which there are ${chunk.players.size}")
|
||||
entities.addAll(chunk.players as Collection<Entity>)
|
||||
}
|
||||
if (Entity::class.java.isAssignableFrom(NPC::class.java)) {
|
||||
println("adding npcs, of which there are ${chunk.npcs.size}")
|
||||
entities.addAll(chunk.npcs as Collection<Entity>)
|
||||
}
|
||||
println("Processed a chunk, now have ${entities.size} entities")
|
||||
}
|
||||
}
|
||||
val b = ZoneBorders(location.x - distance, location.y - distance, location.x + distance, location.y + distance)
|
||||
var filtered = entities.filter { it != ignore && b.insideBorder(it.location.x, it.location.y) }
|
||||
if (maximum > 0 && filtered.size > maximum) {
|
||||
filtered = filtered.slice(0 until maximum)
|
||||
}
|
||||
println("After filtering, ${entities.size} entities")
|
||||
return filtered
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a random teleport location in the radius around the given location.
|
||||
* @param location The centre location.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue