Need help with a formula!

0 favourites
  • 3 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Math. It's my kryptonite. Or maybe it's just my (lack of) logic.

    I'm really new to Construct, so I don't know many of the native commands(?) yet. I have a dinky little scroller I'm toying with, where I want the Player to "fight" with an enemy when they collide. The trick here is that I have a host of attributes that I want to compare to calculate the final damage.

    So far it looks a little something like:

    EnemyHP - ((PlayerAttack + (PlayerStat-EnemyStat) - EnemyDefense)

    I'm trying to take the player's Attack score and boost it with elemental abilities (Stat in the formula), but reduce the effectiveness of that ability if the enemy also has it. Somehow I have to make sure the enemy doesn't actually heal if it has more ability or defense... still trying to wrap my head around that.

    My ACTUAL worry is that I have about 6 different elemental-based stats I need to run that comparison on for each bump attack, as the player and enemies can all have varying degrees of each element at the same time. Am I going to have to run a comparison 6 times within the attack formula, once for each element, or can anyone think of a cleaner way to do it?

    Thanks a bunch!

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There are a few basic math expressions which you can use - min, max, clamp. You can read about them here:

    construct.net/en/make-games/manuals/construct-3/system-reference/system-expressions

    For example, you can modify your formula like this to avoid "healing" the enemy or dealing too much damage:

    Set EnemyHP to EnemyHP-clamp(((PlayerAttack + max(PlayerStat-EnemyStat, 0) - EnemyDefense), 0, 100)

    .

    Or you can use max() to pick the highest value from multiple stats - max(enemyShield, enemyArmor, enemyEnergy)

  • Cool, thanks for the advice! I'll have to give that writeup a hard look.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)