Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
new modules
Browse files Browse the repository at this point in the history
  • Loading branch information
MewMew committed Feb 19, 2019
1 parent 1b6e092 commit 4ed364f
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 102 deletions.
4 changes: 2 additions & 2 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require "score"
-----------------------------

---- enable maps here ----
require "maps.biter_battles"
--require "maps.biter_battles"
--require "maps.cave_miner"
--require "maps.labyrinth"
--require "maps.spooky_forest"
Expand All @@ -39,7 +39,7 @@ require "maps.biter_battles"
--require "maps.tank_battles"
--require "maps.spiral_troopers"
--require "maps.fish_defender"
--require "maps.mountain_fortress"
require "maps.mountain_fortress"
--require "maps.stoneblock"
--require "maps.deep_jungle"
--require "maps.crossing"
Expand Down
30 changes: 28 additions & 2 deletions maps/biter_battles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,30 @@ local function clear_corpses()
end
end

local function send_near_biter_to_silo()
game.surfaces["surface"].set_multi_command({
command={
type=defines.command.attack,
target=global.rocket_silo["north"],
distraction=defines.distraction.none
},
unit_count = 8,
force = "enemy",
unit_search_distance=64
})

game.surfaces["surface"].set_multi_command({
command={
type=defines.command.attack,
target=global.rocket_silo["south"],
distraction=defines.distraction.none
},
unit_count = 8,
force = "enemy",
unit_search_distance=64
})
end

local function on_tick(event)

if global.rocket_silo_destroyed then
Expand Down Expand Up @@ -1148,7 +1172,8 @@ local function on_tick(event)
local c = math.round(global.biter_rage["north"], 0)
if c > 999 then c = 999 end
biter_attack_silo("north", c)
end
end
send_near_biter_to_silo()
refresh_gui()
return
end
Expand All @@ -1157,7 +1182,8 @@ local function on_tick(event)
local c = math.round(global.biter_rage["south"], 0)
if c > 999 then c = 999 end
biter_attack_silo("south", c)
end
end
send_near_biter_to_silo()
refresh_gui()
return
end
Expand Down
47 changes: 14 additions & 33 deletions maps/fish_defender.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- fish defender -- by mewmew --

local event = require 'utils.event'
require "maps.fish_defender_map_intro"
require "maps.modules.rocket_launch_always_yields_science"
require "maps.modules.launch_fish_to_win"
Expand All @@ -10,7 +9,11 @@ require "maps.modules.dynamic_landfill"
require "maps.modules.teleporting_worms"
require "maps.modules.custom_death_messages"
require "maps.modules.splice_double"
require "maps.modules.spitters_spit_biters"
require "maps.modules.biters_double_hp"
require "maps.modules.custom_death_messages"

local event = require 'utils.event'
local map_functions = require "maps.tools.map_functions"
local math_random = math.random
local insert = table.insert
Expand Down Expand Up @@ -528,7 +531,14 @@ local function biter_attack_wave()
else
global.wave_count = global.wave_count + 1
end


local modifier = 0.003
game.forces.enemy.set_ammo_damage_modifier("melee", global.wave_count * modifier)
game.forces.enemy.set_ammo_damage_modifier("biological", global.wave_count * modifier)
game.forces.enemy.set_ammo_damage_modifier("artillery-shell", global.wave_count * modifier)
game.forces.enemy.set_ammo_damage_modifier("flamethrower", global.wave_count * modifier)
game.forces.enemy.set_ammo_damage_modifier("laser-turret", global.wave_count * modifier)

if global.wave_count % 50 == 0 then
global.attack_wave_threat = global.wave_count * 6
spawn_boss_units(surface)
Expand All @@ -545,7 +555,7 @@ local function biter_attack_wave()
if game.forces.enemy.evolution_factor == 1 then
if not global.endgame_modifier then
global.endgame_modifier = 1
game.print("Endgame enemy evolution reached. Biter damage is rising...", {r = 0.7, g = 0.1, b = 0.1})
game.print("Endgame enemy evolution reached.", {r = 0.7, g = 0.1, b = 0.1})
else
global.endgame_modifier = global.endgame_modifier + 1
end
Expand Down Expand Up @@ -901,36 +911,7 @@ local function on_entity_died(event)
end
end

local function on_entity_damaged(event)
if event.cause then
if event.cause.valid then
if event.cause.name == "big-spitter" then
local surface = event.cause.surface
local area = {{event.entity.position.x - 3, event.entity.position.y - 3}, {event.entity.position.x + 3, event.entity.position.y + 3}}
if surface.count_entities_filtered({area = area, name = "small-biter", limit = 3}) < 3 then
local pos = surface.find_non_colliding_position("small-biter", event.entity.position, 4, 0.5)
if pos then surface.create_entity({name = "small-biter", position = pos}) end
end
end

if event.cause.name == "behemoth-spitter" then
local surface = event.cause.surface
local area = {{event.entity.position.x - 3, event.entity.position.y - 3}, {event.entity.position.x + 3, event.entity.position.y + 3}}
if surface.count_entities_filtered({area = area, name = "medium-biter", limit = 3}) < 3 then
local pos = surface.find_non_colliding_position("medium-biter", event.entity.position, 4, 0.5)
if pos then surface.create_entity({name = "medium-biter", position = pos}) end
end
end

if event.cause.force.name == "enemy" then
if global.endgame_modifier then
event.entity.health = event.entity.health - (event.final_damage_amount * global.endgame_modifier * 0.002)
if event.entity.health <= 0 then event.entity.die() end
end
end
end
end

local function on_entity_damaged(event)
if event.entity.valid then
if event.entity.name == "market" then
if event.cause then
Expand Down
2 changes: 1 addition & 1 deletion maps/modules/biters_double_hp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local event = require 'utils.event'
local function on_entity_damaged(event)
if not event.entity.valid then return end
if math.random(1,2) == 1 then return end
if event.entity.force.name ~= "enemy" then return end
if event.entity.type ~= "unit" then return end
event.entity.health = event.entity.health + event.final_damage_amount
end

Expand Down
2 changes: 1 addition & 1 deletion maps/modules/rocks_broken_paint_tiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ local function on_player_mined_entity(event)
local pos = {x = entity.position.x + p.x, y = entity.position.y + p.y}
local tile = entity.surface.get_tile(pos)
if not tile.collides_with("player-layer") then
if replacement_tiles[tile.name] and math_random(1,3) ~= 1 then
if replacement_tiles[tile.name] and math_random(1,3) == 1 then
insert(tiles, {name = replacement_tiles[tile.name], position = pos})
end
end
Expand Down
2 changes: 1 addition & 1 deletion maps/modules/rocks_heal_over_time.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local healing_amount = {

local function heal_rocks()
for key, rock in pairs(global.damaged_rocks) do
if rock.last_damage + 3600 < game.tick then
if rock.last_damage + 54000 < game.tick then
if rock.entity then
if rock.entity.valid then
rock.entity.health = rock.entity.health + healing_amount[rock.entity.name]
Expand Down
46 changes: 0 additions & 46 deletions maps/modules/sushi.lua

This file was deleted.

47 changes: 37 additions & 10 deletions maps/mountain_fortress.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
-- mountain digger fortress -- by mewmew --

require "maps.modules.satellite_score"
require "maps.modules.backpack_research"
require "maps.modules.biters_double_damage"
require "maps.modules.biters_double_hp"
require "maps.modules.biters_yield_coins"
require "maps.modules.dynamic_landfill"
require "maps.modules.dynamic_player_spawn"
require "maps.modules.backpack_research"
require "maps.modules.explosive_biters"
require "maps.modules.rocks_broken_paint_tiles"
require "maps.modules.rocks_heal_over_time"
require "maps.modules.rocks_yield_ore_veins"
require "maps.modules.rocks_yield_ore"
require "maps.modules.biters_yield_coins"
require "maps.modules.explosive_biters"
require "maps.modules.satellite_score"
require "maps.modules.spawners_contain_biters"
require "maps.modules.spitters_spit_biters"
require "maps.modules.splice_double"

local event = require 'utils.event'
Expand Down Expand Up @@ -130,14 +134,14 @@ local function on_player_joined_game(event)

game.map_settings.pollution.enabled = true
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_evolution.destroy_factor = 0.004
game.map_settings.enemy_evolution.destroy_factor = 0.005
game.map_settings.enemy_evolution.time_factor = 0.00002
game.map_settings.enemy_evolution.pollution_factor = 0.00003
game.map_settings.enemy_evolution.pollution_factor = 0.00004
game.map_settings.enemy_expansion.max_expansion_distance = 15
game.map_settings.enemy_expansion.settler_group_min_size = 15
game.map_settings.enemy_expansion.settler_group_max_size = 30
game.map_settings.enemy_expansion.min_expansion_cooldown = 1800
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
game.map_settings.enemy_expansion.settler_group_min_size = 8
game.map_settings.enemy_expansion.settler_group_max_size = 16
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
game.map_settings.enemy_expansion.max_expansion_cooldown = 7200

surface.ticks_per_day = surface.ticks_per_day * 2
game.forces.player.manual_mining_speed_modifier = 1.75
Expand Down Expand Up @@ -438,6 +442,29 @@ local function on_marked_for_deconstruction(event)
end
end

local function on_tick(event)
if game.tick % 3600 ~= 1 then return end
if math_random(1,8) ~= 1 then return end

local surface = game.surfaces["mountain_fortress"]
local target = surface.find_entities_filtered({force = "player"})
if not target[1] then return end
target = target[math_random(1, #target)]

surface.set_multi_command({
command={
type=defines.command.attack_area,
destination=target.position,
radius=16,
distraction=defines.distraction.by_anything
},
unit_count = math_random(6,10),
force = "enemy",
unit_search_distance=1024
})
end

event.add(defines.events.on_tick, on_tick)
event.add(defines.events.on_chunk_charted, on_chunk_charted)
event.add(defines.events.on_entity_damaged, on_entity_damaged)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
Expand Down
19 changes: 13 additions & 6 deletions maps/stoneblock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require "maps.modules.splice_double"
require "maps.modules.spitters_spit_biters"
require "maps.modules.biters_double_hp"
require "maps.modules.biters_double_damage"
require "maps.modules.flashlight_toggle_button"

local event = require 'utils.event'
local math_random = math.random
Expand Down Expand Up @@ -69,12 +70,15 @@ local function secret_shop(pos, surface)
{price = {{"coin", math_random(300,500)}}, offer = {type = 'give-item', item = 'express-loader'}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{"coin", math_random(75,150)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"coin", math_random(2,4)}}, offer = {type = 'give-item', item = 'rail'}},
{price = {{"coin", math_random(20,40)}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"coin", math_random(2,3)}}, offer = {type = 'give-item', item = 'rail'}},
--{price = {{"coin", math_random(20,40)}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"coin", math_random(4,12)}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'car'}},
{price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = 'electric-furnace'}},
{price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = "assembling-machine-3"}},
--{price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = "assembling-machine-3"}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'effectivity-module'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'productivity-module'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'speed-module'}},

{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'raw-wood', count = 50}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
Expand All @@ -95,7 +99,7 @@ local function secret_shop(pos, surface)
local market = surface.create_entity {name = "market", position = pos}
market.destructible = false

for i = 1, math.random(6, 8), 1 do
for i = 1, math.random(8, 10), 1 do
market.add_market_item(secret_market_items[i])
end
end
Expand Down Expand Up @@ -135,10 +139,13 @@ local function on_player_joined_game(event)
game.map_settings.enemy_expansion.max_expansion_distance = 15
game.map_settings.enemy_expansion.settler_group_min_size = 15
game.map_settings.enemy_expansion.settler_group_max_size = 30
game.map_settings.enemy_expansion.min_expansion_cooldown = 1800
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
game.map_settings.enemy_expansion.min_expansion_cooldown = 7200
game.map_settings.enemy_expansion.max_expansion_cooldown = 10800

surface.ticks_per_day = surface.ticks_per_day * 2
surface.daytime = 0.5
surface.freeze_daytime = 1

game.forces.player.manual_mining_speed_modifier = 1.75

global.surface_init_done = true
Expand Down

0 comments on commit 4ed364f

Please sign in to comment.