1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00

first version

This commit is contained in:
MewMew 2019-05-06 13:10:31 +02:00
parent ffbf580e1a
commit d0ba4a212e
8 changed files with 100 additions and 15 deletions

View File

@ -1,7 +1,4 @@
-- Mapcodes made by MewMew, Idea and Map-painting by Kyte
-- Coding-Time by MewMew: 24.04.19 from 11am to 5pm = 6+ Hours !!
-- code for reading coordinates ingame: /silent-command game.players[1].print(game.player.selected.position)
-- Map by Kyte & MewMew
require "maps.wave_of_death.intro"
require "modules.biter_evasion_hp_increaser"
@ -9,18 +6,26 @@ local event = require 'utils.event'
local init = require "maps.wave_of_death.init"
local on_chunk_generated = require "maps.wave_of_death.terrain"
local ai = require "maps.wave_of_death.ai"
local game_status = require "maps.wave_of_death.game_status"
function soft_teleport(player, destination)
local surface = game.surfaces["wave_of_death"]
local pos = surface.find_non_colliding_position("character", destination, 8, 0.5)
if not pos then player.teleport(destination, surface) end
player.teleport(pos, surface)
end
local function autojoin_lane(player)
local lowest_player_count = 256
local lane_number = 1
for i = 1, 4, 1 do
if #game.forces[i].connected_players < lowest_player_count then
if #game.forces[i].connected_players < lowest_player_count and global.wod_lane[i].game_lost == false then
lowest_player_count = #game.forces[i].connected_players
lane_number = i
end
end
player.force = game.forces[lane_number]
player.teleport(game.forces[player.force.name].get_spawn_position(game.surfaces["wave_of_death"]), game.surfaces["wave_of_death"])
soft_teleport(player, game.forces[player.force.name].get_spawn_position(game.surfaces["wave_of_death"]))
player.insert({name = "pistol", count = 1})
player.insert({name = "firearm-magazine", count = 16})
player.insert({name = "submachine-gun", count = 1})
@ -31,7 +36,11 @@ local function on_player_joined_game(event)
init()
local player = game.players[event.player_index]
autojoin_lane(player)
if player.online_time == 0 then autojoin_lane(player) return end
if global.wod_lane[tonumber(player.force.name)].game_lost == true then
player.character.die()
end
end
local function on_entity_damaged(event)
@ -41,6 +50,7 @@ end
local function on_entity_died(event)
if not event.entity.valid then return end
ai.spawn_spread_wave(event)
game_status.has_lane_lost(event)
end
local function on_player_rotated_entity(event)
@ -53,6 +63,8 @@ local function on_tick(event)
for i = 1, 4, 1 do
game.forces[i].chart(game.surfaces["wave_of_death"], {{-320, -384}, {320, 96}})
end
game_status.restart_server()
end
event.add(defines.events.on_tick, on_tick)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

View File

@ -60,21 +60,24 @@ ai.spawn_spread_wave = function(event)
for lane_number = 1, 4, 1 do
if lane_number ~= trigger_lane_number then
if #game.forces[lane_number].players > 0 and global.wod_lane[lane_number].game_lost == false then
ai.spawn_wave(entity.surface, lane_number, global.wod_lane[trigger_lane_number].current_wave - 1, global.spread_amount_modifier)
end
end
end
game.print("Lane #" .. trigger_lane_number .. " has defeated their wave.")
--game.print("Lane #" .. trigger_lane_number .. " has defeated their wave.")
end
--on_entity_rotated event
ai.trigger_new_wave = function(event)
local entity = event.entity
if entity.name ~= "loader" then return end
if game.tick < 600 then return end
local lane_number = tonumber(entity.force.name)
if not global.wod_lane[lane_number] then return end
if global.wod_lane[lane_number].alive_biters > 0 then
entity.force.print("There are " .. global.wod_lane[lane_number].alive_biters .. " spawned biters left.", {r = 180, g = 0, b = 0})
entity.force.print(">> There are " .. global.wod_lane[lane_number].alive_biters .. " spawned biters left.", {r = 180, g = 0, b = 0})
return
end
@ -83,9 +86,9 @@ ai.trigger_new_wave = function(event)
ai.spawn_wave(entity.surface, lane_number, wave_number, 1)
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/new_objective", volume_modifier=0.3} --dont know if a sound would be annoying in a game with 10 lanes playing ^^ maybe a short sound
player.play_sound{path="utility/new_objective", volume_modifier=0.3}
end
game.print("Lane " .. entity.force.name .. " has summoned wave #" .. global.wod_lane[lane_number].current_wave - 1)
game.print(">> Lane " .. entity.force.name .. " summoned wave #" .. global.wod_lane[lane_number].current_wave - 1 .. "", {r = 0, g = 100, b = 0})
end
ai.prevent_friendly_fire = function(event)

View File

@ -0,0 +1,59 @@
local game_status = {}
game_status.restart_server = function()
if not global.server_restart_timer then return end
global.server_restart_timer = global.server_restart_timer - 5
if global.server_restart_timer == 120 then return end
if global.server_restart_timer == 0 then
game.print("Map is restarting!", {r=0.22, g=0.88, b=0.22})
local message = 'Map is restarting! '
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
server_commands.start_scenario('wave_of_death')
global.server_restart_timer = nil
return
end
if global.server_restart_timer % 30 == 0 then
game.print("Map will restart in " .. global.server_restart_timer .. " seconds!", {r=0.22, g=0.88, b=0.22})
end
end
game_status.has_lane_lost = function(event)
if event.entity.name ~= "loader" then return end
local lane_number = tonumber(event.entity.force.name)
global.wod_lane[lane_number].game_lost = true
game.forces[lane_number].set_spawn_position({x = 32, y = 0}, event.entity.surface)
event.entity.surface.create_entity({
name = "atomic-rocket",
position = event.entity.position,
force = "enemy",
source = event.entity.position,
target = event.entity.position,
max_range = 1,
speed = 1
})
for _, player in pairs(game.forces[lane_number].connected_players) do
if player.character then
player.character.die()
end
end
game.print(">> Lane " .. lane_number .. " has been defeated!", {r = 100, g = 50, b = 0})
--determine winner and restart the server
local lanes_alive = 0
for i = 1, 4, 1 do
if global.wod_lane[i].game_lost == false then
lanes_alive = lanes_alive + 1
end
end
if lanes_alive ~= 1 then return end
for i = 1, 4, 1 do
if global.wod_lane[i].game_lost == true then
game.print(">> Lane " .. i .. " has won!!!", {r = 0, g = 150, b = 150})
global.server_restart_timer = 120
end
end
end
return game_status

View File

@ -57,6 +57,7 @@ local function init_globals()
global.wod_lane[i] = {}
global.wod_lane[i].current_wave = 1
global.wod_lane[i].alive_biters = 0
global.wod_lane[i].game_lost = false
end
end

View File

@ -46,7 +46,17 @@ local function init(surface, left_top)
game.forces[i].set_spawn_position({x = position.x, y = position.y + 8}, surface)
rendering.draw_sprite({sprite = "file/maps/wave_of_death/WoD.png", target = {x = -140 + 160*(i - 1), y = 0}, surface = surface, orientation = 0, x_scale = 2, y_scale = 2, render_layer = "ground-tile"})
--rendering.draw_sprite({sprite = "file/maps/wave_of_death/WoD.png", target = {x = -140 + 160*(i - 1), y = 0}, surface = surface, orientation = 0, x_scale = 2, y_scale = 2, render_layer = "ground-tile"})
end
local center_position = {x = 32, y = 0}
for x = -6, 6, 1 do
for y = -6, 6, 1 do
if math.sqrt(x ^ 2 + y ^ 2) < 6 then
local pos = {x = center_position.x + x, y = center_position.y + y}
surface.set_tiles({{name = "water-shallow", position = pos}})
end
end
end
end