Picking from Picked Instances

Get help using Construct 2

Post » Mon Aug 05, 2013 6:25 am

CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6992586

=== PLEASE SKIP DOWN BELOW TO THE UPDATE ===

Starting at line 3 on the "ES Enemy" event sheet, I'm attempting to set up conditions that tell the Enemy instance to find the nearest PatrolNode within the NodeZone (so that it doesn't try to find a Node outside the proper patrol zone even if that other Node is closer) and then follow the patrol routes I've defined.

The enemy will go through a series of statuses:
1. Normal - within each NodeZone, follow the patrol routes setup by the PatrolNodes within that zone.
2. Chase - the enemy will chase the player...
3. Alert - the enemy will randomly search for the player within a range from the last point it saw the player.
4. Resume - Return the the enemy's assign NodeZone and resume the patrol as defined by the Nodes in that zone.

But at present all I can get to work is the chase, alert, and resume statuses. The enemy will not even select a Node to seek out. Can anyone see what I'm missing?

===========================================================

UPDATE: Related issue but not quite the same as before.
In the "ES Enemy" event sheet, line 12, I'm trying to pick those patrol nodes that are within a particular zone.
The enemy and the nodes are assigned the zone's IID - it's "home base". This way, after a chase, it can return to its original patrol area and not just any patrol path.

So, after a chase...
- Pick all patrol nodes which have an HomeZone instance variable value equal to the HomeZone instance variable value of the enemy.
-- From those patrol nodes that are picked, further pick the nearest one to the enemy.
-- Find path.

Everything works up to event line 12. But for some reason the enemy will not return to the node it's closest to within its own zone.

Also check out the "ES Setup" event sheet, lines 4 and 5. That's where I assigned the IID of each patrol zone to the HomeZone variables.Rhindon2013-09-04 00:35:57
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Mon Aug 05, 2013 8:13 am

OpPASS v1-1-4-3 enemy redo_BHT.capx

I changed a number of things. You'll have to decide if they are for the better.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Mon Aug 05, 2013 8:55 am

Thanks, @blackhornet. :D I'll check it out...
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Mon Aug 05, 2013 9:18 am

@blackhornet - Okay, so here's where I stand with your changes...

Event: Your changes
Action: Set MyMind to "blown"

I never once thought to look into using the Browser object. CLEARLY I have some research to do!

In the meantime, can you give me a summary of what's actually going on with the use of the Browser object, please? Like, amongst other things, what's all the "Log in console" about?

Thank you so much! You've just helped me complete the final piece to what's been a three-month headache!!! lol
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Mon Aug 05, 2013 2:41 pm

"Log in console" writes messages to the browsers Console window. I prefer Chrome for debugging, so if you run your game and press F12, you'll get the Developer Tools window popup. On the Console tab, you'll see all of the messages there. This was invaluable to finding your problems as I just added messages at appropriate places and I could see which code was being called, and which wasn't. Most of the logging is actually gone now, as I changed things around.blackhornet2013-08-05 14:41:36
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Mon Aug 05, 2013 11:54 pm

@blackhornet - I think I understand. So it won't hurt anything if I were to delete such Browser events/actions? (I'm gonna read up on the manual before I change anything, though.)

I noticed a couple of things, though, when I repositioned the patrol zones.
CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6971329

1. The enemy does not automatically begin his patrol at the start of the game.
2. When the enemy approaches the upper-left Node, it seems to stutter.
3. I didn't change anything in my PatrolRoutes event sheet, but when the enemy approaches the upper-right Node, it never takes the occasional downward trip to the bottom-right Node. (I'm considering altering this set-up anyway - removing the random nature in which way the enemy will go when it reaches a junction.)

What can you see in light of these issues?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Tue Aug 06, 2013 12:52 am

a) You haven't set up the HomeZone values on all of the objects. NodePatrols are 1, Enemy is -1, and NodeZone is 0. They need to match.
b) You need to figure out your NodePatrol pattern. I made several assumptions. 1) that the Origin is in the middle, but you've moved some, (top-left) so the Enemy stops without overlapping, but the code that picks the next NodePatrol picks the non-overlapping items to pick next, which will include the top-left which it just arrived at. 2) (not in this code, but my previous sample) I was just picking the farthest node, but there where only two at the time.

Once you figure out how to pick the next node, then you can code the steps appropriately.
a) You haven't set up the HomeZone values on all of the objects. NodePatrols are 1, Enemy is -1, and NodeZone is 0. They need to match.
b) You need to figure out your NodePatrol pattern. I made several assumptions. 1) that the Origin is in the middle, but you've moved some, (top-left) so the Enemy stops without overlapping, but the code that picks the next NodePatrol picks the non-overlapping items to pick next, which will include the top-left which it just arrived at. 2) (not in this code, but my previous sample) I was just picking the farthest node, but there where only two at the time.

Once you figure out how to pick the next node, then you can code the steps appropriately.

You can delete the browser object at any time. It's just logging for debugging.blackhornet2013-08-06 00:53:45
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Tue Aug 06, 2013 6:01 am

Thank you, once again, @blackhornet. I'll look it over and see what I can work out. I'm probably gonna scrap my Patrol system (during Normal status) and try to simplify it... May I petition you for further help in the future?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Wed Aug 07, 2013 2:04 pm

Happy to help.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Wed Sep 04, 2013 12:36 am

More help, please? (See the UPDATE to the original post.)
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Next

Return to How do I....?

Who is online

Users browsing this forum: Julot135 and 22 guests