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

Just started using Construct 2? Post your questions here

Post » Sat Jan 31, 2015 7:21 am

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)
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 24
Reputation: 448

Post » Sun Feb 01, 2015 9:54 am

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:
Code: Select all
Bullet.bulletDamage+Bullet.bulletDamage*(Bullet.IsItCrit*Enemy.CritMultiplier)-Player.Defense


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!
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 16
Reputation: 284

Post » Fri Feb 06, 2015 11:08 am

saumanahaii wrote: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:
Code: Select all
Bullet.bulletDamage+Bullet.bulletDamage*(Bullet.IsItCrit*Enemy.CritMultiplier)-Player.Defense


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 :D
B
6
S
1
Posts: 24
Reputation: 448


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 5 guests