How do I make a critical chance of attack

Get help using Construct 2

Post » Tue Apr 29, 2014 8:25 pm

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?
Posts: 73
Reputation: 603

Post » Tue Apr 29, 2014 8:53 pm

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.
composer - multimedia artist
Posts: 1,146
Reputation: 9,649

Post » Tue Apr 29, 2014 10:55 pm

if(random(0,100) < 25) then crit ...
Posts: 2,247
Reputation: 17,461

Post » Wed Apr 30, 2014 6:25 pm

Have a look at this tut done by Kyatric, not sure if this could help you implement into your ideas. ... -cms-20449
Posts: 86
Reputation: 3,267

Return to How do I....?

Who is online

Users browsing this forum: Clark Thy Lord and 1 guest