A Project for Chronicle 4 based on L2JServer.


    Champions for c4

    Share
    avatar
    Karakan

    Posts : 421
    Join date : 2013-10-04

    Champions for c4

    Post  Karakan on 31st March 2014, 11:05

    Runs fine on my test server.

    Have fun!

    custom.properties

    Code:

    #---------------------------------------------------------------
    # Champion mobs                                                -
    # Turns random mobs into Champions                             -
    #---------------------------------------------------------------
    # Enable Champions
    ChampionEnable = true
    # Chance for a mob to became champion (in percents) - 0 to disable
    ChampionFrequency = 1
    # Min and max lvl allowed for a mob to be champion.
    ChampionMinLevel = 20
    ChampionMaxLevel = 80
    # Hp multiplier
    ChampionHp = 2
    # Hp Regen Multiplier
    ChampionRegenHp = 1.
    # Rewards multiplier
    ChampionRewards = 2
    # Adenas & seal stones rewards multiplier
    ChampionAdenasRewards = 2
    # Atk bonus for champion (changes apply on patk & matk)
    ChampionAtk = 2.
    # Spd Atk bonus for champion (changes apply on patkspd & matkspd)
    ChampionSpdAtk = 1.


    /java/net/sf/l2j/Config.java

    Code:
        public static boolean ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE;
    -
    +
    +    /**define custom */
    +    /** Champion Mod*/
    +    public static boolean CUSTOM_CHAMPION_ENABLE;
    +    public static int CUSTOM_CHAMPION_FREQUENCY;
    +    public static int CUSTOM_CHAMP_MIN_LVL;
    +    public static int CUSTOM_CHAMP_MAX_LVL;
    +    public static int CUSTOM_CHAMPION_HP;
    +    public static int CUSTOM_CHAMPION_REWARDS;
    +    public static int CUSTOM_CHAMPION_ADENAS_REWARDS;
    +    public static float CUSTOM_CHAMPION_HP_REGEN;
    +    public static float CUSTOM_CHAMPION_ATK;
    +    public static float CUSTOM_CHAMPION_SPD_ATK;
    +    public static int CUSTOM_CHAMPION_REWARD;





                     AUTO_REWARD_COUNT            = Integer.parseInt(customSettings.getProperty("AutoRewardCount", "1000"));
     
    +                CUSTOM_CHAMPION_ENABLE              = Boolean.parseBoolean(customSettings.getProperty("ChampionEnable", "false"));
    +                CUSTOM_CHAMPION_FREQUENCY              = Integer.parseInt(customSettings.getProperty("ChampionFrequency", "0"));
    +                CUSTOM_CHAMP_MIN_LVL                = Integer.parseInt(customSettings.getProperty("ChampionMinLevel", "20"));
    +                CUSTOM_CHAMP_MAX_LVL                = Integer.parseInt(customSettings.getProperty("ChampionMaxLevel", "60"));
    +                CUSTOM_CHAMPION_HP                     = Integer.parseInt(customSettings.getProperty("ChampionHp", "7"));
    +                CUSTOM_CHAMPION_HP_REGEN               = Float.parseFloat(customSettings.getProperty("ChampionHpRegen", "1."));
    +                CUSTOM_CHAMPION_REWARDS                = Integer.parseInt(customSettings.getProperty("ChampionRewards", "8"));
    +                CUSTOM_CHAMPION_ADENAS_REWARDS         = Integer.parseInt(customSettings.getProperty("ChampionAdenasRewards", "1"));
    +                CUSTOM_CHAMPION_ATK                 = Float.parseFloat(customSettings.getProperty("ChampionAtk", "1."));
    +                CUSTOM_CHAMPION_SPD_ATK             = Float.parseFloat(customSettings.getProperty("ChampionSpdAtk", "1."));



             else if (pName.equalsIgnoreCase("CommonRecipeLimit")) COMMON_RECIPE_LIMIT = Integer.parseInt(pValue);
     
    +        //ChampionMobs L2JMOD
    +        else if (pName.equalsIgnoreCase("ChampionEnable")) CUSTOM_CHAMPION_ENABLE =  Boolean.valueOf(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionFrequency")) CUSTOM_CHAMPION_FREQUENCY = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionMinLevel")) CUSTOM_CHAMP_MIN_LVL = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionMaxLevel")) CUSTOM_CHAMP_MAX_LVL = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionHp")) CUSTOM_CHAMPION_HP = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionHpRegen")) CUSTOM_CHAMPION_HP_REGEN = Float.parseFloat(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionRewards")) CUSTOM_CHAMPION_REWARDS = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionAdenasRewards")) CUSTOM_CHAMPION_ADENAS_REWARDS = Integer.parseInt(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionAtk")) CUSTOM_CHAMPION_ATK = Float.parseFloat(pValue);
    +        else if (pName.equalsIgnoreCase("ChampionSpdAtk")) CUSTOM_CHAMPION_SPD_ATK = Float.parseFloat(pValue);




    /net/sf/l2j/gameserver/serverpackets/NpcInfo.java


    Code:
            if (cha.getTemplate().serverSideName)
                 _name = cha.getTemplate().name;
     
    -        if (cha.getTemplate().serverSideTitle)
    -            _title = cha.getTemplate().title;
    -        else
    -            _title = cha.getTitle();
    +        if(Config.CUSTOM_CHAMPION_ENABLE && cha.isChampion())
    +            _title = ("Champion");
    +        else if (cha.getTemplate().serverSideTitle)
    +     _title = cha.getTemplate().title;
    +     else
    +     _title = cha.getTitle();
     
    -
             if (Config.SHOW_NPC_LVL && _cha instanceof L2MonsterInstance)


    net/sf/l2j/gameserver/model/actor/stat/CharStat.java


    Code:
            if (_ActiveChar == null)
                 return 1;
    -
    + float bonusAtk = 1;
    +     if (Config.CUSTOM_CHAMPION_ENABLE && _ActiveChar.isChampion())
    +     bonusAtk = Config.CUSTOM_CHAMPION_ATK;
             // Get the base MAtk of the L2Character
             double attack = _ActiveChar.getTemplate().baseMAtk;
     


    -
    -        double val = calcStat(Stats.MAGIC_ATTACK_SPEED, _ActiveChar.getTemplate().baseMAtkSpd, null, null);
    + float bonusSpdAtk = 1;
    +     if  (Config.CUSTOM_CHAMPION_ENABLE && _ActiveChar.isChampion())
    +     bonusSpdAtk = Config.CUSTOM_CHAMPION_SPD_ATK;
    +        double val = calcStat(Stats.MAGIC_ATTACK_SPEED, _ActiveChar.getTemplate().baseMAtkSpd * bonusSpdAtk, null, null);
             val /= _ActiveChar.getArmorExpertisePenalty();
             if (_ActiveChar instanceof L2PcInstance)
             {

    -
    -        return (int)calcStat(Stats.POWER_ATTACK, _ActiveChar.getTemplate().basePAtk, target, null);
    + float bonusAtk = 1;
    + if  (Config.CUSTOM_CHAMPION_ENABLE && _ActiveChar.isChampion())
    + bonusAtk = Config.CUSTOM_CHAMPION_ATK;
    +        return (int)calcStat(Stats.POWER_ATTACK, _ActiveChar.getTemplate().basePAtk * bonusAtk, target, null);
         }
     

        /** Return the PAtk Speed (base+modifier) of the L2Character in function of the Armour Expertise Penalty. */
         public int getPAtkSpd()
         {
             if (_ActiveChar == null)
                 return 1;
    -
    -        int val = (int)(calcStat(Stats.POWER_ATTACK_SPEED, _ActiveChar.getTemplate().basePAtkSpd, null, null) / _ActiveChar.getArmorExpertisePenalty());
    + float bonusAtk = 1;
    +        if  (Config.CUSTOM_CHAMPION_ENABLE && _ActiveChar.isChampion())
    +     bonusAtk = Config.CUSTOM_CHAMPION_SPD_ATK;
    +        int val = (int)(calcStat(Stats.POWER_ATTACK_SPEED, _ActiveChar.getTemplate().basePAtkSpd * bonusAtk, null, null) / _ActiveChar.getArmorExpertisePenalty());
             if (_ActiveChar instanceof L2PcInstance)
             {
                 if (val > Config.MAX_PATK_SPEED && !((L2PcInstance)_ActiveChar).isGM())



    /net/sf/l2j/gameserver/model/L2Attackable.java


    Code:
    ===================================================================
    --- D:/workspace/Lisvus_GameServer/java/net/sf/l2j/gameserver/model/L2Attackable.java (revision 471)
    +++ D:/workspace/Lisvus_GameServer/java/net/sf/l2j/gameserver/model/L2Attackable.java (working copy)
    @@ -457,6 +457,17 @@
     
                _log.log(Level.SEVERE, "", e);
             }
    +        setChampion(false);
    +        if (Config.CUSTOM_CHAMPION_ENABLE)
    +        {
    +         //Set champion on next spawn
    + if (this instanceof L2MonsterInstance && Config.CUSTOM_CHAMPION_FREQUENCY > 0 && getLevel()>=Config.CUSTOM_CHAMP_MIN_LVL && getLevel()<=Config.CUSTOM_CHAMP_MAX_LVL)
    +         {
    +         int random = Rnd.get(100);
    +         if (random < Config.CUSTOM_CHAMPION_FREQUENCY)
    +         setChampion(true);
    +         }
    +        }
            return true;
         }
        
    @@ -607,20 +618,26 @@
                     // If there's NO party in progress
                     if (attackerParty == null)
                     {
    -                    // Calculate Exp and SP rewards
    -                    if (attacker.getKnownList().knowsObject(this))
    -                    {
    -                        // Calculate the difference of level between this attacker (L2PcInstance or L2SummonInstance owner) and the L2Attackable
    -                        // mob = 24, atk = 10, diff = -14 (full xp)
    -                        // mob = 24, atk = 28, diff = 4 (some xp)
    -                        // mob = 24, atk = 50, diff = 26 (no xp)
    -                        levelDiff = attacker.getLevel() - getLevel();
    -                        
    -                        tmp = calculateExpAndSp(levelDiff, damage);
    -                        exp = tmp[0];
    -                        exp *= 1 - penalty;
    -                        sp = tmp[1];
    -                        
    +         // Calculate Exp and SP rewards
    +         if (attacker.getKnownList().knowsObject(this))
    +         {
    +         // Calculate the difference of level between this attacker (L2PcInstance or L2SummonInstance owner) and the L2Attackable
    +         // mob = 24, atk = 10, diff = -14 (full xp)
    +         // mob = 24, atk = 28, diff = 4 (some xp)
    +         // mob = 24, atk = 50, diff = 26 (no xp)
    +         levelDiff = attacker.getLevel() - getLevel();
    +
    +         tmp = calculateExpAndSp(levelDiff, damage);
    +         exp = tmp[0];
    +         exp *= 1 - penalty;
    +         sp = tmp[1];
    +
    +                        if (Config.CUSTOM_CHAMPION_ENABLE && isChampion())
    +                        {
    +                        exp *= Config.CUSTOM_CHAMPION_REWARDS;
    +                        sp *= Config.CUSTOM_CHAMPION_REWARDS;
    +                    }
    +
                             // Check for an over-hit enabled strike
                             if (attacker instanceof L2PcInstance)
                             {
    @@ -721,6 +738,12 @@
                         tmp = calculateExpAndSp(levelDiff, partyDmg);
                         exp = tmp[0];
                         sp = tmp[1];
    +
    +         if (Config.CUSTOM_CHAMPION_ENABLE && isChampion())
    +         {
    +         exp *= Config.CUSTOM_CHAMPION_REWARDS;
    +         sp *= Config.CUSTOM_CHAMPION_REWARDS;
    +         }
                       
                        exp *= partyMul;
                         sp *= partyMul;
    @@ -938,6 +961,9 @@
              if (drop.getItemId() == 57) dropChance *= Config.RATE_DROP_ADENA;
              else if (isSweep) dropChance *= Config.RATE_DROP_SPOIL;
              else dropChance *= isRaid() ? Config.RATE_BOSS_DROP_ITEMS : Config.RATE_DROP_ITEMS;
    +
    +         if (Config.CUSTOM_CHAMPION_ENABLE && isChampion())
    +         dropChance *= Config.CUSTOM_CHAMPION_REWARDS;

             // Round drop chance
              dropChance = Math.round(dropChance);
    @@ -974,6 +1000,9 @@
                  // Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
                  dropChance -= L2DropData.MAX_CHANCE;
              }
    + if (Config.CUSTOM_CHAMPION_ENABLE)
    + if ((drop.getItemId() == 57 || (drop.getItemId() >= 6360 && drop.getItemId() <= 6362)) && isChampion())
    + itemCount *= Config.CUSTOM_CHAMPION_ADENAS_REWARDS;

             if (itemCount > 0) return new RewardItem(drop.getItemId(), itemCount);
              else if (itemCount == 0 && Config.DEBUG) _log.fine("Roll produced 0 items to drop...");
    @@ -1019,6 +1048,8 @@
     
              // Applies Drop rates
               categoryDropChance *= isRaid() ? Config.RATE_BOSS_DROP_ITEMS : Config.RATE_DROP_ITEMS;
    +          if (Config.CUSTOM_CHAMPION_ENABLE && isChampion())
    + categoryDropChance *= Config.CUSTOM_CHAMPION_REWARDS;  
     
              // Round drop chance
               categoryDropChance = Math.round(categoryDropChance);
    @@ -1046,10 +1077,10 @@
                   // if smaller.
     
                  int dropChance = drop.getChance();
    -              if (drop.getItemId() == 57)
    -                  dropChance *= Config.RATE_DROP_ADENA;
    -              else
    -                  dropChance *= isRaid() ? Config.RATE_BOSS_DROP_ITEMS : Config.RATE_DROP_ITEMS;
    +              if (drop.getItemId() == 57) dropChance *= Config.RATE_DROP_ADENA;
    +              else dropChance *= isRaid() ? Config.RATE_BOSS_DROP_ITEMS : Config.RATE_DROP_ITEMS;
    +              if (Config.CUSTOM_CHAMPION_ENABLE && isChampion())
    + dropChance *= Config.CUSTOM_CHAMPION_REWARDS;  
     
                  dropChance = Math.round(dropChance);
     
    @@ -1092,6 +1123,9 @@
                       // Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
                       dropChance -= L2DropData.MAX_CHANCE;
                   }
    +              if (Config.CUSTOM_CHAMPION_ENABLE)
    +              if ((drop.getItemId() == 57 || (drop.getItemId() >= 6360 && drop.getItemId() <= 6362)) && isChampion())
    +              itemCount *= Config.CUSTOM_CHAMPION_ADENAS_REWARDS;  
     
                  if (itemCount > 0)
                       return new RewardItem(drop.getItemId(), itemCount);
    @@ -1253,7 +1287,7 @@
                  }
              }
          }
    -    
    +  
          /**
           * Manage Special Events drops created by GM for a defined period.<BR><BR>
           *  


    /net/sf/l2j/gameserver/model/L2Character.java

    Code:
    ===================================================================
    --- D:/workspace/Lisvus_GameServer/java/net/sf/l2j/gameserver/model/L2Character.java (revision 471)
    +++ D:/workspace/Lisvus_GameServer/java/net/sf/l2j/gameserver/model/L2Character.java (working copy)
    @@ -156,6 +156,8 @@
         private double _hpUpdateIncCheck = .0;
         private double _hpUpdateDecCheck = .0;
         private double _hpUpdateInterval = .0;
    + /** The _champion. */
    + private boolean _champion = false;


    @@ -5898,7 +5902,18 @@
     public void addStatusListener(L2Character object) { getStatus().addStatusListener(object); }
     
    public void reduceCurrentHp(double i, L2Character attacker) { reduceCurrentHp(i, attacker, true); }
    - public void reduceCurrentHp(double i, L2Character attacker, boolean awake) { getStatus().reduceHp(i, attacker, awake); }
    +
    + public void reduceCurrentHp(double i, L2Character attacker, boolean awake)
    + {
    + if (Config.CUSTOM_CHAMPION_ENABLE && isChampion() && (Config.CUSTOM_CHAMPION_HP != 0))
    + {
    + getStatus().reduceHp(i / Config.CUSTOM_CHAMPION_HP, attacker, awake);
    + }
    + else
    + {
    + getStatus().reduceHp(i, attacker, awake);
    + }
    + }
     public void reduceCurrentMp(double i) { getStatus().reduceMp(i); }
     public void removeStatusListener(L2Character object) { getStatus().removeStatusListener(object); }
     protected void stopHpMpRegeneration() { getStatus().stopHpMpRegeneration(); }
    @@ -5929,6 +5944,16 @@
     {
     return _LastBuffer;
     }
    +
    + public void setChampion(boolean champ)
    + {
    + _champion = champ;
    + }
    +
    + public boolean isChampion()
    + {
    + return _champion;
    + }

    public int getLastHealAmount()
     {
    avatar
    DnR
    Admin
    Admin

    Posts : 1023
    Join date : 2012-12-03

    Re: Champions for c4

    Post  DnR on 11th June 2014, 17:46

    I updated old champion system and fixed all bugs.
    Also, i imported few extra configurations.
    Revision 483 contains new Champion System, since it's asked so much.

    Thanks a lot for your contribution. Wink

      Current date/time is 20th September 2017, 16:03