1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/maps/space_race/scenario.lua

627 lines
24 KiB
Lua
Raw Normal View History

local Event = require 'utils.event'
local RS = require 'map_gen.shared.redmew_surface'
local Command = require 'utils.command'
local Color = require 'resources.color_presets'
2019-10-09 02:02:48 +02:00
local Global = require 'utils.global'
local Retailer = require 'features.retailer'
local Market_Items = require 'map_gen.maps.space_race.market_items'
local Token = require 'utils.token'
local Task = require 'utils.task'
2019-10-12 13:29:11 +02:00
local config = require 'map_gen.maps.space_race.config'
local Table = require 'utils.table'
2019-10-09 21:36:11 +02:00
local floor = math.floor
require 'map_gen.maps.space_race.map_info'
2019-10-09 21:36:11 +02:00
require 'map_gen.maps.space_race.market_handler'
2019-10-11 20:24:28 +02:00
local Lobby = require 'map_gen.maps.space_race.lobby'
local cliff = require 'map_gen.maps.space_race.cliff_generator'
2019-10-12 13:29:11 +02:00
-- GUIs
local load_gui = require 'map_gen.maps.space_race.gui.load_gui'
2019-10-11 20:24:28 +02:00
local Public = {}
2019-10-12 13:29:11 +02:00
local redmew_config = global.config
2019-10-12 13:29:11 +02:00
redmew_config.market.enabled = false
redmew_config.score.enabled = false
redmew_config.player_rewards.enabled = false
redmew_config.apocalypse.enabled = false
redmew_config.turret_active_delay.turret_types = {
['ammo-turret'] = 60 * 10,
['electric-turret'] = 60 * 20,
['fluid-turret'] = 60 * 15,
2019-10-09 02:02:48 +02:00
['artillery-turret'] = 60 * 60
}
2019-10-12 13:29:11 +02:00
redmew_config.turret_active_delay.techs = {}
redmew_config.player_create.show_info_at_start = false
redmew_config.camera.enabled = false
2019-10-12 13:29:11 +02:00
local players_needed = config.players_needed_to_start_game
local player_kill_reward = config.player_kill_reward
local startup_timer = config.bootstrap_period
local player_ports = {
2019-10-11 20:24:28 +02:00
USA = {{x = -409, y = 0}, {x = -380, y = 0}},
USSR = {{x = 409, y = 0}, {x = 380, y = 0}}
}
2019-10-12 13:29:11 +02:00
local disabled_research = config.disabled_research
2019-10-09 02:02:48 +02:00
local researched_tech = {}
2019-10-12 13:29:11 +02:00
local disabled_recipes = config.disabled_recipes
2019-10-09 02:02:48 +02:00
local primitives = {
game_started = false,
2019-10-11 20:24:28 +02:00
game_generating = false,
2019-10-27 00:45:28 +02:00
started_tick = nil,
2019-10-09 02:02:48 +02:00
force_USA = nil,
force_USSR = nil,
2019-10-11 20:24:28 +02:00
lobby_permissions = nil,
won = nil
2019-10-09 02:02:48 +02:00
}
Global.register(
{
2019-10-14 17:18:06 +02:00
primitives = primitives
2019-10-09 02:02:48 +02:00
},
function(tbl)
primitives = tbl.primitives
end
)
2019-10-12 13:29:11 +02:00
function Public.remove_recipes()
2019-10-09 02:02:48 +02:00
local USA_recipe = primitives.force_USA.recipes
local USSR_recipe = primitives.force_USSR.recipes
for _, recipe in pairs(disabled_recipes) do
USA_recipe[recipe].enabled = false
USSR_recipe[recipe].enabled = false
end
end
local remove_permission_group =
Token.register(
function(params)
params.permission_group.remove_player(params.player)
end
)
Event.on_init(
function()
2019-10-09 02:02:48 +02:00
game.difficulty_settings.technology_price_multiplier = 0.5
local force_USA = game.create_force('United Factory Workers')
local force_USSR = game.create_force('Union of Factory Employees')
local surface = RS.get_surface()
surface.min_brightness = 0;
2019-10-11 20:24:28 +02:00
force_USSR.set_spawn_position({x = 409, y = 0}, surface)
force_USA.set_spawn_position({x = -409, y = 0}, surface)
2019-10-09 02:02:48 +02:00
force_USSR.laboratory_speed_modifier = 1
force_USA.laboratory_speed_modifier = 1
2019-10-12 13:29:11 +02:00
force_USSR.research_queue_enabled = true
force_USA.research_queue_enabled = true
2019-10-09 02:02:48 +02:00
local lobby_permissions = game.permissions.create_group('lobby')
lobby_permissions.set_allows_action(defines.input_action.start_walking, false)
2019-10-12 13:29:11 +02:00
force_USSR.chart(RS.get_surface(), {{x = 380, y = 64}, {x = 420, y = -64}})
force_USA.chart(RS.get_surface(), {{x = -380, y = 64}, {x = -420, y = -64}})
--game.forces.player.chart(RS.get_surface(), {{x = 400, y = 65}, {x = -400, y = -33}})
2019-10-09 02:02:48 +02:00
local market
market = surface.create_entity {name = 'market', position = {x = 404, y = 0}, force = force_USSR}
market.destructible = false
Retailer.add_market('USSR_market', market)
2019-10-09 02:02:48 +02:00
market = surface.create_entity {name = 'market', position = {x = -404, y = 0}, force = force_USA}
market.destructible = false
Retailer.add_market('USA_market', market)
if table.size(Retailer.get_items('USSR_market')) == 0 then
2019-10-12 13:29:11 +02:00
local items = Table.deep_copy(Market_Items)
2019-10-09 21:36:11 +02:00
for _, prototype in pairs(items) do
local name = prototype.name
prototype.price = (disabled_research[name] and disabled_research[name].player) and disabled_research[name].player * player_kill_reward or prototype.price
local unlock_requires = disabled_research[name]
if prototype.disabled and unlock_requires then
if unlock_requires.invert then
prototype.disabled_reason = {'', 'Unlocks when ' .. unlock_requires.player .. ' players have been killed or\n' .. unlock_requires.entity .. ' entities have been destroyed'}
else
prototype.disabled_reason = {'', 'To unlock kill ' .. unlock_requires.player .. ' players or\ndestroy ' .. unlock_requires.entity .. ' entities'}
end
end
2019-10-09 02:02:48 +02:00
Retailer.set_item('USSR_market', prototype)
end
end
if table.size(Retailer.get_items('USA_market')) == 0 then
2019-10-12 13:29:11 +02:00
local items = Table.deep_copy(Market_Items)
2019-10-09 21:36:11 +02:00
for _, prototype in pairs(items) do
local name = prototype.name
prototype.price = (disabled_research[name] and disabled_research[name].player) and disabled_research[name].player * player_kill_reward or prototype.price
2019-10-09 21:36:11 +02:00
local unlock_requires = disabled_research[name]
if prototype.disabled and unlock_requires then
if unlock_requires.invert then
prototype.disabled_reason = {'', 'Unlocks when ' .. unlock_requires.player .. ' players have been killed or\n ' .. unlock_requires.entity .. ' entities have been destroyed'}
else
prototype.disabled_reason = {'', 'To unlock kill ' .. unlock_requires.player .. ' players or\n destroy ' .. unlock_requires.entity .. ' entities'}
end
end
2019-10-09 02:02:48 +02:00
Retailer.set_item('USA_market', prototype)
end
end
--ensures that the spawn points are not water
surface.set_tiles(
{
2019-10-11 20:24:28 +02:00
{name = 'stone-path', position = {x = 409.5, y = 0.5}},
{name = 'stone-path', position = {x = 409.5, y = -0.5}},
{name = 'stone-path', position = {x = 408.5, y = -0.5}},
{name = 'stone-path', position = {x = 408.5, y = 0.5}},
{name = 'stone-path', position = {x = -409.5, y = 0.5}},
{name = 'stone-path', position = {x = -409.5, y = -0.5}},
{name = 'stone-path', position = {x = -408.5, y = -0.5}},
{name = 'stone-path', position = {x = -408.5, y = 0.5}}
2019-10-09 02:02:48 +02:00
}
)
for force_side, ports in pairs(player_ports) do
local force
if force_side == 'USA' then
force = force_USA
elseif force_side == 'USSR' then
force = force_USSR
end
for _, port in pairs(ports) do
2019-10-27 15:46:57 +02:00
rendering.draw_text {text = {'', 'Use the /warp command to teleport across'}, surface = surface, target = port, color = Color.red, forces = {force}, alignment = 'center', scale = 0.75}
end
end
2019-10-09 02:02:48 +02:00
local USA_tech = force_USA.technologies
local USSR_tech = force_USSR.technologies
for research, _ in pairs(disabled_research) do
USA_tech[research].enabled = false
USSR_tech[research].enabled = false
end
for research, _ in pairs(researched_tech) do
USA_tech[research].researched = true
USSR_tech[research].researched = true
end
primitives.force_USA = force_USA
primitives.force_USSR = force_USSR
primitives.lobby_permissions = lobby_permissions
2019-10-12 13:29:11 +02:00
Public.remove_recipes()
end
)
2019-10-09 02:02:48 +02:00
local function restore_character(player)
if primitives.game_started then
2019-10-27 15:46:57 +02:00
local character = player.character
if character then
character.destroy()
end
2019-10-09 02:02:48 +02:00
player.set_controller {type = defines.controllers.god}
player.create_character()
Task.set_timeout_in_ticks(1, remove_permission_group, {permission_group = primitives.lobby_permissions, player = player})
game.permissions.get_group('Default').add_player(player)
2019-10-12 14:09:24 +02:00
for _, item in pairs(redmew_config.player_create.starting_items) do
2019-10-09 02:02:48 +02:00
player.insert(item)
end
end
end
2019-10-14 17:18:06 +02:00
local tiles = {}
local out_of_map_x = 388
local out_of_map_height = 512
local ignored_height = 18
local insert = table.insert
for i = -out_of_map_height / 2, out_of_map_height / 2, 1 do
if i < -ignored_height / 2 or i > ignored_height / 2 then
insert(tiles, {name = 'out-of-map', position = {x = out_of_map_x + 1, y = i}})
insert(tiles, {name = 'out-of-map', position = {x = -(out_of_map_x + 1), y = i}})
insert(tiles, {name = 'out-of-map', position = {x = out_of_map_x - 1, y = i}})
insert(tiles, {name = 'out-of-map', position = {x = -(out_of_map_x - 1), y = i}})
insert(tiles, {name = 'out-of-map', position = {x = out_of_map_x, y = i}})
insert(tiles, {name = 'out-of-map', position = {x = -(out_of_map_x), y = i}})
end
end
local function generate_structures()
local surface = RS.get_surface()
local force_USSR = primitives.force_USSR
local force_USA = primitives.force_USA
local silo
silo = surface.create_entity {name = 'rocket-silo', position = {x = 388.5, y = -0.5}, force = force_USSR}
silo.minable = false
silo = surface.create_entity {name = 'rocket-silo', position = {x = -388.5, y = 0.5}, force = force_USA}
silo.minable = false
local wall
wall = surface.create_entity {name = 'stone-wall', position = {x = 384.5, y = 18.5}, always_place = true, force = 'neutral'}
wall.destructible = false
wall.minable = false
wall = surface.create_entity {name = 'stone-wall', position = {x = 384.5, y = -17.5}, always_place = true, force = 'neutral'}
wall.destructible = false
wall.minable = false
wall = surface.create_entity {name = 'stone-wall', position = {x = -384.5, y = 18.5}, always_place = true, force = 'neutral'}
wall.destructible = false
wall.minable = false
wall = surface.create_entity {name = 'stone-wall', position = {x = -384.5, y = -17.5}, always_place = true, force = 'neutral'}
wall.destructible = false
wall.minable = false
local gun_turret
gun_turret = surface.create_entity {name = 'gun-turret', position = {x = 383, y = 0}, force = force_USSR}
gun_turret.insert({name = 'firearm-magazine', count = 200})
gun_turret = surface.create_entity {name = 'gun-turret', position = {x = -383, y = 0}, force = force_USA}
gun_turret.insert({name = 'firearm-magazine', count = 200})
end
2019-10-09 02:02:48 +02:00
local function start_game()
primitives.game_started = true
2019-10-11 20:24:28 +02:00
primitives.started_tick = game.tick
game.forces.enemy.evolution_factor = 0
2019-10-09 02:02:48 +02:00
for _, player in pairs(primitives.force_USA.players) do
restore_character(player)
end
for _, player in pairs(primitives.force_USSR.players) do
restore_character(player)
end
2019-10-14 17:18:06 +02:00
local surface = RS.get_surface()
cliff.generate_cliffs(surface)
surface.set_tiles(tiles)
generate_structures()
2019-10-09 02:02:48 +02:00
end
local function victory(force)
2019-10-11 20:24:28 +02:00
primitives.won = force
game.print('Congratulations to ' .. force.name .. '. You have gained factory dominance!')
2019-10-11 20:24:28 +02:00
Lobby.all_to_lobby()
end
2019-10-12 13:29:11 +02:00
function Public.lost(force)
2019-10-09 02:02:48 +02:00
local force_USA = primitives.force_USA
if force == force_USA then
2019-10-09 02:02:48 +02:00
victory(primitives.force_USSR)
else
victory(force_USA)
end
end
local function on_rocket_launched(event)
victory(event.entity.force)
end
Event.add(defines.events.on_rocket_launched, on_rocket_launched)
2019-10-09 02:02:48 +02:00
local function on_built_entity(event)
local entity = event.created_entity
if not entity or not entity.valid then
return
end
local name = entity.name
2019-10-12 13:29:11 +02:00
if config.neutral_entities[name] then
entity.force = 'neutral'
return
end
if config.warning_on_built[name] then
2019-10-09 02:02:48 +02:00
local position = entity.position
2019-10-09 21:36:11 +02:00
game.print({'', '[gps=' .. floor(position.x) .. ', ' .. floor(position.y) .. '] [color=yellow]Warning! ', {'entity-name.' .. name}, ' has been deployed![/color]'})
2019-10-09 02:02:48 +02:00
end
end
Event.add(defines.events.on_built_entity, on_built_entity)
local function allow_teleport(force, position)
2019-10-09 02:02:48 +02:00
if force == primitives.force_USA and position.x > 0 then
return false
2019-10-09 02:02:48 +02:00
elseif force == primitives.force_USSR and position.x < 0 then
return false
end
2019-10-12 13:29:11 +02:00
return math.abs(position.x) > 377 and math.abs(position.x) < 410 and position.y > -10 and position.y < 10
end
local function get_teleport_location(force, to_safe_zone)
local port_number = to_safe_zone and 1 or 2
local position
2019-10-09 02:02:48 +02:00
if force == primitives.force_USA then
position = player_ports.USA[port_number]
2019-10-09 02:02:48 +02:00
elseif force == primitives.force_USSR then
position = player_ports.USSR[port_number]
else
position = {0, 0}
end
2019-10-09 02:02:48 +02:00
local non_colliding_pos = RS.get_surface().find_non_colliding_position('character', position, 6, 1)
position = non_colliding_pos and non_colliding_pos or position
return position
end
local function check_damaged_players()
for k, player in pairs (game.connected_players) do
if player.character and player.character.health ~= nil then
local health_missing = 1 - math.ceil(player.character.health) / (250 + player.character.character_health_bonus)
if health_missing > 0 then
local current_modifier = 0
local hurt_speed_percent = 80
local reduction = 1 - hurt_speed_percent / 100
player.character_running_speed_modifier = (1 - health_missing * reduction) * (current_modifier + 1) - 1
end
end
end
end
2019-11-16 20:37:50 +02:00
Event.on_nth_tick(20, check_damaged_players)
local function teleport(_, player)
2019-10-09 02:02:48 +02:00
local character = player.character
if not character or not character.valid then
player.print('[color=yellow]Could not warp, you are not part of a team yet![/color]')
return
end
2019-10-11 20:24:28 +02:00
local tick = game.tick - primitives.started_tick
2019-10-09 02:02:48 +02:00
if tick < startup_timer then
local time_left = startup_timer - tick
if time_left > 60 then
local minutes = (time_left / 3600)
minutes = minutes - minutes % 1
time_left = time_left - (minutes * 3600)
local seconds = (time_left / 60)
seconds = seconds - seconds % 1
time_left = minutes .. ' minutes and ' .. seconds .. ' seconds left'
else
2019-10-11 20:24:28 +02:00
local seconds = (time_left - (time_left % 60)) / 60
2019-10-09 02:02:48 +02:00
time_left = seconds .. ' seconds left'
end
player.print('[color=yellow]Could not warp, in setup phase![/color] [color=red]' .. time_left .. '[/color]')
2019-10-09 02:02:48 +02:00
return
end
local position = character.position
local force = player.force
if allow_teleport(force, position) then
if math.abs(position.x) < 388.5 then
player.teleport(get_teleport_location(force, true))
else
player.teleport(get_teleport_location(force, false))
end
else
player.print('[color=yellow]Could not warp, you are too far from rocket silo![/color]')
end
end
Command.add('warp', {description = 'Use to switch between PVP and Safe-zone in Space Race', capture_excess_arguments = false, allowed_by_server = false}, teleport)
2019-10-11 20:24:28 +02:00
local check_map_gen_is_done
2019-10-27 15:46:57 +02:00
local start_game_delayed =
Token.register(
function()
if primitives.started_tick == -1 then
primitives.started_tick = 0
load_gui.remove_gui()
Event.remove_removable_nth_tick(60, check_map_gen_is_done)
start_game()
end
end
)
2019-10-11 20:24:28 +02:00
check_map_gen_is_done =
Token.register(
function()
local num_usa_players = #primitives.force_USA.connected_players
local num_ussr_players = #primitives.force_USSR.connected_players
local num_players = num_usa_players + num_ussr_players
if not primitives.game_started and num_players >= players_needed then
local surface = RS.get_surface()
2019-10-27 15:46:57 +02:00
if
primitives.started_tick ~= -1 and surface.get_tile({388.5, 0}).name == 'landfill' and surface.get_tile({-388.5, 0}).name == 'landfill' and surface.get_tile({388.5, 60}).name == 'out-of-map' and surface.get_tile({-388.5, 60}).name == 'out-of-map' and
surface.get_tile({-479.5, 0}).name == 'water' and
surface.get_tile({479.5, 0}).name == 'water'
then
primitives.started_tick = -1
game.print('[color=yellow]Game starts in 10 seconds![/color]')
Task.set_timeout_in_ticks(599, start_game_delayed, {})
2019-10-11 20:24:28 +02:00
end
2019-10-12 13:29:11 +02:00
load_gui.show_gui_to_all()
2019-10-11 20:24:28 +02:00
else
2019-10-27 00:45:28 +02:00
primitives.started_tick = nil
2019-10-12 13:29:11 +02:00
load_gui.remove_gui()
2019-10-11 20:24:28 +02:00
Event.remove_removable_nth_tick(60, check_map_gen_is_done)
end
end
)
2019-10-09 02:02:48 +02:00
local function check_ready_to_start()
2019-10-12 13:29:11 +02:00
if primitives.game_started then
2019-10-11 21:07:16 +02:00
return
end
2019-10-11 20:24:28 +02:00
local num_usa_players = #primitives.force_USA.connected_players
local num_ussr_players = #primitives.force_USSR.connected_players
2019-10-09 02:02:48 +02:00
local num_players = num_usa_players + num_ussr_players
if not primitives.game_started and num_players >= players_needed then
2019-10-27 00:45:28 +02:00
if primitives.started_tick == nil then
2019-10-11 20:24:28 +02:00
primitives.started_tick = game.tick
Event.add_removable_nth_tick(60, check_map_gen_is_done)
end
2019-10-09 02:02:48 +02:00
else
2019-10-14 17:18:06 +02:00
local message = primitives.force_USA.name .. ' has ' .. num_usa_players .. ' players\n ' .. primitives.force_USSR.name .. ' has ' .. num_ussr_players .. ' players\n\n' .. players_needed - num_players .. ' more players needed to start!'
2019-10-12 16:57:31 +02:00
load_gui.show_gui_to_all(message)
2019-10-09 02:02:48 +02:00
end
end
local function check_player_balance(force)
local force_USSR = primitives.force_USSR
local force_USA = primitives.force_USA
2019-10-27 15:46:57 +02:00
--local usa_players = #force_USA.players
--local ussr_players = #force_USSR.players
2019-10-11 20:24:28 +02:00
local usa_connected = #force_USA.connected_players
local ussr_connected = #force_USSR.connected_players
2019-10-09 02:02:48 +02:00
if force == force_USSR then
2019-10-27 15:46:57 +02:00
--return ussr_players - 2 <= usa_players and ussr_connected <= usa_connected
return usa_connected - ussr_connected
2019-10-09 02:02:48 +02:00
elseif force == force_USA then
2019-10-27 15:46:57 +02:00
-- return ussr_players >= usa_players - 2 and ussr_connected >= usa_connected
return ussr_connected - usa_connected
2019-10-09 02:02:48 +02:00
end
end
2019-10-11 20:24:28 +02:00
function Public.join_usa(_, player)
2019-10-09 02:02:48 +02:00
local force_USA = primitives.force_USA
local force_USSR = primitives.force_USSR
local force = player.force
2019-10-27 15:46:57 +02:00
local balance = check_player_balance(force_USA)
local allow_switching_team = balance >= 2
if balance < 0 then
2019-10-09 02:02:48 +02:00
player.print('[color=red]Failed to join [/color][color=yellow]United Factory Workers,[/color][color=red] teams would become unbalanced![/color]')
2019-10-11 20:24:28 +02:00
return false
2019-10-09 02:02:48 +02:00
end
2019-10-27 15:46:57 +02:00
if not primitives.game_started or (force ~= force_USSR and force ~= force_USA) or allow_switching_team then
if force == force_USA then
player.print('[color=red]Failed to join [/color][color=yellow]United Factory Workers,[/color][color=red] you are already part of this team![/color]')
return false
end
2019-11-03 16:14:21 +02:00
if allow_switching_team and player.character then
2019-10-27 15:46:57 +02:00
local empty_inventory =
player.get_inventory(defines.inventory.character_main).is_empty() and
player.get_inventory(defines.inventory.character_trash).is_empty() and
player.get_inventory(defines.inventory.character_ammo).is_empty() and
player.get_inventory(defines.inventory.character_armor).is_empty() and
player.get_inventory(defines.inventory.character_guns).is_empty() and
player.crafting_queue_size == 0
if not empty_inventory then
player.print('[color=red]Failed to join [/color][color=yellow]United Factory Workers,[/color][color=red] you need an empty inventory![/color]')
return false
end
end
player.force = force_USA
2019-10-09 02:02:48 +02:00
player.print('[color=green]You have joined United Factory Workers![/color]')
restore_character(player)
2019-10-11 20:24:28 +02:00
player.teleport(get_teleport_location(force_USA, true), RS.get_surface())
2019-10-09 02:02:48 +02:00
check_ready_to_start()
2019-10-27 15:46:57 +02:00
remote.call('space-race-lobby', 'update_gui')
2019-10-11 20:24:28 +02:00
return true
end
player.print('Failed to join new team, do not be a spy!')
end
2019-10-11 20:24:28 +02:00
Command.add('join-UFW', {description = 'Use to join United Factory Workers in Space Race', capture_excess_arguments = false, allowed_by_server = false}, Public.join_usa)
2019-10-11 20:24:28 +02:00
function Public.join_ussr(_, player)
2019-10-09 02:02:48 +02:00
local force_USA = primitives.force_USA
local force_USSR = primitives.force_USSR
local force = player.force
2019-10-27 15:46:57 +02:00
local balance = check_player_balance(force_USSR)
local allow_switching_team = balance >= 2
if balance < 0 then
2019-10-09 02:02:48 +02:00
player.print('[color=red]Failed to join [/color][color=yellow]Union of Factory Employees[/color][color=red], teams would become unbalanced![/color]')
2019-10-11 20:24:28 +02:00
return false
2019-10-09 02:02:48 +02:00
end
2019-10-27 15:46:57 +02:00
if not primitives.game_started or (force ~= force_USSR and force ~= force_USA) or allow_switching_team then
if force == force_USSR then
player.print('[color=red]Failed to join [/color][color=yellow]United Factory Workers,[/color][color=red] you are already part of this team![/color]')
return false
end
if allow_switching_team and player.character then
2019-10-27 15:46:57 +02:00
local empty_inventory =
player.get_inventory(defines.inventory.character_main).is_empty() and
player.get_inventory(defines.inventory.character_trash).is_empty() and
player.get_inventory(defines.inventory.character_ammo).is_empty() and
player.get_inventory(defines.inventory.character_armor).is_empty() and
player.get_inventory(defines.inventory.character_guns).is_empty() and
player.crafting_queue_size == 0
if not empty_inventory then
player.print('[color=red]Failed to join [/color][color=yellow]United Factory Workers,[/color][color=red] you need an empty inventory![/color]')
return false
end
end
player.force = force_USSR
2019-10-09 02:02:48 +02:00
player.print('[color=green]You have joined Union of Factory Employees![/color]')
restore_character(player)
2019-10-11 20:24:28 +02:00
player.teleport(get_teleport_location(force_USSR, true), RS.get_surface())
2019-10-09 02:02:48 +02:00
check_ready_to_start()
2019-10-27 15:46:57 +02:00
remote.call('space-race-lobby', 'update_gui')
2019-10-11 20:24:28 +02:00
return true
end
player.print('Failed to join new team, do not be a spy!')
end
2019-10-11 20:24:28 +02:00
Command.add('join-UFE', {description = 'Use to join Union of Factory Employees in Space Race', capture_excess_arguments = false, allowed_by_server = false}, Public.join_ussr)
2019-10-12 13:29:11 +02:00
local function print_player_num(_, player)
local force_USA = primitives.force_USA
local force_USSR = primitives.force_USSR
2019-10-14 17:18:06 +02:00
player.print('West: ' .. #force_USA.connected_players .. ' online /' .. #force_USA.players .. ' total')
player.print('East: ' .. #force_USSR.connected_players .. ' online /' .. #force_USSR.players .. ' total')
2019-10-12 13:29:11 +02:00
end
Command.add('team_players', {description = 'Use to get number of players on both teams', capture_excess_arguments = false, allowed_by_server = false}, print_player_num)
2019-10-11 20:24:28 +02:00
function Public.get_won()
return primitives.won
end
function Public.get_teams()
return {primitives.force_USA, primitives.force_USSR}
end
function Public.get_game_status()
return primitives.game_started
end
2019-10-12 13:29:11 +02:00
function Public.get_started_tick()
return primitives.started_tick
end
2019-10-11 20:24:28 +02:00
remote.add_interface('space-race', Public)
--[[TODO
2019-10-09 02:02:48 +02:00
Starting trees!
2019-10-09 02:02:48 +02:00
NOTES:
2019-10-09 02:02:48 +02:00
Mapgen is slow (a loading screen would be nice)
2019-10-09 02:02:48 +02:00
Tiny islands in shallow water, space for a couple of turrets but not much
2019-10-09 02:02:48 +02:00
Weapon damage balance -> Testing, testing, testing
]]