1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00

biter_battles spawn fixes

This commit is contained in:
MewMew 2018-12-13 00:36:55 +01:00
parent 62b7b083fb
commit 205199dfda
7 changed files with 65 additions and 38 deletions

View File

@ -9,17 +9,18 @@ require "player_list"
require "poll"
require "score"
require "maps.tools.cheat_mode"
--require "maps.modules.hunger"
--require "maps.tools.cheat_mode"
---- enable maps here ----
--require "maps.biter_battles"
require "maps.biter_battles"
--require "maps.cave_miner"
--require "maps.deep_jungle"
--require "maps.lost_desert"
--require "maps.labyrinth"
--require "maps.spaghettorio"
--require "maps.spiral_troopers"
require "maps.fish_defender"
--require "maps.fish_defender"
--require "maps.crossing"
--require "maps.spooky_forest"
--require "maps.atoll"

View File

@ -757,6 +757,9 @@ local function on_gui_click(event)
global.biter_battle_view_players[player.name] = true
refresh_gui()
end
if not global.terrain_init_done then player.print("Waiting for spawn to generate.", { r=0.98, g=0.66, b=0.22}) return end
if (name == "join_north_button") and global.game_lobby_active == false then join_team(player, "north") end
if (name == "join_south_button") and global.game_lobby_active == false then join_team(player, "south") end
if (name == "join_north_button") and global.game_lobby_active == true then player.print("Waiting for more players to join the game.", { r=0.98, g=0.66, b=0.22}) end
@ -1206,37 +1209,7 @@ local function on_tick(event)
refresh_gui()
return
end
if not global.terrain_init_done then
if game.tick == 240 then
local surface = game.surfaces["surface"]
global.rocket_silo = {}
global.rocket_silo["north"] = surface.create_entity {name="rocket-silo", position={0,(global.horizontal_border_width*3.8)*-1}, force="north"}
global.rocket_silo["north"].minable=false
global.rocket_silo["south"]=surface.create_entity {name="rocket-silo", position={0,global.horizontal_border_width*3.8}, force="south"}
global.rocket_silo["south"].minable=false
global.biter_attack_main_target = {}
global.biter_attack_main_target["north"] = global.rocket_silo["north"].position
global.biter_attack_main_target["south"] = global.rocket_silo["south"].position
biter_battles_terrain.clear_spawn_ores()
biter_battles_terrain.generate_spawn_water_pond()
biter_battles_terrain.generate_spawn_ores("windows")
biter_battles_terrain.generate_market()
--biter_battles_terrain.generate_artillery()
global.terrain_init_done = true
surface.regenerate_decorative()
surface.regenerate_entity({"tree-01", "tree-02","tree-03","tree-04","tree-05","tree-06","tree-07","tree-08","tree-09","dead-dry-hairy-tree","dead-grey-trunk","dead-tree-desert","dry-hairy-tree","dry-tree","rock-big","rock-huge"})
--surface.regenerate_entity({"dead-dry-hairy-tree","dead-grey-trunk","dead-tree-desert","dry-hairy-tree","dry-tree","rock-big","rock-huge"})
local entities = surface.find_entities({{-10,-10},{10,10}})
for _, e in pairs(entities) do
if e.type == "simple-entity" or e.type == "resource" or e.type == "tree" then e.destroy() end
end
surface.destroy_decoratives({{-10,-10},{10,10}})
game.print("Spawn generation done!", { r=0.22, g=0.99, b=0.99})
end
end
if global.game_lobby_active then
if game.tick % 60 == 0 then
if global.game_lobby_timeout-game.tick <= 0 then global.game_lobby_active = false end
@ -1261,6 +1234,44 @@ local function on_tick(event)
end]]--
end
local function on_chunk_generated(event)
if global.terrain_init_done then return end
local surface = game.surfaces["surface"]
if event.surface ~= surface then return end
if event.area.left_top.x > 128 then
global.rocket_silo = {}
global.rocket_silo["north"] = surface.create_entity {name="rocket-silo", position={0,(global.horizontal_border_width*3.8)*-1}, force="north"}
global.rocket_silo["north"].minable=false
global.rocket_silo["south"] = surface.create_entity {name="rocket-silo", position={0,global.horizontal_border_width*3.8}, force="south"}
global.rocket_silo["south"].minable=false
global.biter_attack_main_target = {}
global.biter_attack_main_target["north"] = global.rocket_silo["north"].position
global.biter_attack_main_target["south"] = global.rocket_silo["south"].position
biter_battles_terrain.clear_spawn_ores()
biter_battles_terrain.generate_spawn_water_pond()
biter_battles_terrain.generate_spawn_ores("windows")
biter_battles_terrain.generate_market()
--biter_battles_terrain.generate_artillery()
surface.regenerate_decorative()
surface.regenerate_entity({"tree-01", "tree-02","tree-03","tree-04","tree-05","tree-06","tree-07","tree-08","tree-09","dead-dry-hairy-tree","dead-grey-trunk","dead-tree-desert","dry-hairy-tree","dry-tree","rock-big","rock-huge"})
--surface.regenerate_entity({"dead-dry-hairy-tree","dead-grey-trunk","dead-tree-desert","dry-hairy-tree","dry-tree","rock-big","rock-huge"})
local entities = surface.find_entities({{-10,-10},{10,10}})
for _, e in pairs(entities) do
if e.type == "simple-entity" or e.type == "resource" or e.type == "tree" then e.destroy() end
end
surface.destroy_decoratives({{-10,-10},{10,10}})
game.print("Spawn generation done!", { r=0.22, g=0.99, b=0.99})
global.terrain_init_done = true
end
end
----------share chat with player and spectator force-------------------
local function on_console_chat(event)
if not event.message then return end
@ -1449,6 +1460,7 @@ local function on_research_finished(event)
game.forces.south.recipes["flamethrower-turret"].enabled = false
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_research_finished, on_research_finished)
event.add(defines.events.on_player_died, on_player_died)
event.add(defines.events.on_built_entity, on_built_entity)

View File

@ -1,3 +1,6 @@
0.34
fixes to spawn generation
0.33
flamethrower-turret disabled

View File

@ -417,7 +417,7 @@ function biter_battles_terrain.generate_spawn_water_pond()
for y = -200, 200, 1 do
local t = surface.get_tile(x,y)
if t.name == "water-green" then
if surface.can_place_entity{name="fish", position={x,y}} and math_random(1,10) == 1 then
if surface.can_place_entity{name="fish", position={x,y}} and math_random(1,12) == 1 then
surface.create_entity {name="fish", position={x,y}}
end
end

View File

@ -98,8 +98,19 @@ local function hunger_update(player, food_value)
end
local function respawn_fishes()
if not global.respawn_fish_cake_piece then global.respawn_fish_cake_piece = 1 end
if global.respawn_fish_cake_piece > 4 then global.respawn_fish_cake_piece = 1 end
local r = 1000000
local area = {{0, r * -1}, {r, 0}}
if global.respawn_fish_cake_piece == 2 then area = {{0, 0}, {r, r}} end
if global.respawn_fish_cake_piece == 3 then area = {{r * -1, 0}, {0, r}} end
if global.respawn_fish_cake_piece == 4 then area = {{r * -1, r * -1}, {0, 0}} end
global.respawn_fish_cake_piece = global.respawn_fish_cake_piece + 1
for _, surface in pairs(game.surfaces) do
local water_tiles = surface.find_tiles_filtered({name = {"water", "deepwater", "water-green"}})
local water_tiles = surface.find_tiles_filtered({name = {"water", "deepwater", "water-green"}, area = area})
for _, tile in pairs(water_tiles) do
if math_random(1, 64) == 1 then
local area_entities = {{tile.position.x - 2, tile.position.y - 2},{tile.position.x + 2, tile.position.y + 2}}

View File

@ -574,7 +574,7 @@ local function on_entity_died(event)
if p then event.entity.surface.create_entity {name=t[1], position=p} end
end
end
if math.random(1,150) == 1 then
if math.random(1, 75) == 1 then
local amount = 100000 * (1 + (game.forces.enemy.evolution_factor * 20))
event.entity.surface.create_entity({name = "crude-oil", position = event.entity.position, amount = amount})
end

View File

@ -443,7 +443,7 @@ local function on_player_joined_game(event)
game.create_surface("spooky_forest", map_gen_settings)
local surface = game.surfaces["spooky_forest"]
surface.daytime = 0.5
surface.freeze_daytime = 1
--surface.freeze_daytime = 1
game.forces["player"].set_spawn_position({0, 0}, surface)
game.map_settings.enemy_expansion.enabled = true