How Do I Set Spawning Up Like This?

0 favourites
  • 5 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Whats up everyone!

    I had a question about Npc spawning and i figured this was the best place to ask.

    Im sure that this thread will help alot of people now and in the future.

    What i have is a link to a game called Terraria,for those of you that dont know much about this game you can look it up on google pretty easy,Its a well known game.

    http://terraria.gamepedia.com/NPC_spawning

    What im trying to figure out is how to create the Spawn Logic that they have in place inside this game,I want to have a smarter way of choosing a spot to spawn my Npcs/Mobs and from what i read,I use Tilemaps so it is similar to how the tiles are used in Terraria,This sounds like it is a winner for any sandbox games and other genres aswell.I will copy and paste it inside this post for anyone that thinks they know how to recreate this triple A logic inside construct 2.

    Thanks guys,I hope the info in this thread helps you guys out in some way.

    How Do We Recreate This In Construct 2?

    When the game decides to spawn a monster, it will first choose a random tile within a rectangle around the player. The maximum distance from the player it can choose from is 84 tiles to the left or right, and 47 tiles up or down. If the picked tile is solid block, it will try another one. If the picked tile has a wall that blocks monsters from spawning, it will also try another tile.

    Once an empty tile is found, it moves down until it finds the ground. If there is enough space for a monster to be spawned at this location, this will be the tile it chooses. The exception to this is when the player is in an area where Harpies can be spawned. In this case the game does not attempt to find a ground tile.

    The chosen tile is then checked to make sure it is not within the "safe" area around the player. Monsters cannot spawn less than 62 tiles away left or right, or 35 tiles up or down.

  • Anyone have an idea on how this same logic can be made inside of construct 2? The part that confuses me is how would i make the engine check to make sure there is a solid before my enemy /NPC is spawned?

    How could i do that within this engine?

  • RookieDev If I'm understanding what you're trying to do... I think my idea could work. This is not written in Construct 2 Event code as we're discussing logic but it's a concept made while thinking of the capabilities of the engine functions:

    1) Add two objects, one of the far left of your screen and one on the far right, called LOScheckObj1 and 2. Make them transparent and with the Anchor and LineOfSight behaviours. Face the object down to the ground and give it the cone of view angle you want. Make a check on them for whatever spawn timing you're wanting (every second, two, etc.).

    2) In the above condition you want to check if a floor object is within LOScheckObj's sight angle. Then, on the floor object, you'd need a condition for if in LOS of LOScheckObj, and if so, then that floor object can spawn an enemy of your choosing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • inquiesco That is amazing logic and it just might work using Construct 2 great idea.My thoughts on LOS are limited since i have not used it yet for any projects i have been creating.

    Is there a performance loss when dealing with the LOS?

    I also want to thank you for your reply it helped out a good bit.

  • RookieDev No problem, I enjoy helping people out so I live in the 'How do I' forum as a side activity while making my game, ha ha. And thanks for the compliment, .

    From what I've noticed and read the main performance loss from LOS is if you apply it to individual objects and have a lot of them. To work around that, you should make a family for them. For example, if you had 20 platform types all with LOS and on one screen with a lot other things happening, it might drop performance a little, so if you put the platforms in a family (fam_platforms) and put the check on that, it will only trigger the platforms that are within the LOS of the spawners (LOScheckObj).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)