server icon indicating copy to clipboard operation
server copied to clipboard

[sql+core] Move various exp table data into sql, add ENABLE_EXP_PET_PENALTY setting

Open zach2good opened this issue 2 years ago • 13 comments

I affirm:

  • [x] I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • [x] I have read and understood the Contributing Guide and the Code of Conduct.
  • [x] I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

Steps to test these changes

zach2good avatar Feb 05 '23 18:02 zach2good

This will need testing in the following way:

  • Extract the existing implementation into its own function.
  • Alter the new implementation and the old one to take in just the player level, chain time, chain number, and before exp.
  • It will return the new exp.
  • Run the full list of levels, chain numbers, chain times etc. through it and make sure the before/afters match up exactly.

Then we know we're good to go

zach2good avatar Feb 12 '23 17:02 zach2good

Same with the other functions/tables too I guess

zach2good avatar Feb 12 '23 17:02 zach2good

Chain 3 for level 20 has an incorrect time value. It should be:

INSERT INTO `exp_chain_values` VALUES(20, 3, 1.30, 40000);

Since the table only goes up to pChainNumber 6, when the chainNumber is greater than 6 it is not defaulting to the base values as in the original switch statement.

You would have to break it up into two if statements if a match is found at 6 or before and one if its later.

This should return no errors in your Exp test harness. I did NOT test this manually in-game to see if the exp returns the same value but the values from the old and new return the same...therefore it should work.

    void ApplyExpChainBonuses(uint8 mLvl, uint16& chainNumber, uint32& chainTime, float& exp, EMobDifficulty mobCheck, bool& chainactive)
    {
        if (mobCheck <= EMobDifficulty::DecentChallenge)
        {
            return;
        }

        if (chainTime > 0 || chainTime == 0)
        {
            chainactive = true;
        }
        else
        {
            chainNumber = 1;
        }

        auto mainLevel    = mLvl;
        auto applyExpMult = 1.00f;

        // This will track if a match is found inside the table. If so, break.
        bool foundMatch = false;

        // Loop through the lookup and apply multipliers and times
        for (auto& [upperLevel, pChainNumber, expMultiplier, pChainTime] : g_ExpChainValues)
        {
            if ((pChainNumber == chainNumber || pChainNumber == 6) && mainLevel <= upperLevel)
            {
                // Save this for later
                applyExpMult = expMultiplier;

                // Overwrite chainTime value as we find new valid ones
                chainTime = 0 + pChainTime;

                // Found a match!
                foundMatch = true;

                // If we've matched, we've matched at the soonest possible time.
                // No point in iterating any more.
                break;
            }
        }

        // If no match was found and chainNumber is greater than 6, use chainNumber = 6 values
        if (!foundMatch && chainNumber > 6)
        {
            for (auto& [upperLevel, pChainNumber, expMultiplier, pChainTime] : g_ExpChainValues)
            {
                if (pChainNumber == 6 && mainLevel <= upperLevel)
                {
                    // Save this for later
                    applyExpMult = expMultiplier;

                    // Overwrite chainTime value as we find new valid ones
                    chainTime = 0 + pChainTime;
                    break;
                }
            }
        }

        // Only apply exp multiplier once
        exp *= applyExpMult;
    }

This code returns no warnings from thee test case. image

I am not the greatest coder so there may be an easier way to do this. But that is the issue causing the values not to match.

Frankie-hz avatar Aug 11 '23 03:08 Frankie-hz

Thanks @Frankie-hz! 👍

zach2good avatar Aug 11 '23 08:08 zach2good

WTB Module to make these values era @Frankie-hz

zach2good avatar Aug 11 '23 09:08 zach2good

This passed the test harness, needs actual in-game testing:

  • General solo XP
  • XP with a party member
  • XP in a signet area
  • XP in a signet area with a party member
  • Some XP chains
  • Testing out the setting multiplier I added

zach2good avatar Aug 11 '23 10:08 zach2good

WTB Module to make these values era @Frankie-hz

I can probably do that next week, I’m away for the weekend.

Might be able to sneak it in this weekend.

Frankie-hz avatar Aug 11 '23 12:08 Frankie-hz

I have the era-module done for the chaintime/exp - I can send it to you when I get home tonight.

Frankie-hz avatar Aug 14 '23 18:08 Frankie-hz

If you feel like challenging yourself, you can try and PR it to the branch I'm currently working on: move_exp_sql

zach2good avatar Aug 14 '23 19:08 zach2good

Ready for code review, still needs testing though

zach2good avatar Aug 15 '23 11:08 zach2good

Almost a year later: @Frankie-hz, did you ever get a chance to test this a bit? I want to merge this and get it out from my pile of shame

zach2good avatar Aug 04 '24 08:08 zach2good