How do I make a critical chance of attack

0 favourites
• 4 posts
From the Asset Store
Step into the mystical world of "Critical Hit," where your precision and strategy are put to the ultimate test.
• Hello everyone! I'm trying to design the sword fight system in a plaftform game and what I need is two things. The first is to make the chance of critical damage according to this logic:

compare ability of critical hit with an enemy ability.

and if hero critical ability = enemy critical ability I need a 25% chance to make a critical hit. There is no difficulties with making a critical hit but how to make a chance of 25% to set value for critical hit?

And the second is to prevent many clicks to kill the enemy. How can I count how much animations were ended during for example 2 seconds to make the enemy to block damage?

• For the first part you could try comparing the critical ability of the player and the enemy with the "system compare 2 values" and then add the following to the damage value: choose(0,0,0,normalDamage*2).

The logic behind it is that you are already subtracting a normal damage value on every strike, so when the critical hit condition is met, add to the normal value some extra damage (normalDamage*2), but do it by chance of 4 to 1. The choose expression will do exactly that, every time it will choose between the values within the parenthesis, in our case we have (0, 0, 0, Xdamage) so, 25% chance of getting extra damage.

For the second part, I am not sure what you mean, but perhaps you want a short period of invulnerability for the enemy between each time he gets hit? If yes, you could either add an "is animation "enemyHit" NOT playing" condition (invert the is playing by right click on the condition and choose invert), or add a Boolean instance variable (e.g. "hit") to the enemy and a timer behavior, and each time the enemy is hit (add a condition to check if he can be hit using the Boolean), set the Boolean to "true" and start a timer countdown. On the countdown end, restore the Boolean to false, so the enemy can be vulnerable again.

• Try Construct 3

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

Construct 3 users don't see these ads
• if(random(0,100) < 25) then crit ...

• Have a look at this tut done by Kyatric, not sure if this could help you implement into your ideas.

http://gamedevelopment.tutsplus.com/tut ... -cms-20449

• 4 posts