Search code examples
azerothcore

Azerothcore - Autobalance DungeonScaleDownXP add additional check for solo player


I am currently running the autobalance module on my AzerothCore server. I want to enable the DungeonScaleDownXP:

#
#     AutoBalance.DungeonScaleDownXP
#        Decrease individual player's amount of XP gained during a dungeon to match the
#        amount of XP gained during a full group run. Example: In a 5-man group, you
#        earn 1/5 of the total XP per kill, but if you solo the dungeon with
#        AutoBalance.DungeonScaleDownXP = 0, you will earn 5/5 of the total XP.
#        With the option enabled, you will earn 1/5.
#        Default:     0 (1 = ON, 0 = OFF)

AutoBalance.DungeonScaleDownXP = 0

But I would like to slightly modify it for solo players. I would like to make it so they get 2.5 times XP. But if its a group of two or more use the normal scaled-down XP. I believe this is the section I would need to modify:

void OnGiveXP(Player* player, uint32& amount, Unit* victim) override
{
  if (victim && DungeonScaleDownXP)
  {
    Map* map = player->GetMap();

    if (map->IsDungeon())
    {
      // Ensure that the players always get the same XP, even when entering the dungeon alone
      uint32 maxPlayerCount = ((InstanceMap*)sMapMgr->FindMap(map->GetId(), map->GetInstanceId()))->GetMaxPlayers();
      uint32 currentPlayerCount = map->GetPlayersCountExceptGMs();
      amount *= (float)currentPlayerCount / maxPlayerCount;
    }
  }
}

Just not sure how to go about it. Any suggestions?


Solution

  • Ended up figuring out a solution to this. First i added a new option in the conf:

    #
    #     AutoBalance.DungeonScaleDownXP.rate.solo
    #        Set individual player's amount of XP gained during a dungeon run.
    #        AutoBalance.DungeonScaleDownXP = 1 you will earn 1/5 of the total XP as a solo player
    #        modifying this rate with allow you to set how much XP a solo player will receive 
    #        Default:     1.0
    
    AutoBalance.DungeonScaleDownXP.rate.solo = 1.0
    

    Next i added to the static float the new option:

    static float globalRate, healthMultiplier, manaMultiplier, armorMultiplier, damageMultiplier, MinHPModifier, MinManaModifier, MinDamageModifier, DungeonScaleDownXPSoloRate,
    InflectionPoint, InflectionPointRaid, InflectionPointRaid10M, InflectionPointRaid25M, InflectionPointHeroic, InflectionPointRaidHeroic, InflectionPointRaid10MHeroic, InflectionPointRaid25MHeroic, BossInflectionMult;
    

    Then set the new float option to read from the config:

    DungeonScaleDownXPSoloRate = sConfigMgr->GetFloatDefault("AutoBalance.DungeonScaleDownXP.rate.solo", 1.0f);
    

    Then added an if to check the currentPlayerCount:

    void OnGiveXP(Player* player, uint32& amount, Unit* victim) override
            {
                if (victim && DungeonScaleDownXP)
                {
                    Map* map = player->GetMap();
    
                    if (map->IsDungeon())
                    {
                        // Ensure that the players always get the same XP, even when entering the dungeon alone
                        uint32 maxPlayerCount = ((InstanceMap*)sMapMgr->FindMap(map->GetId(), map->GetInstanceId()))->GetMaxPlayers();
                        uint32 currentPlayerCount = map->GetPlayersCountExceptGMs();
                        if (currentPlayerCount == 1)
                        {
                        amount *= (float)currentPlayerCount / maxPlayerCount * DungeonScaleDownXPSoloRate;
                        }
                        else
                        {
                        amount *= (float)currentPlayerCount / maxPlayerCount;
                        }
                    }
                }
            }
    

    Now i can adjust the xp rate in the config.