# health and shield

Get help using Construct 2

### » Tue Nov 05, 2013 4:22 pm

Hello,
i have a small issue with mine haelth system wich i can't resolve... :(

here's the thing,

I have basic health fom 0 to 100
then i have some powerups that add eg. 10 to health.
then i have shields that start to charge after health is on full 100.

How to add incremental charging with points that are left?

Lets say health is at 95 and powerup is picked up and now i have health at max 100 and mine shield should charge those remaining 5 points.
How to do that?

Thanx!
B
33
S
14
G
3
Posts: 801
Reputation: 6,316

### » Tue Nov 05, 2013 4:32 pm

You mean like:
If POWERUP > 100-HEALTH then SHIELD=SHIELD+POWERUP-(100-HEALTH) and make
HEALTH=100

Does that offer an idea, or do you need the events to do it?
B
248
S
65
G
34
Posts: 905
Reputation: 41,345

### » Tue Nov 05, 2013 4:40 pm

thank you for input, i'll look into that.
:)
B
33
S
14
G
3
Posts: 801
Reputation: 6,316

### » Tue Nov 05, 2013 4:41 pm

@irina,

Think about how you're making things happen.

Having HEALTH and SHIELD affecting your final health (that health seen by the player on the screen), you're able to make separated events to reach it.

For example, to represent the health on screen, use a math like HEALTH + SHIELD (those are variables, the the health with lowercase is a simple text on a text object in your screen).

So, if your player have 95% of HEALTH, and gain a powerup of +10 of SHIELD, your screen will show the 105% of health, simple using the math inside a text object:

everytick -> Text object: "Health: " & HEALTH + SHIELD

Plus, it can improve a lot your work by simple checking wich one you want decrease when hitting an enemy, for example, while physical hits can affect your SHIELD variable first, magical hits can affect your HEALTH variable directly.
B
109
S
24
G
18
Posts: 1,385
Reputation: 22,903

### » Tue Nov 05, 2013 4:58 pm

@ TELLES0808

I have 2 separated bars, one for health and other for shield.
B
33
S
14
G
3
Posts: 801
Reputation: 6,316

### » Tue Nov 05, 2013 6:58 pm

hm... sonething is wrong with this... mine shield gets doubled on each powerup???
B
33
S
14
G
3
Posts: 801
Reputation: 6,316

### » Tue Nov 05, 2013 8:00 pm

ok, i'w fixed it.
mixup between set value and add value...
B
33
S
14
G
3
Posts: 801
Reputation: 6,316

### » Wed Nov 06, 2013 11:46 am

Apparently putting a space between the @ and name doesn't send the notification. Not that it mattered.
B
248
S
65
G
34
Posts: 905
Reputation: 41,345

### » Wed Nov 06, 2013 3:10 pm

B
33
S
14
G
3
Posts: 801
Reputation: 6,316