For Each and picking

For questions about using Classic.

Post » Tue Jun 12, 2012 3:51 am

Update again:

I put NonPlayers overlaps Players check in the LOS function under a "Players: Pick by Players.Value('ClassID') Equal 2"

When I do that even if the player with ClassID=1 goes into LOS the NonPlayers will 'see' the player with ClassID=2. To me this suggests that the condition: NonPlayers overlaps Players does not respect picking (since I'm picking Player with CLassID=2 specifically right before I call it, yet it still triggers when Player with ClassID=1 goes into LOS)

Grumble grumble grumble, now what?

EDIT: Replaced the NonPlayers overlaps Players check with:

Players overlaps NonPlayers (offset is now Players.X-NonPlayers.X-global('LOS_X'), etc). This seems to work. I expected the Player to be picked correctly but expected the NonPlayers to all agro when only one was in LOS since my guess of what was going on was that the second family in teh overlap comparison ignored picking. So now I'm totally confused. Juryiel2012-06-12 05:31:38
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Tue Jun 12, 2012 6:40 am

[quote]The issue is that if I move a Player with ClassID=2 into LOS of a NonPlayer, it still acts as if I moved the Player with ClassID=1 into LOS (The toggled off Debug Text also reports 1 for ClassID when I turn it on), as if picking isn't working with the For Each. Why is that?[/quote]
I have a hunch it might be a bug that hasn't been squashed and comes up from time to time. It has to do with the wrong private variable being set when done from a family.

Do this test:
All you need in the layout are the objects in the player family and an event sheet with just this event:
+ System: Always (every tick)
-> Players: Set 'ClassID' to 1942

Run in debug mode and see if ClassID is 1942 for the objects. If some other variable is 1942 instead of ClassID then it's that bug.

Either way pm the cap or post it here and I'll take a look.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Jun 12, 2012 7:00 am

The class ID seems correct. I didn't do your example, but I in my cap I set the class ID in the properties box and not using the events. Furthermore, I have a variety of functions that use ClassID and they all work correctly, picking the right players and reporting the correct ClassIDs. It sounds to me that you're saying that the bug is a result of setting ClassID at runtime, which I'm not doing. If that's incorrect let me know and I can try your example.

I will be PMing you a cap shortly. You want to look at the SystemFunctions event sheet, specifically the groups "General Enemy Functions" and "Line of Sight Functions". You will also see a cone of all the spots checked for LOS at runtime. It only comes up randomly every second at a random NonPlayer. You can move individual players by selecting them with a mouse and clicking (RTS behavior). If you use the arrow keys they both move.

If you move a player into the LOS cone and an LOS check occurs, the enemy should start chasing the player. This might not work correctly since I haven't tested the other parts of the code that deal with enemy actions, so using it for debugging might not be reliable, so that's why I have the DebugText to use instead.Juryiel2012-06-12 07:09:10
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Jun 14, 2012 3:34 am

As an update for anyone else who might be facing the same issue, it does indeed appear to be a bug with how the Overlapping at Offset event picks the second object to compare (it seems to pick all of them).

R0J0hound provided a fix, where the System Condition "Is overlapping (advanced)" is used. To "rig" the 'offset' part (since that condition doesn't support offsets), the NonPlayer is first moved to each comparison point, then the overlapping comparison is made using the "Is overlapping (advanced)" system condition, and then the NonPlayer is moved back to his position, simulating the "Overlapping at Offset". Since this is all done in the same frame, the moving of the NonPlayer is never drawn on screen.

Thanks for the help!
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest