# Color Based Damage *Solved*

Get help using Construct 2

### » Tue Dec 31, 2013 7:59 pm

I'm going to have to play with that before I grasp it fully and see what it'd be useful for

However...I broke my brain again... I added multiple enemies, and I can't figure out how to get the enemy to spawn the damage version and have it only be affected by the enemy that spawned it

Valkyrie A B and C spawn
ValkyrieA spawns DamgValkyrie
ValkyrieA loses 20 health of 35
ValkyrieA should be the only one with a damg version showing

however, A B and C are all becoming Damaged =/

Valkyrie - on created
>>Valkyrie - spawn ValkyrieDamg
>>ValkyrieDamg - set position to Valkyrie
>>Set Angle to Valkyrie.Angle degrees
>> ValkyrieDamg set affector to self.UID
>> Valkyrie set affectorCall to ValkyrieDamg.UID

Valkyrie - health < self.maxHealth
-ValkrieDamg self.Affector = Valkyrie.affectorCall
>> Set Opacity -- Self.initialOpacity+((valkyrie.maxHealth-valkyrie.health)/valkyrie.maxHealth)*100

Edit: Haven't figured out what that expression would be useful for lol
//(3 - 2) * (15 - 8) / (7 - 2) + 8 //
gives 9.4 - first I'd though maybe range of damage verse armor, but then you'd prob use something like
-damg = random(2,8) -armor = 5 -pierce of 20%
so something like damg-armor+(pierce*damg)= dealt damg
so base 7 - 5 + (0.2 * 7) = 3.4 total damgEffregy2013-12-31 20:21:14
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

### » Tue Dec 31, 2013 8:21 pm

You just have to add a for each valkyre to the last event. You are not picking a specific instance in your event so it affects all instances.

the formula I posted works if you want to find a number.

let's say you have numbers from 0 to 100 and you have to translate it to numbers from 25 to 250. in-min is 0 out-min is 25, in-max is 100 out-max is 250, so if you've got input 10 output would be 37.5
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Tue Dec 31, 2013 8:25 pm

translate number between ranges. so translate from health number to opacity.LittleStain2013-12-31 20:26:21
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Tue Dec 31, 2013 8:54 pm

I'm going to have to look up a tutorial on For Each, I've never used it lol

Also
With what I was trying to achieve -- more damg = more opaque, a percentage based method makes more sense, since the opacity is based off a range of 0 invis - 100 opaque

besides I took a simple problem
20 out of 100 you'd want 80
10 / 100 you'd want 90
15/35 you'd want 57.1ish
ect
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

### » Tue Dec 31, 2013 9:08 pm

This doesn't work

what happens, is it's either at 0 opacity or max
and even when the valkyrie should have full health, it's at max opacity

I knew why it was having trouble connecting each valkyrie to it's damg version, but I don't see how to fix it. I figured it'd be something with the uid's, but even then, when one valkyrie was low on health, all of them were displaying as heavily damagedEffregy2013-12-31 21:10:45
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

### » Tue Dec 31, 2013 9:27 pm

Having a separate red sprite is okay, but if your ships are too big and complex it's going to be a lot of extra video memory, since each ship would represent a separate set of textures.

I would probably try to do this with effects. A Tint effect that starts at 100,100,100 but lowers its green and blue parameter each time the ship is damaged seems like it would do something like what you want?

As for your current method, it will be easier if you use containers and a pin behavior. Put the red ship into a container with the regular ship (this will cause both objects to be created/destroyed/picked whenever one of them is.) You can read about containers here if you haven't used them.

Give the red ship a pin behavior. Then do events similar to this:

On Ship Created -> RedShip Pin To Object: Ship.
On Ship Damaged -> RedShip set opacity as needed
B
7
S
1
Posts: 45
Reputation: 1,315

### » Tue Dec 31, 2013 10:32 pm

I didn't actually notice the effects stuff...
I'd seen containers, but had no idea what they were for, thought it would be something like a more specific family, i/e not something that would fix the issue I'd had

But I will definitely look into both methods

B
9
S
2
G
1
Posts: 36
Reputation: 1,381

### » Tue Dec 31, 2013 10:44 pm

Sweet after causing a black screen from having an the parent the container spawn an object in the container - I unbroke it and it works perfectly!

I'll still try the tint method for smaller enemies, but containers, fixed the problem I'd have with larger enemies, and gave me some ideas for modular boss designs

I'll update the original post with the final code to achieve this result.

Thanks for helping =]Effregy2013-12-31 22:45:13
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Previous

### Who is online

Users browsing this forum: No registered users and 6 guests