diff --git a/Server/src/main/java/core/game/node/entity/combat/handlers/ChinchompaSwingHandler.java b/Server/src/main/java/core/game/node/entity/combat/handlers/ChinchompaSwingHandler.java index 3a5958848..01cf93d59 100644 --- a/Server/src/main/java/core/game/node/entity/combat/handlers/ChinchompaSwingHandler.java +++ b/Server/src/main/java/core/game/node/entity/combat/handlers/ChinchompaSwingHandler.java @@ -146,6 +146,7 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler { s.getVictim().animate(s.getVictim().getProperties().getDefenceAnimation()); } } + addExperience(entity, victim, state); } /** @@ -155,4 +156,4 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler { public static ChinchompaSwingHandler getInstance() { return INSTANCE; } -} \ No newline at end of file +} diff --git a/Server/src/main/java/core/game/world/map/Location.java b/Server/src/main/java/core/game/world/map/Location.java index 17b22e7c0..b7d188f55 100644 --- a/Server/src/main/java/core/game/world/map/Location.java +++ b/Server/src/main/java/core/game/world/map/Location.java @@ -229,6 +229,23 @@ public final class Location extends Node { return product <= dist; } + /** + * Returns if a player is within a specified distance using max norm distance. + * @param other The other location. + * @param dist The amount of distance. + * @return If you're within the other distance. + */ + public boolean withinMaxnormDistance(Location other, int dist) { + if (other.z != z) { + return false; + } + + int a = Math.abs(other.x - x); + int b = Math.abs(other.y - y); + double max = Math.max(a, b); + return max <= dist; + } + /** * Returns the distance between you and the other. * @param other The other location. @@ -455,4 +472,4 @@ public final class Location extends Node { public void setZ(int z) { this.z = z; } -} \ No newline at end of file +} diff --git a/Server/src/main/java/core/game/world/map/RegionManager.kt b/Server/src/main/java/core/game/world/map/RegionManager.kt index 1b3a9b0ba..0aefac707 100644 --- a/Server/src/main/java/core/game/world/map/RegionManager.kt +++ b/Server/src/main/java/core/game/world/map/RegionManager.kt @@ -538,11 +538,15 @@ object RegionManager { */ @JvmStatic fun getSurroundingPlayers(n: Node, maximum: Int, vararg ignore: Node): List { - val players = getLocalPlayers(n.location, 1) + val players = getLocalPlayers(n.location, 2) var count = 0 val it = players.iterator() while (it.hasNext()) { val p = it.next() + if(!p.location.withinMaxnormDistance(n.location, 1)) { + it.remove() + continue + } if (++count >= maximum) { it.remove() continue @@ -577,11 +581,15 @@ object RegionManager { */ @JvmStatic fun getSurroundingNPCs(n: Node, maximum: Int, vararg ignore: Node): List { - val npcs = getLocalNpcs(n.location, 1) + val npcs = getLocalNpcs(n.location, 2) var count = 0 val it = npcs.iterator() while (it.hasNext()) { val p = it.next() + if(!p.location.withinMaxnormDistance(n.location, 1)) { + it.remove() + continue + } if (++count > maximum) { it.remove() continue @@ -806,4 +814,4 @@ object RegionManager { val lock: ReentrantLock @JvmStatic get() = LOCK -} \ No newline at end of file +} diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt index 67839e677..315133061 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt @@ -244,6 +244,18 @@ open class MeleeSwingHandler if (state.secondaryHit > 0) { hit += state.secondaryHit } + if(state.targets != null) { + for (s in state.targets) { + if (s != null) { + if(s.estimatedHit > 0) { + hit += s.estimatedHit + } + if(s.secondaryHit > 0) { + hit += s.secondaryHit + } + } + } + } var experience = hit * EXPERIENCE_MOD val famExp = entity.getAttribute("fam-exp", false) && entity.familiarManager.hasFamiliar() if (!famExp) { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt index c40eaac9d..5e3bc381a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt @@ -148,6 +148,18 @@ open class RangeSwingHandler if (state.secondaryHit > 0) { hit += state.secondaryHit } + if(state.targets != null) { + for (s in state.targets) { + if (s != null) { + if(s.estimatedHit > 0) { + hit += s.estimatedHit + } + if(s.secondaryHit > 0) { + hit += s.secondaryHit + } + } + } + } val p = entity.asPlayer() val famExp = entity.getAttribute("fam-exp", false) && p.familiarManager.hasFamiliar() if (famExp) {