Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Randomized NPC spawn locations

Mr. Open

Villager
Xy$
0.00
Hello! Does anyone know how to make an NPC spawn in one location out of a specific pool randomly? (for example, you set up 5 possible spawn points, where each one has 20% spawn rate and NPC is present at only ONE of them). I want to make a unique set of enemies that would "escape" to another location upon defeat and drop a unique item with a fixed chance, but have no idea how to create the random spawn point system. (aww)
 

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
Hello! Does anyone know how to make an NPC spawn in one location out of a specific pool randomly? (for example, you set up 5 possible spawn points, where each one has 20% spawn rate and NPC is present at only ONE of them). I want to make a unique set of enemies that would "escape" to another location upon defeat and drop a unique item with a fixed chance, but have no idea how to create the random spawn point system. (aww)
@Mr. Open
Made a demo for you using Galv's Event Spawner Plugin: Click Here to View

I'm not sure if it's 100% what you need but it's a good start at least. (cool)(thumbsup)
 

Attachments

Last edited:

Mr. Open

Villager
Xy$
0.00
Well, You're right I meant different spawn locations, but not certainly within only one map. But I already asked Galv whether it's even possible with his script, all I can do is wait for an answer.
 

Dalton Sayre

Towns Guard
Xy$
0.35
I've done a kinda similar thing, both with common events + switches and with variables.
I create the spawn point events at each location with a corresponding switch. I use a conditional branch in conjunction with the "seconds" variable associated with my time system which controls the randomization of which spawn point switch is on or off. The gist is as follows:
Defeat enemy at spawn point 1
Spawn point 1 switch is turned off
(Conditional branch <parallel>: if switch 001 is off
If variable "001: seconds"= 1-3 switch 002 is on
If variable "001: seconds"= 4-6 switch 003 is on
If variable "001: seconds"= 7-9 switch 004 is on
If variable "001: seconds"= 10-12 switch 005 is on
If variable "001: seconds"= 13-15 switch 006 is on
And so on. It is a bit tedious to set up, but once you fine tune it it is pretty smooth and does add variable elements. I played through mine dozens of times in testing & I don't know if I had any indetical playthroughs. I hope this helps and bit.
 
Top