How do I implements critical or evade chance? (Mortred)

0 favourites
  • 3 posts
  • Currently I made attribute for main character or enemy like max HP, Regeneration, Attack, and Defense. I just confused when I want to add Critical or Evade chance and for agility/aspd (more like mortred DoTA). I read some articles but the project can't open so I'm asking now. Please help

    (r195)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've added one to the code. Basically, the logic goes like this: there's a Critical Window, which I saved on the enemy. I made it 75. Then, when the bullet is generated, I create a random value between 0 and 100 and save it to an instance variable. I compare that to the enemy's CritWindow, and if it's greater than the window, I set a variable on the bullet IsItCrit from 0 to 1.

    Then, for the damage calculation, I do the following:

    Bullet.bulletDamage+Bullet.bulletDamage*(Bullet.IsItCrit*Enemy.CritMultiplier)-Player.Defense[/code:59ong6bk]
    
    What that does is take the base bullet damage and add to it the bullet damage * the IsItCrit (which will determine whether you're adding nothing or a crit value to the check) and then mulitplying IsItCrit * the CritMultiplier I also added to the enemy.  I'm sure someone else could clean it up, but that's how I did it in the CapX file I linked you.  I'm pretty sure it works right.
    
    Oh, and the evade could be calculated the same way, multiplying the damage by either a 0 or 1 depending on a randomly generated number.  Hopefully this is what you need!
  • I've added one to the code. Basically, the logic goes like this: there's a Critical Window, which I saved on the enemy. I made it 75. Then, when the bullet is generated, I create a random value between 0 and 100 and save it to an instance variable. I compare that to the enemy's CritWindow, and if it's greater than the window, I set a variable on the bullet IsItCrit from 0 to 1.

    Then, for the damage calculation, I do the following:

    Bullet.bulletDamage+Bullet.bulletDamage*(Bullet.IsItCrit*Enemy.CritMultiplier)-Player.Defense[/code:11imbed5]
    
    What that does is take the base bullet damage and add to it the bullet damage * the IsItCrit (which will determine whether you're adding nothing or a crit value to the check) and then mulitplying IsItCrit * the CritMultiplier I also added to the enemy.  I'm sure someone else could clean it up, but that's how I did it in the CapX file I linked you.  I'm pretty sure it works right.
    
    Oh, and the evade could be calculated the same way, multiplying the damage by either a 0 or 1 depending on a randomly generated number.  Hopefully this is what you need!
    

    Thank you bro, you saved my life

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