1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-11 13:39:14 +02:00

Merge pull request #4 from M3wM3w/master

update
This commit is contained in:
hanakocz 2020-02-27 16:25:59 +01:00 committed by GitHub
commit e482a4cf55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 10 deletions

View File

@ -501,7 +501,7 @@ local function redraw_create_poll_content(data)
delete_flow.add {
type = 'sprite-button',
name = create_poll_delete_answer_name,
sprite = 'utility/remove',
sprite = 'virtual-signal/signal-X',
tooltip = 'Delete answer field.'
}
delete_button.style.height = 26

View File

@ -169,9 +169,9 @@ end
local function spawn_wave_from_belt(force_name)
for _, science_name in pairs(Settings.science_pack_name) do
local nb_science = global.map_forces[force_name].ate_buffer_potion[science_name]
if nb_science >= Gui.wave_price[science_name].price then
Team.on_buy_wave("native_war", force_name, Gui.science_pack[science_name].short)
global.map_forces[force_name].ate_buffer_potion[science_name] = global.map_forces[force_name].ate_buffer_potion[science_name] - Gui.wave_price[science_name].price
if nb_science >= Settings.wave_price[science_name].price then
Team.on_buy_wave("native_war", force_name, Settings.science_pack[science_name].short)
global.map_forces[force_name].ate_buffer_potion[science_name] = global.map_forces[force_name].ate_buffer_potion[science_name] - Settings.wave_price[science_name].price
--if global.map_forces[belt.force.name].ate_buffer_potion[science_name] < 0 then global.map_forces[belt.force.name].ate_buffer_potion[science_name] =0 end
end
end
@ -325,6 +325,8 @@ local function on_built_entity(event)
global.map_forces[player.force.name].radar[unit_number] = entity
end
end
-- on robot build radar is elsewhere EVL
local function on_player_mined_entity(event)
local player = game.players[event.player_index]
@ -347,7 +349,7 @@ local function on_player_joined_game(event)
player.spectator = true
player.force = game.forces.spectator
if surface.is_chunk_generated({0,-190}) then
player.teleport(surface.find_non_colliding_position("character", {0,-190}, 3, 0.5), surface)
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
else
player.teleport({0,-190}, surface)
end

View File

@ -1,3 +1,5 @@
local Basic_markets = require "functions.basic_markets"
local Biter_pets = require "modules.biter_pets"
local get_noise = require 'maps.stone_maze.noise'
local room = {}
@ -197,7 +199,7 @@ room.three_rocks = function(surface, cell_left_top, direction)
if math.random(1,2) == 1 then
local position = surface.find_non_colliding_position("market", {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, grid_size * 0.5, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
if position then Basic_markets.super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
end
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.2, left_top.y + grid_size * 0.8}, force = "neutral"})
@ -211,7 +213,7 @@ room.quad_rocks = function(surface, cell_left_top, direction)
if math.random(1,2) == 1 then
local position = surface.find_non_colliding_position("market", {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, grid_size * 0.5, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
if position then Basic_markets.super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
end
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.15, left_top.y + grid_size * 0.15}, force = "neutral"})
@ -305,6 +307,24 @@ room.maze = function(surface, cell_left_top, direction)
surface.spill_item_stack({x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, get_loot_item_stack(), true, nil, true)
end
room.mr_nibbles = function(surface, cell_left_top, direction)
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
local nibbler
local str = "biter"
if math.random(1, 2) == 1 then
str = "spitter"
end
if global.maze_depth > 250 then
nibbler = surface.create_entity({name = "behemoth-" .. str, position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, force = "enemy"})
else
nibbler = surface.create_entity({name = "big-" .. str, position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, force = "enemy"})
end
Biter_pets.tame_unit_for_closest_player(nibbler)
end
local room_weights = {
{func = room.worms, weight = 12},
{func = room.nests, weight = 8},
@ -313,7 +333,9 @@ local room_weights = {
{func = room.tons_of_rocks, weight = 35},
{func = room.quad_rocks, weight = 7},
{func = room.three_rocks, weight = 3},
{func = room.three_rocks, weight = 4},
{func = room.mr_nibbles, weight = 3},
{func = room.single_rock, weight = 8},
{func = room.checkerboard_ore, weight = 7},

View File

@ -1,3 +1,4 @@
local Basic_markets = require "functions.basic_markets"
local get_noise = require 'maps.stone_maze.noise'
local room = {}
@ -207,7 +208,7 @@ room.circle_pond_with_trees = function(surface, cell_left_top, direction)
map_functions.draw_noise_tile_circle({x = left_top.x + grid_size, y = left_top.y + grid_size}, "water", surface, grid_size * 0.5)
local position = surface.find_non_colliding_position("market", center_pos, grid_size, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
if position then Basic_markets.super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
for x = math.floor(grid_size * 2 * 0.1), math.floor(grid_size * 2 * 0.9), 1 do
for y = math.floor(grid_size * 2 * 0.1), math.floor(grid_size * 2 * 0.9), 1 do

View File

@ -9,7 +9,6 @@ require "modules.no_turrets"
--essentials
require "functions.maze"
require "functions.basic_markets"
require "modules.biters_yield_coins"
require "modules.rocks_yield_ore"
require "modules.mineable_wreckage_yields_scrap"

View File

@ -50,6 +50,13 @@ local function feed_pet(unit)
return true
end
local function is_valid_player(player, unit)
if not player.character then return end
if not player.character.valid then return end
if player.surface.index ~= unit.surface.index then return end
return true
end
function Public.biter_pets_tame_unit(player, unit, forced)
if global.biter_pets[player.index] then return false end
if not forced then
@ -68,6 +75,25 @@ function Public.biter_pets_tame_unit(player, unit, forced)
return true
end
function Public.tame_unit_for_closest_player(unit)
local valid_players = {}
for _, player in pairs(game.connected_players) do
if is_valid_player(player, unit) then table.insert(valid_players, player) end
end
local nearest_player = valid_players[1]
if not nearest_player then return end
for i = 2, #valid_players, 1 do
local player = valid_players[i + 1]
if player.position.x ^ 2 + player.position.y ^ 2 < nearest_player.position.x ^ 2 + nearest_player.position.y ^ 2 then
nearest_player = spawner
end
end
Public.biter_pets_tame_unit(nearest_player, unit, true)
end
local function command_unit(entity, player)
if (player.position.x - entity.position.x) ^ 2 + (player.position.y - entity.position.y) ^ 2 < 256 then
entity.set_command({type = defines.command.wander, distraction = defines.distraction.by_enemy})

View File

@ -41,6 +41,7 @@ local discord_embed_raw_tag = '[DISCORD-EMBED-RAW]'
local discord_admin_embed_tag = '[DISCORD-ADMIN-EMBED]'
local discord_admin_embed_raw_tag = '[DISCORD-ADMIN-EMBED-RAW]'
local start_scenario_tag = '[START-SCENARIO]'
local stop_scenario_tag = '[STOP-SCENARIO]'
local ping_tag = '[PING]'
local data_set_tag = '[DATA-SET]'
local data_get_tag = '[DATA-GET]'
@ -155,6 +156,16 @@ function Public.start_scenario(scenario_name)
raw_print(message)
end
--- Stops and saves the factorio server.
-- @usage
-- local Server = require 'utils.server'
-- Server.stop_scenario()
function Public.stop_scenario()
local message = stop_scenario_tag
raw_print(message)
end
local default_ping_token =
Token.register(
function(sent_tick)