All pastes #36431 Raw Edit

Untitled

public text v1 · immutable
#36431 ·published 2006-01-11 02:21 UTC
rendered paste body
    private int[] calculateExpAndSp(int diff, int damage)
    {
        double xp;
        double sp;
        
        if (Config.ALT_GAME_EXPONENT_XP != 0)
            xp = ((double)getExpReward() * damage / getMaxHp() * Math.pow(2., -diff / Config.ALT_GAME_EXPONENT_XP));
        else 
        	xp = getExpReward() * damage / getMaxHp();
        
        if (Config.ALT_GAME_EXPONENT_SP != 0)
            sp = ((double)getSpReward() * damage / getMaxHp() * Math.pow(2., -diff / Config.ALT_GAME_EXPONENT_SP));
        else 
        	sp = getSpReward() * damage / getMaxHp();
        
        if (Config.ALT_GAME_EXPONENT_XP == 0 && Config.ALT_GAME_EXPONENT_SP == 0)
        {
            // deep blue mob, is more than 8 levels below attacker lvl
            if (diff > 8)
            {
                xp = 0;
                sp = 0;
            }
            // green or light blue mob, is 6 to 8 levels below attacker lvl  
            else if (diff > 5)
            {
                xp -= diff * xp / 10;
                sp -= diff * sp / 10;
            }
            
            if (xp <= 0)
            {
                xp = 0;
                sp = 0;
            }
            else if (sp <= 0)
            {
                sp = 0;
            }
        }
        
        int[] tmp = { (int)xp, (int)sp };
        
        return  tmp;
    }