问题描述
我当前在AzerothCore服务器上运行自动平衡模块。我要启用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
但是我想对独奏者稍加修改。我想做到这一点,让他们获得2.5倍的经验但是,如果一组两个或更多,则使用常规的缩小XP。我相信这是我需要修改的部分:
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;
}
}
}
只是不确定如何去做。有什么建议吗?
解决方法
最终找到了解决方案。首先,我在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
接下来,我向静态浮动添加了新选项:
static float globalRate,healthMultiplier,manaMultiplier,armorMultiplier,damageMultiplier,MinHPModifier,MinManaModifier,MinDamageModifier,DungeonScaleDownXPSoloRate,InflectionPoint,InflectionPointRaid,InflectionPointRaid10M,InflectionPointRaid25M,InflectionPointHeroic,InflectionPointRaidHeroic,InflectionPointRaid10MHeroic,InflectionPointRaid25MHeroic,BossInflectionMult;
然后将新的float选项设置为从配置读取:
DungeonScaleDownXPSoloRate = sConfigMgr->GetFloatDefault("AutoBalance.DungeonScaleDownXP.rate.solo",1.0f);
然后添加了一个if以检查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;
}
}
}
}
现在我可以在配置中调整xp速率了。