Vallar's Recent Forum Activity

  • So there is an array object, and you can load the array files in or sure import as JSON too. The idea is the recipes are listed in the array in whatever format you want so something like :

    item 1 | amount 1 | item 2 | amount 2 | makes what

    Then the crafting area relates to a separate array with the same structure, as you drop in items into slot 1, the item 1 and amount 1 updates, as you drop items into slot 2, the item 2 and amount 2 update.

    When you click on 'craft', you compare this array with the recipe array to see if anything matches.

    So if you drop in 2 wood and 2 stone, it would then look in the recipe array for

    wood | 2 | stone | 2

    and then this makes the item at column 5

    Something like this would be my approach

    So let me see if I understand this correctly, so each recipe is a separate array? So if I want the axe recipe that is an array, if I want a door recipe, that is a second array object? Am I understanding you correctly?

  • Create an array of recipes and compare against them when you try and craft. Recipe would contain 2 items and the amount required so can look something like 2 | Wood | 4 | Stone, then when you drop the items in you compare to a craft array which has the current items and amounts dropped in, in a similar structure.

    I am sorry I am not following, how do you create an array of recipes? I come from Unity and that statement means I'd need to make a struct/class and make the array/list out of that. How do I do that without using JS here?

    Also I thought of saving the recipes in JSON format an loading that in, but I still wasn't sure how do I correlate data from JSON to global variables. I checked the example JSON in C3 and it shows how you can extract a value, but it doesn't show something like "check your JSON to see if this recipe has what the player wants and if so, equate the ingredients in the recipe to global variables to deduct the amount and THEN spawn the correct potion". I feel there is a way using that (or XML for that matter) but I am not sure how I get "Wood" from the JSON to understand wood from the global variables.

    I think global variables are only useful for total item amounts that you would display in a HUD UI.

    So right now the global variables are used for the player's inventory instead of using instanced variables on a sprite. That way I can access them from different layouts without issue.

  • Hello everyone,

    I recently started migrating from C2 to C3 and I reached a point where I need to seriously develop a data structure for my crafting system.

    Here is how the system functions:

    First off, you have to learn a recipe before you actually craft the item in this recipe. I may implement experimenting (i.e. you randomly put items and see what happens) but for now let's assume that is not the case.

    Each recipe has two data points:

    1- What ingredients to use?

    2- The count of each ingredient used.

    So something like "10x stones + 15x wood" would create an axe. The player has to then drag the wood from their inventory and the stone to put it into a crafting station then hit "craft"

    Right now I have global variables representing the ingredients; stone, wood, iron, leather, etc...

    How do I structure a data set that basically has the recipes and the game would then read this data and see "player put stone and wood, which recipe has stone and wood? Oh, that one, OK, then the player wants an axe, here is an axe made"

    Thank you very much.

    Tagged:

  • Hi,

    My game has a tilemap and I'd like the player to move based on these tiles. A similar approach is available in Construct 3 as a behaviour but uses the keyboard for movement.

    What I'd like to do is for the player to click on a tile on the tilemap. The player object would then check if the distance between that tile on the tilemap is within a certain limit. If yes, then the player then moves to that tile (i.e. setting the position to the center of the tile).

    So far what I was able to do is get the object to move to the mouse position within a certain distance, but I can't get the center of a tile in a tilemap to set it as the potion of the player.

    Is this possible in Construct 2? Any idea how I can achieve this?

  • The upper limits for modern computers for objects in a layout is anywhere between 5000 to 10000 depending on hardware with limited to moderate movement.

    Less, and a wider range for mobile of course.

    There are a few optimizations like Render Cells, and mixed objects(part tilemap, part sprites, part tiled background ect.)

    I have just run a test and I was able to put 10K objects (not in the same screen of course) and it worked just fine (web). Mobile isn't a very big concern right now. But if worse comes to worst, I can always separate those into like 4 levels or something.

    I didn't know about Render Cells. Just read about them, super useful. Thank you very much.

    I would suggest making a simple level editor. Just a separate capx where you can click on a tile to change its type and enter specific info about this tile into a few text boxes. Save this info in an array, and then export Array.AsJSON and Tilemap.TilesJSON.

    I thought of this at one point but then felt the hassle is going to defeat the purpose of making this prototype/demo in Construct 2 (quick easy, couple of days work). Unless level editors in Construct 2 are a quick 1-2 hours thing.

    Another option is similar to newt's suggestion - put sprites on your tilemap, but you probably don't need to cover the entire map, only the tiles which have any valuable resources. And this sprite may be a single invisible square.

    Thanks for the suggestion between yours and Newt's I think I'll choose this actually. Have a layer with a Tilemap and then another layer on top of it some squares that On Click or something do some stuff.

    If I want to change the tilemap's tile, I can just simply do that still (since it is a tilemap and don't have to detect what object I am on) using the tilemap.At or I can be lazy and spawn a sprite right on top of that part of the tilemap to render on top as if it replaced it :D

    Thank you both very much!

  • If the map isn't huge like thousands and thousands of tiles, I would go with sprites, and store the data in their instance variables instead of a tilemap.

    You get relative xy's as well as other benefits of frames, collision poly's etc.

    I wondered about that, but I was worried about performance. Do you know what is the upper bounds of something like that rouhgly? Like for example would a map of about 6K tiles be OK? Would that be too much?

  • Hey,

    So I have this tilemap where I create manually in the editor (not generated at runtime).

    What I want is something similar to what is in the game Neo Scavenger, I can click on "Scavenge" and get loot/information based on the tile type. Expanding on that, it is like if you're on a forest tile you get bushes and ropes. If you're in a mountainous area, you get rocks and maybe some iron.

    Now how do I add data to each tile (i.e. each tile knows what kind of text to display and what kind of loot to provide?) and how do I check which tile is which when the player clicks on "Scavenge" on it?

    One way I thought about this was storing data in a JSON/XML/CSV file. But that basically makes the whole create the map in editor moot and I have to generate it at runtime and I don't want that.

    Since I use Unity mainly, the equivalent to this in Unity is to create a data object (doesn't live in the level) and put all the data a tile type needs in it. Then each tile (also a data object) is then given an attribute of type "tile data" and then linking both. Does Construct 2 have something like this? Any ideas how I can do this?

    Tagged:

  • You probably need to add "Pathfinding Stop" action to event #4.

    By the way, instead of checking the distance in that event, you can set the distance in LOS properties.

    Huh! Nice catch, I thought I had that there. Thanks for the solution.

    As for not checking the distance, that is a good point. It is a test at the moment as this AI is basically following the player from the moment it spawns; another might be just far and won't move until it actually sees the player and up till it reaches its attack range then attack.

    But for this one, spot on, yes, thanks for that. I'll remove the distance and depend on LOS' range.

  • Add "For each BasicMeleeFollowEnemy" as a second condition, directly under "BasicMeleeFollowEnemy has LOS.." in event #3. It should fix the issue with attacking and chasing.

    Gotcha, thank you very much! Would you know why the enemies won't stop where the distance is set and they go directly to the player location?

  • In your screenshot you need to add "For each BasicMeleeFollowEnemy" condition to event #3.

    > Your dropbox links won't download.

    This is odd, I checked on another machine and they are working. Try direct links:

    https://www.dropbox.com/s/nndzbogyc0dz2wt/Pathfinding_NoOverlapOnDestination.c3p?dl=0

    https://www.dropbox.com/s/gmvzgg6trvsfipu/Pathfinding_NoOverlapWhileMoving.c3p?dl=0

    Still not working, I think it might be something on my end with Dropbox; One Drive and Google Drive work just fine.

    Wouldn't the For Each BasicMeleeFollowEnemy" pick all of the enemies whether they are nearby or not? Do I have to do a Pick All condition first?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't see the image of your event sheet.

    There are many ways to do all this, try searching the forum and tutorials.

    Here is a recent topic:

    https://www.construct.net/en/forum/construct-3/how-do-i-8/keep-followers-spaced-one-153220

    I also have a few demos, they are for Construct 3, you should be able to open them in the free version and maybe copy some ideas to your game.

    https://howtoconstructdemos.com/avoid-overlapping-while-moving-with-pathfinding/

    I have updated the original post with a link from imgur so you can see the event sheet now. Not sure what is up with Construct's website.

    I checked the first link you posted and that is something I did at one point and it just still overlapped most of the time. Even when I added a delay at the start (before they start pathfinding) and providing a random X and Y offset that is deducted from the player's position.

    I'll see if I can recalculate a position if they are going to overlap with another agent.

    Your dropbox links won't download. I tried on multiple browsers but I get the same exact error message saying "There was an error trying to download this file" even after clearing my Chrome's cache not sure what is up with that.

  • Hi all,

    Recently I got back to using Construct 2 and I am playing around with enemy AI. I am trying to create an enemy that basically does this:

    - On spawn, it pathfinds to player.

    - When it sees player it checks distance; if it is within attack range.

    --- if yes, then attacks the player periodically (i.e. every x seconds based on its attack speed).

    --- if no, then continue to pathfinds till it reaches its attack range.

    - If player moves away (further than attack range) from the enemies, they go back to pathfinding towards the player.

    Another thing I'd like to do is not have enemies overlap on each other when they reach the player (like you see them in the GIF below). I haven't addressed that yet, because I am not sure exactly how to do that in Construct 2.

    This the event sheet:

    i.imgur.com/FYmzmqh.png

    This is the bahaviour I get:

    i.imgur.com/fZ6wRxj.gif

    First off they don't stop at the range I set in LoS (50) they stop RIGHT on top of the player. Second thing is that if I watch the player's HP to check the attacks, all I find is that the HP is being deducted as if one enemy is attacking. In the GIF there are 4 enemies (2 are overlapping each other) and yet when an attack happens HP goes down from say 10 to 8 instead of instantly to 2. Do I have to use a for loop for the attack?

    Not sure what I am doing wrong exactly. Any ideas?

    Thanks in advance.

Vallar's avatar

Vallar

Online Now

Member since 24 Mar, 2014
Last online 6 Nov, 2024

None one is following Vallar yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies