# summation of the three values

Get help using Construct 2

### » Wed Jan 07, 2015 3:00 am

I think we're getting closer, but I'm still not sure I'm completely understanding what you need.

I do think we have a bit of a language barrier, but I would not give up and say what you want to do is not possible.

So you have three attacks, each triggered by its own key press. The total value of all three attacks is displayed.

What do you want to subtract from the enemy's hit points? The sum of all three values, or do you just want to subtract ONE of the three values from the enemy's hit points?
B
33
S
7
G
3
Posts: 22
Reputation: 4,912

### » Wed Jan 07, 2015 4:14 am

@aerger thanks for your initiative, i make this like substract Attack1 + attack2 +attack3 from enemy.hp and this works for me very well.
Yes previously i want sum all three values to ONE and this ONE sum deals damage to enemy.
B
119
S
32
G
52
Posts: 1,896
Reputation: 39,074

### » Wed Jan 07, 2015 5:15 am

So possibly just this, then?

You can then just subtract TotalAttackValue from EnemyHP (and then probably reset TotalAttackValue and your other attack variables back to 0).
B
33
S
7
G
3
Posts: 22
Reputation: 4,912

### » Wed Jan 07, 2015 6:34 am

What is not possible? These are basic maths: Enemyhealth -(Attack1 + Attack2 + Attack3).

If you must have one variable just have a global variable, say Totalattack and change that only when equipment changes. Then subtract that from enemy health (more efficient too, probably).
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

### » Wed Jan 07, 2015 6:43 am

@Somebody yes this is exacly what i use now -(Attack1 + Attack2 + Attack3)
do youhave expression to:
"If you must have one variable just have a global variable, say Totalattack and change that only when equipment changes. Then subtract that from enemy health (more efficient too, probably)."

??
B
119
S
32
G
52
Posts: 1,896
Reputation: 39,074

### » Wed Jan 07, 2015 7:29 am

I think something like this would do (I mocked this together to illustrate the idea - you would have your actual events there):
Untitled.png

Since the TotalAttack only changes any time you change equipment you only need to sum the values when that happens.

Then, when you attack something use the TotalAttack global variable to subtract the damage.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

### » Wed Jan 07, 2015 8:30 am

@Somebody its working every time when i change for example Attack2, suppose that Attack1 and Attack3 its not changed this duplicate with every change i remember when i do something similiar did you check this in practice?
B
119
S
32
G
52
Posts: 1,896
Reputation: 39,074

### » Wed Jan 07, 2015 9:10 am

Each time you change one of the three variables ( attack1, attack2, attack3 ), set variable totalAttack=attack1+attack2+attack3
Each time you hit an enemy, set enemyHealth=enemyHealth-totalAttack
So what's the issue?
B
18
S
4
Posts: 87
Reputation: 1,199

Previous