Forum begins after the advertisement:


[Part 23] Enemy damage stat not scaling properly

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 23] Enemy damage stat not scaling properly

  • This topic has 2 replies, 2 voices, and was last updated 1 month ago by Sean.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16436
    Sean
    Level 11
    Former Patron
    Helpful?
    Up
    1
    ::

    Hi,

    I posted a comment last month in part 23 before I realised the forums were the best place.

    In 3F, is it meant to be “s1.damage += s2.damage” instead of adding maxHealth?

    Kind Regards, Sean

    has upvoted this post.
    #16443
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    You’re right! Thank you for flagging this.

    For anyone else reading this, the issue is here in the EnemyStats.Stats struct:

    // Use the add operator to add stats to the enemy.
    public static Stats operator +(Stats s1, Stats s2) {
        s1.maxHealth += s2.maxHealth;
        s1.moveSpeed += s2.moveSpeed;
        s1.damage += s2.maxHealths2.damage;
        s1.knockbackMultiplier += s2.knockbackMultiplier;
        s1.resistances += s2.resistances;
        return s1;
    }
    
    // Use the multiply operator to scale stats.
    // Used by the buff / debuff system.
    public static Stats operator *(Stats s1, Stats s2)
    {
        s1.maxHealth *= s2.maxHealth;
        s1.moveSpeed *= s2.moveSpeed;
        s1.damage *= s2.maxHealths2.damage;
        s1.knockbackMultiplier *= s2.knockbackMultiplier;
        s1.resistances *= s2.resistances;
        return s1;
    }

    By the way:

    Bug Reporter
    #16463
    Sean
    Level 11
    Former Patron
    Helpful?
    Up
    1
    ::

    I’m glad I could help <3

      1 anonymous person
    has upvoted this post.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: