Index: D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2PcInstance.java
===================================================================
--- D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2PcInstance.java (revision 2211)
+++ D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2PcInstance.java (working copy)
@@ -2391,7 +2391,8 @@
*/
public void doDie(L2Character killer)
{
- // Kill the L2PcInstance
+ int lostXP=0; //useful for new karma reduction...Team Olympus.
+ // Kill the L2PcInstance
super.doDie(killer);
if (killer != null)
@@ -2401,15 +2402,15 @@
{
if (!ZoneManager.getInstance().checkIfInZonePvP(this) && (getSkillLevel(L2Skill.SKILL_LUCKY) < 0 || getStat().getLevel() > 4))
if(killer instanceof L2PcInstance && ((L2PcInstance)killer).getClan() != null && this.getClan() != null && this.getClan().isAtWarWith(((L2PcInstance)killer).getClanId()))
- deathPenalty(true);
+ lostXP=deathPenalty(true);
else
- deathPenalty(false);
+ lostXP=deathPenalty(false);
}
onDieDropItem(killer); // Check if any item should be dropped
}
- if (killer != this) onDieUpdateKarma();
+ if (killer != this) onDieUpdateKarma(lostXP);
setPvpFlag(0); // Clear the pvp flag
// Unsummon the Pet
@@ -2661,21 +2662,42 @@
}
}
- private void onDieUpdateKarma()
+ private void onDieUpdateKarma(int lostXP)
{
// KARMA LOSS FOR DEAD PLAYER
// when a PKer gets killed by another player or a L2MonsterInstance, it loseq a certain amount of Karma based on their level.
- // this (with defaults) results in a level 1 losing about ~2 karma per death, and a lvl 70 loses about 11760 karma per death...
- // You lose karma as long as you were not in a pvp zone and you did not kill urself.
+ //new karma loss code by team Olympus:
+ //Lose karma as a fraction of the XP you lost upon dying (ignoring how much
+ //of that XP might be returned by ressurection).
+ //NOTE: This also provides an elegant solution for no karma loss in PvP zones
+ //and for limitted karma loss in sieges (as specified in discussions from retail).
+ // old karma loss, used when options do not allow XP loss on death:
+ // when a PKer gets killed by another player or a L2MonsterInstance, it loseq a certain amount of Karma based on their level.
+ // You lose karma as long as you were not in a pvp zone and you did not kill urself.
if ( getKarma() > 0 && !ZoneManager.getInstance().checkIfInZonePvP(this) )
{
- // this formula seems to work relatively well:
- // baseKarma * thisLVL * (thisLVL/100)
- // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
- double karmaLost = Config.KARMA_LOST_BASE;
- karmaLost *= getLevel(); // multiply by char lvl
- karmaLost *= (getLevel() / 100); // divide by 0.charLVL
- karmaLost = Math.round(karmaLost);
+
+ int karmaLost = 0;
+ if (Config.ALT_GAME_DELEVEL)
+ {
+ karmaLost = lostXP/260; //this 260 seems to work quite accurately.
+ // leave karmalost to 0 only if 0 xp was lost
+ // This works greate with arena (0 xp loss, 0 karma loss),
+ // sieges (reduced xp loss, reduced karma loss as described in official forums),
+ // and normal zones...
+ if (karmaLost ==0 && lostXP >0)
+ karmaLost = 1;
+ }
+ else
+ {
+ // this formula seems to work relatively well:
+ // baseKarma * thisLVL * (thisLVL/100)
+ // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
+ karmaLost = Config.KARMA_LOST_BASE;
+ karmaLost *= getLevel(); // multiply by char lvl
+ karmaLost *= (int)(getLevel() / 100); // divide by 0.charLVL
+ karmaLost = Math.round(karmaLost);
+ }
if ( karmaLost < 0 ) karmaLost = 1;
// Decrease Karma of the L2PcInstance and Send it a Server->Client StatusUpdate packet with Karma and PvP Flag if necessary
@@ -2812,8 +2834,9 @@
* <li>Set the new Experience value of the L2PcInstance and Decrease its level if necessary </li>
* <li>Send a Server->Client StatusUpdate packet with its new Experience </li><BR><BR>
*
+ * <li>return the amount of XP lost, to be used for karma loss.
*/
- public void deathPenalty(boolean atwar)
+ public int deathPenalty(boolean atwar)
{
// TODO Need Correct Penalty
@@ -2835,6 +2858,7 @@
// Set the new Experience value of the L2PcInstance
getStat().addExp(-lostExp);
+ return lostExp;
}