Bug? Maybe I'm doing something wrong..? HELP!

Get help using Construct 2

Post » Tue May 13, 2014 2:21 am

Edit: I've uploaded a cut down sample game to the new post below. It should explain things in more detail.
Cheers
Chris
---

Hi guys

I've been trying to debug a game for a few hours now and I can't quite understand why something isn't working. I've looked through the forum but because I'm not sure what's going wrong I can't really find anything similar.

Basically, on the start of the layout I create 9 characters (In family 'AllCharacters') and set their associated ChracterID variable to their UID.
Then I create a random weapon (From the 'Weapons' family) for each of them and set their CharacterID variable to the same as their linked character's CharacterID variable.

The 'Weapons' family has a variable called 'Type' which indicates if it's a "Melee" or "Ranged" weapon.

I'm trying to pick all the 'Melee' weapons and their associated character like so:
picking.png


When I run this it seems like the correct number of weapons are being picked however their linked character (based on CharacterID) is not being picked correctly.

If ALL weapons on screen are assigned 'Melee' then it works fine and their associated character is picked 100% of the time. However as soon as one of those weapons are no longer 'Melee' weapons it tends to break and not pick the correct number of characters:
textbox.png


I've debugged the game above where there is one 'Ranged' weapon and all characters and weapons have the correct CharacterID and Type assigned.
For the purposes of this test, I was hoping to be able to set all their opacities to 70%.

I'm obviously not understanding how Construct 2 picking works, so would value some insight into why this might be ocurring.

Thanks!
Chris
You do not have the required permissions to view the files attached to this post.
Last edited by Zacros on Wed Jul 02, 2014 6:23 am, edited 2 times in total.
B
7
S
1
G
1
Posts: 16
Reputation: 1,109

Post » Mon May 19, 2014 8:16 am

Really struggling here - any thoughts or assistance would be very much appreciated.

Cheers
Chris
B
7
S
1
G
1
Posts: 16
Reputation: 1,109

Post » Wed Jul 02, 2014 6:22 am

I've attached a sample game where you can get an idea of what's going on. Press 'A' to create 4 sprites (Let's call them 'Characters') in the centre of the screen, each with a small sprite on top of them (We'll call them 'Weapons').
Each set of Character+Weapon has a unique identifier for them starting at 1 and going to 4.

Pressing 'S' will delete all 'Blue' weapons as well as their linked (via 'ID') character.
Or it SHOULD at least... What it does seems to be rather random.

I'm not sure if it's a bug or if I'm just not doing something correctly... Please help, I've been stuck on this for months!
You do not have the required permissions to view the files attached to this post.
B
7
S
1
G
1
Posts: 16
Reputation: 1,109

Post » Wed Jul 02, 2014 8:02 am

Think this is what you are after @Zacros

PickingBug.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Wed Jul 02, 2014 8:27 am

Thanks mate, really appreciate your help!
While it most certainly helps for this instance, I don't think I can use the same logic with other scenarios.

For instance, let's say that the Character family has a variable called "HitPoints" and I'd like to destroy only one of the characters (randomly) that have HitPoints of 0 and a Blue weapon.
If I add in a pick random, it deletes them all, as it's still going through a loop for the weapons.

To put it in another scenario, I'd like to be able to keep weapon variables on the weapon and character variables on the character. Then I'd like to be able to do "Every 5 seconds, pick one character that has HitPoints > 0 and a linked Weapon that is blue, then move that character 10 pixels to the left. If I use the attached method, it'll move all of the characters that fit the profile, not just a random one.
B
7
S
1
G
1
Posts: 16
Reputation: 1,109


Return to How do I....?

Who is online

Users browsing this forum: Cha0tiXGamer, ketramtu18 and 7 guests