ZhengPeiRu21 / mod-challenge-modes

Challenge Modes Module for AzerothCore
MIT License
40 stars 40 forks source link

OnGiveXP and OnLevelChanged within class ChallengeMode do not work as expected #5

Closed drozco closed 1 year ago

drozco commented 1 year ago

The objects that call those methods are instantiated with UNCONFIGURED data when the server loads the scripts, and fail when called since the value of challengeEnabled and xpModifier are default values, and will never use the configured values in the .conf file. The ChallengeMode constructor is using default values for all its parameters.

void OnGiveXP(Player* player, uint32& amount, Unit* /*victim*/) override { if (!challengesEnabled || !challengeEnabled || !player->GetPlayerSetting("mod-challenge-modes", settingsIdx).value)

In this line, challengeEnabled is always false, and this always returns without modifying the XP gain.

I'm not sure how to fix this to work AND use the configuration values, except to perhaps not have each challenge mode class derive from ChallengeMode, and instead create a new instance of that class every time it's called. OR create the instance after the configuration is loaded.

drozco commented 1 year ago

As a temporary solution, I put this in the constructor for ChallengeMode:

    {
        hardcoreEnable= semiHardcoreEnable= selfCraftedEnable= itemQualityLevelEnable= slowXpGainEnable= verySlowXPGainEnable= questXpOnlyEnable= ironManEnable=1;
        hardcoreXpBonus= semiHardcoreXpBonus= selfCraftedXpBonus= itemQualityLevelXpBonus= questXpOnlyXpBonus=1.0f;
    }
ZhengPeiRu21 commented 1 year ago

Thank you for this very useful and detailed report. I will work out a solution!

ZhengPeiRu21 commented 1 year ago

This should be fixed with https://github.com/ZhengPeiRu21/mod-challenge-modes/commit/19f520bb8fba2f9917e57e0f7d6d1aea1e925c2d. Please let me know if you still continue to see the problem.