DUNE - The Spice must flow!

by RedRafe

Production Challenge where you need to collect Spice to survive on Arrakis!

Scenarios
1 year, 11 months ago
1.1
603
Enemies Environment Mining

b [Open] Enemies spawning in base

1 year, 5 months ago
(updated 1 year, 5 months ago)

in the create_enemy_forces function

                local spawn_radius = (400 + (global.level * 20))
                local x_offset = math.random(-spawn_radius, spawn_radius) 
                local y_offset = math.random(-spawn_radius, spawn_radius) 
                local save_zone = 100 - (global.attack_increase / 15)
                if x_offset >= 0 and x_offset < save_zone then x_offset = x_offset + save_zone elseif x_offset >= (save_zone*-1) then x_offset = x_offset - save_zone end
                if y_offset >= 0 and y_offset < save_zone then y_offset = y_offset + save_zone elseif y_offset >= (save_zone*-1) then y_offset = y_offset - save_zone end

Enemies can always spawn in the base, at a minimum distance of save_zone until global.attack_increase is negative enough to pass through 0,0 and start spawning them opposite to what math.random rolled
If it were instead:

                local spawn_radius = (100 + (global.level * 5)) --could use balancing
                local x_offset = math.random(spawn_radius, 1.5 * spawn_radius) * (math.random() < .5 and -1 or 1)
                local y_offset = math.random(spawn_radius, 1.5 * spawn_radius)* (math.random() < .5 and -1 or 1)
                --local save_zone = 100 - (global.attack_increase / 15)
                --if x_offset >= 0 and x_offset < save_zone then x_offset = x_offset + save_zone elseif x_offset >= (save_zone*-1) then x_offset = x_offset - save_zone end
                --if y_offset >= 0 and y_offset < save_zone then y_offset = y_offset + save_zone elseif y_offset >= (save_zone*-1) then y_offset = y_offset - save_zone end

or something like it, then the enemies spawn a distance out, between two squares. It's a starting point that is easier to understand, at least. (in my opinion)

1 year, 5 months ago
(updated 1 year, 5 months ago)

Sorry, the code I posted makes the outside corners of a square, not including the sides.

This way is a circle:

local radius = math.random(spawn_radius, 1.5 * spawn_radius)
local theta = math.random() * 6.28
local spawn_position = { x = radius * math.cos(theta), y = radius * math.sin(theta) }

New response