mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
updates
This commit is contained in:
parent
b4d9623809
commit
f8bcc22d9e
10
control.lua
10
control.lua
@ -59,6 +59,7 @@ require "modules.autostash"
|
||||
--require "modules.no_blueprint_library"
|
||||
--require "modules.explosives"
|
||||
--require "modules.biter_pets"
|
||||
--require "modules.no_solar"
|
||||
--require "modules.wave_defense.main"
|
||||
--require "modules.fjei.main"
|
||||
-----------------------------
|
||||
@ -67,7 +68,7 @@ require "modules.autostash"
|
||||
--require "maps.fish_defender.main"
|
||||
--require "maps.fish_defender_v1.fish_defender"
|
||||
--require "maps.biter_battles_v2.main"
|
||||
require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.mountain_fortress"
|
||||
--require "maps.island_troopers.main"
|
||||
--require "maps.biter_hatchery.main"
|
||||
@ -79,6 +80,7 @@ require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.biter_battles.biter_battles"
|
||||
--require "maps.wave_of_death.WoD"
|
||||
--require "maps.stone_maze.main"
|
||||
--require "maps.choppy"
|
||||
--require "maps.overgrowth"
|
||||
--require "maps.wave_defense"
|
||||
--require "maps.quarters"
|
||||
@ -97,7 +99,6 @@ require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.atoll"
|
||||
--require "maps.rainbow_road"
|
||||
--require "maps.cratewood_forest"
|
||||
--require "maps.choppy"
|
||||
--require "maps.tank_battles"
|
||||
--require "maps.spiral_troopers"
|
||||
--require "maps.refactor-io"
|
||||
@ -110,14 +111,15 @@ require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.lost_desert"
|
||||
--require "maps.cube"
|
||||
--require "maps.forest_circle"
|
||||
--require "maps.empty_map"
|
||||
--require "maps.custom_start"
|
||||
-----------------------------
|
||||
|
||||
---- more modules here ----
|
||||
--require "modules.towny.main"
|
||||
--require "modules.rpg"
|
||||
--require "modules.trees_grow"
|
||||
--require "modules.trees_randomly_die"
|
||||
--require "terrain_layouts.cone_to_east"
|
||||
--require "terrain_layouts.biters_and_resources_east"
|
||||
------
|
||||
|
||||
if _DUMP_ENV then
|
||||
|
@ -12,10 +12,11 @@ local balance_functions = {
|
||||
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.combat_balance[force_name].flamethrower_damage)
|
||||
end,
|
||||
["land-mine"] = function(force_name)
|
||||
global.combat_balance[force_name].land_mine = -0.5
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.5 end
|
||||
game.forces[force_name].set_ammo_damage_modifier("landmine", global.combat_balance[force_name].land_mine)
|
||||
end,
|
||||
["stronger-explosives"] = function(force_name)
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.5 end
|
||||
global.combat_balance[force_name].land_mine = global.combat_balance[force_name].land_mine + 0.05
|
||||
game.forces[force_name].set_ammo_damage_modifier("landmine", global.combat_balance[force_name].land_mine)
|
||||
end,
|
||||
|
69
modules/towny/biters.lua
Normal file
69
modules/towny/biters.lua
Normal file
@ -0,0 +1,69 @@
|
||||
local Public = {}
|
||||
local math_random = math.random
|
||||
|
||||
local function roll_market()
|
||||
local r_max = 0
|
||||
local town_centers = global.towny.town_centers
|
||||
for k, town_center in pairs(town_centers) do
|
||||
r_max = r_max + town_center.research_counter
|
||||
end
|
||||
if r_max == 0 then return end
|
||||
local r = math_random(0, r_max)
|
||||
|
||||
local chance = 0
|
||||
for k, town_center in pairs(town_centers) do
|
||||
chance = chance + town_center.research_counter
|
||||
if r <= chance then return town_center end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_random_close_spawner(surface, market)
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
|
||||
if not spawners[1] then return false end
|
||||
local size_of_spawners = #spawners
|
||||
local center = market.position
|
||||
local spawner = spawners[math_random(1, size_of_spawners)]
|
||||
for i = 1, 3, 1 do
|
||||
local spawner_2 = spawners[math_random(1, size_of_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
|
||||
return spawner
|
||||
end
|
||||
|
||||
function Public.swarm()
|
||||
local town_center = roll_market()
|
||||
if not town_center then return end
|
||||
local market = town_center.market
|
||||
local surface = market.surface
|
||||
local spawner = get_random_close_spawner(surface, market)
|
||||
if not spawner then return end
|
||||
local units = spawner.surface.find_enemy_units(spawner.position, 256, market.force)
|
||||
if not units[1] then return end
|
||||
local unit_group_position = units[1].position
|
||||
local unit_group = surface.create_unit_group({position = units[1].position, force = units[1].force})
|
||||
local count = town_center.research_counter
|
||||
for key, unit in pairs(units) do
|
||||
if key > count then break end
|
||||
unit_group.add_member(unit)
|
||||
end
|
||||
unit_group.set_command({
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = {
|
||||
{
|
||||
type = defines.command.attack_area,
|
||||
destination = market.position,
|
||||
radius = 12,
|
||||
distraction = defines.distraction.by_enemy
|
||||
},
|
||||
{
|
||||
type = defines.command.attack,
|
||||
target = market,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
}
|
||||
})
|
||||
unit_group.start_moving()
|
||||
end
|
||||
|
||||
return Public
|
@ -9,7 +9,8 @@ local info = [[
|
||||
|
||||
To found your own town, place down a stone furnace at a valid location.
|
||||
Buildings can only be placed close to your other buildings.
|
||||
|
||||
Beware, biters are more aggressive towards towns that are advanced in research.
|
||||
|
||||
Only one town center can be owned at a time.
|
||||
Only the owner can banish members.
|
||||
Members can invite other players and teams.
|
||||
|
@ -1,3 +1,4 @@
|
||||
local Biters = require "modules.towny.biters"
|
||||
local Combat_balance = require "modules.towny.combat_balance"
|
||||
local Connected_building = require "modules.towny.connected_building"
|
||||
local Info = require "modules.towny.info"
|
||||
@ -103,6 +104,12 @@ local function on_gui_click(event)
|
||||
Info.close(event)
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
local town_center = global.towny.town_centers[event.research.force.name]
|
||||
if not town_center then return end
|
||||
town_center.research_counter = town_center.research_counter + 1
|
||||
end
|
||||
|
||||
local function on_player_died(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
@ -113,6 +120,7 @@ end
|
||||
local minute_actions = {
|
||||
[60 * 5] = Team.update_town_chart_tags,
|
||||
[60 * 10] = Team.set_all_player_colors,
|
||||
[60 * 15] = Biters.swarm,
|
||||
}
|
||||
|
||||
local function on_nth_tick(event)
|
||||
@ -159,4 +167,5 @@ Event.add(defines.events.on_player_dropped_item, on_player_dropped_item)
|
||||
Event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
||||
Event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
@ -347,6 +347,7 @@ function Public.found(event)
|
||||
town_center.max_health = 1000
|
||||
town_center.health = town_center.max_health
|
||||
town_center.color = colors[math_random(1, #colors)]
|
||||
town_center.research_counter = 0
|
||||
|
||||
town_center.health_text = rendering.draw_text{
|
||||
text = "HP: " .. town_center.health .. " / " .. town_center.max_health,
|
||||
|
Loading…
x
Reference in New Issue
Block a user