mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-07 13:31:40 +02:00
updates
This commit is contained in:
parent
cf6dc2283c
commit
b3def1c10b
@ -883,7 +883,9 @@ local function on_player_joined_game(event)
|
||||
is_game_lost()
|
||||
end
|
||||
|
||||
if game.tick < 5 then game.forces.player.chart(game.surfaces["fish_defender"], {{-256, -512},{768, 512}}) end
|
||||
if global.charting_done then return end
|
||||
game.forces.player.chart(game.surfaces["fish_defender"], {{-256, -512},{768, 512}})
|
||||
global.charting_done = true
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
|
@ -302,6 +302,11 @@ local function process_chunk(left_top)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if game.tick == 0 then return end
|
||||
if game.forces.player.is_chunk_charted(surface, {left_top.x / 32, left_top.y / 32}) then
|
||||
game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}})
|
||||
end
|
||||
end
|
||||
|
||||
local function process_chunk_queue()
|
||||
@ -324,5 +329,5 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_nth_tick(16, process_chunk_queue)
|
||||
event.on_nth_tick(30, process_chunk_queue)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
74
maps/fish_defender_v1/boss_biters.lua
Normal file
74
maps/fish_defender_v1/boss_biters.lua
Normal file
@ -0,0 +1,74 @@
|
||||
local boss_biter = {}
|
||||
local math_random = math.random
|
||||
local radius = 6
|
||||
local targets = {}
|
||||
local acid_splashes = {
|
||||
["big-biter"] = "acid-stream-worm-medium",
|
||||
["behemoth-biter"] = "acid-stream-worm-big"
|
||||
}
|
||||
local acid_lines = {
|
||||
["big-spitter"] = "acid-stream-spitter-medium",
|
||||
["behemoth-spitter"] = "acid-stream-spitter-big"
|
||||
}
|
||||
for x = radius * -1, radius, 1 do
|
||||
for y = radius * -1, radius, 1 do
|
||||
if math.sqrt(x^2 + y^2) <= radius then
|
||||
targets[#targets + 1] = {x = x, y = y}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function acid_nova(event)
|
||||
for _ = 1, math.random(20, 40) do
|
||||
local i = math.random(1, #targets)
|
||||
event.entity.surface.create_entity({
|
||||
name = acid_splashes[event.entity.name],
|
||||
position = event.entity.position,
|
||||
force = event.entity.force.name,
|
||||
source = event.entity.position,
|
||||
target = {x = event.entity.position.x + targets[i].x, y = event.entity.position.y + targets[i].y},
|
||||
max_range = radius,
|
||||
speed = 0.001
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
boss_biter.died = function(event)
|
||||
if acid_splashes[event.entity.name] then acid_nova(event) end
|
||||
if global.acid_lines_delay[event.entity.unit_number] then global.acid_lines_delay[event.entity.unit_number] = nil end
|
||||
global.boss_biters[event.entity.unit_number] = nil
|
||||
end
|
||||
|
||||
local function acid_line(surface, name, source, target)
|
||||
local distance = math.sqrt((source.x - target.x) ^ 2 + (source.y - target.y) ^ 2)
|
||||
local modifier = {(target.x - source.x) / distance, (target.y - source.y) / distance}
|
||||
|
||||
local position = {source.x, source.y}
|
||||
|
||||
for i = 1, distance * 1.5, 1 do
|
||||
if math_random(1,2) ~= 1 then
|
||||
surface.create_entity({
|
||||
name = name,
|
||||
position = source,
|
||||
force = "enemy",
|
||||
source = source,
|
||||
target = position,
|
||||
max_range = 25,
|
||||
speed = 1
|
||||
})
|
||||
end
|
||||
position = {position[1] + modifier[1], position[2] + modifier[2]}
|
||||
end
|
||||
end
|
||||
|
||||
boss_biter.damaged_entity = function(event)
|
||||
if acid_lines[event.cause.name] then
|
||||
if not global.acid_lines_delay[event.cause.unit_number] then global.acid_lines_delay[event.cause.unit_number] = 0 end
|
||||
if global.acid_lines_delay[event.cause.unit_number] < game.tick then
|
||||
acid_line(event.cause.surface, acid_lines[event.cause.name], event.cause.position, event.entity.position)
|
||||
global.acid_lines_delay[event.cause.unit_number] = game.tick + 180
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return boss_biter
|
63
maps/fish_defender_v1/bouncy_shells.lua
Normal file
63
maps/fish_defender_v1/bouncy_shells.lua
Normal file
@ -0,0 +1,63 @@
|
||||
local radius = 9
|
||||
local math_random = math.random
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local ammo_to_projectile_translation = {
|
||||
["shotgun-shell"] = "shotgun-pellet",
|
||||
["piercing-shotgun-shell"] = "piercing-shotgun-pellet"
|
||||
}
|
||||
|
||||
local function create_projectile(surface, position, target, name)
|
||||
surface.create_entity({
|
||||
name = name,
|
||||
position = position,
|
||||
force = force,
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = 16,
|
||||
speed = 0.3
|
||||
})
|
||||
end
|
||||
|
||||
local function bounce(surface, position, ammo)
|
||||
if math_random(1,3) ~= 1 then return end
|
||||
local valid_entities = {}
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}})) do
|
||||
if e.health then
|
||||
if e.force.name ~= "player" then
|
||||
--local distance_from_center = math_sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
--if distance_from_center <= radius then
|
||||
valid_entities[#valid_entities + 1] = e
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not valid_entities[1] then return end
|
||||
|
||||
for c = 1, math_random(3,6), 1 do
|
||||
create_projectile(surface, position, valid_entities[math_random(1, #valid_entities)].position, ammo)
|
||||
end
|
||||
end
|
||||
|
||||
local function bouncy_shells(event)
|
||||
if event.damage_type.name ~= "physical" then return false end
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then return false end
|
||||
local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index]
|
||||
if selected_weapon.name ~= "combat-shotgun" and selected_weapon.name ~= "shotgun" then return false end
|
||||
|
||||
local selected_ammo = player.get_inventory(defines.inventory.character_ammo)[player.selected_gun_index]
|
||||
if not selected_ammo then return end
|
||||
if not ammo_to_projectile_translation[selected_ammo.name] then return end
|
||||
|
||||
bounce(
|
||||
player.surface,
|
||||
event.entity.position,
|
||||
ammo_to_projectile_translation[selected_ammo.name]
|
||||
)
|
||||
end
|
||||
|
||||
return bouncy_shells
|
||||
|
||||
|
15
maps/fish_defender_v1/crumbly_walls.lua
Normal file
15
maps/fish_defender_v1/crumbly_walls.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local rock_raffle = {"sand-rock-big", "rock-big", "rock-big", "rock-big", "rock-huge"}
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not global.crumbly_walls_unlocked then return end
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.name ~= "stone-wall" then return end
|
||||
if math_random(1,4) == 1 then return end
|
||||
entity.surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = entity.position, force = "player"})
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
36
maps/fish_defender_v1/explosive_gun_bullets.lua
Normal file
36
maps/fish_defender_v1/explosive_gun_bullets.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local radius = 3
|
||||
|
||||
local function splash_damage(surface, position, final_damage_amount)
|
||||
local damage = math.random(math.floor(final_damage_amount * 3), math.floor(final_damage_amount * 4))
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}})) do
|
||||
if e.valid and e.health then
|
||||
local distance_from_center = math.sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
local damage_distance_modifier = 1 - distance_from_center / radius
|
||||
if damage > 0 then
|
||||
if math.random(1, 3) == 1 then surface.create_entity({name = "explosion", position = e.position}) end
|
||||
e.damage(damage * damage_distance_modifier, "player", "explosion")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function explosive_bullets(event)
|
||||
if math.random(1, 3) ~= 1 then return false end
|
||||
if event.damage_type.name ~= "physical" then return false end
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then return false end
|
||||
local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index]
|
||||
if selected_weapon.name ~= "submachine-gun" and selected_weapon.name ~= "pistol" then return false end
|
||||
|
||||
player.surface.create_entity({name = "explosion", position = event.entity.position})
|
||||
|
||||
splash_damage(
|
||||
player.surface,
|
||||
event.entity.position,
|
||||
event.final_damage_amount
|
||||
)
|
||||
end
|
||||
|
||||
return explosive_bullets
|
1453
maps/fish_defender_v1/fish_defender.lua
Normal file
1453
maps/fish_defender_v1/fish_defender.lua
Normal file
File diff suppressed because it is too large
Load Diff
40
maps/fish_defender_v1/flame_boots.lua
Normal file
40
maps/fish_defender_v1/flame_boots.lua
Normal file
@ -0,0 +1,40 @@
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
if not global.flame_boots then return end
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
if player.character.driving then return end
|
||||
|
||||
if not global.flame_boots[player.index] then global.flame_boots[player.index] = {} end
|
||||
|
||||
if not global.flame_boots[player.index].fuel then return end
|
||||
|
||||
if global.flame_boots[player.index].fuel < 0 then
|
||||
player.print("Your flame boots have worn out.", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.flame_boots[player.index] = {}
|
||||
return
|
||||
end
|
||||
|
||||
if global.flame_boots[player.index].fuel % 500 == 0 then player.print("Fuel remaining: " .. global.flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44}) end
|
||||
|
||||
if not global.flame_boots[player.index].step_history then global.flame_boots[player.index].step_history = {} end
|
||||
|
||||
local elements = #global.flame_boots[player.index].step_history
|
||||
|
||||
global.flame_boots[player.index].step_history[elements + 1] = {x = player.position.x, y = player.position.y}
|
||||
|
||||
if elements < 50 then return end
|
||||
|
||||
player.surface.create_entity({name = "fire-flame", position = global.flame_boots[player.index].step_history[elements - 2]})
|
||||
|
||||
global.flame_boots[player.index].fuel = global.flame_boots[player.index].fuel - 1
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
if not global.flame_boots then global.flame_boots = {} end
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
31
maps/fish_defender_v1/laser_pointer.lua
Normal file
31
maps/fish_defender_v1/laser_pointer.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local event = require 'utils.event'
|
||||
local radius = 32
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
if not global.laser_pointer_unlocked then return end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
local position = event.position
|
||||
local used_item = event.item
|
||||
if used_item.name ~= "artillery-targeting-remote" then return end
|
||||
|
||||
for _, unit in pairs(player.surface.find_enemy_units(position, radius, "player")) do
|
||||
if math.random(1,2) == 1 then
|
||||
unit.set_command({
|
||||
type = defines.command.go_to_location,
|
||||
destination = position,
|
||||
radius = 2,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = false
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
||||
|
||||
|
97
maps/fish_defender_v1/map_intro.lua
Normal file
97
maps/fish_defender_v1/map_intro.lua
Normal file
@ -0,0 +1,97 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local main_caption = " --Fish Defender-- "
|
||||
local sub_caption = " *blb blubby blub* "
|
||||
local info = [[
|
||||
The biters have catched the scent of fish in the market.
|
||||
Fend them off as long as possible!
|
||||
This however will not be an easy task,
|
||||
since their strength and resistance increases constantly over time.
|
||||
|
||||
Your ultimate goal is to evacuate all the fish to cat planet!
|
||||
Put them in your rocket's cargo and launch them into space.
|
||||
Don't worry, you will still get space science.
|
||||
|
||||
The Market will gladly take any coin you might find.
|
||||
Additional turret slots can be bought at the market.
|
||||
Several unique upgrades are available too.
|
||||
|
||||
Researching tanks will unlock the artillery technology early.
|
||||
|
||||
Any container bearing dangerous goods, like ammo, grenades or barrels,
|
||||
causes heavy explosions when it breaks.
|
||||
Maybe this can be used to our advantage.
|
||||
]]
|
||||
|
||||
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.11, g=0.8, b=0.44}
|
||||
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 tt = t.add {type = "table", column_count = 3}
|
||||
local l = tt.add {type = "label", caption = main_caption}
|
||||
l.style.font = "heading-1"
|
||||
l.style.font_color = {r=0.11, g=0.8, b=0.44}
|
||||
|
||||
local l = tt.add {type = "label", caption = sub_caption}
|
||||
l.style.font = "heading-2"
|
||||
l.style.font_color = {r=0.33, g=0.66, b=0.9}
|
||||
l.style.minimal_width = 320
|
||||
|
||||
local b = tt.add {type = "button", caption = "X", name = "close_map_intro_frame", align = "right"}
|
||||
b.style.font = "heading-2"
|
||||
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 tt = t.add {type = "table", column_count = 1}
|
||||
local frame = t.add {type = "frame"}
|
||||
local l = frame.add {type = "label", caption = info}
|
||||
l.style.single_line = false
|
||||
l.style.font = "heading-2"
|
||||
l.style.font_color = {r=0.75, g=0.8, b=0.8}
|
||||
l.style.minimal_width = 480
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
264
maps/fish_defender_v1/market.lua
Normal file
264
maps/fish_defender_v1/market.lua
Normal file
@ -0,0 +1,264 @@
|
||||
require 'maps.fish_defender.flame_boots'
|
||||
require 'maps.fish_defender.trapped_capsules'
|
||||
require 'maps.fish_defender.ultra_mines'
|
||||
require 'maps.fish_defender.crumbly_walls'
|
||||
require 'maps.fish_defender.vehicle_nanobots'
|
||||
require 'maps.fish_defender.laser_pointer'
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
||||
local slot_upgrade_offers = {
|
||||
[1] = {"gun-turret", "gun turret"},
|
||||
[2] = {"laser-turret", "laser turret"},
|
||||
[3] = {"artillery-turret", "artillery turret"},
|
||||
[4] = {"flamethrower-turret", "flamethrower turret"},
|
||||
[5] = {"land-mine", "land mine"}
|
||||
}
|
||||
|
||||
local special_descriptions = {
|
||||
["flame-boots"] = "Flame Boots - Get yourself some hot boots.",
|
||||
["explosive-bullets"] = "Unlock Explosive Bullets - Submachine-Gun and Pistol gains a chance to deal splash damage.",
|
||||
["bouncy-shells"] = "Unlock Bouncy Shells - Shotgun projectiles may bounce to multiple targets.",
|
||||
["trapped-capsules"] = "Unlock Trapped Capsules - Combat robots will send a last deadly projectile to a nearby enemy when killed.",
|
||||
["ultra-mines"] = "Unlock Ultra Mines - Careful with these...",
|
||||
["railgun-enhancer"] = "Unlock Railgun Enhancer - Turns the railgun into a powerful forking gun.",
|
||||
["crumbly-walls"] = "Unlock Crumbly Walls - Fortifications which crumble, may turn into rocks.",
|
||||
["vehicle-nanobots"] = "Unlock Vehicle Nanobots - Vehicles repair rapidly while driving.",
|
||||
["laser-pointer"] = "Unlock Laser Pointer - The biters are on a quest to slay the red (artillery) dot."
|
||||
}
|
||||
|
||||
function place_fish_market(surface, position)
|
||||
local market = surface.create_entity({name = "market", position = position, force = "player"})
|
||||
market.minable = false
|
||||
return market
|
||||
end
|
||||
|
||||
local function refresh_market_offers()
|
||||
if not global.market then return end
|
||||
for i = 1, 100, 1 do
|
||||
local a = global.market.remove_market_item(1)
|
||||
if a == false then break end
|
||||
end
|
||||
|
||||
local str1 = "Gun Turret Slot for " .. tostring(global.entity_limits["gun-turret"].limit * global.entity_limits["gun-turret"].slot_price)
|
||||
str1 = str1 .. " Coins."
|
||||
|
||||
local str2 = "Laser Turret Slot for " .. tostring(global.entity_limits["laser-turret"].limit * global.entity_limits["laser-turret"].slot_price)
|
||||
str2 = str2 .. " Coins."
|
||||
|
||||
local str3 = "Artillery Slot for " .. tostring(global.entity_limits["artillery-turret"].limit * global.entity_limits["artillery-turret"].slot_price)
|
||||
str3 = str3 .. " Coins."
|
||||
|
||||
local current_limit = 1
|
||||
if global.entity_limits["flamethrower-turret"].limit ~= 0 then current_limit = current_limit + global.entity_limits["flamethrower-turret"].limit end
|
||||
local str4 = "Flamethrower Turret Slot for " .. tostring(current_limit * global.entity_limits["flamethrower-turret"].slot_price)
|
||||
str4 = str4 .. " Coins."
|
||||
|
||||
local str5 = "Landmine Slot for " .. tostring(math.ceil((global.entity_limits["land-mine"].limit / 3) * global.entity_limits["land-mine"].slot_price))
|
||||
str5 = str5 .. " Coins."
|
||||
|
||||
local market_items = {
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str1}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str2}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str3}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str4}},
|
||||
{price = {}, offer = {type = 'nothing', effect_description = str5}},
|
||||
{price = {{"coin", 5}}, offer = {type = 'give-item', item = "raw-fish", count = 1}},
|
||||
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'wood', count = 8}},
|
||||
{price = {{"coin", 8}}, offer = {type = 'give-item', item = 'grenade', count = 1}},
|
||||
{price = {{"coin", 32}}, offer = {type = 'give-item', item = 'cluster-grenade', count = 1}},
|
||||
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'land-mine', count = 1}},
|
||||
{price = {{"coin", 80}}, offer = {type = 'give-item', item = 'car', count = 1}},
|
||||
{price = {{"coin", 1200}}, offer = {type = 'give-item', item = 'tank', count = 1}},
|
||||
{price = {{"coin", 3}}, offer = {type = 'give-item', item = 'cannon-shell', count = 1}},
|
||||
{price = {{"coin", 7}}, offer = {type = 'give-item', item = 'explosive-cannon-shell', count = 1}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'gun-turret', count = 1}},
|
||||
{price = {{"coin", 300}}, offer = {type = 'give-item', item = 'laser-turret', count = 1}},
|
||||
{price = {{"coin", 450}}, offer = {type = 'give-item', item = 'artillery-turret', count = 1}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'artillery-shell', count = 1}},
|
||||
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
|
||||
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'firearm-magazine', count = 1}},
|
||||
{price = {{"coin", 4}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine', count = 1}},
|
||||
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'shotgun-shell', count = 1}},
|
||||
{price = {{"coin", 6}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell', count = 1}},
|
||||
{price = {{"coin", 30}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}},
|
||||
{price = {{"coin", 250}}, offer = {type = 'give-item', item = 'combat-shotgun', count = 1}},
|
||||
{price = {{"coin", 450}}, offer = {type = 'give-item', item = 'flamethrower', count = 1}},
|
||||
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 1}},
|
||||
{price = {{"coin", 125}}, offer = {type = 'give-item', item = 'rocket-launcher', count = 1}},
|
||||
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'rocket', count = 1}},
|
||||
{price = {{"coin", 7}}, offer = {type = 'give-item', item = 'explosive-rocket', count = 1}},
|
||||
{price = {{"coin", 7500}}, offer = {type = 'give-item', item = 'atomic-bomb', count = 1}},
|
||||
{price = {{"coin", 325}}, offer = {type = 'give-item', item = 'railgun', count = 1}},
|
||||
{price = {{"coin", 8}}, offer = {type = 'give-item', item = 'railgun-dart', count = 1}},
|
||||
{price = {{"coin", 40}}, offer = {type = 'give-item', item = 'poison-capsule', count = 1}},
|
||||
{price = {{"coin", 4}}, offer = {type = 'give-item', item = 'defender-capsule', count = 1}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'light-armor', count = 1}},
|
||||
{price = {{"coin", 125}}, offer = {type = 'give-item', item = 'heavy-armor', count = 1}},
|
||||
{price = {{"coin", 350}}, offer = {type = 'give-item', item = 'modular-armor', count = 1}},
|
||||
{price = {{"coin", 1500}}, offer = {type = 'give-item', item = 'power-armor', count = 1}},
|
||||
{price = {{"coin", 12000}}, offer = {type = 'give-item', item = 'power-armor-mk2', count = 1}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
|
||||
{price = {{"coin", 2250}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment', count = 1}},
|
||||
{price = {{"coin", 100}}, offer = {type = 'give-item', item = 'battery-equipment', count = 1}},
|
||||
{price = {{"coin", 200}}, offer = {type = 'give-item', item = 'energy-shield-equipment', count = 1}},
|
||||
{price = {{"coin", 850}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment', count = 1}},
|
||||
{price = {{"coin", 175}}, offer = {type = 'give-item', item = 'exoskeleton-equipment', count = 1}},
|
||||
{price = {{"coin", 125}}, offer = {type = 'give-item', item = 'night-vision-equipment', count = 1}},
|
||||
{price = {{"coin", 200}}, offer = {type = 'give-item', item = 'belt-immunity-equipment', count = 1}},
|
||||
{price = {{"coin", 250}}, offer = {type = 'give-item', item = 'personal-roboport-equipment', count = 1}},
|
||||
{price = {{"coin", 35}}, offer = {type = 'give-item', item = 'construction-robot', count = 1}},
|
||||
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'cliff-explosives', count = 1}},
|
||||
{price = {{"coin", 80}}, offer = {type = 'nothing', effect_description = special_descriptions["flame-boots"]}}
|
||||
}
|
||||
|
||||
for _, item in pairs(market_items) do
|
||||
global.market.add_market_item(item)
|
||||
end
|
||||
|
||||
if not global.railgun_enhancer_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 1500}}, offer = {type = 'nothing', effect_description = special_descriptions["railgun-enhancer"]}})
|
||||
end
|
||||
if not global.trapped_capsules_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 3500}}, offer = {type = 'nothing', effect_description = special_descriptions["trapped-capsules"]}})
|
||||
end
|
||||
if not global.explosive_bullets_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 4500}}, offer = {type = 'nothing', effect_description = special_descriptions["explosive-bullets"]}})
|
||||
end
|
||||
if not global.bouncy_shells_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 10000}}, offer = {type = 'nothing', effect_description = special_descriptions["bouncy-shells"]}})
|
||||
end
|
||||
if not global.vehicle_nanobots_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 15000}}, offer = {type = 'nothing', effect_description = special_descriptions["vehicle-nanobots"]}})
|
||||
end
|
||||
if not global.crumbly_walls_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 35000}}, offer = {type = 'nothing', effect_description = special_descriptions["crumbly-walls"]}})
|
||||
end
|
||||
if not global.ultra_mines_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 45000}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
|
||||
end
|
||||
if not global.laser_pointer_unlocked then
|
||||
global.market.add_market_item({price = {{"coin", 65000}}, offer = {type = 'nothing', effect_description = special_descriptions["laser-pointer"]}})
|
||||
end
|
||||
end
|
||||
|
||||
local function slot_upgrade(player, offer_index)
|
||||
local price = global.entity_limits[slot_upgrade_offers[offer_index][1]].limit * global.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
|
||||
local gain = 1
|
||||
if offer_index == 5 then
|
||||
price = math.ceil((global.entity_limits[slot_upgrade_offers[offer_index][1]].limit / 3) * global.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price)
|
||||
gain = 3
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index][1] == "flamethrower-turret" then
|
||||
price = (global.entity_limits[slot_upgrade_offers[offer_index][1]].limit + 1) * global.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
end
|
||||
|
||||
local coins_removed = player.remove_item({name = "coin", count = price})
|
||||
if coins_removed ~= price then
|
||||
if coins_removed > 0 then
|
||||
player.insert({name = "coin", count = coins_removed})
|
||||
end
|
||||
player.print("Not enough coins.", {r = 0.22, g = 0.77, b = 0.44})
|
||||
return false
|
||||
end
|
||||
|
||||
global.entity_limits[slot_upgrade_offers[offer_index][1]].limit = global.entity_limits[slot_upgrade_offers[offer_index][1]].limit + gain
|
||||
game.print(player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
server_commands.to_discord_bold(table.concat{player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!"})
|
||||
refresh_market_offers()
|
||||
end
|
||||
|
||||
local function on_market_item_purchased(event)
|
||||
local player = game.players[event.player_index]
|
||||
local market = event.market
|
||||
local offer_index = event.offer_index
|
||||
local offers = market.get_market_items()
|
||||
local bought_offer = offers[offer_index].offer
|
||||
if bought_offer.type ~= "nothing" then return end
|
||||
|
||||
if slot_upgrade_offers[offer_index] then
|
||||
if slot_upgrade(player, offer_index) then return end
|
||||
end
|
||||
|
||||
if offer_index < 50 then return end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["flame-boots"] then
|
||||
game.print(player.name .. " has bought themselves some flame boots.", {r = 0.22, g = 0.77, b = 0.44})
|
||||
if not global.flame_boots[player.index].fuel then
|
||||
global.flame_boots[player.index].fuel = math.random(1500, 3000)
|
||||
else
|
||||
global.flame_boots[player.index].fuel = global.flame_boots[player.index].fuel + math.random(1500, 3000)
|
||||
end
|
||||
|
||||
player.print("Fuel remaining: " .. global.flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44})
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["explosive-bullets"] then
|
||||
game.print(player.name .. " has unlocked explosive bullets.", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.explosive_bullets_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["bouncy-shells"] then
|
||||
game.print(player.name .. " has unlocked bouncy shells.", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.bouncy_shells_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["trapped-capsules"] then
|
||||
game.print(player.name .. " has unlocked trapped capsules!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.trapped_capsules_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["ultra-mines"] then
|
||||
game.print(player.name .. " has unlocked ultra mines!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.ultra_mines_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["laser-pointer"] then
|
||||
game.print(player.name .. " has unleashed the quest to slay the red dot!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.laser_pointer_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["railgun-enhancer"] then
|
||||
game.print(player.name .. " has unlocked the enhanced railgun!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.railgun_enhancer_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["crumbly-walls"] then
|
||||
game.print(player.name .. " has unlocked crumbly walls!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.crumbly_walls_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
|
||||
if bought_offer.effect_description == special_descriptions["vehicle-nanobots"] then
|
||||
game.print(player.name .. " has unlocked vehicle nanobots!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
global.vehicle_nanobots_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
if not event.entity then return end
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.name == "market" then refresh_market_offers() return end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
|
||||
event.add(defines.events.on_gui_opened, on_gui_opened)
|
42
maps/fish_defender_v1/on_entity_damaged.lua
Normal file
42
maps/fish_defender_v1/on_entity_damaged.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local enhance_railgun = require 'maps.fish_defender.railgun_enhancer'
|
||||
local explosive_bullets = require 'maps.fish_defender.explosive_gun_bullets'
|
||||
local bouncy_shells = require 'maps.fish_defender.bouncy_shells'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
|
||||
local function protect_market(event)
|
||||
if event.entity.name ~= "market" then return false end
|
||||
if event.cause then
|
||||
if event.cause.force.name == "enemy" then return false end
|
||||
end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
return true
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.entity then return end
|
||||
if not event.entity.valid then return end
|
||||
|
||||
if protect_market(event) then return end
|
||||
|
||||
if not event.cause then return end
|
||||
|
||||
if event.cause.unit_number then
|
||||
if global.boss_biters[event.cause.unit_number] then
|
||||
boss_biter.damaged_entity(event)
|
||||
end
|
||||
end
|
||||
|
||||
if event.cause.name ~= "character" then return end
|
||||
|
||||
if enhance_railgun(event) then return end
|
||||
if global.explosive_bullets_unlocked then
|
||||
if explosive_bullets(event) then return end
|
||||
end
|
||||
if global.bouncy_shells_unlocked then
|
||||
if bouncy_shells(event) then return end
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
98
maps/fish_defender_v1/railgun_enhancer.lua
Normal file
98
maps/fish_defender_v1/railgun_enhancer.lua
Normal file
@ -0,0 +1,98 @@
|
||||
-- improves the damage of the railgun and adds visual effects -- by mewmew
|
||||
-- laser turret research will increase it´s damage even further --
|
||||
|
||||
local damage_min = 400
|
||||
local damage_max = 800
|
||||
local math_random = math.random
|
||||
local additional_visual_effects = true
|
||||
|
||||
local biological_target_types = {
|
||||
["unit"] = true,
|
||||
["player"] = true,
|
||||
["turret"] = true,
|
||||
["unit-spawner"] = true
|
||||
}
|
||||
|
||||
local function create_visuals(source_entity, target_entity)
|
||||
if not source_entity.valid then return end
|
||||
if not target_entity.valid then return end
|
||||
if not additional_visual_effects then return end
|
||||
local surface = target_entity.surface
|
||||
surface.create_entity({name = "water-splash", position = target_entity.position})
|
||||
if biological_target_types[target_entity.type] then
|
||||
surface.create_entity({name = "blood-explosion-big", position = target_entity.position})
|
||||
for x = -8, 8, 1 do
|
||||
for y = -8, 8, 1 do
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = "blood-fountain", position = {target_entity.position.x + (x * 0.1), target_entity.position.y + (y * 0.1)}})
|
||||
surface.create_entity({name = "blood-fountain-big", position = {target_entity.position.x + (x * 0.1), target_entity.position.y + (y * 0.1)}})
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if math_random(1, 3) ~= 1 then
|
||||
surface.create_entity({name = "fire-flame", position = target_entity.position})
|
||||
end
|
||||
for x = -3, 3, 1 do
|
||||
for y = -3, 3, 1 do
|
||||
if math_random(1, 3) == 1 then
|
||||
surface.create_trivial_smoke({name="smoke-fast", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}})
|
||||
end
|
||||
if math_random(1, 5) == 1 then
|
||||
surface.create_trivial_smoke({name="train-smoke", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function do_splash_damage_around_entity(source_entity, player)
|
||||
if not source_entity.valid then return end
|
||||
local research_damage_bonus = player.force.get_ammo_damage_modifier("laser-turret") + 1
|
||||
local research_splash_radius_bonus = player.force.get_ammo_damage_modifier("laser-turret") * 0.5
|
||||
local splash_area = {
|
||||
{source_entity.position.x - (2.5 + research_splash_radius_bonus), source_entity.position.y - (2.5 + research_splash_radius_bonus)},
|
||||
{source_entity.position.x + (2.5 + research_splash_radius_bonus), source_entity.position.y + (2.5 + research_splash_radius_bonus)}
|
||||
}
|
||||
local entities = source_entity.surface.find_entities_filtered({area = splash_area})
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.valid then
|
||||
if entity.health and entity ~= source_entity and entity ~= player then
|
||||
if additional_visual_effects then
|
||||
local surface = entity.surface
|
||||
surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = entity.position})
|
||||
surface.create_entity({name = "water-splash", position = entity.position})
|
||||
if biological_target_types[entity.type] then
|
||||
surface.create_entity({name = "blood-fountain", position = entity.position})
|
||||
end
|
||||
end
|
||||
local damage = math_random(math.ceil((damage_min * research_damage_bonus) / 16), math.ceil((damage_max * research_damage_bonus) / 16))
|
||||
entity.damage(damage, player.force, "physical")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function enhance(event)
|
||||
if not global.railgun_enhancer_unlocked then return end
|
||||
if event.damage_type.name ~= "physical" then return end
|
||||
if event.original_damage_amount ~= 100 then return end
|
||||
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then return end
|
||||
local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index]
|
||||
if selected_weapon.name ~= "railgun" then return end
|
||||
|
||||
create_visuals(event.cause, event.entity)
|
||||
|
||||
do_splash_damage_around_entity(event.entity, player)
|
||||
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
|
||||
local research_damage_bonus = player.force.get_ammo_damage_modifier("laser-turret") + 1
|
||||
local damage = math_random(math.ceil(damage_min * research_damage_bonus), math.ceil(damage_max * research_damage_bonus))
|
||||
event.entity.damage(damage, player.force, "physical")
|
||||
return true
|
||||
end
|
||||
|
||||
return enhance
|
28
maps/fish_defender_v1/shotgun_buff.lua
Normal file
28
maps/fish_defender_v1/shotgun_buff.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local event = require 'utils.event'
|
||||
local gain_multiplier = 4
|
||||
|
||||
local function on_research_finished(event)
|
||||
local research = event.research
|
||||
local force_name = research.force.name
|
||||
|
||||
if not global.shotgun_shell_damage_modifier_old[force_name] then global.shotgun_shell_damage_modifier_old[force_name] = game.forces[force_name].get_ammo_damage_modifier("shotgun-shell") - 0.1 end
|
||||
|
||||
if string.sub(research.name, 0, 26) == "physical-projectile-damage" then
|
||||
local current_damage = game.forces[force_name].get_ammo_damage_modifier("shotgun-shell")
|
||||
local vanilla_gain = current_damage - global.shotgun_shell_damage_modifier_old[force_name]
|
||||
local additional_gain = vanilla_gain * (gain_multiplier - 1)
|
||||
game.forces[force_name].set_ammo_damage_modifier("shotgun-shell", current_damage + additional_gain)
|
||||
end
|
||||
|
||||
global.shotgun_shell_damage_modifier_old[force_name] = game.forces[force_name].get_ammo_damage_modifier("shotgun-shell")
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
game.forces.player.set_ammo_damage_modifier("shotgun-shell", 1)
|
||||
global.shotgun_shell_damage_modifier_old = {}
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
|
||||
|
44
maps/fish_defender_v1/trapped_capsules.lua
Normal file
44
maps/fish_defender_v1/trapped_capsules.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local radius = 20
|
||||
|
||||
local whitelist = {
|
||||
["defender"] = "explosive-cannon-projectile",
|
||||
["distractor"] = "explosive-uranium-cannon-projectile",
|
||||
["destroyer"] = "explosive-uranium-cannon-projectile"
|
||||
}
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not global.trapped_capsules_unlocked then return end
|
||||
|
||||
if not event.entity.valid then return end
|
||||
if not whitelist[event.entity.name] then return end
|
||||
|
||||
local valid_targets = {}
|
||||
local position = event.entity.position
|
||||
|
||||
for _, e in pairs(event.entity.surface.find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}, force = "enemy"})) do
|
||||
if e.health then
|
||||
local distance_from_center = math.sqrt((e.position.x - position.x) ^ 2 + (e.position.y - position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
valid_targets[#valid_targets + 1] = e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not valid_targets[1] then return end
|
||||
|
||||
event.entity.surface.create_entity({
|
||||
name = whitelist[event.entity.name],
|
||||
position = position,
|
||||
force = "player",
|
||||
source = position,
|
||||
target = valid_targets[math.random(1, #valid_targets)].position,
|
||||
max_range = 20,
|
||||
speed = 0.1
|
||||
})
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
|
34
maps/fish_defender_v1/ultra_mines.lua
Normal file
34
maps/fish_defender_v1/ultra_mines.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local event = require 'utils.event'
|
||||
local radius = 8
|
||||
|
||||
local function damage_entities_around_target(entity, damage)
|
||||
for _, e in pairs(entity.surface.find_entities_filtered({area = {{entity.position.x - radius, entity.position.y - radius},{entity.position.x + radius, entity.position.y + radius}}})) do
|
||||
if e.health then
|
||||
if e.force.name ~= "player" then
|
||||
local distance_from_center = math.sqrt((e.position.x - entity.position.x) ^ 2 + (e.position.y - entity.position.y) ^ 2)
|
||||
if distance_from_center <= radius then
|
||||
e.damage(damage, "player", "explosion")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not global.ultra_mines_unlocked then return end
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.name ~= "land-mine" then return end
|
||||
|
||||
event.entity.surface.create_entity({
|
||||
name = "big-artillery-explosion",
|
||||
position = event.entity.position
|
||||
})
|
||||
|
||||
local damage = (1 + event.entity.force.get_ammo_damage_modifier("grenade")) * 250
|
||||
|
||||
damage_entities_around_target(event.entity, damage)
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
|
16
maps/fish_defender_v1/vehicle_nanobots.lua
Normal file
16
maps/fish_defender_v1/vehicle_nanobots.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
if not global.vehicle_nanobots_unlocked then return end
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
if not player.character.driving then return end
|
||||
if not player.vehicle then return end
|
||||
if not player.vehicle.valid then return end
|
||||
if player.vehicle.health == player.vehicle.prototype.max_health then return end
|
||||
player.vehicle.health = player.vehicle.health + player.vehicle.prototype.max_health * 0.005
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
||||
|
@ -112,12 +112,12 @@ function add_enemies(surface, tiles)
|
||||
if math.random(1, 5) == 1 or is_boss_stage() then
|
||||
local evolution = (global.current_level * 2 * difficulties_votes[global.difficulty_vote_index].strength_modifier) * 0.01
|
||||
if evolution > 1 then evolution = 1 end
|
||||
game.forces.enemy.evolution_factor = evolution
|
||||
local count = math.random(1, math.ceil(global.current_level * 0.05))
|
||||
if count > 3 then count = 3 end
|
||||
game.forces.enemy_spawners.evolution_factor = evolution
|
||||
local count = math.random(1, math.ceil(global.current_level * 0.10))
|
||||
if count > 5 then count = 5 end
|
||||
for k, tile in pairs(tiles) do
|
||||
if surface.can_place_entity({name = "biter-spawner", position = tile.position, force = "enemy"}) then
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"})
|
||||
if surface.can_place_entity({name = "biter-spawner", position = tile.position, force = "enemy_spawners"}) then
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy_spawners"})
|
||||
global.alive_enemies = global.alive_enemies + 1
|
||||
count = count - 1
|
||||
if count == 0 then break end
|
||||
|
@ -176,6 +176,10 @@ end
|
||||
|
||||
|
||||
local function on_init()
|
||||
game.create_force("enemy_spawners")
|
||||
game.forces.enemy_spawners.set_friend("enemy", true)
|
||||
game.forces.enemy.set_friend("enemy_spawners", true)
|
||||
|
||||
local surface = game.surfaces[1]
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 16)
|
||||
surface.force_generate_chunk_requests()
|
||||
@ -223,11 +227,14 @@ local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
|
||||
if entity.force.name ~= "enemy" then return end
|
||||
if entity.type == "unit" then
|
||||
if entity.spawner then return end
|
||||
if entity.force.name == "enemy_spawners" then
|
||||
if entity.type == "unit" then return end
|
||||
global.alive_enemies = global.alive_enemies - 1
|
||||
return
|
||||
end
|
||||
|
||||
if entity.force.name ~= "enemy" then return end
|
||||
|
||||
global.alive_enemies = global.alive_enemies - 1
|
||||
update_stage_gui()
|
||||
|
||||
@ -259,7 +266,7 @@ local gamestate_functions = {
|
||||
|
||||
local function on_tick()
|
||||
gamestate_functions[global.gamestate]()
|
||||
if game.tick % 120 == 0 then drift_corpses_toward_beach() end
|
||||
if game.tick % 150 == 0 then drift_corpses_toward_beach() end
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
@ -268,11 +268,14 @@ local function process_tile(surface, position)
|
||||
if position.x < -128 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end
|
||||
if position.x > 8192 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end
|
||||
if position.y < 0 then surface.set_tiles({{name = "deepwater", position = position}}, true) return end
|
||||
if position.y > 32 then surface.set_tiles({{name = "water-green", position = position}}, true)
|
||||
if position.y > 32 then
|
||||
surface.set_tiles({{name = "water-green", position = position}}, true)
|
||||
if math.random(1, 4096) == 1 then
|
||||
if math.random(1, 4) == 1 then
|
||||
surface.set_tiles({{name = "sand-1", position = position}}, true)
|
||||
create_dump_chest(surface, position, false)
|
||||
else
|
||||
surface.set_tiles({{name = "sand-1", position = position}}, true)
|
||||
create_shopping_chest(surface, position, false)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user