Skills based system

99.99999999% of them are syntax errors, here’s a picture:

There’s a missing “}” I couldn’t fit in the screenshot (this is a seriously fun way for you to convince students of your idea… (takes notes))

Where did you get ‘effort’ and ‘totalEffort’ from…?

And I’m guessing ‘reward’ is the ‘rewardXP’, right?

The first one, damageOrder.AddUnique(skill), I covered in a previous reply…

For the second… there is great value in typing out code in a compiler instead of on the fly in the editor. (See, more experience points for both of us) I know this one compiles because I just rewrote it in Rider, and corrected a silly issue with the floating point comparison (floats are almost -=never=- “equal”)

        private Skill GetMostDamagingSkill()
        {
            var pairs = damagePerSkill.OrderByDescending(s => s.Value).ToList();
            if (pairs.Count == 1) return pairs[0].Key;
            if (Math.Abs(pairs[0].Value - pairs[1].Value) < .01f)
            {
                for (int i = 0; i < damageOrder.Count; i++)
                {
                    if (damageOrder[i] == pairs[0].Key) return damageOrder[i];
                    if (damageOrder[i] == pairs[1].Key) return damageOrder[i];
                }
            }
            return pairs[0].Key;
        }

That is merely an example equation. You look to it, and replace your actual values into it.
The TL:DR is that once you get the percentage (ratio) of total damage done, you multiply that times the reward. By dividing, you are actually greatly multiplying the reward.

the math still isn’t mathing up… the result is still the same whacky errors. Can you please check my ‘AwardExperience()’ function for me:

private void AwardExperience(GameObject instigator, Skill skill, Skill otherSkill = Skill.Defence)
        {

            if (instigator.TryGetComponent(out SkillExperience skillExperience))
            {

                if (instigator.TryGetComponent(out Health otherHealth) && !otherHealth.IsDead())
                {

                    float totalReward = GetComponent<AIController>().GetXPReward();
                    float totalDamage = damagePerSkill.Values.Sum();

                    // float ratio = GetComponent<Fighter>().GetDamage()/totalDamage;
                    // float reward = totalReward * ratio;

                    foreach (var pair in damagePerSkill) {
                        float relativeValue = pair.Value / totalDamage;
                        skillExperience.GainExperience(pair.Key, 2*Mathf.RoundToInt(totalReward/relativeValue)/3);
                    }

                    // This line sends 2/3rd of the XP Reward to whichever skill is associated to the Players' weapon:
                    // skillExperience.GainExperience(skill, 2 * Mathf.RoundToInt(GetComponent<AIController>().GetXPReward() / 3));
                    // This line sends 1/3rd of the XP Reward to the defence XP, which is always 1/3rd of whatever the AI Reward XP is assigned to:
                    skillExperience.GainExperience(otherSkill, Mathf.RoundToInt(GetComponent<AIController>().GetXPReward() / 3));
                    // skillExperience.GainExperience(otherSkill, Mathf.RoundToInt(totalAward/3));

                }

            }

        }

You never changed this line… You’re dividing by relativeValue instead of Multiplying…

OK that actually worked… Boy oh boy do I have SO MUCH to go back and read now, all in ‘health.cs’… (+1 XP for me)

Anyway, I have a new topic (they’re two, similar to resource gathering, but polar opposites) for tomorrow coming soon :slight_smile: , let me just properly verbalize it. Thanks again Brian for tonight

Not done here yet, I’m still trying something out solo before this one :upside_down_face:

Making this a Talk, or it will keep showing up on the unsolved list clogging up all the other TA’s Inbox.

1 Like

Sure, no worries. I’ll tag you here again when we return to this topic :slightly_smiling_face:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms