More than one active layouts

Get help using Construct 2

Post » Thu Sep 12, 2013 10:18 pm

Hello everyone.

For two weeks now I am focused on a new project that I intend to share with you soon. But I feel a danger aproaching and would like to ask for your help before it's too late.

In my (real time) game, I will need an interior level (an inn per se), and an exterior level(wilderness). There will be many npc's doing various jobs outside, and they will frequent the inn. So how will I handle wilderness events when the player is inside the inn? I will have switched the layout to inside, so wilderness events will stop, right? But I still need my rangers to scout for game, and hunt if they see them. I need my burglars to attack caravans, in real time, even when the player is inside.

The reverse is also true, people inside the inn should be doing their jobs even when the player is outside, in realtime.

And NPC's and player should be able to come in or get outside as they need to...

AI part of the NPC's are done, but I don't know how to do both places active in the same time. I did a quick search but couldn't find something similar. Anyone had such an experience? Should I just hide inside of the inn far away from the wilderness in the same layout and switch camera positions?

Thanks in advance,
-Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Thu Sep 12, 2013 10:53 pm

The best approach to games like this one is to separate the logic/ai from the visuals. All the scouting, hunting, attacking, cooking, serving drinks, etc. should be managed with variables, arrays and dictionaries. You can then hook in to whatever part of the world is currently visible and link the appropriate sprites with the data.

Such seperation would be done with one or more global event sheets (for the calculation parts) that you include in every layout.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Sep 12, 2013 11:10 pm

@tulamide thanks. In fact I feared for such a thing, because it seems there is a lot to take into consideration when trying to move them into logic. (pathfingin location, destination, current state of HP, hunger, task, line of sight and all the other actions... How am I going to create a "virtual machine" layout that keeps track of all these and turns them into display when needed?

I'm afraid I am not that hot with Construct 2 yet. Could you direct me to an example of how this can be implemented?

Thanks again;
-Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Thu Sep 12, 2013 11:36 pm

Unfortunately I don't know of any C2 example. It sure is a huge project and you would be more of a database administrator than a developer, but once managed it is very easy to extend, for example.
You wouldn't work on a layout but a separate event sheet. Create it on the first of all your layouts and use 'include event sheet' to add it to each layout (even the first one).
Things, you'd have to manage, are not easy though. For example the hunting. Begin with the speed, direction and position of the animals. Some math will let you keep track of their positions that are stored in some table.
animal a, 100, 120
animal b, 200, 300
etc.
Now you need math for the scouting of the hunters. Where are their positions, what is their scout range, is any of the animals within range. If so, a hunter's table would be updated
hunter a, 180, 240, in range, animal b
Now he sneaks towards the animal and tries to kill it. Math again to keep track of position and luck/bad luck when trying to kill.
And so on.

But, when all this happens, while the player is inside the inn, it's simple math that's calculated fast. And whenever the player enters the wilderness, you just need to lookup your tables to see what you need to display (player is near a hunter, or near some animals, whatever). You look up those values and set the appropriate sprites to those coordinates, check the animations/frames) etc.

Yes, it is a whole lot of effort. But I wouldn't know of any easier method that's equally versatile...

But without above method you can of course try to work on one layout, offsetting all wilderness items when player is in the inn and vice versa. It makes it harder to maintain though.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Sep 13, 2013 8:52 am

@tulamide thanks for the explanation. I will have to try since it's the natural way and it would possibly be the first time it's done in C2 :) I know I will probably fail but I think it will be a challenge that teaches great amount of things. I am not very good with maths but will have to figure sth out.

Meanwhile, any of you out there with any other aproach or more detailed explation on tulamide's offer for solution; all help is welcome :)
Regards;
-Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Fri Sep 13, 2013 9:11 am

Another option if you already have a lot done:

You could hide the layers of the background, and make the layers of inside space appear. You could put all interaction with each environment in a group, and disable the group when that layer is hidden, so you can't click on the exterior door, or woodland creatures, for example.
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Fri Sep 13, 2013 9:52 am

@Paradox thanks, I will try that as well. However, I really wish there was a way to keep more than one layout active while displaying only one of them. How do people manage NPC's chasing players between levels anyway?

Regards;
-Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Fri Sep 13, 2013 10:00 am

There is "Persist" behavior, but what you want sounds like it may still require tracking in the events, because Persist can return to a layer in progress, but it would be paused while you were away.

https://www.scirra.com/manual/161/persist
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Fri Sep 13, 2013 10:08 am

@Paradox yes, exactly. Doing it mathetmatically in a "game loop" is not impossible, though the hardest part is to simulate the pathfinding behaviour I think.

The inn problem is not that hard. I can use the inn within the same layout with wilderness and prevent interaction between them. But inn is not the only place. There is also the mines, which is entirely something else. I thought of keeping everything in one huge layout but it will bog down eventually, especially with a hundred npc's trying to pathfind around, all the while searching for their prey or chasing whatever tasks they have.

Will read more through the manual and tutorials, maybe something will come up. Meanwhile, please keep the advices flowing; especially any example of the mathematical solution would be welcome.

Regards & thanks for help;
Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Fri Sep 13, 2013 10:14 am

i.e. I need persistent events :)
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Next

Return to How do I....?

Who is online

Users browsing this forum: TRMG, Yahoo [Bot] and 12 guests