All pastes #157807 Raw Edit

Mine

public text v1 · immutable
·published 2006-09-01 19:46 UTC
rendered paste body
        if ((checkIfPvP(target) && //   Can pvp and
            targetPlayer.getPvpFlag() != 0 //   Target player has pvp flag set
            ) || // or
            (ZoneManager.getInstance().checkIfInZonePvP(this) && //   Player is inside pvp zone and
            ZoneManager.getInstance().checkIfInZonePvP(target) //   Target player is inside pvp zone
            ))
        {
            increasePvpKills(targetPlayer.getLevel());
        }
        else
        // Target player doesn't have pvp flag set
        {
            // check about wars
            if (targetPlayer.getClan() != null && this.getClan() != null)
            {
                if (this.getClan().isAtWarWith(targetPlayer.getClanId()))
                {
                    if (targetPlayer.getClan().isAtWarWith(this.getClanId()))
                    {
                        // 'Both way war' -> 'PvP Kill' 
                        increasePvpKills(targetPlayer.getLevel());
                        return;
                    }
                }
            }

            // 'No war' or 'One way war' -> 'Normal PK'
            if (targetPlayer.getKarma() > 0) // Target player has karma
            {
                if (Config.KARMA_AWARD_PK_KILL)
                {
                    increasePvpKills(targetPlayer.getLevel());
                }
            }
            else
            // Target player doesn't have karma
            {
                increasePkKillsAndKarma(targetPlayer.getLevel());
            }
        }
    }

    /**
     * Increase the pvp kills count and send the info to the player
     *
     */
    public void increasePvpKills(int targLVL)
    {
        // Add karma to attacker and increase its PK counter
        setPvpKills(getPvpKills() + 1);
        if(targLVL > 0)

        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
        sendPacket(new UserInfo(this));
        
        //Send a quick announce for PVP...
        String killer = getName();
        String target = getTarget().getName();
        int killerlvl = getLevel();
        String text = "[PVP] "+killer+"["+killerlvl+"] killed"+target+"["+targLVL+"]!";
        Announcements.getInstance().announceToAll(text); 
    }

    /**
     * Increase pk count, karma and send the info to the player
     * 
     * @param targLVL : level of the killed player
     */
    public void increasePkKillsAndKarma(int targLVL)
    {
        int baseKarma = Config.KARMA_MIN_KARMA;
        int newKarma = baseKarma;
        int karmaLimit = Config.KARMA_MAX_KARMA;

        int pkLVL = getLevel();
        int pkPKCount = getPkKills();

        int lvlDiffMulti = 0;
        int pkCountMulti = 0;

        // Check if the attacker has a PK counter greater than 0
        if (pkPKCount > 0) pkCountMulti = pkPKCount / 2;
        else pkCountMulti = 1;
        if (pkCountMulti < 1) pkCountMulti = 1;

        // Calculate the level difference Multiplier between attacker and killed L2PcInstance
        if (pkLVL > targLVL) lvlDiffMulti = pkLVL / targLVL;
        else lvlDiffMulti = 1;
        if (lvlDiffMulti < 1) lvlDiffMulti = 1;

        // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
        newKarma *= pkCountMulti;
        newKarma *= lvlDiffMulti;

        // Make sure newKarma is less than karmaLimit and higher than baseKarma
        if (newKarma < baseKarma) newKarma = baseKarma;
        if (newKarma > karmaLimit) newKarma = karmaLimit;

        // Fix to prevent overflow (=> karma has a  max value of 2 147 483 647)
        if (getKarma() > (Integer.MAX_VALUE - newKarma)) newKarma = Integer.MAX_VALUE - getKarma();

        // Add karma to attacker and increase its PK counter
        setPkKills(getPkKills() + 1);
        setKarma(getKarma() + newKarma);

        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
        sendPacket(new UserInfo(this));
        
        //Send a quick announce for PVP...
        String killer = getName();
        String target = getTarget().getName();
        int killerlvl = getLevel();
        String text = "[PVP] "+killer+"["+killerlvl+"] killed"+target+"["+targLVL+"]!";
        Announcements.getInstance().announceToAll(text); 
    }