Improved lootshare so that drops are awarded to clan members near a slain NPC, participation in combat is not necessary
Reconnecting in combat will no longer cause lost drops
This commit is contained in:
@@ -263,7 +263,7 @@ public final class DuelSession extends ComponentPlugin {
|
|||||||
Player o = getOpposite(p);
|
Player o = getOpposite(p);
|
||||||
o.getImpactHandler().setDisabledTicks(6);
|
o.getImpactHandler().setDisabledTicks(6);
|
||||||
o.teleport(RandomFunction.getRandomElement(DuelArea.RESPAWN_LOCATIONS));
|
o.teleport(RandomFunction.getRandomElement(DuelArea.RESPAWN_LOCATIONS));
|
||||||
boolean victory = type == 0 || type == 2 || type == 1 && p.getImpactHandler().getImpactLog().containsKey(o);
|
boolean victory = type == 0 || type == 2 || type == 1 && p.getImpactHandler().getPlayerImpactLog().containsKey(o.getDetails().getUid());
|
||||||
fightState = 2;
|
fightState = 2;
|
||||||
p.removeExtension(DuelSession.class);
|
p.removeExtension(DuelSession.class);
|
||||||
end();
|
end();
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ public final class DeathTask extends NodeTask {
|
|||||||
e.getProperties().setTeleportLocation(spawn);
|
e.getProperties().setTeleportLocation(spawn);
|
||||||
e.unlock();
|
e.unlock();
|
||||||
e.finalizeDeath(killer);
|
e.finalizeDeath(killer);
|
||||||
e.getImpactHandler().getImpactLog().clear();// check if this needs to be
|
e.getImpactHandler().getNpcImpactLog().clear();// check if this needs to be before finalize
|
||||||
// before finalize
|
e.getImpactHandler().getPlayerImpactLog().clear();// check if this needs to be before finalize
|
||||||
e.getImpactHandler().setDisabledTicks(4);
|
e.getImpactHandler().setDisabledTicks(4);
|
||||||
e.dispatch(new SelfDeathEvent(killer));
|
e.dispatch(new SelfDeathEvent(killer));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import core.game.node.entity.skill.Skills;
|
|||||||
import content.global.skill.summoning.familiar.Familiar;
|
import content.global.skill.summoning.familiar.Familiar;
|
||||||
import content.global.skill.summoning.pet.Pet;
|
import content.global.skill.summoning.pet.Pet;
|
||||||
import core.game.node.entity.Entity;
|
import core.game.node.entity.Entity;
|
||||||
import core.game.node.entity.npc.NPC;
|
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.entity.player.link.prayer.PrayerType;
|
import core.game.node.entity.player.link.prayer.PrayerType;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
@@ -14,13 +13,13 @@ import core.game.system.task.Pulse;
|
|||||||
import core.game.bots.AIPlayer;
|
import core.game.bots.AIPlayer;
|
||||||
import core.game.world.GameWorld;
|
import core.game.world.GameWorld;
|
||||||
import core.game.world.map.zone.ZoneType;
|
import core.game.world.map.zone.ZoneType;
|
||||||
|
import core.game.world.repository.Repository;
|
||||||
import org.rs09.consts.Items;
|
import org.rs09.consts.Items;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used for handling combat impacts.
|
* Class used for handling combat impacts.
|
||||||
@@ -39,9 +38,14 @@ public final class ImpactHandler {
|
|||||||
private int disabledTicks;
|
private int disabledTicks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The impact log.
|
* The NPC impact log.
|
||||||
*/
|
*/
|
||||||
private final Map<Entity, Integer> impactLog = new HashMap<>();
|
private final Map<Entity, Integer> npcImpactLog = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The player impact log. This is by player uid to cope with players relogging.
|
||||||
|
*/
|
||||||
|
private final Map<Integer, Integer> playerImpactLog = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current hitsplats to show.
|
* Gets the current hitsplats to show.
|
||||||
@@ -167,11 +171,14 @@ public final class ImpactHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (hit > 0) {
|
if (hit > 0) {
|
||||||
Integer value = impactLog.get(source);
|
if (source instanceof Player) {
|
||||||
if (value == null) {
|
int uid = source.asPlayer().getDetails().getUid();
|
||||||
value = 0;
|
Integer value = playerImpactLog.get(uid);
|
||||||
|
playerImpactLog.put(uid, value == null ? hit : hit + value);
|
||||||
|
} else {
|
||||||
|
Integer value = npcImpactLog.get(source);
|
||||||
|
npcImpactLog.put(source, value == null ? hit : hit + value);
|
||||||
}
|
}
|
||||||
impactLog.put(source, hit + value);
|
|
||||||
}
|
}
|
||||||
if (style != null && style.getSwingHandler() != null && source instanceof Player) {
|
if (style != null && style.getSwingHandler() != null && source instanceof Player) {
|
||||||
Player player = source.asPlayer();
|
Player player = source.asPlayer();
|
||||||
@@ -248,35 +255,47 @@ public final class ImpactHandler {
|
|||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
return killer;
|
return killer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int damage = -1;
|
int damage = -1;
|
||||||
for (Entity e : impactLog.keySet()) {
|
if (playerImpactLog.isEmpty()) {
|
||||||
if (e == this.entity) {
|
for (Entity e : npcImpactLog.keySet()) {
|
||||||
continue;
|
if (e == this.entity) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int amount = npcImpactLog.get(e);
|
||||||
|
if (amount > damage) {
|
||||||
|
damage = amount;
|
||||||
|
entity = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int amount = impactLog.get(e);
|
return entity;
|
||||||
if (amount > damage || (entity instanceof NPC && e instanceof Player)) {
|
}
|
||||||
|
|
||||||
|
int player = 0; //needs to be fake-initialized because java is dumb
|
||||||
|
for (int uid : playerImpactLog.keySet()) {
|
||||||
|
int amount = playerImpactLog.get(uid);
|
||||||
|
if (amount > damage) {
|
||||||
damage = amount;
|
damage = amount;
|
||||||
entity = e;
|
player = uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entity;
|
return Repository.getPlayerByUid(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the impact log.
|
* Gets the npc impact log.
|
||||||
* @return The impact log.
|
* @return The npc impact log.
|
||||||
*/
|
*/
|
||||||
public Map<Entity, Integer> getImpactLog() {
|
public Map<Entity, Integer> getNpcImpactLog() {
|
||||||
return impactLog;
|
return npcImpactLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the impact log filtered for Player objects
|
* Gets the player impact log.
|
||||||
* @return The impact log of each Player and their damage
|
* @return The player impact log.
|
||||||
*/
|
*/
|
||||||
public Map<Player, Integer> getPlayerImpactLog() {
|
public Map<Integer, Integer> getPlayerImpactLog() {
|
||||||
return impactLog.entrySet().stream().filter(entry -> entry.getKey() instanceof Player).collect(
|
return playerImpactLog;
|
||||||
Collectors.toMap(m -> m.getKey().asPlayer(), m -> m.getValue()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -390,4 +409,4 @@ public final class ImpactHandler {
|
|||||||
public static enum HitsplatType {
|
public static enum HitsplatType {
|
||||||
MISS, NORMAL, POISON, DISEASE, NORMAL_1, VENOM;
|
MISS, NORMAL, POISON, DISEASE, NORMAL_1, VENOM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ public class NPC extends Entity {
|
|||||||
handleDrops(p, killer);
|
handleDrops(p, killer);
|
||||||
if (!isRespawn())
|
if (!isRespawn())
|
||||||
clear();
|
clear();
|
||||||
isRespawning = true;
|
isRespawning = true;
|
||||||
behavior.onDeathFinished(this, killer);
|
behavior.onDeathFinished(this, killer);
|
||||||
killer.dispatch(new NPCKillEvent(this));
|
killer.dispatch(new NPCKillEvent(this));
|
||||||
setRespawnTick(GameWorld.getTicks() + definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 17));
|
setRespawnTick(GameWorld.getTicks() + definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 17));
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public final class NPCDropTables {
|
|||||||
List<Player> players = RegionManager.getLocalPlayers(npc, 16);
|
List<Player> players = RegionManager.getLocalPlayers(npc, 16);
|
||||||
List<Player> looters = new ArrayList<>(20);
|
List<Player> looters = new ArrayList<>(20);
|
||||||
for (Player p : players) {
|
for (Player p : players) {
|
||||||
if (p != null && p.getCommunication().getClan() != null && p.getCommunication().getClan() == player.getCommunication().getClan() && p.getCommunication().isLootShare() && p.getCommunication().getLootRequirement().ordinal() >= p.getCommunication().getClan().getLootRequirement().ordinal() && npc.getImpactHandler().getImpactLog().containsKey(p)) {
|
if (p != null && p.getCommunication().getClan() != null && p.getCommunication().getClan() == player.getCommunication().getClan() && p.getCommunication().isLootShare() && p.getCommunication().getLootRequirement().ordinal() >= p.getCommunication().getClan().getLootRequirement().ordinal() && !p.getIronmanManager().isIronman()) {
|
||||||
looters.add(p);
|
looters.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user