1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

fish_defender > coin yield comes from module; nightfall > update; explosives_are_explosive > entity valid check

This commit is contained in:
MewMew 2019-01-01 17:17:18 +01:00
parent e657fd9f9e
commit 88f9ca9055
5 changed files with 41 additions and 96 deletions

View File

@ -3,6 +3,7 @@
local event = require 'utils.event'
require "maps.fish_defender_map_intro"
require "maps.modules.biters_yield_coins"
require "maps.modules.railgun_enhancer"
require "maps.modules.dynamic_landfill"
@ -777,19 +778,6 @@ local function is_game_lost()
game.map_settings.enemy_expansion.max_expansion_cooldown = 600
end
local biter_building_inhabitants = {
[1] = {{"small-biter",8,16}},
[2] = {{"small-biter",12,24}},
[3] = {{"small-biter",8,16},{"medium-biter",1,2}},
[4] = {{"small-biter",4,8},{"medium-biter",4,8}},
[5] = {{"small-biter",3,5},{"medium-biter",8,12}},
[6] = {{"small-biter",3,5},{"medium-biter",5,7},{"big-biter",1,2}},
[7] = {{"medium-biter",6,8},{"big-biter",3,5}},
[8] = {{"medium-biter",2,4},{"big-biter",6,8}},
[9] = {{"medium-biter",2,3},{"big-biter",7,9}},
[10] = {{"big-biter",4,8},{"behemoth-biter",3,4}}
}
local function damage_entities_in_radius(position, radius, damage)
local entities_to_damage = game.surfaces["fish_defender"].find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}})
for _, entity in pairs(entities_to_damage) do
@ -806,77 +794,9 @@ local function damage_entities_in_radius(position, radius, damage)
end
end
end
local coin_earnings = {
["small-biter"] = 1,
["medium-biter"] = 2,
["big-biter"] = 3,
["behemoth-biter"] = 5,
["small-spitter"] = 1,
["medium-spitter"] = 2,
["big-spitter"] = 3,
["behemoth-spitter"] = 5,
["spitter-spawner"] = 32,
["biter-spawner"] = 32
}
local entities_that_earn_coins = {
["artillery-turret"] = true,
["gun-turret"] = true,
["laser-turret"] = true,
["flamethrower-turret"] = true
}
local function on_entity_died(event)
if event.entity.force.name == "enemy" then
local players_to_reward = {}
local reward_has_been_given = false
if event.cause then
if event.entity.type == "unit" or event.entity.type == "unit-spawner" then
if event.cause.name == "player" then
insert(players_to_reward, event.cause)
reward_has_been_given = true
end
if event.cause.type == "car" then
player = event.cause.get_driver()
passenger = event.cause.get_passenger()
if player then insert(players_to_reward, player.player) end
if passenger then insert(players_to_reward, passenger.player) end
reward_has_been_given = true
end
if event.cause.type == "locomotive" then
train_passengers = event.cause.train.passengers
if train_passengers then
for _, passenger in pairs(train_passengers) do
insert(players_to_reward, passenger)
end
reward_has_been_given = true
end
end
for _, player in pairs(players_to_reward) do
player.insert({name = "coin", count = coin_earnings[event.entity.name]})
end
if entities_that_earn_coins[event.cause.name] then
event.entity.surface.spill_item_stack(event.cause.position,{name = "coin", count = coin_earnings[event.entity.name]}, true)
reward_has_been_given = true
end
end
end
if reward_has_been_given == false and coin_earnings[event.entity.name] then
event.entity.surface.spill_item_stack(event.entity.position,{name = "coin", count = coin_earnings[event.entity.name]}, true)
end
if event.entity.name == "biter-spawner" or event.entity.name == "spitter-spawner" then
local e = math.ceil(game.forces.enemy.evolution_factor*10, 0)
for _, t in pairs (biter_building_inhabitants[e]) do
for x = 1, math.random(t[2],t[3]), 1 do
local p = event.entity.surface.find_non_colliding_position(t[1] , event.entity.position, 6, 1)
if p then event.entity.surface.create_entity {name=t[1], position=p} end
end
end
end
if event.entity.force.name == "enemy" then
if event.entity.name == "medium-biter" then
event.entity.surface.create_entity({name = "explosion", position = event.entity.position})

View File

@ -7,11 +7,11 @@ local coin_yield = {
["small-biter"] = 1,
["medium-biter"] = 2,
["big-biter"] = 3,
["behemoth-biter"] = 4,
["behemoth-biter"] = 5,
["small-spitter"] = 1,
["medium-spitter"] = 2,
["big-spitter"] = 3,
["behemoth-spitter"] = 4,
["behemoth-spitter"] = 5,
["spitter-spawner"] = 32,
["biter-spawner"] = 32,
["small-worm-turret"] = 8,

View File

@ -121,6 +121,7 @@ end
local function on_entity_damaged(event)
local entity = event.entity
if not entity.valid then return end
if not entity.health then return end
if entity.health > entity.prototype.max_health * 0.75 then return end

View File

@ -212,8 +212,19 @@ local function clear_corpses(surface)
end
end
local spawner_search_areas = {
[1] = {{0, -10000},{10000, 0}},
[2] = {{0, 0},{10000, 10000}},
[3] = {{-10000, 0},{0, -10000}},
[4] = {{-10000, -10000},{0, 0}}
}
local function send_attack_group(surface)
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
if not global.area_rotation then global.area_rotation = 0 end
global.area_rotation = global.area_rotation + 1
if global.area_rotation > 4 then global.area_rotation = 1 end
local spawners = surface.find_entities_filtered({type = "unit-spawner", area = spawner_search_areas[global.area_rotation]})
if not spawners[1] then return end
local spawner = spawners[math_random(1, #spawners)]
@ -228,7 +239,7 @@ local function send_attack_group(surface)
local unit_group = surface.create_unit_group({position=pos, force="enemy"})
local group_size = 4 + (global.night_count * 4)
local group_size = 8 + (global.night_count * 8)
if group_size > 200 then group_size = 200 end
for i = 1, group_size, 1 do
@ -270,19 +281,30 @@ local function send_attack_group(surface)
end
end
local daytime_messages = {
"It´s daytime!",
"The sun is rising, they are calming down."
}
local function set_daytime_modifiers(surface)
if surface.peaceful_mode == true then return end
if game.map_settings.enemy_expansion.enabled == false then return end
game.map_settings.enemy_expansion.enabled = false
surface.peaceful_mode = true
game.print("It´s daytime!", {r = 255, g = 255, b = 50})
game.print(daytime_messages[math_random(1, #daytime_messages)], {r = 255, g = 255, b = 50})
clear_corpses(surface)
end
local nightfall_messages = {
"Night is falling.",
"It is getting dark.",
"They are becoming restless."
}
local function set_nighttime_modifiers(surface)
if surface.peaceful_mode == false then return end
if game.map_settings.enemy_expansion.enabled == true then return end
if not global.night_count then
global.night_count = 1
@ -322,7 +344,7 @@ local function set_nighttime_modifiers(surface)
if max_expansion_cooldown < 1800 then max_expansion_cooldown = 1800 end
game.map_settings.enemy_expansion.max_expansion_cooldown = max_expansion_cooldown
game.print("Night is falling!", {r = 150, g = 0, b = 0})
game.print(nightfall_messages[math_random(1, #nightfall_messages)], {r = 150, g = 0, b = 0})
end
local function generate_spawn_area(surface)
@ -441,7 +463,7 @@ local function on_tick(event)
local surface = game.surfaces["nightfall"]
if surface.daytime > 0.25 and surface.daytime < 0.75 then
set_nighttime_modifiers(surface)
if surface.daytime < 0.55 then
if surface.daytime < 0.65 then
send_attack_group(surface)
end
else
@ -494,12 +516,14 @@ local function on_player_joined_game(event)
game.create_surface("nightfall", map_gen_settings)
local surface = game.surfaces["nightfall"]
surface.ticks_per_day = surface.ticks_per_day * 3
local radius = 512
game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})
--game.map_settings.enemy_evolution.destroy_factor = 0
--game.map_settings.enemy_evolution.time_factor = 0
--game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.destroy_factor = 0.004
game.map_settings.enemy_evolution.time_factor = 0.000008
game.map_settings.enemy_evolution.pollution_factor = 0.00003
game.forces.player.set_ammo_damage_modifier("shotgun-shell", 1)

View File

@ -1,7 +1,7 @@
local event = require 'utils.event'
local main_caption = " --Nightfall-- "
local sub_caption = "*something is lurking in the dark*"
local sub_caption = "*can you make it through the night*"
local info = [[
They come out at night.
Trying to nom your rocket silo.
@ -12,7 +12,7 @@ local info = [[
There seem to be shipwrecks of misfortunate explorers all over this place.
It might be worth scavenging a few.
The wreck loot quality increases with distance.
Wreck loot quality increases with distance.
]]
local function create_map_intro(player)