RewardInfo reward = e.getValue();
if(attacker == null || attacker.isDead() || reward == null)
{
continue;
}
L2Party party = attacker.getParty();
int maxHp = getMaxHp();
if(party == null)
{
int damage = Math.min(reward._dmg, maxHp);
if(damage > 0)
{
double[] xpsp = calculateExpAndSp(attacker, attacker.getLevel(), damage);
double neededExp = attacker.calcStat(Stats.SOULS_CONSUME_EXP, 0, this, null); // Начисление душ камаэлянам
if(neededExp > 0 && xpsp[0] > neededExp)
{
broadcastPacket(new SpawnEmitter(this, attacker));
ThreadPoolManager.getInstance().scheduleGeneral(new SoulConsumeTask(attacker), 1000);
}
xpsp[0] = applyOverhit(killer, xpsp[0]);
xpsp = attacker.applyVitality(this, xpsp[0], xpsp[1], 1.0);
attacker.addExpAndSp((long) xpsp[0], (long) xpsp[1], false, true);
}
rewards.remove(attacker);
}
else
{
int partyDmg = 0;
int partylevel = 1;
GArray<L2Player> rewardedMembers = new GArray<L2Player>();
for(L2Player partyMember : party.getPartyMembers())
{
RewardInfo ai = rewards.remove(partyMember);
if(partyMember.isDead() || !partyMember.isInRange(lastAttacker, Config.ALT_PARTY_DISTRIBUTION_RANGE))
{
continue;
}
if(ai != null)
{
partyDmg += ai._dmg;
}
rewardedMembers.add(partyMember);
if(partyMember.getLevel() > partylevel)
{
partylevel = partyMember.getLevel();
}
}
partyDmg = Math.min(partyDmg, maxHp);
if(partyDmg > 0)
{
double[] xpsp = calculateExpAndSp(attacker, partylevel, partyDmg);
double partyMul = (double) partyDmg / maxHp;
xpsp[0] *= partyMul;
xpsp[1] *= partyMul;
xpsp[0] = applyOverhit(killer, xpsp[0]);
party.distributeXpAndSp(xpsp[0], xpsp[1], rewardedMembers, lastAttacker, this);
}
}
}
// Check the drop of a cursed weapon
CursedWeaponsManager.getInstance().dropAttackable(this, killer);