Increase random spawn rate with a property (Via phyton)?

Hi, and well, the title says all.
I want to control the random spawn rate of some NPCs, using a property. Pretty much like a wave sistem. After each wave, the enemies spawn in bigger numbers, plus it spawns different types of enemies.

I understand phyton, but not too well, since i’m still practicing, but it would be better for me to control that sistem with phyton.

Any help is appreciated :slight_smile:

This type of thing can be accomplished with a simple for loop.

import bge

scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
own = cont.owner
number = own['number']

for i in range(number):
    scene.addObject('Enemy', own)

You can of course do things like position the enemies randomly or choose a random enemy type in the for loop as well.

Actually, what i meant was that i wanted to control the rate (speed or whatever you wanna call it) of the spawning of the enemies based on the number of a property, probably a float property.

What that script does, is just spawn objects if the property ‘‘number’’ is something more than 1.

You could just call the spawning script only when the property reaches a certain value. You could then change the rate enemies are spawned by adjusting the rate you change the property.

Possible design:

A) creating the wave (= adding the enemies)
B) calculating the dimensions of the next wave.

as this is a loop you can switch A) and B) :wink:

property waveSize = 5
property increase = 3

when starting a wave you add as much enemies as stated by waveSize
after that you increase waveSize by increase.

Alternative: you multiply the waveSize by some factor (e.g. 1.2)

You can do that with several other parameters like enemy strength, health, armory, type …

Well, that’s exactly what i want, but as i said befero, i’m still pretty much a complete noob at phyton, and a little help with that would be nice :slight_smile: