mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
commit
f220b2ddda
@ -26,7 +26,6 @@ local this = {
|
||||
players_warned = {},
|
||||
log_tree_harvest = false,
|
||||
do_not_check_trusted = true,
|
||||
protect_entities = true,
|
||||
enable_autokick = true,
|
||||
enable_autoban = false
|
||||
}
|
||||
@ -53,52 +52,6 @@ local ammo_names = {
|
||||
['rocket'] = true
|
||||
}
|
||||
|
||||
local protected = {
|
||||
['reactor'] = true,
|
||||
['roboport'] = true,
|
||||
['rocket-silo'] = true,
|
||||
['solar-panel'] = true,
|
||||
['generator'] = true,
|
||||
['splitter'] = true,
|
||||
['transport-belt'] = true,
|
||||
['underground-belt'] = true,
|
||||
['assembling-machine'] = true,
|
||||
['storage-tank'] = true,
|
||||
['pump'] = true,
|
||||
['mining-drill'] = true,
|
||||
['market'] = true,
|
||||
['accumulator'] = true,
|
||||
['ammo-turret'] = true,
|
||||
['artillery-turret'] = true,
|
||||
['artillery-wagon'] = true,
|
||||
['beacon'] = true,
|
||||
['boiler'] = true,
|
||||
['burner-generator'] = true,
|
||||
['car'] = true,
|
||||
['cargo-wagon'] = true,
|
||||
['constant-combinator'] = true,
|
||||
['straight-rail'] = true,
|
||||
['curved-rail'] = true,
|
||||
['decider-combinator'] = true,
|
||||
['electric-pole'] = true,
|
||||
['electric-turret'] = true,
|
||||
['fluid-turret'] = true,
|
||||
['fluid-wagon'] = true,
|
||||
['furnace'] = true,
|
||||
['gate'] = true,
|
||||
['heat-interface'] = true,
|
||||
['heat-pipe'] = true,
|
||||
['inserter'] = true,
|
||||
['lab'] = true,
|
||||
['lamp'] = true,
|
||||
['loader'] = true,
|
||||
['locomotive'] = true,
|
||||
['logistic-robot'] = true,
|
||||
['offshore-pump'] = true,
|
||||
['pipe-to-ground'] = true,
|
||||
['pipe'] = true
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
@ -704,46 +657,6 @@ local function on_player_cancelled_crafting(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function protect_entities(event)
|
||||
local entity = event.entity
|
||||
|
||||
local function is_protected(e)
|
||||
if protected[e.type] then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
if is_protected(entity) then
|
||||
entity.health = entity.health + event.final_damage_amount
|
||||
end
|
||||
end
|
||||
|
||||
--- Protect entities from the player force
|
||||
---@param event
|
||||
local function on_entity_damaged(event)
|
||||
if not this.protect_entities then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if event.force.index ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if entity.force.index ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
protect_entities(event)
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
local branch_version = '0.18.35'
|
||||
local sub = string.sub
|
||||
@ -767,14 +680,6 @@ local function on_init()
|
||||
end
|
||||
end
|
||||
|
||||
--- Enabling this will protect all entities except for those in the not_protected table.
|
||||
---@param boolean true/false
|
||||
function Public.protect_entities(value)
|
||||
if value then
|
||||
this.protect_entities = value
|
||||
end
|
||||
end
|
||||
|
||||
--- This will reset the table of this
|
||||
function Public.reset_tables()
|
||||
this.landfill_history = {}
|
||||
@ -833,6 +738,5 @@ Event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
||||
Event.add(defines.events.on_player_cursor_stack_changed, on_player_cursor_stack_changed)
|
||||
Event.add(defines.events.on_player_cancelled_crafting, on_player_cancelled_crafting)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
|
||||
return Public
|
||||
|
@ -13,7 +13,8 @@ to your scenario control.lua.
|
||||
Minor changes by ~~~Gerkiz~~~
|
||||
--]]
|
||||
local Event = require 'utils.event'
|
||||
local play_time = require 'utils.session_data'
|
||||
local Session = require 'utils.session_data'
|
||||
local Jailed = require 'utils.jail_data'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local symbol_asc = '▲'
|
||||
@ -218,7 +219,7 @@ local function get_formatted_playtime(x)
|
||||
end
|
||||
|
||||
local function get_rank(player)
|
||||
local play_table = play_time.get_session_table()
|
||||
local play_table = Session.get_session_table()
|
||||
local t = 0
|
||||
if play_table then
|
||||
if play_table[player.name] then
|
||||
@ -337,7 +338,7 @@ local function get_comparator(sort_by)
|
||||
end
|
||||
|
||||
local function get_sorted_list(sort_by)
|
||||
local play_table = play_time.get_session_table()
|
||||
local play_table = Session.get_session_table()
|
||||
local player_list = {}
|
||||
for i, player in pairs(game.connected_players) do
|
||||
player_list[i] = {}
|
||||
@ -369,12 +370,14 @@ local function player_list_show(player, frame, sort_by)
|
||||
-- Frame management
|
||||
frame.clear()
|
||||
frame.style.padding = 8
|
||||
local play_table = play_time.get_trusted_table()
|
||||
local play_table = Session.get_trusted_table()
|
||||
local jailed = Jailed.get_jailed_table()
|
||||
|
||||
-- Header management
|
||||
local t = frame.add {type = 'table', name = 'player_list_panel_header_table', column_count = 5}
|
||||
local column_widths = {tonumber(40), tonumber(240), tonumber(240), tonumber(150), tonumber(100)}
|
||||
for _, w in ipairs(column_widths) do
|
||||
local column_widths = {tonumber(40), tonumber(218), tonumber(220), tonumber(222), tonumber(50)}
|
||||
local header_column_widths = {tonumber(40), tonumber(210), tonumber(220), tonumber(226), tonumber(50)}
|
||||
for _, w in ipairs(header_column_widths) do
|
||||
local label = t.add {type = 'label', caption = ''}
|
||||
label.style.minimal_width = w
|
||||
label.style.maximal_width = w
|
||||
@ -427,14 +430,14 @@ local function player_list_show(player, frame, sort_by)
|
||||
header_modifier[sort_by](headers)
|
||||
|
||||
for k, v in ipairs(headers) do
|
||||
local label =
|
||||
local header_label =
|
||||
t.add {
|
||||
type = 'label',
|
||||
name = 'player_list_panel_header_' .. k,
|
||||
caption = v
|
||||
}
|
||||
label.style.font = 'default-bold'
|
||||
label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
header_label.style.font = 'default-bold'
|
||||
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
end
|
||||
|
||||
-- special style on first header
|
||||
@ -476,6 +479,9 @@ local function player_list_show(player, frame, sort_by)
|
||||
if game.players[player_list[i].name].admin then
|
||||
trusted = '[color=red][A][/color]'
|
||||
tooltip = 'This player is an admin of this server.'
|
||||
elseif jailed[player_list[i].name] then
|
||||
trusted = '[color=orange][J][/color]'
|
||||
tooltip = 'This player is currently jailed.'
|
||||
elseif play_table[player_list[i].name] then
|
||||
trusted = '[color=green][T][/color]'
|
||||
tooltip = 'This player is trusted.'
|
||||
@ -485,41 +491,42 @@ local function player_list_show(player, frame, sort_by)
|
||||
end
|
||||
|
||||
-- Name
|
||||
local label =
|
||||
local name_label =
|
||||
player_list_panel_table.add {
|
||||
type = 'label',
|
||||
name = 'player_list_panel_player_names_' .. i,
|
||||
caption = player_list[i].name .. ' ' .. trusted,
|
||||
tooltip = tooltip
|
||||
}
|
||||
label.style.font = 'default'
|
||||
label.style.font_color = {
|
||||
r = .4 + game.players[player_list[i].player_index].color.r * 0.6,
|
||||
g = .4 + game.players[player_list[i].player_index].color.g * 0.6,
|
||||
b = .4 + game.players[player_list[i].player_index].color.b * 0.6
|
||||
local p_color = game.players[player_list[i].player_index]
|
||||
name_label.style.font = 'default'
|
||||
name_label.style.font_color = {
|
||||
r = .4 + p_color.color.r * 0.6,
|
||||
g = .4 + p_color.color.g * 0.6,
|
||||
b = .4 + p_color.color.b * 0.6
|
||||
}
|
||||
label.style.minimal_width = column_widths[2]
|
||||
label.style.maximal_width = column_widths[2]
|
||||
name_label.style.minimal_width = column_widths[2]
|
||||
name_label.style.maximal_width = column_widths[2]
|
||||
|
||||
-- Total time
|
||||
local label =
|
||||
local total_label =
|
||||
player_list_panel_table.add {
|
||||
type = 'label',
|
||||
name = 'player_list_panel_player_total_time_played_' .. i,
|
||||
caption = player_list[i].total_played_time
|
||||
}
|
||||
label.style.minimal_width = column_widths[3]
|
||||
label.style.maximal_width = column_widths[3]
|
||||
total_label.style.minimal_width = column_widths[3]
|
||||
total_label.style.maximal_width = column_widths[3]
|
||||
|
||||
-- Current time
|
||||
local label =
|
||||
local current_label =
|
||||
player_list_panel_table.add {
|
||||
type = 'label',
|
||||
name = 'player_list_panel_player_time_played_' .. i,
|
||||
caption = player_list[i].played_time
|
||||
}
|
||||
label.style.minimal_width = column_widths[4]
|
||||
label.style.maximal_width = column_widths[4]
|
||||
current_label.style.minimal_width = column_widths[4]
|
||||
current_label.style.maximal_width = column_widths[4]
|
||||
|
||||
-- Poke
|
||||
local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}
|
||||
@ -527,6 +534,7 @@ local function player_list_show(player, frame, sort_by)
|
||||
local button =
|
||||
flow.add {type = 'button', name = 'poke_player_' .. player_list[i].name, caption = player_list[i].pokes}
|
||||
button.style.font = 'default'
|
||||
button.tooltip = 'Poke ' .. player_list[i].name .. ' with a random message!'
|
||||
label.style.font_color = {r = 0.83, g = 0.83, b = 0.83}
|
||||
button.style.minimal_height = 30
|
||||
button.style.minimal_width = 30
|
||||
|
@ -70,6 +70,7 @@ require 'modules.autostash'
|
||||
|
||||
---- enable maps here ---- (maps higher up in the list may be more actually playable)
|
||||
--require 'maps.chronosphere.main'
|
||||
--require 'maps.fish_defender_v2.main'
|
||||
--require 'maps.fish_defender.main'
|
||||
--require 'maps.biter_battles_v2.main'
|
||||
--require 'maps.mountain_fortress_v3.main'
|
||||
|
45
locale/en/fish_defender_v2.cfg
Normal file
45
locale/en/fish_defender_v2.cfg
Normal file
@ -0,0 +1,45 @@
|
||||
[fish_defender_v2]
|
||||
map_info_main_caption=--Fish Defender v2--
|
||||
map_info_sub_caption= ~~blb blubby blub~~
|
||||
map_info_text=The biters have catched the scent of fish in the market.\nFend them off as long as possible!\nThis however will not be an easy task,\nsince their strength and resistance increases constantly over time.\n\nYour ultimate goal is to evacuate all the fish to cat planet!\nPut them in your rocket's cargo and launch them into space.\nDon't worry, you will still get space science.\n\nThe Market will gladly take any coin you might find.\nAdditional turret slots can be bought at the market.\nSeveral unique upgrades are available too.\nResearching tanks will unlock the artillery technology early.\nAny container bearing dangerous goods, like ammo, grenades or barrels,\ncauses heavy explosions when it breaks.\nMaybe this can be used to our advantage.
|
||||
boss_message=Boss Wave __1__ - - __2__
|
||||
50=The Big Biter Gang
|
||||
100=Biterzilla
|
||||
150=The Spitter Squad
|
||||
200=The Wall Nibblers
|
||||
250=Conveyor Munchers
|
||||
300=Furnace Freezers
|
||||
350=Cable Chewers
|
||||
400=Power Pole Thieves
|
||||
450=Assembler Annihilators
|
||||
500=Inserter Crunchers
|
||||
550=Engineer Eaters
|
||||
600=Belt Unbalancers
|
||||
650=Turret Devourers
|
||||
700=Pipe Perforators
|
||||
750=Desync Bros
|
||||
800=Ratio Randomizers
|
||||
850=Wire Chompers
|
||||
900=The Bus Mixers
|
||||
950=Roundabout Deadlockers
|
||||
1000=Happy Tree Friends
|
||||
1050=Uranium Digesters
|
||||
1100=Bot Banishers
|
||||
1150=Chest Crushers
|
||||
1200=Cargo Wagon Scratchers
|
||||
1250=Transport Belt Surfers
|
||||
1300=Pumpjack Pulverizers
|
||||
1350=Radar Ravagers
|
||||
1400=Mall Deconstrutors
|
||||
1450=Lamp Dimmers
|
||||
1500=Roboport Disablers
|
||||
1550=Signal Spammers
|
||||
1600=Brick Tramplers
|
||||
1650=Drill Destroyers
|
||||
1700=Gearwheel Grinders
|
||||
1750=Silo Seekers
|
||||
1800=Circuit Breakers
|
||||
1850=Bullet Absorbers
|
||||
1900=Oil Guzzlers
|
||||
1950=Belt Rotators
|
||||
2000=Bluescreen Factor
|
@ -1,99 +1,83 @@
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
|
||||
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',
|
||||
['big-spitter'] = 'acid-stream-worm-medium',
|
||||
['behemoth-spitter'] = 'acid-stream-worm-big'
|
||||
["big-biter"] = "acid-stream-worm-medium",
|
||||
["behemoth-biter"] = "acid-stream-worm-big",
|
||||
["big-spitter"] = "acid-stream-worm-medium",
|
||||
["behemoth-spitter"] = "acid-stream-worm-big"
|
||||
}
|
||||
local acid_lines = {
|
||||
['big-spitter'] = 'acid-stream-spitter-medium',
|
||||
['behemoth-spitter'] = 'acid-stream-spitter-big'
|
||||
["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
|
||||
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(16, 32) 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
|
||||
for _ = 1, math.random(16, 32) 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)
|
||||
local this = FDT.get()
|
||||
if acid_splashes[event.entity.name] then
|
||||
acid_nova(event)
|
||||
end
|
||||
if this.acid_lines_delay[event.entity.unit_number] then
|
||||
this.acid_lines_delay[event.entity.unit_number] = nil
|
||||
end
|
||||
this.boss_biters[event.entity.unit_number] = nil
|
||||
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)
|
||||
|
||||
if distance > 16 then
|
||||
return false
|
||||
end
|
||||
|
||||
local modifier = {(target.x - source.x) / distance, (target.y - source.y) / distance}
|
||||
|
||||
local position = {source.x, source.y}
|
||||
|
||||
for i = 1, distance + 4, 1 do
|
||||
if math_random(1, 3) == 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
|
||||
|
||||
return true
|
||||
local distance = math.sqrt((source.x - target.x) ^ 2 + (source.y - target.y) ^ 2)
|
||||
|
||||
if distance > 16 then return false end
|
||||
|
||||
local modifier = {(target.x - source.x) / distance, (target.y - source.y) / distance}
|
||||
|
||||
local position = {source.x, source.y}
|
||||
|
||||
for i = 1, distance + 4, 1 do
|
||||
if math_random(1,3) == 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
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
boss_biter.damaged_entity = function(event)
|
||||
if acid_lines[event.cause.name] then
|
||||
local this = FDT.get()
|
||||
if not this.acid_lines_delay[event.cause.unit_number] then
|
||||
this.acid_lines_delay[event.cause.unit_number] = 0
|
||||
end
|
||||
|
||||
if this.acid_lines_delay[event.cause.unit_number] < game.tick then
|
||||
if acid_line(event.cause.surface, acid_lines[event.cause.name], event.cause.position, event.entity.position) then
|
||||
this.acid_lines_delay[event.cause.unit_number] = game.tick + 180
|
||||
end
|
||||
end
|
||||
end
|
||||
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
|
||||
if acid_line(event.cause.surface, acid_lines[event.cause.name], event.cause.position, event.entity.position) then
|
||||
global.acid_lines_delay[event.cause.unit_number] = game.tick + 180
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return boss_biter
|
||||
return boss_biter
|
@ -1,76 +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'
|
||||
["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 = 'player',
|
||||
source = position,
|
||||
target = target,
|
||||
max_range = 16,
|
||||
speed = 0.3
|
||||
}
|
||||
)
|
||||
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 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
|
||||
|
||||
if not valid_entities[1] then
|
||||
return
|
||||
end
|
||||
|
||||
for _ = 1, math_random(3, 6), 1 do
|
||||
create_projectile(surface, position, valid_entities[math_random(1, #valid_entities)].position, ammo)
|
||||
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])
|
||||
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
|
||||
|
||||
|
||||
|
@ -1,27 +1,15 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
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 rock_raffle = {"sand-rock-big", "rock-big", "rock-big", "rock-big", "rock-huge"}
|
||||
|
||||
local function on_entity_died(event)
|
||||
local crumbly_walls_unlocked = FDT.get('crumbly_walls_unlocked')
|
||||
if not 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'}
|
||||
)
|
||||
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)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
@ -1,46 +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
|
||||
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
|
||||
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})
|
||||
player.surface.create_entity({name = "explosion", position = event.entity.position})
|
||||
|
||||
splash_damage(player.surface, event.entity.position, event.final_damage_amount)
|
||||
splash_damage(
|
||||
player.surface,
|
||||
event.entity.position,
|
||||
event.final_damage_amount
|
||||
)
|
||||
end
|
||||
|
||||
return explosive_bullets
|
||||
|
@ -1,52 +1,40 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local flame_boots = FDT.get('flame_boots')
|
||||
if not 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 flame_boots[player.index] then
|
||||
flame_boots[player.index] = {}
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].fuel then
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel < 0 then
|
||||
player.print('Your flame boots have worn out.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
flame_boots[player.index] = {}
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel % 500 == 0 then
|
||||
player.print('Fuel remaining: ' .. flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44})
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].step_history then
|
||||
flame_boots[player.index].step_history = {}
|
||||
end
|
||||
|
||||
local elements = #flame_boots[player.index].step_history
|
||||
|
||||
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 = flame_boots[player.index].step_history[elements - 2]})
|
||||
|
||||
flame_boots[player.index].fuel = flame_boots[player.index].fuel - 1
|
||||
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
|
||||
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
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)
|
||||
|
@ -1,37 +1,31 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local event = require 'utils.event'
|
||||
local radius = 32
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
local laser_pointer_unlocked = FDT.get('laser_pointer_unlocked')
|
||||
if not laser_pointer_unlocked then
|
||||
return
|
||||
end
|
||||
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
|
||||
|
||||
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
|
||||
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)
|
||||
event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,341 +5,263 @@ require 'maps.fish_defender.crumbly_walls'
|
||||
require 'maps.fish_defender.vehicle_nanobots'
|
||||
require 'maps.fish_defender.laser_pointer'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
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'}
|
||||
}
|
||||
[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.'
|
||||
["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()
|
||||
local this = FDT.get()
|
||||
if not this.market or not this.market.valid then
|
||||
return
|
||||
end
|
||||
for i = 1, 100, 1 do
|
||||
local a = this.market.remove_market_item(1)
|
||||
if a == false then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local str1 =
|
||||
'Gun Turret Slot for ' ..
|
||||
tostring(this.entity_limits['gun-turret'].limit * this.entity_limits['gun-turret'].slot_price)
|
||||
str1 = str1 .. ' Coins.'
|
||||
|
||||
local str2 =
|
||||
'Laser Turret Slot for ' ..
|
||||
tostring(this.entity_limits['laser-turret'].limit * this.entity_limits['laser-turret'].slot_price)
|
||||
str2 = str2 .. ' Coins.'
|
||||
|
||||
local str3 =
|
||||
'Artillery Slot for ' ..
|
||||
tostring(this.entity_limits['artillery-turret'].limit * this.entity_limits['artillery-turret'].slot_price)
|
||||
str3 = str3 .. ' Coins.'
|
||||
|
||||
local current_limit = 1
|
||||
if this.entity_limits['flamethrower-turret'].limit ~= 0 then
|
||||
current_limit = current_limit + this.entity_limits['flamethrower-turret'].limit
|
||||
end
|
||||
local str4 =
|
||||
'Flamethrower Turret Slot for ' ..
|
||||
tostring(current_limit * this.entity_limits['flamethrower-turret'].slot_price)
|
||||
str4 = str4 .. ' Coins.'
|
||||
|
||||
local str5 =
|
||||
'Landmine Slot for ' ..
|
||||
tostring(math.ceil((this.entity_limits['land-mine'].limit / 3) * this.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
|
||||
this.market.add_market_item(item)
|
||||
end
|
||||
|
||||
if not this.railgun_enhancer_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 1500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['railgun-enhancer']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.trapped_capsules_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 3500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['trapped-capsules']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.explosive_bullets_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 4500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['explosive-bullets']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.bouncy_shells_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 10000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['bouncy-shells']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.vehicle_nanobots_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 15000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['vehicle-nanobots']}
|
||||
}
|
||||
)
|
||||
end
|
||||
--[[
|
||||
if not this.crumbly_walls_unlocked then
|
||||
this.market.add_market_item({price = {{"coin", 35000}}, offer = {type = 'nothing', effect_description = special_descriptions["crumbly-walls"]}})
|
||||
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
|
||||
if not this.ultra_mines_unlocked then
|
||||
this.market.add_market_item({price = {{"coin", 45000}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
|
||||
|
||||
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 this.laser_pointer_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 65000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['laser-pointer']}
|
||||
}
|
||||
)
|
||||
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 this = FDT.get()
|
||||
local price =
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit *
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
|
||||
local gain = 1
|
||||
if offer_index == 5 then
|
||||
price =
|
||||
math.ceil(
|
||||
(this.entity_limits[slot_upgrade_offers[offer_index][1]].limit / 3) *
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
)
|
||||
gain = 3
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index][1] == 'flamethrower-turret' then
|
||||
price =
|
||||
(this.entity_limits[slot_upgrade_offers[offer_index][1]].limit + 1) *
|
||||
this.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
|
||||
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit =
|
||||
this.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}
|
||||
)
|
||||
if math.random(1, 2) == 1 then
|
||||
Server.to_discord_bold(
|
||||
table.concat {
|
||||
'*** ' ..
|
||||
player.name ..
|
||||
' has bought a ' ..
|
||||
slot_upgrade_offers[offer_index][2] .. ' slot for ' .. price .. ' coins! ***'
|
||||
}
|
||||
)
|
||||
end
|
||||
refresh_market_offers()
|
||||
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.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
|
||||
local this = FDT.get()
|
||||
|
||||
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 this.flame_boots[player.index].fuel then
|
||||
this.flame_boots[player.index].fuel = math.random(1500, 3000)
|
||||
else
|
||||
this.flame_boots[player.index].fuel = this.flame_boots[player.index].fuel + math.random(1500, 3000)
|
||||
end
|
||||
|
||||
player.print('Fuel remaining: ' .. this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.vehicle_nanobots_unlocked = true
|
||||
refresh_market_offers()
|
||||
return
|
||||
end
|
||||
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
|
||||
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)
|
||||
event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
|
||||
event.add(defines.events.on_gui_opened, on_gui_opened)
|
@ -1,65 +1,42 @@
|
||||
require 'maps.fish_defender.boss_biters'
|
||||
local event = require 'utils.event'
|
||||
|
||||
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 FDT = require 'maps.fish_defender.table'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
|
||||
local function protect_market(event)
|
||||
if event.entity.name ~= 'market' then
|
||||
return
|
||||
end
|
||||
if event.cause then
|
||||
if event.cause.force.name == 'enemy' then
|
||||
return
|
||||
end
|
||||
end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
return true
|
||||
if event.entity.name ~= "market" then return end
|
||||
if event.cause then
|
||||
if event.cause.force.name == "enemy" then return 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
|
||||
local explosive_bullets_unlocked = FDT.get('explosive_bullets_unlocked')
|
||||
local bouncy_shells_unlocked = FDT.get('bouncy_shells_unlocked')
|
||||
|
||||
--if event.cause.unit_number then
|
||||
-- if this.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 explosive_bullets_unlocked then
|
||||
if explosive_bullets(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if bouncy_shells_unlocked then
|
||||
if bouncy_shells(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
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)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
@ -1,157 +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 FDT = require 'maps.fish_defender.table'
|
||||
|
||||
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
|
||||
["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
|
||||
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
|
||||
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)
|
||||
local railgun_enhancer_unlocked = FDT.get('railgun_enhancer_unlocked')
|
||||
if not 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
|
||||
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
|
||||
return enhance
|
@ -1,31 +1,28 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
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
|
||||
local this = FDT.get()
|
||||
|
||||
if not this.shotgun_shell_damage_modifier_old[force_name] then
|
||||
this.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 - this.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
|
||||
|
||||
this.shotgun_shell_damage_modifier_old[force_name] =
|
||||
game.forces[force_name].get_ammo_damage_modifier('shotgun-shell')
|
||||
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)
|
||||
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)
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
|
||||
|
||||
|
@ -1,75 +1,48 @@
|
||||
local Event = require 'utils.event'
|
||||
local map_functions = require 'tools.map_functions'
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local map_functions = require "tools.map_functions"
|
||||
local simplex_noise = require "utils.simplex_noise".d2
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local Public = {}
|
||||
|
||||
local rock_raffle = {
|
||||
'sand-rock-big',
|
||||
'sand-rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-huge'
|
||||
}
|
||||
|
||||
local function shuffle(t)
|
||||
local tbl = {}
|
||||
for i = 1, #t do
|
||||
tbl[i] = t[i]
|
||||
end
|
||||
for i = #tbl, 2, -1 do
|
||||
local j = math.random(i)
|
||||
tbl[i], tbl[j] = tbl[j], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
local hourglass_center_piece_length = 64
|
||||
local worm_raffle_table = {
|
||||
[1] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret"},
|
||||
[2] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret"},
|
||||
[3] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret"},
|
||||
[4] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret"},
|
||||
[5] = {"small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"},
|
||||
[6] = {"small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"},
|
||||
[7] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[8] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[9] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[10] = {"medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}
|
||||
}
|
||||
local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
|
||||
|
||||
local function get_replacement_tile(surface, position)
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
shuffle(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'grass-1'
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with("resource-layer") then return tile.name end
|
||||
end
|
||||
end
|
||||
return "grass-1"
|
||||
end
|
||||
|
||||
local function is_enemy_territory(p)
|
||||
if p.x - 64 < math_abs(p.y) then
|
||||
return false
|
||||
end
|
||||
--if p.x - 64 < p.y then return false end
|
||||
if p.x < 160 then
|
||||
return false
|
||||
end
|
||||
if p.x > 1024 then
|
||||
return false
|
||||
end
|
||||
if p.y > 512 then
|
||||
return false
|
||||
end
|
||||
if p.y < -512 then
|
||||
return false
|
||||
end
|
||||
local noise = math_abs(simplex_noise(0, p.y * 0.015, game.surfaces[1].map_gen_settings.seed) * 96)
|
||||
local noise_2 = math_abs(simplex_noise(0, p.y * 0.1, game.surfaces[1].map_gen_settings.seed) * 16)
|
||||
if p.x > 288 + noise + noise_2 + math_abs(p.y * 0.75) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
if p.x - 64 < math_abs(p.y) then return false end
|
||||
--if p.x - 64 < p.y then return false end
|
||||
if p.x < 160 then return false end
|
||||
if p.x > 1024 then return false end
|
||||
if p.y > 512 then return false end
|
||||
if p.y < -512 then return false end
|
||||
local noise = math_abs(simplex_noise(0, p.y * 0.015, game.surfaces[1].map_gen_settings.seed) * 96)
|
||||
local noise_2 = math_abs(simplex_noise(0, p.y * 0.1, game.surfaces[1].map_gen_settings.seed) * 16)
|
||||
if p.x > 288 + noise + noise_2 + math_abs(p.y * 0.75) then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
local body_radius = 3072
|
||||
@ -84,490 +57,323 @@ local square_fin_radius = fin_radius ^ 2
|
||||
local fin_circle_center_1 = {x = -480, y = 0}
|
||||
local fin_circle_center_2 = {x = -480 - 360, y = 0}
|
||||
|
||||
local function is_body(p)
|
||||
local this = FDT.get()
|
||||
if p.y <= this.map_height and p.y >= this.map_height * -1 and p.x <= 160 and p.x > body_center_position.x then
|
||||
return true
|
||||
end
|
||||
|
||||
--Main Fish Body
|
||||
local distance_to_center_1 = ((p.x - body_circle_center_1.x) ^ 2 + (p.y - body_circle_center_1.y) ^ 2)
|
||||
local distance_to_center_2 = ((p.x - body_circle_center_2.x) ^ 2 + (p.y - body_circle_center_2.y) ^ 2)
|
||||
--if distance_to_center_1 < body_square_radius and distance_to_center_2 < body_square_radius then return true end
|
||||
if distance_to_center_1 < body_square_radius then
|
||||
if distance_to_center_2 < body_square_radius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--Fish Fins
|
||||
distance_to_center_1 = ((p.x - fin_circle_center_1.x) ^ 2 + (p.y - fin_circle_center_1.y) ^ 2)
|
||||
if
|
||||
distance_to_center_1 + math_abs(simplex_noise(0, p.y * 0.075, game.surfaces[1].map_gen_settings.seed) * 32000) >
|
||||
square_fin_radius
|
||||
then
|
||||
distance_to_center_2 = ((p.x - fin_circle_center_2.x) ^ 2 + (p.y - fin_circle_center_2.y) ^ 2)
|
||||
if distance_to_center_2 < square_fin_radius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
local function is_body(p)
|
||||
if p.y <= map_height and p.y >= map_height * -1 and p.x <= 160 and p.x > body_center_position.x then return true end
|
||||
|
||||
--Main Fish Body
|
||||
local distance_to_center_1 = ((p.x - body_circle_center_1.x)^2 + (p.y - body_circle_center_1.y)^2)
|
||||
local distance_to_center_2 = ((p.x - body_circle_center_2.x)^2 + (p.y - body_circle_center_2.y)^2)
|
||||
--if distance_to_center_1 < body_square_radius and distance_to_center_2 < body_square_radius then return true end
|
||||
if distance_to_center_1 < body_square_radius then
|
||||
if distance_to_center_2 < body_square_radius then return true end
|
||||
end
|
||||
|
||||
--Fish Fins
|
||||
local distance_to_center_1 = ((p.x - fin_circle_center_1.x)^2 + (p.y - fin_circle_center_1.y)^2)
|
||||
if distance_to_center_1 + math_abs(simplex_noise(0, p.y * 0.075, game.surfaces[1].map_gen_settings.seed) * 32000) > square_fin_radius then
|
||||
local distance_to_center_2 = ((p.x - fin_circle_center_2.x)^2 + (p.y - fin_circle_center_2.y)^2)
|
||||
if distance_to_center_2 < square_fin_radius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function is_out_of_map_tile(p)
|
||||
if p.y > 850 then
|
||||
return true
|
||||
end
|
||||
if p.y < -850 then
|
||||
return true
|
||||
end
|
||||
if p.x < -3264 then
|
||||
return true
|
||||
end
|
||||
if p.x > 800 then
|
||||
return true
|
||||
end
|
||||
if is_enemy_territory(p) then
|
||||
return false
|
||||
end
|
||||
if is_body(p) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
if p.y > 850 then return true end
|
||||
if p.y < -850 then return true end
|
||||
if p.x < -3264 then return true end
|
||||
if p.x > 800 then return true end
|
||||
if is_enemy_territory(p) then return false end
|
||||
if is_body(p) then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
local function place_fish_market(surface, position)
|
||||
local market = surface.create_entity({name = 'market', position = position, force = 'player'})
|
||||
market.minable = false
|
||||
return market
|
||||
local function generate_spawn_area(surface)
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 7)
|
||||
surface.request_to_generate_chunks({x = 160, y = 0}, 5)
|
||||
--surface.force_generate_chunk_requests()
|
||||
if global.spawn_area_generated then return end
|
||||
if not surface.is_chunk_generated({-7, 0}) then return end
|
||||
if not surface.is_chunk_generated({5, 0}) then return end
|
||||
global.spawn_area_generated = true
|
||||
|
||||
local spawn_position_x = -128
|
||||
|
||||
surface.create_entity({name = "electric-beam", position = {160, -96}, source = {160, -96}, target = {160,96}})
|
||||
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {"water", "deepwater"}, area = {{-160, -160},{160, 160}}})) do
|
||||
local noise = math_abs(simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16)
|
||||
if tile.position.x > -160 + noise then surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true) end
|
||||
end
|
||||
|
||||
for _, entity in pairs(surface.find_entities_filtered({type = {"resource", "cliff"}, area = {{spawn_position_x - 32, -256},{160, 256}}})) do
|
||||
if is_body(entity.position) then
|
||||
if entity.position.x > spawn_position_x - 32 + math_abs(simplex_noise(entity.position.x * 0.02, entity.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16) then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local decorative_names = {}
|
||||
for k,v in pairs(game.decorative_prototypes) do
|
||||
if v.autoplace_specification then
|
||||
decorative_names[#decorative_names+1] = k
|
||||
end
|
||||
end
|
||||
for x = -4, 4, 1 do
|
||||
for y = -3, 3, 1 do
|
||||
surface.regenerate_decorative(decorative_names, {{x,y}})
|
||||
end
|
||||
end
|
||||
|
||||
local y = 80
|
||||
local ore_positions = {{x = spawn_position_x - 52, y = y},{x = spawn_position_x - 52, y = y * 0.5},{x = spawn_position_x - 52, y = 0},{x = spawn_position_x - 52, y = y * -0.5},{x = spawn_position_x - 52, y = y * -1}}
|
||||
table.shuffle_table(ore_positions)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], "copper-ore", surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], "iron-ore", surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], "coal", surface, 15, 1500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], "stone", surface, 15, 1500)
|
||||
map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, "water", surface, 16)
|
||||
map_functions.draw_oil_circle(ore_positions[5], "crude-oil", surface, 8, 200000)
|
||||
|
||||
local pos = surface.find_non_colliding_position("market",{spawn_position_x, 0}, 50, 1)
|
||||
global.market = place_fish_market(surface, pos)
|
||||
|
||||
local r = 16
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = {{global.market.position.x - r, global.market.position.y - r}, {global.market.position.x + r, global.market.position.y + r}}, type = "tree"})) do
|
||||
local distance_to_center = math_sqrt((entity.position.x - global.market.position.x)^2 + (entity.position.y - global.market.position.y)^2)
|
||||
if distance_to_center < r then
|
||||
if math_random(1, r) > distance_to_center then entity.destroy() end
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position("gun-turret",{spawn_position_x + 5, 1}, 50, 1)
|
||||
local turret = surface.create_entity({name = "gun-turret", position = pos, force = "player"})
|
||||
turret.insert({name = "firearm-magazine", count = 32})
|
||||
|
||||
for x = -20, 20, 1 do
|
||||
for y = -20, 20, 1 do
|
||||
local pos = {x = global.market.position.x + x, y = global.market.position.y + y}
|
||||
--local distance_to_center = math_sqrt(x^2 + y^2)
|
||||
--if distance_to_center > 8 and distance_to_center < 15 then
|
||||
local distance_to_center = x^2 + y^2
|
||||
if distance_to_center > 64 and distance_to_center < 225 then
|
||||
if math_random(1,3) == 1 and surface.can_place_entity({name = "wooden-chest", position = pos, force = "player"}) then
|
||||
local chest = surface.create_entity({name = "wooden-chest", position = pos, force = "player"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local area = {{x = -160, y = -96}, {x = 160, y = 96}}
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = "water", area = area})) do
|
||||
if math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = "fish", position = tile.position})
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position("character",{spawn_position_x + 1, 4}, 50, 1)
|
||||
game.forces["player"].set_spawn_position(pos, surface)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local pos = surface.find_non_colliding_position("character",{spawn_position_x + 1, 4}, 50, 1)
|
||||
player.teleport(pos, surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function enemy_territory(surface, left_top)
|
||||
if left_top.x < 160 then
|
||||
return
|
||||
end
|
||||
if left_top.x > 750 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 512 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -512 then
|
||||
return
|
||||
end
|
||||
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}}
|
||||
|
||||
if left_top.x > 256 then
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_enemy_territory(pos) then
|
||||
if math_random(1, 512) == 1 then
|
||||
if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then
|
||||
local entity
|
||||
if math_random(1, 4) == 1 then
|
||||
entity =
|
||||
surface.create_entity(
|
||||
{name = 'spitter-spawner', force = 'decoratives', position = pos}
|
||||
)
|
||||
else
|
||||
entity =
|
||||
surface.create_entity(
|
||||
{name = 'biter-spawner', force = 'decoratives', position = pos}
|
||||
)
|
||||
end
|
||||
entity.active = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = {'tree', 'cliff'}})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = 'resource'})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
surface.create_entity({name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000)})
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = area})) do
|
||||
if is_enemy_territory(tile.position) then
|
||||
surface.set_tiles(
|
||||
{{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}},
|
||||
true
|
||||
)
|
||||
end
|
||||
end
|
||||
--surface.request_to_generate_chunks({x = 256, y = 0}, 16)
|
||||
--surface.force_generate_chunk_requests()
|
||||
|
||||
if left_top.x < 160 then return end
|
||||
if left_top.x > 750 then return end
|
||||
if left_top.y > 512 then return end
|
||||
if left_top.y < -512 then return end
|
||||
|
||||
local area = {{left_top.x, left_top.y},{left_top.x + 32, left_top.y + 32}}
|
||||
|
||||
--local area = {{160, -512},{750, 512}}
|
||||
--for _, tile in pairs(surface.find_tiles_filtered({area = area})) do
|
||||
-- if is_enemy_territory(tile.position) then
|
||||
-- surface.set_tiles({{name = "water-mud", position = {tile.position.x, tile.position.y}}}, true)
|
||||
-- end
|
||||
--end
|
||||
if left_top.x > 256 then
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_enemy_territory(pos) then
|
||||
if math_random(1, 512) == 1 then
|
||||
if surface.can_place_entity({name = "biter-spawner", force = "decoratives", position = pos}) then
|
||||
local entity
|
||||
if math_random(1,4) == 1 then
|
||||
entity = surface.create_entity({name = "spitter-spawner", force = "decoratives", position = pos})
|
||||
else
|
||||
entity = surface.create_entity({name = "biter-spawner", force = "decoratives", position = pos})
|
||||
end
|
||||
entity.active = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
--if pos.x % 32 == 0 and pos.y % 32 == 0 then
|
||||
-- local decorative_names = {}
|
||||
-- for k,v in pairs(game.decorative_prototypes) do
|
||||
-- if v.autoplace_specification then
|
||||
-- decorative_names[#decorative_names+1] = k
|
||||
-- end
|
||||
-- end
|
||||
-- surface.regenerate_decorative(decorative_names, {{x=math_floor(pos.x/32),y=math_floor(pos.y/32)}})
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = {"tree", "cliff"}})) do
|
||||
if is_enemy_territory(entity.position) then entity.destroy() end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = "resource"})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
surface.create_entity({name = "uranium-ore", position = entity.position, amount = math_random(200, 8000)})
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {"water", "deepwater"}, area = area})) do
|
||||
if is_enemy_territory(tile.position) then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function fish_mouth(surface, left_top)
|
||||
if left_top.x > -2300 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 64 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -64 then
|
||||
return
|
||||
end
|
||||
if left_top.x < -3292 then
|
||||
return
|
||||
end
|
||||
if left_top.x > -2300 then return end
|
||||
if left_top.y > 64 then return end
|
||||
if left_top.y < -64 then return end
|
||||
if left_top.x < -3292 then return end
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20
|
||||
if pos.y <= 12 + noise and pos.y >= -12 + noise then
|
||||
surface.set_tiles({{name = 'water', position = pos}})
|
||||
end
|
||||
end
|
||||
end
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20
|
||||
if pos.y <= 12 + noise and pos.y >= -12 + noise then surface.set_tiles({{name = "water", position = pos}}) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ores = {'coal', 'iron-ore', 'copper-ore', 'stone'}
|
||||
function fish_eye(surface, position)
|
||||
surface.request_to_generate_chunks(position, 2)
|
||||
surface.force_generate_chunk_requests()
|
||||
for x = -48, 48, 1 do
|
||||
for y = -48, 48, 1 do
|
||||
local p = {x = position.x + x, y = position.y + y}
|
||||
--local distance = math_sqrt(((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2))
|
||||
--if distance < 44 then
|
||||
-- surface.set_tiles({{name = "water-green", position = p}}, true)
|
||||
--end
|
||||
--if distance < 22 then
|
||||
-- surface.set_tiles({{name = "out-of-map", position = p}}, true)
|
||||
--end
|
||||
|
||||
local function plankton_territory(surface, position, seed)
|
||||
local noise = simplex_noise(position.x * 0.009, position.y * 0.009, seed)
|
||||
local d = 196
|
||||
if
|
||||
position.x + position.y > (d * -1) - (math_abs(noise) * d * 3) and
|
||||
position.x > position.y - (d + (math_abs(noise) * d * 3))
|
||||
then
|
||||
return 'out-of-map'
|
||||
end
|
||||
local distance = ((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2)
|
||||
if distance < 1936 then
|
||||
if distance < 484 then
|
||||
surface.set_tiles({{name = "out-of-map", position = p}}, true)
|
||||
else
|
||||
surface.set_tiles({{name = "water-green", position = p}}, true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local noise_2 = simplex_noise(position.x * 0.0075, position.y * 0.0075, seed + 10000)
|
||||
--if noise_2 > 0.87 then surface.set_tiles({{name = "deepwater-green", position = position}}, true) return true end
|
||||
if noise_2 > 0.87 then
|
||||
return 'deepwater-green'
|
||||
end
|
||||
if noise_2 > 0.75 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
surface.create_entity({name = ores[i], position = position, amount = 1 + 2500 * math_abs(noise_2 * 3)})
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if noise_2 < -0.76 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if noise_2 < -0.86 then
|
||||
surface.create_entity(
|
||||
{name = 'uranium-ore', position = position, amount = 1 + 1000 * math_abs(noise_2 * 2)}
|
||||
)
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if math_random(1, 3) ~= 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position})
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
local ores = {"coal", "iron-ore", "copper-ore", "stone"}
|
||||
|
||||
if noise < 0.12 and noise > -0.12 then
|
||||
local i = math_floor(noise * 32) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if math_random(1, 5) == 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position})
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
|
||||
--surface.set_tiles({{name = "water", position = position}}, true)
|
||||
if math_random(1, 128) == 1 then
|
||||
surface.create_entity({name = 'fish', position = position})
|
||||
end
|
||||
|
||||
return 'water'
|
||||
local function plankton_territory(surface, position, seed)
|
||||
local noise = simplex_noise(position.x * 0.009, position.y * 0.009, seed)
|
||||
local d = 196
|
||||
local tile_to_set = "out-of-map"
|
||||
if position.x + position.y > (d * -1) - (math_abs(noise) * d * 3) and position.x > position.y - (d + (math_abs(noise) * d * 3)) then return "out-of-map" end
|
||||
|
||||
local noise_2 = simplex_noise(position.x * 0.0075, position.y * 0.0075, seed + 10000)
|
||||
--if noise_2 > 0.87 then surface.set_tiles({{name = "deepwater-green", position = position}}, true) return true end
|
||||
if noise_2 > 0.87 then return "deepwater-green" end
|
||||
if noise_2 > 0.75 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
surface.create_entity({name = ores[i], position = position, amount = 1 + 2500 * math_abs(noise_2 * 3)})
|
||||
return ("grass-" .. i)
|
||||
end
|
||||
if noise_2 < -0.76 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if noise_2 < -0.86 then surface.create_entity({name = "uranium-ore", position = position, amount = 1 + 1000 * math_abs(noise_2 * 2)}) return ("grass-" .. i) end
|
||||
if math_random(1, 3) ~= 1 then surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position}) end
|
||||
return ("grass-" .. i)
|
||||
end
|
||||
|
||||
if noise < 0.12 and noise > -0.12 then
|
||||
local i = math_floor(noise * 32) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if math_random(1, 5) == 1 then surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position}) end
|
||||
return ("grass-" .. i)
|
||||
end
|
||||
|
||||
--surface.set_tiles({{name = "water", position = position}}, true)
|
||||
if math_random(1, 128) == 1 then surface.create_entity({name = "fish", position = position}) end
|
||||
|
||||
return "water"
|
||||
end
|
||||
|
||||
local function process_chunk(left_top)
|
||||
local this = FDT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
|
||||
Public.generate_spawn_area(this, surface, left_top)
|
||||
enemy_territory(surface, left_top)
|
||||
fish_mouth(surface, left_top)
|
||||
|
||||
local tiles = {}
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_out_of_map_tile(pos) then
|
||||
--if not plankton_territory(surface, pos, seed) then surface.set_tiles({{name = "out-of-map", position = pos}}, true) end
|
||||
local tile_to_set = plankton_territory(surface, pos, seed)
|
||||
--local tile_to_set = "out-of-map"
|
||||
tiles[#tiles + 1] = {name = tile_to_set, position = pos}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
|
||||
--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
|
||||
if this.market and this.market.valid then
|
||||
this.game_reset = false
|
||||
end
|
||||
local surface = game.surfaces["fish_defender"]
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
|
||||
generate_spawn_area(surface)
|
||||
enemy_territory(surface, left_top)
|
||||
fish_mouth(surface, left_top)
|
||||
|
||||
local tiles = {}
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_out_of_map_tile(pos) then
|
||||
--if not plankton_territory(surface, pos, seed) then surface.set_tiles({{name = "out-of-map", position = pos}}, true) end
|
||||
local tile_to_set = plankton_territory(surface, pos, seed)
|
||||
--local tile_to_set = "out-of-map"
|
||||
table.insert(tiles, {name = tile_to_set, position = pos})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles,true)
|
||||
|
||||
--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()
|
||||
local chunks = #global.chunk_queue
|
||||
if chunks <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
for k, left_top in pairs(global.chunk_queue) do
|
||||
process_chunk(left_top)
|
||||
global.chunk_queue[k] = nil
|
||||
return
|
||||
end
|
||||
for k, left_top in pairs(global.chunk_queue) do
|
||||
process_chunk(left_top)
|
||||
table.remove(global.chunk_queue, k)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local map_name = 'fish_defender'
|
||||
|
||||
if string.sub(event.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
local left_top = event.area.left_top
|
||||
local this = FDT.get()
|
||||
if this.game_has_ended then
|
||||
return
|
||||
end
|
||||
|
||||
if game.tick == 0 or this.game_reset or this.force_chunk then
|
||||
process_chunk(left_top)
|
||||
else
|
||||
global.chunk_queue[#global.chunk_queue + 1] = {x = left_top.x, y = left_top.y}
|
||||
end
|
||||
if game.surfaces["fish_defender"].index ~= event.surface.index then return end
|
||||
local left_top = event.area.left_top
|
||||
|
||||
if game.tick == 0 then
|
||||
process_chunk(left_top)
|
||||
else
|
||||
table.insert(global.chunk_queue, {x = left_top.x, y = left_top.y})
|
||||
end
|
||||
end
|
||||
|
||||
local function render_market_hp()
|
||||
local this = FDT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
this.health_text =
|
||||
rendering.draw_text {
|
||||
text = 'HP: ' .. this.market_health .. ' / ' .. this.market_max_health,
|
||||
surface = surface,
|
||||
target = this.market,
|
||||
target_offset = {0, -3},
|
||||
color = {0, 255, 0},
|
||||
scale = 1.40,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
this.caption =
|
||||
rendering.draw_text {
|
||||
text = 'Fish Market',
|
||||
surface = surface,
|
||||
target = this.market,
|
||||
target_offset = {0, -4.4},
|
||||
color = {0, 255, 0},
|
||||
scale = 1.80,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
function Public.generate_spawn_area(this, surface)
|
||||
if this.spawn_area_generated then
|
||||
return
|
||||
end
|
||||
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 7)
|
||||
surface.request_to_generate_chunks({x = 160, y = 0}, 4)
|
||||
--surface.force_generate_chunk_requests()
|
||||
|
||||
if not surface.is_chunk_generated({-7, 0}) then
|
||||
return
|
||||
end
|
||||
if not surface.is_chunk_generated({5, 0}) then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_position_x = -128
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {160, -96}, source = {160, -96}, target = {160, 96}})
|
||||
|
||||
for _, tile in pairs(
|
||||
surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-160, -160}, {160, 160}}})
|
||||
) do
|
||||
local noise =
|
||||
math_abs(
|
||||
simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16
|
||||
)
|
||||
if tile.position.x > -160 + noise then
|
||||
surface.set_tiles(
|
||||
{{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}},
|
||||
true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{type = {'resource', 'cliff'}, area = {{spawn_position_x - 32, -256}, {160, 256}}}
|
||||
)
|
||||
) do
|
||||
if is_body(entity.position) then
|
||||
if
|
||||
entity.position.x >
|
||||
spawn_position_x - 32 +
|
||||
math_abs(
|
||||
simplex_noise(
|
||||
entity.position.x * 0.02,
|
||||
entity.position.y * 0.02,
|
||||
game.surfaces[1].map_gen_settings.seed
|
||||
) * 16
|
||||
)
|
||||
then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local decorative_names = {}
|
||||
for k, v in pairs(game.decorative_prototypes) do
|
||||
if v.autoplace_specification then
|
||||
decorative_names[#decorative_names + 1] = k
|
||||
end
|
||||
end
|
||||
for x = -4, 4, 1 do
|
||||
for y = -3, 3, 1 do
|
||||
surface.regenerate_decorative(decorative_names, {{x, y}})
|
||||
end
|
||||
end
|
||||
|
||||
local y = 80
|
||||
local ore_positions = {
|
||||
{x = spawn_position_x - 52, y = y},
|
||||
{x = spawn_position_x - 52, y = y * 0.5},
|
||||
{x = spawn_position_x - 52, y = 0},
|
||||
{x = spawn_position_x - 52, y = y * -0.5},
|
||||
{x = spawn_position_x - 52, y = y * -1}
|
||||
}
|
||||
shuffle(ore_positions)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 15, 1500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 15, 1500)
|
||||
map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, 'water', surface, 16)
|
||||
map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000)
|
||||
|
||||
local pos = surface.find_non_colliding_position('market', {spawn_position_x, 0}, 50, 1)
|
||||
this.market = place_fish_market(surface, pos)
|
||||
|
||||
render_market_hp()
|
||||
|
||||
local r = 16
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{
|
||||
area = {
|
||||
{this.market.position.x - r, this.market.position.y - r},
|
||||
{this.market.position.x + r, this.market.position.y + r}
|
||||
},
|
||||
type = 'tree'
|
||||
}
|
||||
)
|
||||
) do
|
||||
local distance_to_center =
|
||||
math_sqrt(
|
||||
(entity.position.x - this.market.position.x) ^ 2 + (entity.position.y - this.market.position.y) ^ 2
|
||||
)
|
||||
if distance_to_center < r then
|
||||
if math_random(1, r) > distance_to_center then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x + 5, 1}, 50, 1)
|
||||
local turret = surface.create_entity({name = 'gun-turret', position = pos, force = 'player'})
|
||||
turret.insert({name = 'firearm-magazine', count = 32})
|
||||
|
||||
for x = -20, 20, 1 do
|
||||
for y = -20, 20, 1 do
|
||||
local pos = {x = this.market.position.x + x, y = this.market.position.y + y}
|
||||
--local distance_to_center = math_sqrt(x^2 + y^2)
|
||||
--if distance_to_center > 8 and distance_to_center < 15 then
|
||||
local distance_to_center = x ^ 2 + y ^ 2
|
||||
if distance_to_center > 64 and distance_to_center < 225 then
|
||||
if
|
||||
math_random(1, 3) == 1 and
|
||||
surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'player'})
|
||||
then
|
||||
surface.create_entity({name = 'wooden-chest', position = pos, force = 'player'})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local area = {{x = -160, y = -96}, {x = 160, y = 96}}
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do
|
||||
if math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = 'fish', position = tile.position})
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
game.forces['player'].set_spawn_position(pos, surface)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
player.teleport(pos, surface)
|
||||
end
|
||||
this.spawn_area_generated = true
|
||||
end
|
||||
|
||||
function Public.fish_eye(surface, position)
|
||||
surface.request_to_generate_chunks(position, 2)
|
||||
surface.force_generate_chunk_requests()
|
||||
for x = -48, 48, 1 do
|
||||
for y = -48, 48, 1 do
|
||||
local p = {x = position.x + x, y = position.y + y}
|
||||
--local distance = math_sqrt(((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2))
|
||||
--if distance < 44 then
|
||||
-- surface.set_tiles({{name = "water-green", position = p}}, true)
|
||||
--end
|
||||
--if distance < 22 then
|
||||
-- surface.set_tiles({{name = "out-of-map", position = p}}, true)
|
||||
--end
|
||||
|
||||
local distance = ((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2)
|
||||
if distance < 1936 then
|
||||
if distance < 484 then
|
||||
surface.set_tiles({{name = 'out-of-map', position = p}}, true)
|
||||
else
|
||||
surface.set_tiles({{name = 'water-green', position = p}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.on_nth_tick(25, process_chunk_queue)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
|
||||
return Public
|
||||
local event = require 'utils.event'
|
||||
event.on_nth_tick(25, process_chunk_queue)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
@ -1,61 +1,44 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local event = require 'utils.event'
|
||||
|
||||
local radius = 20
|
||||
|
||||
local whitelist = {
|
||||
['defender'] = 'explosive-cannon-projectile',
|
||||
['distractor'] = 'explosive-uranium-cannon-projectile',
|
||||
['destroyer'] = 'explosive-uranium-cannon-projectile'
|
||||
["defender"] = "explosive-cannon-projectile",
|
||||
["distractor"] = "explosive-uranium-cannon-projectile",
|
||||
["destroyer"] = "explosive-uranium-cannon-projectile"
|
||||
}
|
||||
|
||||
local function on_entity_died(event)
|
||||
local trapped_capsules_unlocked = FDT.get('trapped_capsules_unlocked')
|
||||
if not 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
|
||||
}
|
||||
)
|
||||
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)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
|
||||
|
@ -1,52 +1,34 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
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
|
||||
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)
|
||||
local ultra_mines_unlocked = FDT.get('ultra_mines_unlocked')
|
||||
if not 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)
|
||||
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)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local vehicle_nanobots_unlocked = FDT.get('vehicle_nanobots_unlocked')
|
||||
|
||||
if not vehicle_nanobots_unlocked then
|
||||
if not global.vehicle_nanobots_unlocked then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
99
maps/fish_defender_v2/boss_biters.lua
Normal file
99
maps/fish_defender_v2/boss_biters.lua
Normal file
@ -0,0 +1,99 @@
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
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',
|
||||
['big-spitter'] = 'acid-stream-worm-medium',
|
||||
['behemoth-spitter'] = '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(16, 32) 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)
|
||||
local this = FDT.get()
|
||||
if acid_splashes[event.entity.name] then
|
||||
acid_nova(event)
|
||||
end
|
||||
if this.acid_lines_delay[event.entity.unit_number] then
|
||||
this.acid_lines_delay[event.entity.unit_number] = nil
|
||||
end
|
||||
this.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)
|
||||
|
||||
if distance > 16 then
|
||||
return false
|
||||
end
|
||||
|
||||
local modifier = {(target.x - source.x) / distance, (target.y - source.y) / distance}
|
||||
|
||||
local position = {source.x, source.y}
|
||||
|
||||
for i = 1, distance + 4, 1 do
|
||||
if math_random(1, 3) == 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
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
boss_biter.damaged_entity = function(event)
|
||||
if acid_lines[event.cause.name] then
|
||||
local this = FDT.get()
|
||||
if not this.acid_lines_delay[event.cause.unit_number] then
|
||||
this.acid_lines_delay[event.cause.unit_number] = 0
|
||||
end
|
||||
|
||||
if this.acid_lines_delay[event.cause.unit_number] < game.tick then
|
||||
if acid_line(event.cause.surface, acid_lines[event.cause.name], event.cause.position, event.entity.position) then
|
||||
this.acid_lines_delay[event.cause.unit_number] = game.tick + 180
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return boss_biter
|
76
maps/fish_defender_v2/bouncy_shells.lua
Normal file
76
maps/fish_defender_v2/bouncy_shells.lua
Normal file
@ -0,0 +1,76 @@
|
||||
local radius = 9
|
||||
local math_random = math.random
|
||||
|
||||
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 = 'player',
|
||||
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 _ = 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
|
@ -1,5 +1,6 @@
|
||||
local Server = require 'utils.server'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
local Task = require 'utils.task'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
@ -31,7 +32,7 @@ commands.add_command(
|
||||
::continue::
|
||||
|
||||
local this = FDT.get()
|
||||
local reset_map = require 'maps.fish_defender.main'.reset_game
|
||||
local reset_map = require 'maps.fish_defender_v2.main'.reset_game
|
||||
|
||||
if not this.reset_are_you_sure then
|
||||
this.reset_are_you_sure = true
|
||||
@ -61,7 +62,7 @@ commands.add_command(
|
||||
elseif param == 'restartnow' then
|
||||
this.reset_are_you_sure = nil
|
||||
p(player.name .. ' has restarted the game.')
|
||||
Server.start_scenario('Fish_Defender')
|
||||
Server.start_scenario('Fish_Defender_v2')
|
||||
return
|
||||
elseif param == 'shutdown' then
|
||||
if this.shutdown then
|
||||
@ -93,3 +94,55 @@ commands.add_command(
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
commands.add_command(
|
||||
'set_queue_speed',
|
||||
'Usable only for admins - sets the queue speed of this map!',
|
||||
function(cmd)
|
||||
local p
|
||||
local player = game.player
|
||||
local param = tonumber(cmd.parameter)
|
||||
|
||||
if player then
|
||||
if player ~= nil then
|
||||
p = player.print
|
||||
if not player.admin then
|
||||
p("[ERROR] You're not admin!", Color.fail)
|
||||
return
|
||||
end
|
||||
if not param then
|
||||
return
|
||||
end
|
||||
p('Queue speed set to: ' .. param)
|
||||
Task.set_queue_speed(param)
|
||||
else
|
||||
p = log
|
||||
p('Queue speed set to: ' .. param)
|
||||
Task.set_queue_speed(param)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
commands.add_command(
|
||||
'get_queue_speed',
|
||||
'Usable only for admins - gets the queue speed of this map!',
|
||||
function()
|
||||
local p
|
||||
local player = game.player
|
||||
|
||||
if player then
|
||||
if player ~= nil then
|
||||
p = player.print
|
||||
if not player.admin then
|
||||
p("[ERROR] You're not admin!", Color.fail)
|
||||
return
|
||||
end
|
||||
p(Task.get_queue_speed())
|
||||
else
|
||||
p = log
|
||||
p(Task.get_queue_speed())
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
27
maps/fish_defender_v2/crumbly_walls.lua
Normal file
27
maps/fish_defender_v2/crumbly_walls.lua
Normal file
@ -0,0 +1,27 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
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)
|
||||
local crumbly_walls_unlocked = FDT.get('crumbly_walls_unlocked')
|
||||
if not 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)
|
46
maps/fish_defender_v2/explosive_gun_bullets.lua
Normal file
46
maps/fish_defender_v2/explosive_gun_bullets.lua
Normal file
@ -0,0 +1,46 @@
|
||||
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
|
52
maps/fish_defender_v2/flame_boots.lua
Normal file
52
maps/fish_defender_v2/flame_boots.lua
Normal file
@ -0,0 +1,52 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local flame_boots = FDT.get('flame_boots')
|
||||
if not 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 flame_boots[player.index] then
|
||||
flame_boots[player.index] = {}
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].fuel then
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel < 0 then
|
||||
player.print('Your flame boots have worn out.', {r = 0.22, g = 0.77, b = 0.44})
|
||||
flame_boots[player.index] = {}
|
||||
return
|
||||
end
|
||||
|
||||
if flame_boots[player.index].fuel % 500 == 0 then
|
||||
player.print('Fuel remaining: ' .. flame_boots[player.index].fuel, {r = 0.22, g = 0.77, b = 0.44})
|
||||
end
|
||||
|
||||
if not flame_boots[player.index].step_history then
|
||||
flame_boots[player.index].step_history = {}
|
||||
end
|
||||
|
||||
local elements = #flame_boots[player.index].step_history
|
||||
|
||||
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 = flame_boots[player.index].step_history[elements - 2]})
|
||||
|
||||
flame_boots[player.index].fuel = flame_boots[player.index].fuel - 1
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
37
maps/fish_defender_v2/laser_pointer.lua
Normal file
37
maps/fish_defender_v2/laser_pointer.lua
Normal file
@ -0,0 +1,37 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
local radius = 32
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
local laser_pointer_unlocked = FDT.get('laser_pointer_unlocked')
|
||||
if not 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)
|
1546
maps/fish_defender_v2/main.lua
Normal file
1546
maps/fish_defender_v2/main.lua
Normal file
File diff suppressed because it is too large
Load Diff
345
maps/fish_defender_v2/market.lua
Normal file
345
maps/fish_defender_v2/market.lua
Normal file
@ -0,0 +1,345 @@
|
||||
require 'maps.fish_defender_v2.flame_boots'
|
||||
require 'maps.fish_defender_v2.trapped_capsules'
|
||||
require 'maps.fish_defender_v2.ultra_mines'
|
||||
require 'maps.fish_defender_v2.crumbly_walls'
|
||||
require 'maps.fish_defender_v2.vehicle_nanobots'
|
||||
require 'maps.fish_defender_v2.laser_pointer'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
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.'
|
||||
}
|
||||
|
||||
local function refresh_market_offers()
|
||||
local this = FDT.get()
|
||||
if not this.market or not this.market.valid then
|
||||
return
|
||||
end
|
||||
for i = 1, 100, 1 do
|
||||
local a = this.market.remove_market_item(1)
|
||||
if a == false then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local str1 =
|
||||
'Gun Turret Slot for ' ..
|
||||
tostring(this.entity_limits['gun-turret'].limit * this.entity_limits['gun-turret'].slot_price)
|
||||
str1 = str1 .. ' Coins.'
|
||||
|
||||
local str2 =
|
||||
'Laser Turret Slot for ' ..
|
||||
tostring(this.entity_limits['laser-turret'].limit * this.entity_limits['laser-turret'].slot_price)
|
||||
str2 = str2 .. ' Coins.'
|
||||
|
||||
local str3 =
|
||||
'Artillery Slot for ' ..
|
||||
tostring(this.entity_limits['artillery-turret'].limit * this.entity_limits['artillery-turret'].slot_price)
|
||||
str3 = str3 .. ' Coins.'
|
||||
|
||||
local current_limit = 1
|
||||
if this.entity_limits['flamethrower-turret'].limit ~= 0 then
|
||||
current_limit = current_limit + this.entity_limits['flamethrower-turret'].limit
|
||||
end
|
||||
local str4 =
|
||||
'Flamethrower Turret Slot for ' ..
|
||||
tostring(current_limit * this.entity_limits['flamethrower-turret'].slot_price)
|
||||
str4 = str4 .. ' Coins.'
|
||||
|
||||
local str5 =
|
||||
'Landmine Slot for ' ..
|
||||
tostring(math.ceil((this.entity_limits['land-mine'].limit / 3) * this.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
|
||||
this.market.add_market_item(item)
|
||||
end
|
||||
|
||||
if not this.railgun_enhancer_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 1500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['railgun-enhancer']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.trapped_capsules_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 3500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['trapped-capsules']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.explosive_bullets_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 4500}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['explosive-bullets']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.bouncy_shells_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 10000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['bouncy-shells']}
|
||||
}
|
||||
)
|
||||
end
|
||||
if not this.vehicle_nanobots_unlocked then
|
||||
this.market.add_market_item(
|
||||
{
|
||||
price = {{'coin', 15000}},
|
||||
offer = {type = 'nothing', effect_description = special_descriptions['vehicle-nanobots']}
|
||||
}
|
||||
)
|
||||
end
|
||||
--[[
|
||||
if not this.crumbly_walls_unlocked then
|
||||
this.market.add_market_item({price = {{"coin", 35000}}, offer = {type = 'nothing', effect_description = special_descriptions["crumbly-walls"]}})
|
||||
end
|
||||
if not this.ultra_mines_unlocked then
|
||||
this.market.add_market_item({price = {{"coin", 45000}}, offer = {type = 'nothing', effect_description = special_descriptions["ultra-mines"]}})
|
||||
end
|
||||
]]
|
||||
if not this.laser_pointer_unlocked then
|
||||
this.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 this = FDT.get()
|
||||
local price =
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit *
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
|
||||
local gain = 1
|
||||
if offer_index == 5 then
|
||||
price =
|
||||
math.ceil(
|
||||
(this.entity_limits[slot_upgrade_offers[offer_index][1]].limit / 3) *
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].slot_price
|
||||
)
|
||||
gain = 3
|
||||
end
|
||||
|
||||
if slot_upgrade_offers[offer_index][1] == 'flamethrower-turret' then
|
||||
price =
|
||||
(this.entity_limits[slot_upgrade_offers[offer_index][1]].limit + 1) *
|
||||
this.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
|
||||
|
||||
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit =
|
||||
this.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}
|
||||
)
|
||||
if math.random(1, 2) == 1 then
|
||||
Server.to_discord_bold(
|
||||
table.concat {
|
||||
'*** ' ..
|
||||
player.name ..
|
||||
' has bought a ' ..
|
||||
slot_upgrade_offers[offer_index][2] .. ' slot for ' .. price .. ' coins! ***'
|
||||
}
|
||||
)
|
||||
end
|
||||
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
|
||||
local this = FDT.get()
|
||||
|
||||
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 this.flame_boots[player.index].fuel then
|
||||
this.flame_boots[player.index].fuel = math.random(1500, 3000)
|
||||
else
|
||||
this.flame_boots[player.index].fuel = this.flame_boots[player.index].fuel + math.random(1500, 3000)
|
||||
end
|
||||
|
||||
player.print('Fuel remaining: ' .. this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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})
|
||||
this.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)
|
65
maps/fish_defender_v2/on_entity_damaged.lua
Normal file
65
maps/fish_defender_v2/on_entity_damaged.lua
Normal file
@ -0,0 +1,65 @@
|
||||
require 'maps.fish_defender_v2.boss_biters'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local enhance_railgun = require 'maps.fish_defender_v2.railgun_enhancer'
|
||||
local explosive_bullets = require 'maps.fish_defender_v2.explosive_gun_bullets'
|
||||
local bouncy_shells = require 'maps.fish_defender_v2.bouncy_shells'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
local function protect_market(event)
|
||||
if event.entity.name ~= 'market' then
|
||||
return
|
||||
end
|
||||
if event.cause then
|
||||
if event.cause.force.name == 'enemy' then
|
||||
return
|
||||
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
|
||||
local explosive_bullets_unlocked = FDT.get('explosive_bullets_unlocked')
|
||||
local bouncy_shells_unlocked = FDT.get('bouncy_shells_unlocked')
|
||||
|
||||
--if event.cause.unit_number then
|
||||
-- if this.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 explosive_bullets_unlocked then
|
||||
if explosive_bullets(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if bouncy_shells_unlocked then
|
||||
if bouncy_shells(event) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
157
maps/fish_defender_v2/railgun_enhancer.lua
Normal file
157
maps/fish_defender_v2/railgun_enhancer.lua
Normal file
@ -0,0 +1,157 @@
|
||||
-- improves the damage of the railgun and adds visual effects -- by mewmew
|
||||
-- laser turret research will increase it´s damage even further --
|
||||
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
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)
|
||||
local railgun_enhancer_unlocked = FDT.get('railgun_enhancer_unlocked')
|
||||
if not 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
|
31
maps/fish_defender_v2/shotgun_buff.lua
Normal file
31
maps/fish_defender_v2/shotgun_buff.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
local gain_multiplier = 4
|
||||
|
||||
local function on_research_finished(event)
|
||||
local research = event.research
|
||||
local force_name = research.force.name
|
||||
local this = FDT.get()
|
||||
|
||||
if not this.shotgun_shell_damage_modifier_old[force_name] then
|
||||
this.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 - this.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
|
||||
|
||||
this.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)
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
@ -25,6 +25,7 @@ function Public.reset_table()
|
||||
this.game_reset = false
|
||||
this.spawn_area_generated = false
|
||||
this.results_sent = false
|
||||
|
||||
this.explosive_bullets_unlocked = false
|
||||
this.bouncy_shells_unlocked = false
|
||||
this.trapped_capsules_unlocked = false
|
||||
@ -49,7 +50,7 @@ function Public.reset_table()
|
||||
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
|
||||
['artillery-turret'] = {placed = 0, limit = 1, str = 'artillery turret', slot_price = 500},
|
||||
['flamethrower-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
|
||||
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 6}
|
||||
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 20}
|
||||
}
|
||||
this.difficulties_votes = {
|
||||
[1] = {wave_interval = 4500, amount_modifier = 0.52, strength_modifier = 0.40, boss_modifier = 3.0},
|
578
maps/fish_defender_v2/terrain.lua
Normal file
578
maps/fish_defender_v2/terrain.lua
Normal file
@ -0,0 +1,578 @@
|
||||
local Event = require 'utils.event'
|
||||
local map_functions = require 'tools.map_functions'
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
local tiles_per_call = 16
|
||||
local total_calls = math.ceil(1024 / tiles_per_call)
|
||||
|
||||
local Public = {}
|
||||
|
||||
local rock_raffle = {
|
||||
'sand-rock-big',
|
||||
'sand-rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-huge'
|
||||
}
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math.random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local function get_replacement_tile(surface, position)
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
shuffle(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'grass-1'
|
||||
end
|
||||
|
||||
local function is_enemy_territory(p)
|
||||
if p.x - 64 < math_abs(p.y) then
|
||||
return false
|
||||
end
|
||||
--if p.x - 64 < p.y then return false end
|
||||
if p.x < 160 then
|
||||
return false
|
||||
end
|
||||
if p.x > 1024 then
|
||||
return false
|
||||
end
|
||||
if p.y > 512 then
|
||||
return false
|
||||
end
|
||||
if p.y < -512 then
|
||||
return false
|
||||
end
|
||||
local noise = math_abs(simplex_noise(0, p.y * 0.015, game.surfaces[1].map_gen_settings.seed) * 96)
|
||||
local noise_2 = math_abs(simplex_noise(0, p.y * 0.1, game.surfaces[1].map_gen_settings.seed) * 16)
|
||||
if p.x > 288 + noise + noise_2 + math_abs(p.y * 0.75) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local body_radius = 3072
|
||||
local body_square_radius = body_radius ^ 2
|
||||
local body_center_position = {x = -1500, y = 0}
|
||||
local body_spacing = math_floor(body_radius * 0.82)
|
||||
local body_circle_center_1 = {x = body_center_position.x, y = body_center_position.y - body_spacing}
|
||||
local body_circle_center_2 = {x = body_center_position.x, y = body_center_position.y + body_spacing}
|
||||
|
||||
local fin_radius = 800
|
||||
local square_fin_radius = fin_radius ^ 2
|
||||
local fin_circle_center_1 = {x = -480, y = 0}
|
||||
local fin_circle_center_2 = {x = -480 - 360, y = 0}
|
||||
|
||||
local function is_body(p)
|
||||
local this = FDT.get()
|
||||
if p.y <= this.map_height and p.y >= this.map_height * -1 and p.x <= 160 and p.x > body_center_position.x then
|
||||
return true
|
||||
end
|
||||
|
||||
--Main Fish Body
|
||||
local distance_to_center_1 = ((p.x - body_circle_center_1.x) ^ 2 + (p.y - body_circle_center_1.y) ^ 2)
|
||||
local distance_to_center_2 = ((p.x - body_circle_center_2.x) ^ 2 + (p.y - body_circle_center_2.y) ^ 2)
|
||||
--if distance_to_center_1 < body_square_radius and distance_to_center_2 < body_square_radius then return true end
|
||||
if distance_to_center_1 < body_square_radius then
|
||||
if distance_to_center_2 < body_square_radius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--Fish Fins
|
||||
distance_to_center_1 = ((p.x - fin_circle_center_1.x) ^ 2 + (p.y - fin_circle_center_1.y) ^ 2)
|
||||
if
|
||||
distance_to_center_1 + math_abs(simplex_noise(0, p.y * 0.075, game.surfaces[1].map_gen_settings.seed) * 32000) >
|
||||
square_fin_radius
|
||||
then
|
||||
distance_to_center_2 = ((p.x - fin_circle_center_2.x) ^ 2 + (p.y - fin_circle_center_2.y) ^ 2)
|
||||
if distance_to_center_2 < square_fin_radius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function is_out_of_map_tile(p)
|
||||
if p.y > 850 then
|
||||
return true
|
||||
end
|
||||
if p.y < -850 then
|
||||
return true
|
||||
end
|
||||
if p.x < -3264 then
|
||||
return true
|
||||
end
|
||||
if p.x > 800 then
|
||||
return true
|
||||
end
|
||||
if is_enemy_territory(p) then
|
||||
return false
|
||||
end
|
||||
if is_body(p) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local 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 enemy_territory(surface, left_top)
|
||||
if left_top.x < 160 then
|
||||
return
|
||||
end
|
||||
if left_top.x > 750 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 512 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -512 then
|
||||
return
|
||||
end
|
||||
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + 32, left_top.y + 32}}
|
||||
|
||||
if left_top.x > 256 then
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_enemy_territory(pos) then
|
||||
if math_random(1, 512) == 1 then
|
||||
if surface.can_place_entity({name = 'biter-spawner', force = 'decoratives', position = pos}) then
|
||||
local entity
|
||||
if math_random(1, 4) == 1 then
|
||||
entity =
|
||||
surface.create_entity(
|
||||
{name = 'spitter-spawner', force = 'decoratives', position = pos}
|
||||
)
|
||||
else
|
||||
entity =
|
||||
surface.create_entity(
|
||||
{name = 'biter-spawner', force = 'decoratives', position = pos}
|
||||
)
|
||||
end
|
||||
entity.active = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = {'tree', 'cliff'}})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area, type = 'resource'})) do
|
||||
if is_enemy_territory(entity.position) then
|
||||
surface.create_entity({name = 'uranium-ore', position = entity.position, amount = math_random(200, 8000)})
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = area})) do
|
||||
if is_enemy_territory(tile.position) then
|
||||
surface.set_tiles(
|
||||
{{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}},
|
||||
true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function fish_mouth(surface, left_top)
|
||||
if left_top.x > -2300 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 64 then
|
||||
return
|
||||
end
|
||||
if left_top.y < -64 then
|
||||
return
|
||||
end
|
||||
if left_top.x < -3292 then
|
||||
return
|
||||
end
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local noise = simplex_noise(pos.x * 0.006, 0, game.surfaces[1].map_gen_settings.seed) * 20
|
||||
if pos.y <= 12 + noise and pos.y >= -12 + noise then
|
||||
surface.set_tiles({{name = 'water', position = pos}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ores = {'coal', 'iron-ore', 'copper-ore', 'stone'}
|
||||
|
||||
local function plankton_territory(surface, position, seed)
|
||||
local noise = simplex_noise(position.x * 0.009, position.y * 0.009, seed)
|
||||
local d = 196
|
||||
if
|
||||
position.x + position.y > (d * -1) - (math_abs(noise) * d * 3) and
|
||||
position.x > position.y - (d + (math_abs(noise) * d * 3))
|
||||
then
|
||||
return 'out-of-map'
|
||||
end
|
||||
|
||||
local noise_2 = simplex_noise(position.x * 0.0075, position.y * 0.0075, seed + 10000)
|
||||
--if noise_2 > 0.87 then surface.set_tiles({{name = "deepwater-green", position = position}}, true) return true end
|
||||
if noise_2 > 0.87 then
|
||||
return 'deepwater-green'
|
||||
end
|
||||
if noise_2 > 0.75 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
surface.create_entity({name = ores[i], position = position, amount = 1 + 2500 * math_abs(noise_2 * 3)})
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if noise_2 < -0.76 then
|
||||
local i = math_floor(noise * 6) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if noise_2 < -0.86 then
|
||||
surface.create_entity(
|
||||
{name = 'uranium-ore', position = position, amount = 1 + 1000 * math_abs(noise_2 * 2)}
|
||||
)
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
if math_random(1, 3) ~= 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position})
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
|
||||
if noise < 0.12 and noise > -0.12 then
|
||||
local i = math_floor(noise * 32) % 4 + 1
|
||||
--surface.set_tiles({{name = "grass-" .. i, position = position}}, true)
|
||||
if math_random(1, 5) == 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position})
|
||||
end
|
||||
return ('grass-' .. i)
|
||||
end
|
||||
|
||||
--surface.set_tiles({{name = "water", position = position}}, true)
|
||||
if math_random(1, 128) == 1 then
|
||||
surface.create_entity({name = 'fish', position = position})
|
||||
end
|
||||
|
||||
return 'water'
|
||||
end
|
||||
|
||||
local function render_market_hp()
|
||||
local this = FDT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
this.health_text =
|
||||
rendering.draw_text {
|
||||
text = 'HP: ' .. this.market_health .. ' / ' .. this.market_max_health,
|
||||
surface = surface,
|
||||
target = this.market,
|
||||
target_offset = {0, -3},
|
||||
color = {0, 255, 0},
|
||||
scale = 1.40,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
this.caption =
|
||||
rendering.draw_text {
|
||||
text = 'Fish Market',
|
||||
surface = surface,
|
||||
target = this.market,
|
||||
target_offset = {0, -4.4},
|
||||
color = {0, 255, 0},
|
||||
scale = 1.80,
|
||||
font = 'default-game',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
local function generate_spawn_area(this, surface)
|
||||
if this.spawn_area_generated then
|
||||
return
|
||||
end
|
||||
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 7)
|
||||
surface.request_to_generate_chunks({x = 160, y = 0}, 4)
|
||||
--surface.force_generate_chunk_requests()
|
||||
|
||||
if not surface.is_chunk_generated({-7, 0}) then
|
||||
return
|
||||
end
|
||||
if not surface.is_chunk_generated({5, 0}) then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_position_x = -128
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {160, -96}, source = {160, -96}, target = {160, 96}})
|
||||
|
||||
for _, tile in pairs(
|
||||
surface.find_tiles_filtered({name = {'water', 'deepwater'}, area = {{-160, -160}, {160, 160}}})
|
||||
) do
|
||||
local noise =
|
||||
math_abs(
|
||||
simplex_noise(tile.position.x * 0.02, tile.position.y * 0.02, game.surfaces[1].map_gen_settings.seed) * 16
|
||||
)
|
||||
if tile.position.x > -160 + noise then
|
||||
surface.set_tiles(
|
||||
{{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}},
|
||||
true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{type = {'resource', 'cliff'}, area = {{spawn_position_x - 32, -256}, {160, 256}}}
|
||||
)
|
||||
) do
|
||||
if is_body(entity.position) then
|
||||
if
|
||||
entity.position.x >
|
||||
spawn_position_x - 32 +
|
||||
math_abs(
|
||||
simplex_noise(
|
||||
entity.position.x * 0.02,
|
||||
entity.position.y * 0.02,
|
||||
game.surfaces[1].map_gen_settings.seed
|
||||
) * 16
|
||||
)
|
||||
then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local decorative_names = {}
|
||||
for k, v in pairs(game.decorative_prototypes) do
|
||||
if v.autoplace_specification then
|
||||
decorative_names[#decorative_names + 1] = k
|
||||
end
|
||||
end
|
||||
for x = -4, 4, 1 do
|
||||
for y = -3, 3, 1 do
|
||||
surface.regenerate_decorative(decorative_names, {{x, y}})
|
||||
end
|
||||
end
|
||||
|
||||
local y = 80
|
||||
local ore_positions = {
|
||||
{x = spawn_position_x - 52, y = y},
|
||||
{x = spawn_position_x - 52, y = y * 0.5},
|
||||
{x = spawn_position_x - 52, y = 0},
|
||||
{x = spawn_position_x - 52, y = y * -0.5},
|
||||
{x = spawn_position_x - 52, y = y * -1}
|
||||
}
|
||||
shuffle(ore_positions)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 15, 2500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 15, 1500)
|
||||
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 15, 1500)
|
||||
map_functions.draw_noise_tile_circle({x = spawn_position_x - 20, y = 0}, 'water', surface, 16)
|
||||
map_functions.draw_oil_circle(ore_positions[5], 'crude-oil', surface, 8, 200000)
|
||||
|
||||
local pos = surface.find_non_colliding_position('market', {spawn_position_x, 0}, 50, 1)
|
||||
this.market = place_fish_market(surface, pos)
|
||||
|
||||
render_market_hp()
|
||||
|
||||
local r = 16
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered(
|
||||
{
|
||||
area = {
|
||||
{this.market.position.x - r, this.market.position.y - r},
|
||||
{this.market.position.x + r, this.market.position.y + r}
|
||||
},
|
||||
type = 'tree'
|
||||
}
|
||||
)
|
||||
) do
|
||||
local distance_to_center =
|
||||
math_sqrt(
|
||||
(entity.position.x - this.market.position.x) ^ 2 + (entity.position.y - this.market.position.y) ^ 2
|
||||
)
|
||||
if distance_to_center < r then
|
||||
if math_random(1, r) > distance_to_center then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position('gun-turret', {spawn_position_x + 5, 1}, 50, 1)
|
||||
local turret = surface.create_entity({name = 'gun-turret', position = pos, force = 'player'})
|
||||
turret.insert({name = 'firearm-magazine', count = 32})
|
||||
|
||||
for x = -20, 20, 1 do
|
||||
for y = -20, 20, 1 do
|
||||
local pos = {x = this.market.position.x + x, y = this.market.position.y + y}
|
||||
--local distance_to_center = math_sqrt(x^2 + y^2)
|
||||
--if distance_to_center > 8 and distance_to_center < 15 then
|
||||
local distance_to_center = x ^ 2 + y ^ 2
|
||||
if distance_to_center > 64 and distance_to_center < 225 then
|
||||
if
|
||||
math_random(1, 3) == 1 and
|
||||
surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'player'})
|
||||
then
|
||||
surface.create_entity({name = 'wooden-chest', position = pos, force = 'player'})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local area = {{x = -160, y = -96}, {x = 160, y = 96}}
|
||||
for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = area})) do
|
||||
if math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = 'fish', position = tile.position})
|
||||
end
|
||||
end
|
||||
|
||||
local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
game.forces['player'].set_spawn_position(pos, surface)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local pos = surface.find_non_colliding_position('character', {spawn_position_x + 1, 4}, 50, 1)
|
||||
player.teleport(pos, surface)
|
||||
end
|
||||
this.spawn_area_generated = true
|
||||
end
|
||||
|
||||
local function process_chunk(left_top)
|
||||
local this = FDT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
|
||||
generate_spawn_area(this, surface, left_top)
|
||||
enemy_territory(surface, left_top)
|
||||
fish_mouth(surface, left_top)
|
||||
|
||||
local tiles = {}
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_out_of_map_tile(pos) then
|
||||
--if not plankton_territory(surface, pos, seed) then surface.set_tiles({{name = "out-of-map", position = pos}}, true) end
|
||||
local tile_to_set = plankton_territory(surface, pos, seed)
|
||||
--local tile_to_set = "out-of-map"
|
||||
tiles[#tiles + 1] = {name = tile_to_set, position = pos}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
|
||||
--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
|
||||
if this.market and this.market.valid then
|
||||
this.game_reset = false
|
||||
end
|
||||
end
|
||||
|
||||
local process_chunk_queue =
|
||||
Token.register(
|
||||
function(data)
|
||||
local chunk_queue = data.chunk_queue
|
||||
|
||||
for i = 1, #chunk_queue do
|
||||
local pos = {x = chunk_queue[i].x, y = chunk_queue[i].y}
|
||||
process_chunk(pos)
|
||||
chunk_queue[i] = nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local map_name = 'fish_defender'
|
||||
|
||||
if string.sub(event.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
local left_top = event.area.left_top
|
||||
local this = FDT.get()
|
||||
if this.game_has_ended then
|
||||
return
|
||||
end
|
||||
|
||||
if game.tick == 0 or this.game_reset or this.force_chunk then
|
||||
process_chunk(left_top)
|
||||
else
|
||||
global.chunk_queue[#global.chunk_queue + 1] = {x = left_top.x, y = left_top.y}
|
||||
|
||||
local data = {
|
||||
chunk_queue = global.chunk_queue
|
||||
}
|
||||
Task.set_timeout_in_ticks(total_calls, process_chunk_queue, data)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.fish_eye(surface, position)
|
||||
surface.request_to_generate_chunks(position, 2)
|
||||
surface.force_generate_chunk_requests()
|
||||
for x = -48, 48, 1 do
|
||||
for y = -48, 48, 1 do
|
||||
local p = {x = position.x + x, y = position.y + y}
|
||||
--local distance = math_sqrt(((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2))
|
||||
--if distance < 44 then
|
||||
-- surface.set_tiles({{name = "water-green", position = p}}, true)
|
||||
--end
|
||||
--if distance < 22 then
|
||||
-- surface.set_tiles({{name = "out-of-map", position = p}}, true)
|
||||
--end
|
||||
|
||||
local distance = ((position.x - p.x) ^ 2) + ((position.y - p.y) ^ 2)
|
||||
if distance < 1936 then
|
||||
if distance < 484 then
|
||||
surface.set_tiles({{name = 'out-of-map', position = p}}, true)
|
||||
else
|
||||
surface.set_tiles({{name = 'water-green', position = p}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
|
||||
return Public
|
61
maps/fish_defender_v2/trapped_capsules.lua
Normal file
61
maps/fish_defender_v2/trapped_capsules.lua
Normal file
@ -0,0 +1,61 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
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)
|
||||
local trapped_capsules_unlocked = FDT.get('trapped_capsules_unlocked')
|
||||
if not 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)
|
52
maps/fish_defender_v2/ultra_mines.lua
Normal file
52
maps/fish_defender_v2/ultra_mines.lua
Normal file
@ -0,0 +1,52 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
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)
|
||||
local ultra_mines_unlocked = FDT.get('ultra_mines_unlocked')
|
||||
if not 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)
|
29
maps/fish_defender_v2/vehicle_nanobots.lua
Normal file
29
maps/fish_defender_v2/vehicle_nanobots.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local Event = require 'utils.event'
|
||||
local FDT = require 'maps.fish_defender_v2.table'
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local vehicle_nanobots_unlocked = FDT.get('vehicle_nanobots_unlocked')
|
||||
|
||||
if not 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)
|
@ -210,7 +210,6 @@ function Public.reset_map()
|
||||
local Diff = Difficulty.get()
|
||||
local this = WPT.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local get_score = Score.get_table()
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
if player.controller_type == defines.controllers.editor then
|
||||
@ -265,7 +264,7 @@ function Public.reset_map()
|
||||
Collapse.set_direction('north')
|
||||
Collapse.start_now(false)
|
||||
|
||||
--[[ local x_value = rng(15, 25)
|
||||
local x_value = rng(15, 25)
|
||||
local y_value = rng(50, 60)
|
||||
|
||||
local data = {
|
||||
@ -274,7 +273,7 @@ function Public.reset_map()
|
||||
['fluid-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}},
|
||||
['locomotive'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}}
|
||||
}
|
||||
ICT.set_wagon_area(data) ]]
|
||||
ICT.set_wagon_area(data)
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user