Advanced Enemy spawning

Have any questions or problems in making your game, subscribing and/or using our software? Post here.
Forum rules
Make sure you are using the newest version. This can be downloaded at the top of the site via the "downloads" link.

Use a very good subject. "Problem" or "Help" are unacceptable titles.

Use the search feature before posting a question, as the answer is probably already here.

Subscript out of range error 9: This is a generic error, and we'll need way more information than that to figure out the problem. If you get this, strongly consider following the instructions of submitting your project through the Submit Bug feature within the editor.
User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Advanced Enemy spawning

Postby Danny » Sun Jan 24, 2016 5:08 am

I need some help, badly. I need to find away to spawn enemies slightly off screen but always around the actual "main" actor. My game is kind of a open world game (You have to go fro map to map but its still openworld"ish")

I have tried to find a way to always have the player battling enemies when out and about (Except Towns where their safe) but i simply just can't find that "Piece" that fits. I have tried a few of things.

1) Pre-place enemies on the map

Not very useful because the player may not explore the area where the enemies are and having enemies pre-placed on maps covering every angle so the player gets attacked is going to mean to many sprites on a map.

2) Map Timers

Nice feature btw Mike! This is nifty and i can use this feature in certain places such as an Arena Battle but not for random encounters, once again the player may not go in the area.

3) Making Zones

Spawning enemies in when the player trips a zone. Still that means making loads of zones. Not something i want.

I want to create a system where the enemy spawns via a timer (In the HUD) and it will relate to the current map they are on. I want it to it will spawn a enemy off screen but very close to the player so that once spawned it will go directly towards the player.

I'm having a hard time spawning it in proximity of the player, off-screen and finding away to make it avoid solids. Anyone able to help? Thanks.

fma_lvr
001 Subscriber
 
Joined: Wed Sep 15, 2010 5:02 am

Re: Advanced Enemy spawning

Postby fma_lvr » Sun Jan 24, 2016 2:28 pm

It sounds like you'd want to use a system of switches in conjuction with Create Actor branches, on a timer within the player character. I did something like this to check if the player had a certain item equipped, to periodically give off a visual effect around the character. Steps:

1. Create as many global variables or switches (your preference) as needed for various enemy types for the random encounters.
2. Go into every map (yes, all of them) and have the Player Enters script include a modification of the switches/global variables. If you want only 1 possible enemy at a given time or map, you could use 1 global variable with each number representing a different enemy (think: hidden bestiary) but if you want more variety, you'll be betteroff using more than one variable. You could also have 0, or a switch, represent a peacetime area, with no enemies to be encountered.
3. Create a While/timer script in the player character (this will probably work in the HUD as well), checking periodically (as often as you want random encounters to happen; put in chance branches and delays for variation) for the global variables or switches, using Comparison Branches, then Create the relevant actor near the player's position. That should look something like this:

Effectively, this should create specific enemies near the player at your discretion. If you want them offscreen though, you'd have to mess with with those numbers and test the camera to see how far they would need to be. I'm not sure if you could spawn them outside the boundaries of the map, but you could probably have the actor templates be invisible until they come within a certain pixel radius of the player. Hope this helps.


Return to Technical Support Questions

Who is online

Users browsing this forum: No registered users

cron