Merge branch 'fix-multitarget-xp' into 'master'

Fix xp of multitarget attacks (like chinchompas, dragon claw/halberd spec) and...

See merge request 2009scape/2009scape!265
This commit is contained in:
Ceikry 2021-09-22 21:09:31 +00:00
commit 9cdd121a8d
5 changed files with 55 additions and 5 deletions

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -538,11 +538,15 @@ object RegionManager {
*/
@JvmStatic
fun getSurroundingPlayers(n: Node, maximum: Int, vararg ignore: Node): List<Player> {
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<NPC> {
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
}
}

View file

@ -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) {

View file

@ -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) {