You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-09-16 09:06:21 +02:00
tweaks and things
This commit is contained in:
@@ -26,7 +26,6 @@ local function remove_acceleration()
|
||||
if global.locomotive_driver then global.locomotive_driver.destroy() end
|
||||
end
|
||||
|
||||
---DESYNC?
|
||||
local function set_player_spawn()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
@@ -44,14 +43,31 @@ local function set_player_spawn_and_refill_fish()
|
||||
game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface)
|
||||
end
|
||||
|
||||
local function force_nearby_units_to_attack()
|
||||
if not global.locomotive_cargo then return end
|
||||
if not global.locomotive_cargo.valid then return end
|
||||
|
||||
global.locomotive_cargo.surface.set_multi_command({
|
||||
command={
|
||||
type = defines.command.attack,
|
||||
target = global.locomotive_cargo,
|
||||
distraction = defines.distraction.none
|
||||
},
|
||||
unit_count = 4,
|
||||
force = "enemy",
|
||||
unit_search_distance = 256
|
||||
})
|
||||
end
|
||||
|
||||
local function tick()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
|
||||
if game.tick % 30 == 0 then
|
||||
accelerate()
|
||||
if game.tick % 900 == 0 then
|
||||
set_player_spawn_and_refill_fish()
|
||||
accelerate()
|
||||
if game.tick % 1800 == 0 then
|
||||
--force_nearby_units_to_attack()
|
||||
set_player_spawn_and_refill_fish()
|
||||
end
|
||||
else
|
||||
remove_acceleration()
|
||||
|
@@ -45,7 +45,7 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16
|
||||
local function get_gen_settings()
|
||||
local map = {
|
||||
["seed"] = math.random(1, 1000000),
|
||||
["width"] = 768,
|
||||
["width"] = 1280,
|
||||
["water"] = 0.001,
|
||||
["starting_area"] = 1,
|
||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
@@ -182,6 +182,7 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
local function on_init(surface)
|
||||
global.rocks_yield_ore_distance_modifier = 0.1
|
||||
reset_map()
|
||||
end
|
||||
|
||||
|
@@ -69,10 +69,10 @@ local function process_rock_chunk_position(p, seed, tiles, entities, markets, tr
|
||||
--Rock Free Zones
|
||||
if p.y < -64 + noise_cave_ponds * 10 then
|
||||
if no_rocks < 0.08 and no_rocks > -0.08 then
|
||||
if small_caves > 0.25 then
|
||||
if small_caves > 0.20 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math.floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,320) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 500} end
|
||||
if math_random(1,128) == 1 then
|
||||
if math_random(1,96) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * 0.5)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
@@ -233,6 +233,10 @@ local function out_of_map(surface, left_top)
|
||||
end
|
||||
|
||||
local function process_chunk(surface, left_top)
|
||||
if not surface then return end
|
||||
if not surface.valid then return end
|
||||
if left_top.x >= 640 then return end
|
||||
if left_top.x < -640 then return end
|
||||
--game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}})
|
||||
if left_top.y == 64 and left_top.x == 64 then
|
||||
local p = global.locomotive.position
|
||||
@@ -246,12 +250,8 @@ local function process_chunk(surface, left_top)
|
||||
end
|
||||
|
||||
local function process_chunk_queue()
|
||||
for k, chunk in pairs(global.chunk_queue) do
|
||||
if chunk.surface then
|
||||
if chunk.surface.valid then
|
||||
process_chunk(chunk.surface, chunk.left_top)
|
||||
end
|
||||
end
|
||||
for k, chunk in pairs(global.chunk_queue) do
|
||||
process_chunk(game.surfaces[chunk.surface_index], chunk.left_top)
|
||||
global.chunk_queue[k] = nil
|
||||
return
|
||||
end
|
||||
@@ -259,7 +259,7 @@ end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
if event.surface.index == 1 then return end
|
||||
global.chunk_queue[#global.chunk_queue + 1] = {left_top = event.area.left_top, surface = event.surface}
|
||||
global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index}
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--destroying and mining rocks yields ore -- load as last module
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local rock_yield = {
|
||||
["rock-big"] = 1,
|
||||
@@ -40,7 +40,7 @@ for _, t in pairs (rock_mining_chance_weights) do
|
||||
end
|
||||
|
||||
local function create_particles(surface, name, position, amount, cause_position)
|
||||
local math_random = math.random
|
||||
|
||||
|
||||
local direction_mod = (-100 + math_random(0,200)) * 0.0004
|
||||
local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004
|
||||
@@ -69,16 +69,23 @@ local function create_particles(surface, name, position, amount, cause_position)
|
||||
end
|
||||
|
||||
local function get_amount(entity)
|
||||
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
|
||||
local amount = 35 + (distance_to_center * 0.15)
|
||||
if amount > 100 then amount = 100 end
|
||||
amount = rock_yield[entity.name] * amount
|
||||
local distance_to_center = math.floor(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
|
||||
|
||||
if not global.rock_yield_amount_modifier then global.rock_yield_amount_modifier = 1 end
|
||||
amount = amount * global.rock_yield_amount_modifier
|
||||
local distance_modifier = 0.25
|
||||
local base_amount = 35
|
||||
local maximum_amount = 100
|
||||
if global.rocks_yield_ore_distance_modifier then distance_modifier = global.rocks_yield_ore_distance_modifier end
|
||||
if global.rocks_yield_ore_base_amount then base_amount = global.rocks_yield_ore_base_amount end
|
||||
if global.rocks_yield_ore_maximum_amount then maximum_amount = global.rocks_yield_ore_maximum_amount end
|
||||
|
||||
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
|
||||
local amount = base_amount + (distance_to_center * distance_modifier)
|
||||
if amount > maximum_amount then amount = maximum_amount end
|
||||
|
||||
local m = (75 + math_random(0, 50)) * 0.01
|
||||
|
||||
amount = math.floor(amount * rock_yield[entity.name] * m)
|
||||
if amount < 1 then amount = 1 end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
@@ -87,7 +94,7 @@ local function on_player_mined_entity(event)
|
||||
if not entity.valid then return end
|
||||
if rock_yield[entity.name] then
|
||||
event.buffer.clear()
|
||||
local ore = ore_raffle[math.random(1, #ore_raffle)]
|
||||
local ore = ore_raffle[math_random(1, #ore_raffle)]
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
local inventory = player.get_inventory(defines.inventory.character_main)
|
||||
@@ -120,11 +127,21 @@ end
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
|
||||
if rock_yield[entity.name] then
|
||||
local surface = entity.surface
|
||||
local amount = get_amount(entity)
|
||||
amount = math.ceil(amount * 0.1)
|
||||
local ore = ore_raffle[math.random(1, #ore_raffle)]
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 then
|
||||
amount = math_random(4, 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ore = ore_raffle[math_random(1, #ore_raffle)]
|
||||
local pos = {entity.position.x, entity.position.y}
|
||||
entity.destroy()
|
||||
surface.spill_item_stack(pos,{name = ore, count = amount}, true)
|
||||
@@ -132,5 +149,6 @@ local function on_entity_died(event)
|
||||
end
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
@@ -37,7 +37,7 @@ local function get_random_close_spawner()
|
||||
if not spawners[1] then return false end
|
||||
local center = global.wave_defense.target.position
|
||||
local spawner = spawners[math_random(1,#spawners)]
|
||||
for i = 1, 5, 1 do
|
||||
for i = 1, global.wave_defense.get_random_close_spawner_attempts, 1 do
|
||||
local spawner_2 = spawners[math_random(1,#spawners)]
|
||||
if (center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 < (center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2 then spawner = spawner_2 end
|
||||
end
|
||||
@@ -84,7 +84,7 @@ end
|
||||
local function spawn_biter()
|
||||
if global.wave_defense.threat <= 0 then return false end
|
||||
if global.wave_defense.active_biter_count >= global.wave_defense.max_active_biters then return false end
|
||||
local name = wave_defense_roll_biter_name()
|
||||
local name = wave_defense_roll_biter_name()
|
||||
local position = global.wave_defense.surface.find_non_colliding_position(name, global.wave_defense.spawn_position, 32, 1)
|
||||
if not position then return false end
|
||||
local biter = global.wave_defense.surface.create_entity({name = name, position = position, force = "enemy"})
|
||||
@@ -255,7 +255,9 @@ local function update_gui(player)
|
||||
if global.wave_defense.wave_number == 0 then player.gui.top.wave_defense.label.caption = "First wave in " .. math.floor((global.wave_defense.next_wave - game.tick) / 60) + 1 end
|
||||
local interval = global.wave_defense.next_wave - global.wave_defense.last_wave
|
||||
player.gui.top.wave_defense.progressbar.value = 1 - (global.wave_defense.next_wave - game.tick) / interval
|
||||
player.gui.top.wave_defense.threat.caption = "Threat: " .. global.wave_defense.threat
|
||||
local value = global.wave_defense.threat
|
||||
if value < 0 then value = 0 end
|
||||
player.gui.top.wave_defense.threat.caption = "Threat: " .. value
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
@@ -292,6 +294,7 @@ function reset_wave_defense()
|
||||
max_biter_age = 3600 * 60,
|
||||
active_unit_group_count = 0,
|
||||
active_biter_count = 0,
|
||||
get_random_close_spawner_attempts = 2,
|
||||
spawn_position = {x = 0, y = 64},
|
||||
last_wave = game.tick,
|
||||
next_wave = game.tick + 3600 * 5,
|
||||
@@ -299,6 +302,8 @@ function reset_wave_defense()
|
||||
wave_number = 0,
|
||||
game_lost = false,
|
||||
threat = 0,
|
||||
simple_entity_shredding_count_modifier = 0.0003,
|
||||
simple_entity_shredding_cost_modifier = 0.005, --threat cost for one health
|
||||
}
|
||||
end
|
||||
|
||||
|
@@ -68,9 +68,10 @@ local function shred_simple_entities(entity)
|
||||
if global.wave_defense.threat < 10000 then return end
|
||||
local simple_entities = entity.surface.find_entities_filtered({type = "simple-entity", area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}})
|
||||
if #simple_entities == 0 then return end
|
||||
if #simple_entities > 1 then table.shuffle_table(simple_entities) end
|
||||
|
||||
local count = math.random(1, math.floor(global.wave_defense.threat * 0.0003))
|
||||
if #simple_entities > 1 then table.shuffle_table(simple_entities) end
|
||||
local r = math.floor(global.wave_defense.threat * global.wave_defense.simple_entity_shredding_count_modifier)
|
||||
if r < 1 then r = 1 end
|
||||
local count = math.random(1, r)
|
||||
local damage_dealt = 0
|
||||
for i = 1, count, 1 do
|
||||
if not simple_entities[i] then break end
|
||||
@@ -83,7 +84,7 @@ local function shred_simple_entities(entity)
|
||||
end
|
||||
end
|
||||
if damage_dealt == 0 then return end
|
||||
local threat_cost = math.floor(damage_dealt * 0.01)
|
||||
local threat_cost = math.floor(damage_dealt * global.wave_defense.simple_entity_shredding_cost_modifier)
|
||||
if threat_cost < 1 then threat_cost = 1 end
|
||||
global.wave_defense.threat = global.wave_defense.threat - threat_cost
|
||||
end
|
||||
|
Reference in New Issue
Block a user