How do I add 15% to health pool

Get help using Construct 2

Post » Mon Dec 08, 2014 10:32 am

i i have two variables hp and max hp (10/100)
and when i click on 'rest' button hp should increase about 15% of maxhp
how do this?
B
109
S
26
G
46
Posts: 1,887
Reputation: 35,170

Post » Mon Dec 08, 2014 10:46 am

You want something like

Set instance variable hp:
((maxhp * 0.15) + hp) > maxhp ? maxhp : (maxhp * 0.15) + hp

In human words, if 15% of maxhp + hp is grater than maxhp
set hp to maxhp
else set hp to 15% of maxhp + hp
B
5
S
1
Posts: 5
Reputation: 285

Post » Mon Dec 08, 2014 10:58 am

@Egozi i know what i must do when hp is less than 0 and more than maxhp -> set hp to maxhp and i receive 100/100

I have to translate into construct2
Set instance variable hp:
((maxhp * 0.15) + hp) > maxhp ? maxhp : (maxhp * 0.15) + hp
B
109
S
26
G
46
Posts: 1,887
Reputation: 35,170

Post » Mon Dec 08, 2014 11:02 am

@Ashley can you add a simple expression 'add x% of variable to other variable' ?
B
109
S
26
G
46
Posts: 1,887
Reputation: 35,170

Post » Mon Dec 08, 2014 2:21 pm

No, it should be easy already, just multiply it by 1.15 to add 15% for example.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842


Return to How do I....?

Who is online

Users browsing this forum: Cub3D, David181, Google [Bot] and 20 guests