Prevent Karma transfer bug.

This commit is contained in:
MobiusDev
2015-09-12 11:04:02 +00:00
parent cc669ba506
commit 41e442577b
2 changed files with 25 additions and 19 deletions

View File

@@ -450,7 +450,7 @@ public final class L2PcInstance extends L2Playable
private long _expBeforeDeath; private long _expBeforeDeath;
/** The Karma of the L2PcInstance (if higher than 0, the name of the L2PcInstance appears in red) */ /** The Karma of the L2PcInstance (if higher than 0, the name of the L2PcInstance appears in red) */
private int _karma; private int _karma = 0;
/** The Reputation of the L2PcInstance (if higher than 0, the name of the L2PcInstance appears in green) */ /** The Reputation of the L2PcInstance (if higher than 0, the name of the L2PcInstance appears in green) */
private int _reputation; private int _reputation;
@@ -5656,24 +5656,25 @@ public final class L2PcInstance extends L2Playable
return; return;
} }
// PK Points are increased only if you kill a player. // Calculate new karma. (calculate karma before incrase pk count!)
if (target.isPlayer()) final int addedKarma = Formulas.calculateKarmaGain(getPkKills(), target);
if (addedKarma > 0)
{ {
if (target.getActingPlayer().getKarma() <= 0) if (!Config.FACTION_SYSTEM_ENABLED)
{ {
if (!Config.FACTION_SYSTEM_ENABLED) setKarma(getKarma() + addedKarma);
{
// Calculate new karma. (calculate karma before incrase pk count!)
setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target.isSummon()));
}
if (_PvPRegTask != null)
{
_PvPRegTask.cancel(true);
updatePvPFlag(0);
}
setPkKills(getPkKills() + 1);
_reputation = 0;
} }
// PK Points are increased only if you kill a player.
if (target.isPlayer())
{
setPkKills(getPkKills() + 1);
}
if (_PvPRegTask != null)
{
_PvPRegTask.cancel(true);
updatePvPFlag(0);
}
_reputation = 0;
} }
// Update player's UI. // Update player's UI.

View File

@@ -2166,14 +2166,19 @@ public final class Formulas
/** /**
* Calculates karma gain upon playable kill.</br> Updated to High Five on 10.09.2014 by Zealar tested in retail. * Calculates karma gain upon playable kill.</br> Updated to High Five on 10.09.2014 by Zealar tested in retail.
* @param pkCount * @param pkCount
* @param isSummon * @param target
* @return karma points that will be added to the player. * @return karma points that will be added to the player.
*/ */
public static int calculateKarmaGain(int pkCount, boolean isSummon) public static int calculateKarmaGain(int pkCount, L2Character target)
{ {
if ((target.isPlayer() && (target.getActingPlayer().getKarma() > 0)) || (target.isSummon() && (target.getSummoner().getActingPlayer().getKarma() > 0)))
{
return 0;
}
int result = 43200; int result = 43200;
if (isSummon) if (target.isSummon())
{ {
result = (int) ((((pkCount * 0.375) + 1) * 60) * 4) - 150; result = (int) ((((pkCount * 0.375) + 1) * 60) * 4) - 150;