Skip to content

Commit

Permalink
Update to 1.0.6 - Add fishlips changes for spitter spawners
Browse files Browse the repository at this point in the history
  • Loading branch information
AnodeCathode committed Jan 6, 2015
1 parent 67b1a52 commit 9463ea6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
15 changes: 6 additions & 9 deletions config.lua
Expand Up @@ -6,16 +6,16 @@ region_size=8 -- alternative mean to control how further away resources would be
-- each region is region_size*region_size chunks
-- each chunk is 32*32 tiles

override_normal_spawn = false -- if false then the standard spawner can also spawn full grown resources/entities,
override_normal_spawn = true -- if false then the standard spawner can also spawn full grown resources/entities,
-- set resources you want to control through this config to "None" in worldgen "Size" settings when starting a new game
-- changing of this setting requires game restart, i.e. close game and start it again, not actally a new game

override_type = 'partially' -- 'full' - no spawns by game are allowed, 'partially' - very small patches are spawned by world gen
override_type = 'full' -- 'full' - no spawns by game are allowed, 'partially' - very small patches are spawned by world gen
-- changing of this setting requires game restart

starting_area_size=1 -- starting area in regions, safe from random nonsense

absolute_resource_chance=0.60 -- chance to spawn an resource in a region
absolute_resource_chance=0.40 -- chance to spawn an resource in a region
global_richness_mult = 1.0 -- multiply richness all resources

multi_resource_richness_factor=0.60 -- any additional resource is multiplied by this value times resources-1
Expand All @@ -33,6 +33,9 @@ endless_resource_mode_sizeModifier = 0.30

disable_RSO_biter_spawning = false -- if true, no biters will be spawned by RSO. Do not use with override_normal_spawn = true, because then no biters will be spawned at all.

biter_ratio_segment=1 --the ratio components determining how many biters to spitters will be spawned
spitter_ratio_segment=1 --eg. 1 and 1 -> equal number of biters and spitters, 10 and 1 -> 10 times as many biters to spitters

config={
["iron-ore"] = {
type="resource-ore",
Expand Down Expand Up @@ -167,12 +170,6 @@ config={
allotment=1000,
allotment_distance_factor=1.15,
clear_range = {1, 1},
},
["spitter-spawner"]={
min_distance=4,
allotment=1000,
allotment_distance_factor=1.10,
clear_range = {3, 3},
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions control.lua
Expand Up @@ -39,6 +39,7 @@ local assoc_config = {}
local max_allotment = 0
local rgen = nil
local distance = util.distance
local spawner_probability_edge = 0 -- below this value a biter spawner, above/equal this value a spitter spawner


--[[ HELPER METHODS ]]--
Expand Down Expand Up @@ -450,7 +451,13 @@ local function spawn_entity(ent, r_config, x, y)
if game.gettile(s_x, s_y).valid and game.canplaceentity{name=ent, position={s_x, s_y}} then
_total = _total + richness
debug("@ "..s_x..","..s_y)
game.createentity{name=ent, position={s_x, s_y}, force=game.forces[r_config.force], amount=richness, direction=rgen:random(4)}
if spawner_probability_edge > 0 then
if rgen:random() < spawner_probability_edge then
game.createentity{name="biter-spawner", position={s_x, s_y}, force=game.forces[r_config.force], amount=richness, direction=rgen:random(4)}
else
game.createentity{name="spitter-spawner", position={s_x, s_y}, force=game.forces[r_config.force], amount=richness, direction=rgen:random(4)}
end
end
end
if r_config.sub_spawn_probability then
local sub_spawn_prob = r_config.sub_spawn_probability*math.min(r_config.sub_spawn_max_distance_factor, r_config.sub_spawn_distance_factor^r_distance)
Expand Down Expand Up @@ -579,10 +586,18 @@ local function generate_seed()
--game.player.print("Initial seed: "..glob.seed)
end

-- set up the probabilty segments from which to roll between for biter and spitter spawners
local function calculate_spawner_ratio()
if (biter_ratio_segment ~= 0 and spitter_ratio_segment ~= 0) and biter_ratio_segment >= 0 and spitter_ratio_segment >= 0 then
spawner_probability_edge=biter_ratio_segment/(biter_ratio_segment+spitter_ratio_segment) -- normalize to between 0 and 1
end
end

local function init()
if not glob.regions then glob.regions = {} end
prebuild_config_data()
generate_seed()
calculate_spawner_ratio()
spawn_starting_resources()

if debug_enabled and not glob.debug_once then
Expand Down Expand Up @@ -780,7 +795,7 @@ local function clear_chunk(c_x, c_y)

-- remove biters
for _, obj in ipairs(game.findentitiesfiltered{area = {{c_x - CHUNK_SIZE/2, c_y - CHUNK_SIZE/2}, {c_x + CHUNK_SIZE/2, c_y + CHUNK_SIZE/2}}, type="unit"}) do
if obj.valid and obj.force.name == "enemy" and string.find(obj.name, "-biter", -6) then
if obj.valid and obj.force.name == "enemy" and (string.find(obj.name, "-biter", -6) or string.find(obj.name, "-spitter", -8)) then
obj.destroy()
end
end
Expand Down
2 changes: 1 addition & 1 deletion info.json
@@ -1,6 +1,6 @@
{
"name": "rso-mod",
"version": "1.0.5",
"version": "1.0.6",
"title": "Resource Spawner Overhaul",
"author": "Dark",
"homepage": "http://www.factorioforums.com/forum/viewtopic.php?f=14&t=4761",
Expand Down

0 comments on commit 9463ea6

Please sign in to comment.