mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
new modules
This commit is contained in:
parent
9d26b8dfce
commit
dc23ffa2ba
74
maps/modules/biters_yield_coins.lua
Normal file
74
maps/modules/biters_yield_coins.lua
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
-- enemy units yield coins -- by mewmew
|
||||||
|
|
||||||
|
local event = require 'utils.event'
|
||||||
|
local insert = table.insert
|
||||||
|
|
||||||
|
local coin_yield = {
|
||||||
|
["small-biter"] = 1,
|
||||||
|
["medium-biter"] = 2,
|
||||||
|
["big-biter"] = 3,
|
||||||
|
["behemoth-biter"] = 5,
|
||||||
|
["small-spitter"] = 1,
|
||||||
|
["medium-spitter"] = 2,
|
||||||
|
["big-spitter"] = 3,
|
||||||
|
["behemoth-spitter"] = 5,
|
||||||
|
["spitter-spawner"] = 32,
|
||||||
|
["biter-spawner"] = 32,
|
||||||
|
["small-worm-turret"] = 8,
|
||||||
|
["medium-worm-turret"] = 16,
|
||||||
|
["big-worm-turret"] = 24
|
||||||
|
}
|
||||||
|
|
||||||
|
local entities_that_earn_coins = {
|
||||||
|
["artillery-turret"] = true,
|
||||||
|
["gun-turret"] = true,
|
||||||
|
["laser-turret"] = true,
|
||||||
|
["flamethrower-turret"] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
local function on_entity_died(event)
|
||||||
|
|
||||||
|
if event.entity.force.name ~= "enemy" then return end
|
||||||
|
if not coin_yield[event.entity.name] then return end
|
||||||
|
|
||||||
|
local players_to_reward = {}
|
||||||
|
local reward_has_been_given = false
|
||||||
|
|
||||||
|
if event.cause then
|
||||||
|
if event.cause.valid then
|
||||||
|
if event.cause.name == "player" then
|
||||||
|
insert(players_to_reward, event.cause)
|
||||||
|
reward_has_been_given = true
|
||||||
|
end
|
||||||
|
if event.cause.type == "car" then
|
||||||
|
player = event.cause.get_driver()
|
||||||
|
passenger = event.cause.get_passenger()
|
||||||
|
if player then insert(players_to_reward, player.player) end
|
||||||
|
if passenger then insert(players_to_reward, passenger.player) end
|
||||||
|
reward_has_been_given = true
|
||||||
|
end
|
||||||
|
if event.cause.type == "locomotive" then
|
||||||
|
train_passengers = event.cause.train.passengers
|
||||||
|
if train_passengers then
|
||||||
|
for _, passenger in pairs(train_passengers) do
|
||||||
|
insert(players_to_reward, passenger)
|
||||||
|
end
|
||||||
|
reward_has_been_given = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for _, player in pairs(players_to_reward) do
|
||||||
|
player.insert({name = "coin", count = coin_yield[event.entity.name]})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if entities_that_earn_coins[event.cause.name] then
|
||||||
|
event.entity.surface.spill_item_stack(event.cause.position,{name = "coin", count = coin_yield[event.entity.name]}, true)
|
||||||
|
reward_has_been_given = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if reward_has_been_given == false then
|
||||||
|
event.entity.surface.spill_item_stack(event.entity.position,{name = "coin", count = coin_yield[event.entity.name]}, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
event.add(defines.events.on_entity_died, on_entity_died)
|
32
maps/modules/spawners_contain_biters.lua
Normal file
32
maps/modules/spawners_contain_biters.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
-- spawners release biters on death -- by mewmew
|
||||||
|
|
||||||
|
local event = require 'utils.event'
|
||||||
|
local math_random = math.random
|
||||||
|
|
||||||
|
local biter_building_inhabitants = {
|
||||||
|
[1] = {{"small-biter",8,16}},
|
||||||
|
[2] = {{"small-biter",12,24}},
|
||||||
|
[3] = {{"small-biter",8,16},{"medium-biter",1,2}},
|
||||||
|
[4] = {{"small-biter",4,8},{"medium-biter",4,8}},
|
||||||
|
[5] = {{"small-biter",3,5},{"medium-biter",8,12}},
|
||||||
|
[6] = {{"small-biter",3,5},{"medium-biter",5,7},{"big-biter",1,2}},
|
||||||
|
[7] = {{"medium-biter",6,8},{"big-biter",3,5}},
|
||||||
|
[8] = {{"medium-biter",2,4},{"big-biter",6,8}},
|
||||||
|
[9] = {{"medium-biter",2,3},{"big-biter",7,9}},
|
||||||
|
[10] = {{"big-biter",4,8},{"behemoth-biter",3,4}}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function on_entity_died(event)
|
||||||
|
if event.entity.type == "unit-spawner" then
|
||||||
|
local e = math.ceil(game.forces.enemy.evolution_factor*10, 0)
|
||||||
|
for _, t in pairs (biter_building_inhabitants[e]) do
|
||||||
|
for x = 1, math_random(t[2],t[3]), 1 do
|
||||||
|
local p = event.entity.surface.find_non_colliding_position(t[1] , event.entity.position, 6, 1)
|
||||||
|
if p then event.entity.surface.create_entity {name=t[1], position=p} end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
event.add(defines.events.on_entity_died, on_entity_died)
|
@ -8,6 +8,8 @@ local simplex_noise = require 'utils.simplex_noise'
|
|||||||
local simplex_noise = simplex_noise.d2
|
local simplex_noise = simplex_noise.d2
|
||||||
require "maps.modules.splice"
|
require "maps.modules.splice"
|
||||||
require "maps.modules.explosive_biters"
|
require "maps.modules.explosive_biters"
|
||||||
|
require "maps.modules.biters_yield_coins"
|
||||||
|
require "maps.modules.spawners_contain_biters"
|
||||||
|
|
||||||
local spawn_turret_amount = 8
|
local spawn_turret_amount = 8
|
||||||
|
|
||||||
@ -52,12 +54,46 @@ local function send_attack_group(surface)
|
|||||||
|
|
||||||
local unit_group = surface.create_unit_group({position=pos, force="enemy"})
|
local unit_group = surface.create_unit_group({position=pos, force="enemy"})
|
||||||
|
|
||||||
for i = 1, global.night_count * 4, 1 do
|
local group_size = 4 + (global.night_count * 4)
|
||||||
|
if group_size > 250 then group_size = 250 end
|
||||||
|
|
||||||
|
for i = 1, group_size, 1 do
|
||||||
if not biters[i] then break end
|
if not biters[i] then break end
|
||||||
unit_group.add_member(biters[i])
|
unit_group.add_member(biters[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
unit_group.set_command({type = defines.command.attack_area, destination = {0,0}, radius = 32, distraction = defines.distraction.by_anything})
|
if global.rocket_silo.valid then
|
||||||
|
unit_group.set_command({
|
||||||
|
type = defines.command.compound,
|
||||||
|
structure_type = defines.compound_command.return_last,
|
||||||
|
commands = {
|
||||||
|
{
|
||||||
|
type = defines.command.attack_area,
|
||||||
|
destination = {x = 0, y = 0},
|
||||||
|
radius = 48,
|
||||||
|
distraction=defines.distraction.by_anything
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = defines.command.attack,
|
||||||
|
target = global.rocket_silo,
|
||||||
|
distraction = defines.distraction.by_enemy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
else
|
||||||
|
unit_group.set_command({
|
||||||
|
type = defines.command.compound,
|
||||||
|
structure_type = defines.compound_command.return_last,
|
||||||
|
commands = {
|
||||||
|
{
|
||||||
|
type = defines.command.attack_area,
|
||||||
|
destination = {x = 0, y = 0},
|
||||||
|
radius = 48,
|
||||||
|
distraction=defines.distraction.by_anything
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_daytime_modifiers(surface)
|
local function set_daytime_modifiers(surface)
|
||||||
@ -77,7 +113,9 @@ local function set_nighttime_modifiers(surface)
|
|||||||
global.splice_modifier = 1
|
global.splice_modifier = 1
|
||||||
else
|
else
|
||||||
global.night_count = global.night_count + 1
|
global.night_count = global.night_count + 1
|
||||||
global.splice_modifier = global.splice_modifier + 0.33
|
--if game.forces["enemy"].evolution_factor > 0.75 then
|
||||||
|
global.splice_modifier = global.splice_modifier + 0.25
|
||||||
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, player in pairs(game.connected_players) do
|
for _, player in pairs(game.connected_players) do
|
||||||
@ -152,17 +190,17 @@ local function generate_spawn_area(surface)
|
|||||||
|
|
||||||
local ore_positions = {{x = -16, y = -16},{x = 16, y = -16},{x = -16, y = 16},{x = 16, y = 16}}
|
local ore_positions = {{x = -16, y = -16},{x = 16, y = -16},{x = -16, y = 16},{x = 16, y = 16}}
|
||||||
ore_positions = shuffle(ore_positions)
|
ore_positions = shuffle(ore_positions)
|
||||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], "copper-ore", surface, 15, 2500)
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], "copper-ore", surface, 18, 2500)
|
||||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], "iron-ore", surface, 15, 2500)
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], "iron-ore", surface, 18, 2500)
|
||||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], "coal", surface, 15, 1500)
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], "coal", surface, 18, 2500)
|
||||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], "stone", surface, 15, 1500)
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], "stone", surface, 18, 2500)
|
||||||
map_functions.draw_oil_circle({x = 0, y = 0}, "crude-oil", surface, 8, 200000)
|
|
||||||
|
|
||||||
local lake_size = 14
|
local lake_size = 14
|
||||||
local lake_distance = fort_size - (lake_size + fort_wall_width)
|
local lake_distance = fort_size - (lake_size + fort_wall_width)
|
||||||
local lake_positioons = {{x = lake_distance * -1, y = lake_distance * -1},{x = lake_distance, y = lake_distance * -1},{x = lake_distance, y = lake_distance},{x = lake_distance * -1, y = lake_distance}}
|
local lake_positions = {{x = lake_distance * -1, y = lake_distance * -1},{x = lake_distance, y = lake_distance * -1},{x = lake_distance, y = lake_distance},{x = lake_distance * -1, y = lake_distance}}
|
||||||
lake_positioons = shuffle(lake_positioons)
|
lake_positions = shuffle(lake_positions)
|
||||||
map_functions.draw_noise_tile_circle(lake_positioons[1], "water", surface, lake_size)
|
map_functions.draw_noise_tile_circle(lake_positions[1], "water", surface, lake_size)
|
||||||
|
map_functions.draw_oil_circle(lake_positions[2], "crude-oil", surface, 8, 200000)
|
||||||
|
|
||||||
turrets = shuffle(turrets)
|
turrets = shuffle(turrets)
|
||||||
local x = spawn_turret_amount
|
local x = spawn_turret_amount
|
||||||
@ -177,6 +215,12 @@ local function generate_spawn_area(surface)
|
|||||||
if x == 0 then break end
|
if x == 0 then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
global.rocket_silo = surface.create_entity({name = "rocket-silo", position = {0, 0}, force = "player"})
|
||||||
|
global.rocket_silo.minable = false
|
||||||
|
|
||||||
|
local radius = 256
|
||||||
|
game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_chunk_generated(event)
|
local function on_chunk_generated(event)
|
||||||
@ -194,6 +238,16 @@ local function on_chunk_generated(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_entity_damaged(event)
|
||||||
|
if not event.cause then return end
|
||||||
|
if event.entity.valid then
|
||||||
|
if event.entity == global.rocket_silo then
|
||||||
|
if event.cause.force.name == "enemy" then return end
|
||||||
|
event.entity.health = event.entity.health + event.final_damage_amount
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function on_tick(event)
|
local function on_tick(event)
|
||||||
if game.tick % 600 ~= 0 then return end
|
if game.tick % 600 ~= 0 then return end
|
||||||
local surface = game.surfaces["nightfall"]
|
local surface = game.surfaces["nightfall"]
|
||||||
@ -205,6 +259,26 @@ local function on_tick(event)
|
|||||||
else
|
else
|
||||||
set_daytime_modifiers(surface)
|
set_daytime_modifiers(surface)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if global.rocket_silo then
|
||||||
|
if global.rocket_silo.valid then return end
|
||||||
|
end
|
||||||
|
|
||||||
|
if game.tick < 3600 then return end
|
||||||
|
|
||||||
|
if not global.game_restart_timer then
|
||||||
|
global.game_restart_timer = 7200
|
||||||
|
else
|
||||||
|
if global.game_restart_timer < 0 then return end
|
||||||
|
global.game_restart_timer = global.game_restart_timer - 600
|
||||||
|
end
|
||||||
|
if global.game_restart_timer % 1800 == 0 then
|
||||||
|
if global.game_restart_timer > 0 then game.print("Map will restart in " .. global.game_restart_timer / 60 .. " seconds!", { r=0.22, g=0.88, b=0.22}) end
|
||||||
|
if global.game_restart_timer == 0 then
|
||||||
|
game.print("Map is restarting!", { r=0.22, g=0.88, b=0.22})
|
||||||
|
game.write_file("commandPipe", ":loadscenario --force", false, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
@ -214,7 +288,7 @@ local function on_player_joined_game(event)
|
|||||||
local map_gen_settings = {}
|
local map_gen_settings = {}
|
||||||
map_gen_settings.water = "small"
|
map_gen_settings.water = "small"
|
||||||
map_gen_settings.starting_area = "small"
|
map_gen_settings.starting_area = "small"
|
||||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 5, cliff_elevation_0 = 5}
|
map_gen_settings.cliff_settings = {cliff_elevation_interval = 35, cliff_elevation_0 = 35}
|
||||||
map_gen_settings.autoplace_controls = {
|
map_gen_settings.autoplace_controls = {
|
||||||
["coal"] = {frequency = "high", size = "very-big", richness = "normal"},
|
["coal"] = {frequency = "high", size = "very-big", richness = "normal"},
|
||||||
["stone"] = {frequency = "high", size = "very-big", richness = "normal"},
|
["stone"] = {frequency = "high", size = "very-big", richness = "normal"},
|
||||||
@ -234,12 +308,11 @@ local function on_player_joined_game(event)
|
|||||||
local radius = 512
|
local radius = 512
|
||||||
game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})
|
game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})
|
||||||
|
|
||||||
----game.map_settings.enemy_evolution.destroy_factor = 0
|
--game.map_settings.enemy_evolution.destroy_factor = 0
|
||||||
--game.map_settings.enemy_evolution.time_factor = 0
|
--game.map_settings.enemy_evolution.time_factor = 0
|
||||||
--game.map_settings.enemy_evolution.pollution_factor = 0
|
--game.map_settings.enemy_evolution.pollution_factor = 0
|
||||||
|
|
||||||
game.forces.player.set_ammo_damage_modifier("shotgun-shell", 1)
|
game.forces.player.set_ammo_damage_modifier("shotgun-shell", 1)
|
||||||
--game.forces.player.set_turret_attack_modifier("flamethrower-turret", -0.5)
|
|
||||||
|
|
||||||
global.fish_defense_init_done = true
|
global.fish_defense_init_done = true
|
||||||
end
|
end
|
||||||
@ -255,16 +328,17 @@ local function on_player_joined_game(event)
|
|||||||
|
|
||||||
local surface = game.surfaces["nightfall"]
|
local surface = game.surfaces["nightfall"]
|
||||||
if player.online_time < 2 and surface.is_chunk_generated({0,0}) then
|
if player.online_time < 2 and surface.is_chunk_generated({0,0}) then
|
||||||
player.teleport(surface.find_non_colliding_position("player", {0, 0}, 50, 1), "nightfall")
|
player.teleport(surface.find_non_colliding_position("player", {0, 8}, 50, 1), "nightfall")
|
||||||
else
|
else
|
||||||
if player.online_time < 2 then
|
if player.online_time < 2 then
|
||||||
player.teleport({0, 0}, "nightfall")
|
player.teleport({0, 8}, "nightfall")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create_time_gui(player)
|
create_time_gui(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||||
event.add(defines.events.on_tick, on_tick)
|
event.add(defines.events.on_tick, on_tick)
|
||||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
Loading…
x
Reference in New Issue
Block a user