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 2082) +++ D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2PcInstance.java (working copy) @@ -1276,9 +1276,9 @@ */ public void setKarma(int karma) { + int oldKarma = _karma; _karma = karma; - - if (karma > 0) + if (karma > 0 || oldKarma != _karma) { StatusUpdate su = new StatusUpdate(getObjectId()); su.addAttribute(StatusUpdate.KARMA, karma); @@ -1563,22 +1563,8 @@ setSp(currSp); // Remove Karma when the player kills L2MonsterInstance - if (currExp != 0 || isGM()) - { - // NEW KARMA REMOVAL FROM XP by ootz0rz - int karmaRemove = addToExp; - int xpDivi = Config.KARMA_XP_DIVIDER; - karmaRemove /= xpDivi; + // removed and placed in l2attackable - if ( karmaRemove < 0 ) karmaRemove = 1; - _karma -= karmaRemove; - - if (Config.DEBUG) _log.fine("removed "+karmaRemove+" karma from " + getName()); - } - - if (_karma < 0) - _karma = 0; - // Send a Server->Client packet StatusUpdate to the L2PcInstance StatusUpdate su = new StatusUpdate(getObjectId()); su.addAttribute(StatusUpdate.EXP, currExp); @@ -2589,6 +2575,10 @@ deathPenalty(true); else deathPenalty(false); + //If the character is participating in a siege, also calculate death penalty + // but this will be 1/4 the normal XP loss. + if (L2Siege.checkIfObjectInZone(getX(), getY())) + deathPenalty(true); } @@ -2707,28 +2697,13 @@ // 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. + + System.out.println("check if he has karma"); if ( this.getKarma() > 0 ) { - - // this formula seems to work relatively well: - // baseKarma * thisLVL * (thisLVL/100) - int finalKarma = 0; - double baseKarmaLost = Config.KARMA_LOST_BASE; - double karmaLost = baseKarmaLost; - double thisLVL = this.getLevel(); - double tempMulti = thisLVL / 100; - - - // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti - karmaLost *= thisLVL; // multiply by char lvl - karmaLost *= tempMulti; // divide by 0.charLVL - karmaLost = Math.round(karmaLost); - finalKarma = (int)karmaLost; - if ( finalKarma < 0 ) finalKarma = 1; - - // Decrease Karma of the L2PcInstance and Send it a Server->Client StatusUpdate packet with Karma and PvP Flag if necessary + System.out.println("he has karma and died, reuce karma by 600"); + int finalKarma = 600; this.redreaseKarma(finalKarma); - } } } Index: D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2Attackable.java =================================================================== --- D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2Attackable.java (revision 2082) +++ D:/Source/trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2Attackable.java (working copy) @@ -667,6 +667,19 @@ // Distribute the Exp and SP between the L2PcInstance and its L2Summon attacker.addExpAndSp((int)attacker.calcStat(Stats.EXPSP_RATE, xp, null, null), (int)attacker.calcStat(Stats.EXPSP_RATE, sp, null, null)); + if (attacker instanceof L2PcInstance) + { + int karmaloss; + int currKarma = ((L2PcInstance) attacker).getKarma(); + if (diff < 0) + karmaloss = 20; + else if (diff > 10) + karmaloss = 0; + else + karmaloss = 230 - 20 * diff; + if (currKarma - karmaloss < 0) karmaloss = currKarma; + ((L2PcInstance) attacker).setKarma(currKarma-karmaloss); + } } else { @@ -689,13 +702,30 @@ // If the L2PcInstance is in the L2Attackable rewards add its damages to party damages if (ai != null) { - // Add L2PcInstance damages to party damages + // Add L2PcInstance damages to party damages partyDmg += ai.dmg; - - // Remove the L2PcInstance from the L2Attackable rewards - rewards.remove(pl); + // work out karma loss + if (!pl.isDead()) + { + float karmaRatio = ai.dmg/(float)getMaxHp(); + int diff = attackerParty.getLevel() - getLevel(); + int karmaloss; + int currKarma = pl.getKarma(); + if (diff < 0) + karmaloss = 20; + else if (diff > 10) + karmaloss = 0; + else + karmaloss = 230 - 20 * diff; + + karmaloss = (int)(karmaloss * karmaRatio); + if (currKarma - karmaloss < 0) karmaloss = currKarma; + pl.setKarma(currKarma-karmaloss); + + //Remove the L2PcInstance from the L2Attackable rewards + rewards.remove(pl); + } } - // Add L2PcInstance of the party (that have attacked or not) to members that can be rewarded if it's not dead if (!pl.isDead()) rewardedMembers.add(pl); } @@ -723,7 +753,7 @@ xp *= partyMul; sp *= partyMul; - + // Distribute Experience and SP rewards to L2PcInstance Party members in the known area of the last attacker if (partyDmg > 0) attackerParty.distributeXpAndSp(xp, sp, rewardedMembers, lastAttacker);