mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-01 13:08:05 +02:00
Add files via upload
This commit is contained in:
parent
b49cee5dd2
commit
db9b176383
@ -250,8 +250,8 @@ local function on_chunk_generated(event)
|
|||||||
if x == 1 then
|
if x == 1 then
|
||||||
local a = math_random(1,8)
|
local a = math_random(1,8)
|
||||||
if a == 1 then
|
if a == 1 then
|
||||||
local q =math_abs(position.x)/100
|
local q =math_abs(position.x)/80
|
||||||
local w =math_abs(position.y)/100
|
local w =math_abs(position.y)/80
|
||||||
local maxs =math.floor(q+w)
|
local maxs =math.floor(q+w)
|
||||||
-- game.print(maxs)
|
-- game.print(maxs)
|
||||||
MT.mountain_market(surface,position,maxs)
|
MT.mountain_market(surface,position,maxs)
|
||||||
|
@ -3,7 +3,7 @@ local Event = require 'utils.event'
|
|||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local WPT = require 'maps.amap.table'
|
local WPT = require 'maps.amap.table'
|
||||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||||
|
local atry_talbe = require "maps.amap.enemy_arty"
|
||||||
local function calc_players()
|
local function calc_players()
|
||||||
local players = game.connected_players
|
local players = game.connected_players
|
||||||
local check_afk_players = WPT.get('check_afk_players')
|
local check_afk_players = WPT.get('check_afk_players')
|
||||||
@ -34,22 +34,19 @@ local easy = function()
|
|||||||
wave_defense_table.max_active_biters = 4000
|
wave_defense_table.max_active_biters = 4000
|
||||||
end
|
end
|
||||||
local wave_number = WD.get('wave_number')
|
local wave_number = WD.get('wave_number')
|
||||||
local heath = 1 + player_count * 0.05
|
if wave_number >= 1500 then
|
||||||
if heath >= 3 then
|
wave_number = 1500
|
||||||
heath = 3
|
|
||||||
end
|
end
|
||||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
|
||||||
-- threat gain / wave
|
-- threat gain / wave
|
||||||
local max_threat = 1 + player_count * 0.1
|
local max_threat = 1 + player_count * 0.1
|
||||||
if max_threat >= 4 then
|
if max_threat >= 4 then
|
||||||
max_threat = 4
|
max_threat = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
if wave_number > 850 then
|
|
||||||
max_threat = max_threat + wave_number * 0.0013
|
max_threat = max_threat + wave_number * 0.0013
|
||||||
|
|
||||||
WD.set_biter_health_boost(wave_number * 0.002+1)
|
WD.set_biter_health_boost(wave_number * 0.002+1)
|
||||||
wave_defense_table.threat_gain_multiplier = max_threat
|
wave_defense_table.threat_gain_multiplier = max_threat
|
||||||
end
|
|
||||||
|
|
||||||
wave_defense_table.wave_interval = 4200 - player_count * 30
|
wave_defense_table.wave_interval = 4200 - player_count * 30
|
||||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||||
@ -74,22 +71,18 @@ local med = function()
|
|||||||
wave_defense_table.max_active_biters = 4000
|
wave_defense_table.max_active_biters = 4000
|
||||||
end
|
end
|
||||||
local wave_number = WD.get('wave_number')
|
local wave_number = WD.get('wave_number')
|
||||||
local heath = 1 + player_count * 0.15
|
|
||||||
if heath >= 3 then
|
|
||||||
heath = 3
|
|
||||||
end
|
|
||||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
|
||||||
-- threat gain / wave
|
-- threat gain / wave
|
||||||
|
if wave_number >= 1500 then
|
||||||
|
wave_number = 1500
|
||||||
|
end
|
||||||
local max_threat = 1 + player_count * 0.1
|
local max_threat = 1 + player_count * 0.1
|
||||||
if max_threat >= 4 then
|
if max_threat >= 4 then
|
||||||
max_threat = 4
|
max_threat = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
if wave_number > 850 then
|
max_threat = max_threat + wave_number * 0.0013
|
||||||
max_threat = max_threat + wave_number * 0.004
|
WD.set_biter_health_boost(wave_number * 0.002+1)
|
||||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
|
||||||
wave_defense_table.threat_gain_multiplier = max_threat
|
wave_defense_table.threat_gain_multiplier = max_threat
|
||||||
end
|
|
||||||
|
|
||||||
wave_defense_table.wave_interval = 4200 - player_count * 45
|
wave_defense_table.wave_interval = 4200 - player_count * 45
|
||||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||||
@ -112,23 +105,20 @@ local hard = function()
|
|||||||
if wave_defense_table.max_active_biters >= 4000 then
|
if wave_defense_table.max_active_biters >= 4000 then
|
||||||
wave_defense_table.max_active_biters = 4000
|
wave_defense_table.max_active_biters = 4000
|
||||||
end
|
end
|
||||||
|
|
||||||
local wave_number = WD.get('wave_number')
|
local wave_number = WD.get('wave_number')
|
||||||
local heath = 1.2 + player_count * 0.1
|
|
||||||
if heath >= 4 then
|
|
||||||
heath = 4
|
|
||||||
end
|
|
||||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
|
||||||
-- threat gain / wave
|
-- threat gain / wave
|
||||||
local max_threat = 1 + player_count * 0.2
|
if wave_number >= 1500 then
|
||||||
|
wave_number = 1500
|
||||||
|
end
|
||||||
|
local max_threat = 1 + player_count * 0.1
|
||||||
if max_threat >= 4 then
|
if max_threat >= 4 then
|
||||||
max_threat = 4
|
max_threat = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
if wave_number > 850 then
|
max_threat = max_threat + wave_number * 0.0013
|
||||||
max_threat = max_threat + wave_number * 0.005
|
WD.set_biter_health_boost(wave_number * 0.002+1)
|
||||||
WD.set_biter_health_boost(wave_number * 0.003+1)
|
|
||||||
wave_defense_table.threat_gain_multiplier = max_threat
|
wave_defense_table.threat_gain_multiplier = max_threat
|
||||||
end
|
|
||||||
|
|
||||||
wave_defense_table.wave_interval = 3900 - player_count * 60
|
wave_defense_table.wave_interval = 3900 - player_count * 60
|
||||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||||
@ -177,11 +167,21 @@ local set_diff = function()
|
|||||||
if k <= 1 then
|
if k <= 1 then
|
||||||
k =1
|
k =1
|
||||||
end
|
end
|
||||||
|
k=math.floor(k)
|
||||||
damage_increase = wave_number * 0.001*k
|
damage_increase = wave_number * 0.001*k
|
||||||
|
game.forces.enemy.set_ammo_damage_modifier("artillery-shell", damage_increase)
|
||||||
|
game.forces.enemy.set_ammo_damage_modifier("rocket", damage_increase)
|
||||||
game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase)
|
game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase)
|
||||||
game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase)
|
game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase)
|
||||||
|
|
||||||
|
local table = atry_talbe.get()
|
||||||
|
local radius=math.floor(wave_number*0.15)*k
|
||||||
|
table.radius=350+radius
|
||||||
|
local pace=wave_number*0.0002*k+1
|
||||||
|
if pace >= 2 then
|
||||||
|
pace = 2
|
||||||
|
end
|
||||||
|
table.pace=pace
|
||||||
|
|
||||||
end
|
end
|
||||||
Event.on_nth_tick(1000, set_diff)
|
Event.on_nth_tick(600, set_diff)
|
||||||
|
@ -1,14 +1,27 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
|
local Task = require 'utils.task'
|
||||||
local arty_count = {}
|
local arty_count = {}
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
local WPT = require 'maps.amap.table'
|
||||||
local artillery_target_entities = {
|
local artillery_target_entities = {
|
||||||
'character',
|
'character',
|
||||||
'roboport',
|
'tank',
|
||||||
|
'car',
|
||||||
|
'radar',
|
||||||
|
'lab',
|
||||||
'furnace',
|
'furnace',
|
||||||
|
'locomotive',
|
||||||
|
'cargo-wagon',
|
||||||
|
'fluid-wagon',
|
||||||
|
'artillery-wagon',
|
||||||
|
'artillery-turret',
|
||||||
|
'laser-turret',
|
||||||
|
'gun-turret',
|
||||||
|
'flamethrower-turret',
|
||||||
|
-- 'silo',
|
||||||
|
'spidertron'
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register(
|
Global.register(
|
||||||
@ -19,10 +32,13 @@ Global.register(
|
|||||||
)
|
)
|
||||||
|
|
||||||
function Public.reset_table()
|
function Public.reset_table()
|
||||||
arty_count.max = 500
|
arty_count.max = 200
|
||||||
arty_count.all = {}
|
arty_count.all = {}
|
||||||
arty_count.count = 0
|
arty_count.count = 0
|
||||||
arty_count.distance = 0
|
arty_count.pace = 1
|
||||||
|
arty_count.radius = 350
|
||||||
|
arty_count.distance = 1400
|
||||||
|
arty_count.surface = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +66,6 @@ local on_init = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function add_bullet ()
|
local function add_bullet ()
|
||||||
game.print(arty_count.count)
|
|
||||||
for k, p in pairs(arty_count.all) do
|
for k, p in pairs(arty_count.all) do
|
||||||
if arty_count.all[k].valid then
|
if arty_count.all[k].valid then
|
||||||
arty_count.all[k].insert{name='artillery-shell', count = '5'}
|
arty_count.all[k].insert{name='artillery-shell', count = '5'}
|
||||||
@ -75,16 +90,17 @@ local function on_chunk_generated(event)
|
|||||||
if arty_count.count >= arty_count.max then
|
if arty_count.count >= arty_count.max then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local roll = math.random(1, 1024)
|
local roll = math.random(1, 2024)
|
||||||
if roll <= 2 then
|
if roll == 1 then
|
||||||
local arty = surface.create_entity{name = "artillery-turret", position = position, force='enemy'}
|
local arty = surface.create_entity{name = "artillery-turret", position = position, force='enemy'}
|
||||||
arty.insert{name='artillery-shell', count = '5'}
|
-- arty.insert{name='artillery-shell', count = '5'}
|
||||||
--local k = #arty_count.all
|
--local k = #arty_count.all
|
||||||
-- game.print(k)
|
-- game.print(k)
|
||||||
arty_count.all[#arty_count.all+1]=arty
|
arty_count.all[arty.unit_number]=arty
|
||||||
|
-- game.print(arty_count.all[1].name)
|
||||||
arty_count.count = arty_count.count + 1
|
arty_count.count = arty_count.count + 1
|
||||||
-- game.print(arty_count.count)
|
-- game.print(arty_count.count)
|
||||||
game.print(position)
|
-- game.print(position)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -95,38 +111,136 @@ end
|
|||||||
|
|
||||||
local function on_entity_died(event)
|
local function on_entity_died(event)
|
||||||
|
|
||||||
local name = event.entity.name
|
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
local force = event.entity.force
|
|
||||||
|
|
||||||
if name == 'artillery-turret' and force.name == 'enemy' then
|
if not entity or not entity.valid then return end
|
||||||
|
|
||||||
arty_count.count = arty_count.count -1
|
|
||||||
|
|
||||||
if arty_count.count <= 0 then
|
if arty_count.all[entity.unit_number] then
|
||||||
arty_count.count = 0
|
arty_count.all[entity.unit_number] = nil
|
||||||
end
|
arty_count.count = arty_count.count - 1
|
||||||
end
|
end
|
||||||
|
-- local force = entity.force
|
||||||
|
-- local name = entity.name
|
||||||
|
-- if name == 'artillery-turret' and force.name == 'enemy' then
|
||||||
|
-- arty_count.all[entity.unit_number] = nil
|
||||||
|
-- arty_count.count = arty_count.count -1
|
||||||
|
--
|
||||||
|
-- if arty_count.count <= 0 then
|
||||||
|
-- arty_count.count = 0
|
||||||
|
-- end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_player_changed_position(event)
|
function on_player_changed_position(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
|
local surface = player.surface
|
||||||
|
if not surface.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local position = player.position
|
local position = player.position
|
||||||
|
|
||||||
local q =position.x*position.x
|
local q =position.x*position.x
|
||||||
local w =position.y*position.y
|
local w =position.y*position.y
|
||||||
local distance =math.sqrt(q+w)
|
local distance =math.sqrt(q+w)
|
||||||
|
--artillery-targeting-remote
|
||||||
if distance >= arty_count.distance-200 then
|
game.print("123")
|
||||||
|
surface.create_entity(
|
||||||
|
{
|
||||||
|
name = 'artillery-targeting-remote',
|
||||||
end
|
position = position,
|
||||||
|
force = 'enemy',
|
||||||
|
-- target = position,
|
||||||
|
-- speed = 0.001
|
||||||
|
}
|
||||||
|
)
|
||||||
|
game.print("logging")
|
||||||
end
|
end
|
||||||
|
local artillery_target_callback =
|
||||||
|
Token.register(
|
||||||
|
function(data)
|
||||||
|
local position = data.position
|
||||||
|
local entity = data.entity
|
||||||
|
|
||||||
|
if not entity.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local tx, ty = position.x, position.y
|
||||||
|
local pos = entity.position
|
||||||
|
local x, y = pos.x, pos.y
|
||||||
|
local dx, dy = tx - x, ty - y
|
||||||
|
local d = dx * dx + dy * dy
|
||||||
|
-- if d >= 1024 and d <= 441398 then -- 704 in depth~
|
||||||
|
if entity.name == 'character' then
|
||||||
|
entity.surface.create_entity {
|
||||||
|
name = 'artillery-projectile',
|
||||||
|
position = position,
|
||||||
|
target = entity,
|
||||||
|
force = 'enemy',
|
||||||
|
speed = arty_count.pace
|
||||||
|
}
|
||||||
|
elseif entity.name ~= 'character' then
|
||||||
|
entity.surface.create_entity {
|
||||||
|
name = 'rocket',
|
||||||
|
position = position,
|
||||||
|
target = entity,
|
||||||
|
force = 'enemy',
|
||||||
|
speed = arty_count.pace
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- end
|
||||||
|
)
|
||||||
|
|
||||||
|
local function do_artillery_turrets_targets()
|
||||||
|
--local surface = arty_count.surface
|
||||||
|
local this = WPT.get()
|
||||||
|
local surface = game.surfaces[this.active_surface_index]
|
||||||
|
--选取重炮
|
||||||
|
local roll_table = {}
|
||||||
|
for index, arty in pairs(arty_count.all) do
|
||||||
|
if arty.valid then
|
||||||
|
roll_table[#roll_table + 1] = arty
|
||||||
|
else
|
||||||
|
arty_count.all[index] = nil -- <- if not valid, remove from table
|
||||||
|
arty_count.count = arty_count.count - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #roll_table <= 0 then return end
|
||||||
|
local roll = math.random(1, #roll_table)
|
||||||
|
local position = roll_table[roll].position
|
||||||
|
|
||||||
|
--扫描区域
|
||||||
|
-- local normal_area = {left_top = {-480, -480}, right_bottom = {480, 480}}
|
||||||
|
-- game.print(123)
|
||||||
|
-- normal_area= roll_table[roll].artillery_area
|
||||||
|
-- game.print(12)
|
||||||
|
local entities = surface.find_entities_filtered{position = position, radius = arty_count.radius, name = artillery_target_entities, force = game.forces.player}
|
||||||
|
|
||||||
|
-- local entities = surface.find_entities_filtered {area = normal_area, name = artillery_target_entities, force = 'player'}
|
||||||
|
if #entities == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--开火
|
||||||
|
for i = 1, arty_count.count do
|
||||||
|
local entity = entities[math.random(#entities)]
|
||||||
|
--game.print(entity.position)
|
||||||
|
if entity and entity.valid then
|
||||||
|
local data = {position = position, entity = entity}
|
||||||
|
Task.set_timeout_in_ticks(i * 60, artillery_target_callback, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
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_entity_died, on_entity_died)
|
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||||
Event.on_nth_tick(600, add_bullet)
|
--Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||||
|
--Event.on_nth_tick(600, add_bullet)
|
||||||
|
Event.on_nth_tick(10, do_artillery_turrets_targets)
|
||||||
Event.on_init(on_init)
|
Event.on_init(on_init)
|
||||||
|
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ local name = event.created_entity.name
|
|||||||
local entity = event.created_entity
|
local entity = event.created_entity
|
||||||
local this = WPT.get()
|
local this = WPT.get()
|
||||||
if name == 'flamethrower-turret' then
|
if name == 'flamethrower-turret' then
|
||||||
if this.flame >= 12 then
|
if this.flame >= 15 then
|
||||||
game.print({'amap.too_many'})
|
game.print({'amap.too_many'})
|
||||||
entity.destroy()
|
entity.destroy()
|
||||||
else
|
else
|
||||||
|
@ -608,12 +608,15 @@ local on_tick = function()
|
|||||||
|
|
||||||
if tick % 40 == 0 then
|
if tick % 40 == 0 then
|
||||||
-- pos()
|
-- pos()
|
||||||
timereward()
|
|
||||||
--bigermap()
|
--bigermap()
|
||||||
getrawrad()
|
|
||||||
is_player_valid()
|
|
||||||
-- has_the_game_ended()
|
-- has_the_game_ended()
|
||||||
|
is_player_valid()
|
||||||
chunk_load()
|
chunk_load()
|
||||||
|
timereward()
|
||||||
|
getrawrad()
|
||||||
-- biterup()
|
-- biterup()
|
||||||
end
|
end
|
||||||
if tick % 500 == 0 then
|
if tick % 500 == 0 then
|
||||||
|
@ -132,7 +132,9 @@ end
|
|||||||
local function on_entity_died(Event)
|
local function on_entity_died(Event)
|
||||||
local this = WPT.get()
|
local this = WPT.get()
|
||||||
if Event.entity == this.rock then
|
if Event.entity == this.rock then
|
||||||
|
for _, player in pairs(game.connected_players) do
|
||||||
|
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.75}
|
||||||
|
end
|
||||||
--game.print({'amap.lost',wave_number}),{r = 1, g = 0, b = 0, a = 0.5})
|
--game.print({'amap.lost',wave_number}),{r = 1, g = 0, b = 0, a = 0.5})
|
||||||
local wave_number = WD.get('wave_number')
|
local wave_number = WD.get('wave_number')
|
||||||
local msg = {'amap.lost',wave_number}
|
local msg = {'amap.lost',wave_number}
|
||||||
@ -142,14 +144,18 @@ local function on_entity_died(Event)
|
|||||||
|
|
||||||
end
|
end
|
||||||
Server.to_discord_embed(table.concat({'** we lost the game ! Record is ', wave_number}))
|
Server.to_discord_embed(table.concat({'** we lost the game ! Record is ', wave_number}))
|
||||||
local Reset_map = require 'maps.amap.main'.reset_map
|
local Reset_map = require 'maps.amap.main'.reset_map
|
||||||
wave_defense_table.game_lost = true
|
wave_defense_table.game_lost = true
|
||||||
wave_defense_table.target = nil
|
wave_defense_table.target = nil
|
||||||
-- game.forces.enemy.set_friend('player', true)
|
-- game.forces.enemy.set_friend('player', true)
|
||||||
--game.print('设置右军友好')
|
--game.print('设置右军友好')
|
||||||
--game.forces.player.set_friend('enemy', true)
|
-- game.forces.player.set_friend('enemy', true)
|
||||||
--game.print('设置敌军友好')
|
--game.print('设置敌军友好')
|
||||||
Reset_map()
|
--local game_reset_tick = WPT.get('game_reset_tick')
|
||||||
|
-- game.print('GG,游戏结束,稍后自动重启',{r = 0.99, g = 0.00, b = 0.22})
|
||||||
|
-- this.game_reset_tick = 5400
|
||||||
|
|
||||||
|
Reset_map()
|
||||||
|
|
||||||
--abc()
|
--abc()
|
||||||
end
|
end
|
||||||
@ -226,6 +232,9 @@ local function on_market_item_purchased(event)
|
|||||||
if offer_index == 5 then
|
if offer_index == 5 then
|
||||||
local wave_number = WD.get('wave_number')
|
local wave_number = WD.get('wave_number')
|
||||||
local times = math.floor(wave_number/100)+this.cap+1
|
local times = math.floor(wave_number/100)+this.cap+1
|
||||||
|
if times >= 30 then
|
||||||
|
times = 30
|
||||||
|
end
|
||||||
if this.biter_dam >= times then
|
if this.biter_dam >= times then
|
||||||
player.print({'amap.cap_upgrad'})
|
player.print({'amap.cap_upgrad'})
|
||||||
local pirce_biter_dam=this.biter_dam*1000 +7000
|
local pirce_biter_dam=this.biter_dam*1000 +7000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user