Picking enemy that has highest HP

Get help using Construct 2

Post » Wed Jul 11, 2012 9:21 am

As the subject suggested, I tried to have the system pick the enemy with the highest HP (to shoot at).

Although we have the condition: "Picking instance that are nearest or furthest",
We don't have "picking instance that has highest/lowest instance variable value"


In desperation I tried to created multiple subevent as in:

Enemy HP > 0   ---set position of bullet to Enemy
   Enemy HP > 1    ---set position of bullet to Enemy
     Enemy HP > 2    ---set position of bullet to Enemy
       Enemy HP > 3    ---set position of bullet to Enemy

And actually it works, but obviously it was very messy.




I am sure there is a much clever way to do that, help thanks!~
ZhaoYun2012-07-11 09:46:40
B
12
S
4
G
4
Posts: 64
Reputation: 4,014

Post » Wed Jul 11, 2012 1:28 pm

You could use 'For each: ordered'.
System: For each enemy order by enemy.hp descending
   [Shoot at enemy]
   System: Stop loop


pickHighestHP.capx (r98)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Wed Jul 11, 2012 3:02 pm

Always a good solution @Ramones. Thx
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Thu Jul 12, 2012 4:26 pm

@Ramones Thank you so much! Now that I know how 'For each: ordered' can be use, I am sure I will use it somewhere else too =)
B
12
S
4
G
4
Posts: 64
Reputation: 4,014


Return to How do I....?

Who is online

Users browsing this forum: Braus and 16 guests