All pastes #160725 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-09-04 17:28 UTC
rendered paste body
  * 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);
        
        // 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 PK...
              String killer = getName();
              String target = getTarget().getName();
              int killerlvl = getLevel();
              String text = "[PK] "+killer+"["+killerlvl+"] killed "+target+"["+targLVL+"]!";
              Announcements.getInstance().announceToAll(text); 
    }