1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00

biter_battles_v2 > updates

This commit is contained in:
MewMew 2019-03-14 04:25:54 +01:00
parent 62316d6aa3
commit 050caed605
6 changed files with 194 additions and 13 deletions

View File

@ -0,0 +1,32 @@
local event = require 'utils.event'
local function send_near_biter_to_silo()
if not global.rocket_silo then return end
game.surfaces["surface"].set_multi_command({
command={
type=defines.command.attack,
target=global.rocket_silo["north"],
distraction=defines.distraction.none
},
unit_count = 8,
force = "enemy",
unit_search_distance=64
})
game.surfaces["surface"].set_multi_command({
command={
type=defines.command.attack,
target=global.rocket_silo["south"],
distraction=defines.distraction.none
},
unit_count = 8,
force = "enemy",
unit_search_distance=64
})
end
local function on_tick(event)
end
event.add(defines.events.on_tick, on_tick)

View File

@ -1,20 +1,14 @@
-- Biter Battles v2 -- by MewMew
require "maps.biter_battles_v2.terrain"
require "maps.biter_battles_v2.mirror_terrain"
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2
local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local map_functions = require "tools.map_functions"
local function init_surface(event)
local function init_surface()
if game.surfaces["biter_battles"] then return end
local map_gen_settings = {}
map_gen_settings.water = "none"
map_gen_settings.starting_area = "5"
--map_gen_settings.water = "none"
--map_gen_settings.starting_area = "5"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 12, cliff_elevation_0 = 32}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "0.8", size = "1", richness = "0.3"},
@ -25,15 +19,77 @@ local function init_surface(event)
["trees"] = {frequency = "0.8", size = "0.5", richness = "0.3"},
["enemy-base"] = {frequency = "0.8", size = "1", richness = "0.4"}
}
--game.create_surface("biter_battles", map_gen_settings)
game.create_surface("biter_battles", map_gen_settings)
game.map_settings.enemy_evolution.time_factor = 0
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_expansion.enabled = false
game.map_settings.pollution.enabled = false
end
local function init_forces(surface)
if game.forces.north then return end
game.create_force("north")
game.create_force("south")
game.create_force("spectator")
local f = game.forces["north"]
f.set_spawn_position({0, -32}, surface)
f.set_cease_fire("player", true)
f.set_friend("spectator", true)
f.share_chart = true
local f = game.forces["south"]
f.set_spawn_position({0, 32}, surface)
f.set_cease_fire("player", true)
f.set_friend("spectator", true)
f.share_chart = true
local f = game.forces["spectator"]
f.technologies["toolbelt"].researched=true
f.set_spawn_position({0,0},surface)
f.set_friend("north", true)
f.set_friend("south", true)
f.set_friend("player", true)
local f = game.forces["player"]
f.set_spawn_position({0,0},surface)
for _, force in pairs(game.forces) do
game.forces[force.name].technologies["artillery"].enabled = false
game.forces[force.name].technologies["artillery-shell-range-1"].enabled = false
game.forces[force.name].technologies["artillery-shell-speed-1"].enabled = false
game.forces[force.name].technologies["atomic-bomb"].enabled = false
game.forces[force.name].set_ammo_damage_modifier("shotgun-shell", 1)
end
end
local function on_player_joined_game(event)
--init_surface(event)
local player = game.players[event.player_index]
player.character.destructible = false
init_surface()
local surface = game.surfaces["biter_battles"]
init_forces(surface)
local player = game.players[event.player_index]
--player.character.destroy()
if player.online_time == 0 then
if surface.is_chunk_generated({0,0}) then
player.teleport(surface.find_non_colliding_position("player", {0,0}, 3, 0.5), surface)
else
player.teleport({0,0}, surface)
end
player.character.destructible = false
end
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
require "maps.biter_battles_v2.terrain"
require "maps.biter_battles_v2.mirror_terrain"
require "maps.biter_battles_v2.gui"
require "maps.biter_battles_v2.chat"
require "maps.biter_battles_v2.ai"
require "maps.biter_battles_v2.game_won"

View File

@ -0,0 +1,36 @@
local event = require 'utils.event'
----------share chat with player and spectator force-------------------
local function on_console_chat(event)
if not event.message then return end
if not event.player_index then return end
local player = game.players[event.player_index]
local color = {}
color = player.color
color.r = color.r * 0.6 + 0.35
color.g = color.g * 0.6 + 0.35
color.b = color.b * 0.6 + 0.35
color.a = 1
if player.force.name == "north" then
game.forces.spectator.print(player.name .. " (north): ".. event.message, color)
game.forces.player.print(player.name .. " (north): ".. event.message, color)
end
if player.force.name == "south" then
game.forces.spectator.print(player.name .. " (south): ".. event.message, color)
game.forces.player.print(player.name .. " (south): ".. event.message, color)
end
if player.force.name == "player" then
game.forces.north.print(player.name .. " (spawn): ".. event.message, color)
game.forces.south.print(player.name .. " (spawn): ".. event.message, color)
game.forces.spectator.print(player.name .. " (spawn): ".. event.message, color)
end
if player.force.name == "spectator" then
game.forces.north.print(player.name .. " (spectator): ".. event.message, color)
game.forces.south.print(player.name .. " (spectator): ".. event.message, color)
game.forces.player.print(player.name .. " (spectator): ".. event.message, color)
end
end
event.add(defines.events.on_console_chat, on_console_chat)

View File

@ -0,0 +1,49 @@
local event = require 'utils.event'
local particles = {"coal-particle", "copper-ore-particle", "iron-ore-particle", "stone-particle"}
local function create_fireworks_rocket(surface, position)
local particle = particles[math_random(1, #particles)]
local m = math_random(16, 36)
local m2 = m * 0.005
for i = 1, 80, 1 do
surface.create_entity({
name = particle,
position = position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (math_random(0, m) * 0.01), m2 - (math_random(0, m) * 0.01)}
})
end
if math_random(1,16) ~= 1 then return end
surface.create_entity({name = "explosion", position = position})
end
local function fireworks(surface)
local radius = 96
for t = 1, 18000, 1 do
if not global.on_tick_schedule[game.tick + t] then global.on_tick_schedule[game.tick + t] = {} end
for x = 1, 3, 1 do
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
func = create_fireworks_rocket,
args = {surface, {x = radius - math_random(0, radius * 2),y = radius - math_random(0, radius * 2)}}
}
end
t = t + 1
end
end
local function on_entity_died(event)
if not event.entity.valid then return end
if event.entity.name ~= "rocket-silo" then return end
if event.entity == global.rocket_silo.south or event.entity == global.rocket_silo.north then
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/game_won", volume_modifier=1}
end
fireworks(surface)
end
end
event.add(defines.events.on_entity_died, on_entity_died)

View File

@ -0,0 +1,7 @@
local event = require 'utils.event'
local function on_gui_click(event)
end
event.add(defines.events.on_gui_click, on_gui_click)

View File

@ -91,6 +91,7 @@ end
local function on_chunk_generated(event)
if event.area.left_top.y >= 0 then return end
local surface = event.surface
if surface.name ~= "biter_battles" then return end
for _, e in pairs(surface.find_entities_filtered({area = event.area, force = "enemy"})) do
e.destroy()