mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
new map
This commit is contained in:
parent
345a518478
commit
c3cec34f77
@ -24,6 +24,7 @@ require "modules.floaty_chat"
|
||||
---- enable modules here ----
|
||||
--require "tools.cheat_mode"
|
||||
--require "modules.the_floor_is_lava"
|
||||
--require "modules.trees_grow"
|
||||
--require "modules.autodecon_when_depleted"
|
||||
--require "modules.biter_noms_you"
|
||||
--require "modules.biters_avoid_damage"
|
||||
@ -61,7 +62,7 @@ require "modules.floaty_chat"
|
||||
--require "maps.fish_defender.fish_defender"
|
||||
--require "maps.wave_of_death.WoD"
|
||||
--require "maps.stone_maze.main"
|
||||
require "maps.maze_challenge"
|
||||
--require "maps.maze_challenge"
|
||||
--require "maps.cave_miner"
|
||||
--require "maps.rocky_waste"
|
||||
--require "maps.labyrinth"
|
||||
@ -75,6 +76,7 @@ require "maps.maze_challenge"
|
||||
--require "maps.atoll"
|
||||
--require "maps.rainbow_road"
|
||||
--require "maps.cratewood_forest"
|
||||
require "maps.overgrowth"
|
||||
--require "maps.choppy"
|
||||
--require "maps.tank_battles"
|
||||
--require "maps.spiral_troopers"
|
||||
|
114
maps/overgrowth.lua
Normal file
114
maps/overgrowth.lua
Normal file
@ -0,0 +1,114 @@
|
||||
--overgrowth-- by mewmew --
|
||||
|
||||
require "on_tick_schedule"
|
||||
require "modules.dynamic_landfill"
|
||||
require "modules.satellite_score"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.biters_yield_coins"
|
||||
require "modules.rocks_yield_ore"
|
||||
require "modules.ores_are_mixed"
|
||||
require "modules.more_attacks"
|
||||
|
||||
require "modules.trees_grow"
|
||||
require "modules.trees_randomly_die"
|
||||
|
||||
require "maps.overgrowth_map_info"
|
||||
|
||||
local unearthing_biters = require "functions.unearthing_biters"
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
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
|
||||
|
||||
if cause_position then
|
||||
direction_mod = (cause_position.x - position.x) * 0.025
|
||||
direction_mod_2 = (cause_position.y - position.y) * 0.025
|
||||
end
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(4, 10)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_entity({
|
||||
name = name,
|
||||
position = position,
|
||||
frame_speed = 1,
|
||||
vertical_speed = 0.130,
|
||||
height = 0,
|
||||
movement = {
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_market(surface, position)
|
||||
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
|
||||
market.destructible = false
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}})
|
||||
|
||||
market.add_market_item({price = {{'coin', 4}}, offer = {type = 'give-item', item = "raw-fish", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}})
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
local left_top = event.area.left_top
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
player.insert({name = "pistol", count = 1})
|
||||
player.insert({name = "firearm-magazine", count = 8})
|
||||
end
|
||||
|
||||
if not global.market then
|
||||
spawn_market(player.surface, {x = 0, y = -8})
|
||||
game.map_settings.enemy_evolution.time_factor = 0.0001
|
||||
global.market = true
|
||||
end
|
||||
end
|
||||
|
||||
local function trap(entity)
|
||||
if math_random(1,8) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.type ~= "tree" then return end
|
||||
|
||||
trap(entity)
|
||||
entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true)
|
||||
|
||||
if event.player_index then
|
||||
create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position)
|
||||
return
|
||||
end
|
||||
create_particles(entity.surface, "wooden-particle", entity.position, 128)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
on_player_mined_entity(event)
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
76
maps/overgrowth_map_info.lua
Normal file
76
maps/overgrowth_map_info.lua
Normal file
@ -0,0 +1,76 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local info = [[
|
||||
Nature in this world is out of control!
|
||||
|
||||
Stop the trees before it is too late.
|
||||
|
||||
Concrete and other solid tiles are resistant to the wild growth, but can break after a while.
|
||||
|
||||
For your effort to colonize this overgrown planet,
|
||||
we pay you a coin for each tree you defeat.
|
||||
|
||||
Good Luck
|
||||
]]
|
||||
|
||||
local function create_map_intro_button(player)
|
||||
if player.gui.top["map_intro_button"] then return end
|
||||
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
|
||||
b.style.font_color = {r = 0.1, g = 0.8, b = 0.1}
|
||||
b.style.font = "heading-1"
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 38
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
end
|
||||
|
||||
local function create_map_intro(player)
|
||||
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
|
||||
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
|
||||
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
|
||||
local b = frame.add {type = "button", caption = "Close", name = "close_map_intro_frame", align = "right"}
|
||||
b.style.font = "default"
|
||||
b.style.minimal_height = 30
|
||||
b.style.minimal_width = 30
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
|
||||
local frame = t.add {type = "frame"}
|
||||
local l = frame.add {type = "label", caption = info}
|
||||
l.style.single_line = false
|
||||
l.style.font = "heading-3"
|
||||
l.style.font_color = {r=0.95, g=0.95, b=0.95}
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
create_map_intro_button(player)
|
||||
if player.online_time == 0 then
|
||||
create_map_intro(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() return end
|
||||
if event.element.name == "map_intro_button" then
|
||||
if player.gui.left["map_intro_frame"] then
|
||||
player.gui.left["map_intro_frame"].destroy()
|
||||
else
|
||||
create_map_intro(player)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
68
modules/trees_grow.lua
Normal file
68
modules/trees_grow.lua
Normal file
@ -0,0 +1,68 @@
|
||||
-- trees multiply -- mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local vectors = {}
|
||||
local r = 8
|
||||
for x = r * -1, r, 0.25 do
|
||||
for y = r * -1, r, 0.25 do
|
||||
if math.sqrt(x ^ 2 + y ^ 2) <= r then
|
||||
vectors[#vectors + 1] = {x, y}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local immune_tiles = {
|
||||
["concrete"] = true,
|
||||
["hazard-concrete-left"] = true,
|
||||
["hazard-concrete-right"] = true,
|
||||
["refined-concrete"] = true,
|
||||
["refined-hazard-concrete-left"] = true,
|
||||
["refined-hazard-concrete-right"] = true,
|
||||
["stone-path"] = true
|
||||
}
|
||||
|
||||
local function get_random_chunk_area(surface)
|
||||
local p = surface.get_random_chunk()
|
||||
if not p then return end
|
||||
local area = {{p.x * 32, p.y * 32}, {p.x * 32 + 32, p.y * 32 + 32}}
|
||||
return area
|
||||
end
|
||||
|
||||
local function grow_trees(surface)
|
||||
local trees = surface.find_entities_filtered({type = "tree", area = get_random_chunk_area(surface)})
|
||||
if not trees[1] then return false end
|
||||
|
||||
for a = 1, math_random(1, 6), 1 do
|
||||
local tree = trees[math_random(1, #trees)]
|
||||
local vector = vectors[math_random(1, #vectors)]
|
||||
|
||||
local p = surface.find_non_colliding_position("car", {tree.position.x + vector[1], tree.position.y + vector[2]}, 16, 0.5)
|
||||
if not p then return false end
|
||||
|
||||
local tile = surface.get_tile(p)
|
||||
if immune_tiles[tile.name] then
|
||||
if math_random(1, 4) == 1 then
|
||||
surface.set_tiles({{name = tile.hidden_tile, position = p}})
|
||||
surface.create_entity({name = tree.name, position = p, force = tree.force.name})
|
||||
end
|
||||
else
|
||||
surface.create_entity({name = tree.name, position = p, force = tree.force.name})
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function tick(event)
|
||||
local surface = game.players[1].surface
|
||||
|
||||
for a = 1, 16, 1 do
|
||||
if grow_trees(surface) then break end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
event.on_nth_tick(3, tick)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
66
modules/trees_randomly_die.lua
Normal file
66
modules/trees_randomly_die.lua
Normal file
@ -0,0 +1,66 @@
|
||||
-- trees get randomly hit by lightning strikes -- mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local function create_particles(surface, name, position, amount)
|
||||
local math_random = math.random
|
||||
|
||||
local direction_mod = (-100 + math_random(0,200)) * 0.0005
|
||||
local direction_mod_2 = (-100 + math_random(0,200)) * 0.0005
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(12, 18)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_entity({
|
||||
name = name,
|
||||
position = position,
|
||||
frame_speed = 1,
|
||||
vertical_speed = 0.130,
|
||||
height = 0,
|
||||
movement = {
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
surface.create_entity({
|
||||
name = "railgun-beam",
|
||||
position = {x = position.x, y = position.y},
|
||||
target = {x = (position.x - 6) + math.random(0,12), y = position.y - math.random(12,24)}
|
||||
})
|
||||
surface.create_entity({
|
||||
name = "fire-flame",
|
||||
position = {x = position.x, y = position.y}
|
||||
})
|
||||
end
|
||||
|
||||
local r = 128
|
||||
local function get_random_area(surface)
|
||||
local p = game.players[math_random(1, #game.players)].position
|
||||
if not p then return end
|
||||
local area = {{p.x - r, p.y - r}, {p.x + r, p.y + r}}
|
||||
return area
|
||||
end
|
||||
|
||||
local function kill_random_tree(surface)
|
||||
local trees = surface.find_entities_filtered({type = "tree", area = get_random_area(surface)})
|
||||
if not trees[1] then return false end
|
||||
local tree = trees[math_random(1, #trees)]
|
||||
create_particles(surface, "wooden-particle", tree.position, 320)
|
||||
tree.die()
|
||||
return true
|
||||
end
|
||||
|
||||
local function tick(event)
|
||||
if math_random(1, 12) ~= 1 then return end
|
||||
local surface = game.players[1].surface
|
||||
for a = 1, 8, 1 do
|
||||
if kill_random_tree(surface) then return end
|
||||
end
|
||||
end
|
||||
|
||||
event.on_nth_tick(60, tick)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
Loading…
x
Reference in New Issue
Block a user