1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-30 04:40:54 +02:00

fishy fixes

This commit is contained in:
Gerkiz 2020-11-04 20:53:19 +01:00
parent a76fafa944
commit 2ab7fb055f
8 changed files with 2297 additions and 190 deletions

View File

@ -423,8 +423,7 @@ local function send_unit_group(unit_group)
local commands = {}
local market = FDT.get('market')
for x = unit_group.position.x, market.position.x, -48 do
local destination =
unit_group.surface.find_non_colliding_position('stone-wall', {x = x, y = unit_group.position.y}, 32, 4)
local destination = unit_group.surface.find_non_colliding_position('stone-wall', {x = x, y = unit_group.position.y}, 32, 4)
if destination then
commands[#commands + 1] = {
type = defines.command.attack_area,
@ -459,10 +458,7 @@ local function spawn_boss_units(surface)
local Diff = Difficulty.get()
local this = FDT.get()
if this.wave_count <= 2000 then
game.print(
{'fish_defender.boss_message', this.wave_count, {'fish_defender.' .. this.wave_count}},
{r = 0.8, g = 0.1, b = 0.1}
)
game.print({'fish_defender.boss_message', this.wave_count, {'fish_defender.' .. this.wave_count}}, {r = 0.8, g = 0.1, b = 0.1})
else
game.print({'fish_defender.boss_message', this.wave_count}, {r = 0.8, g = 0.1, b = 0.1})
end
@ -577,8 +573,7 @@ local function damage_entity_outside_of_fence(e)
return
end
e.health =
e.health - math_random(math.floor(e.prototype.max_health * 0.05), math.floor(e.prototype.max_health * 0.1))
e.health = e.health - math_random(math.floor(e.prototype.max_health * 0.05), math.floor(e.prototype.max_health * 0.1))
if e.health <= 0 then
e.die('enemy')
end
@ -806,8 +801,7 @@ local function is_game_lost()
local l = t.add({type = 'label', caption = 'MVP Defender >> '})
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local l =
t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
local l = t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
@ -862,9 +856,7 @@ end
local function damage_entities_in_radius(surface, position, radius, damage)
local entities_to_damage =
surface.find_entities_filtered(
{area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}}
)
surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}})
for _, entity in pairs(entities_to_damage) do
if entity.valid then
if entity.health and entity.name ~= 'land-mine' then
@ -966,12 +958,7 @@ local function on_entity_died(event)
for _, visual in pairs(splash.visuals) do
surface.create_entity({name = visual, position = event.entity.position})
end
damage_entities_in_radius(
surface,
event.entity.position,
splash.radius,
math_random(splash.damage_min, splash.damage_max)
)
damage_entities_in_radius(surface, event.entity.position, splash.radius, math_random(splash.damage_min, splash.damage_max))
return
end
end
@ -1067,8 +1054,7 @@ local function on_built_entity(event)
name = 'flying-text',
position = entity.position,
text = this.entity_limits[entity.name].placed ..
' / ' ..
this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
' / ' .. this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
color = {r = 0.98, g = 0.66, b = 0.22}
}
)
@ -1194,8 +1180,7 @@ local function on_init(reset)
if not this.active_surface_index then
this.active_surface_index = game.create_surface('fish_defender', map_gen_settings).index
elseif reset then
this.active_surface_index =
Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
this.active_surface_index = Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
end
local surface = game.surfaces[this.active_surface_index]
@ -1284,10 +1269,7 @@ local function on_tick()
if this.game_restart_timer > 0 then
this.game_reset = true
this.game_has_ended = true
game.print(
'Map will restart in ' .. this.game_restart_timer / 60 .. ' seconds!',
{r = 0.22, g = 0.88, b = 0.22}
)
game.print('Map will restart in ' .. this.game_restart_timer / 60 .. ' seconds!', {r = 0.22, g = 0.88, b = 0.22})
end
if this.game_restart_timer == 0 then
on_init(true)

View File

@ -43,7 +43,7 @@ function Public.reset_table()
this.game_restart_timer = nil
this.wave_count = 1
this.market = nil
this.wave_limit = 2000
this.wave_limit = 9999
this.market_age = nil
this.last_reset = game.tick
this.wave_interval = 3600

View File

@ -1,6 +1,6 @@
local simplex_noise = require 'utils.simplex_noise'.d2
-- local map_data = require 'maps.fish_defender_v2.fish_defender_layout'
local map_data = require 'maps.fish_defender_v2.cat_defender_layout_v2'
local map_data = require 'maps.fish_defender_v2.map'
local random = math.random
local abs = math.abs
@ -109,10 +109,7 @@ local function plankton_territory(position, seed, ent)
return
end
if
position.x + position.y > (d * -1) - (abs(noise) * d * 3) and
position.x > position.y - (d + (abs(noise) * d * 3))
then
if position.x + position.y > (d * -1) - (abs(noise) * d * 3) and position.x > position.y - (d + (abs(noise) * d * 3)) then
return 'out-of-map'
end

View File

@ -23,13 +23,11 @@ local Poll = require 'comfy_panel.poll'
local boss_biter = require 'maps.fish_defender_v2.boss_biters'
local FDT = require 'maps.fish_defender_v2.table'
local Score = require 'comfy_panel.score'
local AntiGrief = require 'antigrief'
local math_random = math.random
local insert = table.insert
local enable_start_grace_period = true
local branch_version = '0.18.35'
local sub = string.sub
local Public = {}
local starting_items = {
@ -56,7 +54,7 @@ local function create_wave_gui(player)
player.gui.top['fish_defense_waves'].destroy()
end
local this = FDT.get()
local frame = player.gui.top.add({type = 'frame', name = 'fish_defense_waves', tooltip = 'Click to show map info'})
local frame = player.gui.top.add({type = 'frame', name = 'fish_defense_waves'})
frame.style.maximal_height = 38
local wave_count = 0
@ -326,6 +324,32 @@ local function get_biter_initial_pool()
end
end
local 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 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 function get_biter_pool()
local biter_pool = get_biter_initial_pool()
local biter_raffle = {}
@ -420,8 +444,7 @@ local function send_unit_group(unit_group)
local commands = {}
local this = FDT.get()
for x = unit_group.position.x, this.market.position.x, -48 do
local destination =
unit_group.surface.find_non_colliding_position('stone-wall', {x = x, y = unit_group.position.y}, 32, 4)
local destination = unit_group.surface.find_non_colliding_position('stone-wall', {x = x, y = unit_group.position.y}, 32, 4)
if destination then
commands[#commands + 1] = {
type = defines.command.attack_area,
@ -572,8 +595,7 @@ local function damage_entity_outside_and_inside_of_fence(e)
e.surface.create_entity({name = 'water-splash', position = e.position})
if e.type == 'land-mine' then
e.health =
e.health - math_random(math.floor(e.prototype.max_health * 0.2), math.floor(e.prototype.max_health * 0.4))
e.health = e.health - math_random(math.floor(e.prototype.max_health * 0.2), math.floor(e.prototype.max_health * 0.4))
if e.health <= 0 then
e.die('enemy')
end
@ -585,8 +607,7 @@ local function damage_entity_outside_and_inside_of_fence(e)
return
end
e.health =
e.health - math_random(math.floor(e.prototype.max_health * 0.05), math.floor(e.prototype.max_health * 0.1))
e.health = e.health - math_random(math.floor(e.prototype.max_health * 0.05), math.floor(e.prototype.max_health * 0.1))
if e.health <= 0 then
e.die('enemy')
end
@ -801,8 +822,7 @@ local function is_game_lost()
market_age_label.style.font = 'default-bold'
market_age_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
else
market_age_label =
t.add({type = 'label', caption = math.ceil((this.market_age % 216000 / 60) / 60) .. ' minutes'})
market_age_label = t.add({type = 'label', caption = math.ceil((this.market_age % 216000 / 60) / 60) .. ' minutes'})
market_age_label.style.font = 'default-bold'
market_age_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
end
@ -814,8 +834,7 @@ local function is_game_lost()
mvp_defender_label.style.font = 'default-listbox'
mvp_defender_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local mvp_killscore_label =
t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
local mvp_killscore_label = t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
mvp_killscore_label.style.font = 'default-bold'
mvp_killscore_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
@ -837,8 +856,7 @@ local function is_game_lost()
mvp_deaths_label.style.font = 'default-listbox'
mvp_deaths_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local mvp_deaths_name_label =
t.add({type = 'label', caption = mvp.deaths.name .. ' died ' .. mvp.deaths.score .. ' times'})
local mvp_deaths_name_label = t.add({type = 'label', caption = mvp.deaths.name .. ' died ' .. mvp.deaths.score .. ' times'})
mvp_deaths_name_label.style.font = 'default-bold'
mvp_deaths_name_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
@ -871,9 +889,7 @@ end
local function damage_entities_in_radius(surface, position, radius, damage)
local entities_to_damage =
surface.find_entities_filtered(
{area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}}
)
surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}})
for _, entity in pairs(entities_to_damage) do
if entity.valid then
if entity.health and entity.name ~= 'land-mine' then
@ -899,9 +915,6 @@ local function market_kill_visuals()
return
end
local is_branch_18 = sub(branch_version, 3, 4)
local get_active_version = sub(game.active_mods.base, 3, 4)
if not surface or not surface.valid then
return
end
@ -912,33 +925,19 @@ local function market_kill_visuals()
local m = 32
local m2 = m * 0.005
if get_active_version >= is_branch_18 then
for i = 1, 1024, 1 do
surface.create_particle(
{
name = 'branch-particle',
position = this.market.position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)}
}
)
end
else
for i = 1, 1024, 1 do
surface.create_entity(
{
name = 'branch-particle',
position = this.market.position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)}
}
)
end
for i = 1, 1024, 1 do
surface.create_particle(
{
name = 'branch-particle',
position = this.market.position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)}
}
)
end
for x = -5, 5, 0.5 do
for y = -5, 5, 0.5 do
if math_random(1, 2) == 1 then
@ -1006,12 +1005,7 @@ local function on_entity_died(event)
for _, visual in pairs(splash.visuals) do
surface.create_entity({name = visual, position = event.entity.position})
end
damage_entities_in_radius(
surface,
event.entity.position,
splash.radius,
math_random(splash.damage_min, splash.damage_max)
)
damage_entities_in_radius(surface, event.entity.position, splash.radius, math_random(splash.damage_min, splash.damage_max))
return
end
end
@ -1105,8 +1099,7 @@ local function on_built_entity(event)
name = 'flying-text',
position = entity.position,
text = this.entity_limits[entity.name].placed ..
' / ' ..
this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
' / ' .. this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
color = {r = 0.98, g = 0.66, b = 0.22}
}
)
@ -1147,8 +1140,7 @@ local function on_robot_built_entity(event)
name = 'flying-text',
position = entity.position,
text = this.entity_limits[entity.name].placed ..
' / ' ..
this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
' / ' .. this.entity_limits[entity.name].limit .. ' ' .. this.entity_limits[entity.name].str .. 's',
color = {r = 0.98, g = 0.66, b = 0.22}
}
)
@ -1283,14 +1275,46 @@ local function has_the_game_ended()
end
function Public.reset_game()
FDT.reset_table()
local get_score = Score.get_table()
Poll.reset()
local this = FDT.get()
local is_branch_18 = sub(branch_version, 3, 4)
local get_active_version = sub(game.active_mods.base, 3, 4)
Difficulty.reset_difficulty_poll()
Difficulty.set_poll_closing_timeout = game.tick + 36000
Difficulty.set_poll_closing_timeout(this.wave_grace_period)
AntiGrief.reset_tables()
FDT.reset_table()
global.fish_in_space = 0
get_score.score_table = {}
local difficulties = {
[1] = {
name = 'Normal',
value = 1,
color = {r = 0.00, g = 0.00, b = 0.25},
print_color = {r = 0.0, g = 0.0, b = 0.5}
},
[2] = {
name = 'Hard',
value = 1.5,
color = {r = 0.25, g = 0.00, b = 0.00},
print_color = {r = 0.4, g = 0.0, b = 0.00}
},
[3] = {
name = 'Nightmare',
value = 3,
color = {r = 0.35, g = 0.00, b = 0.00},
print_color = {r = 0.6, g = 0.0, b = 0.00}
},
[4] = {
name = 'Impossible',
value = 5,
color = {r = 0.45, g = 0.00, b = 0.00},
print_color = {r = 0.8, g = 0.0, b = 0.00}
}
}
Difficulty.set_difficulties(difficulties)
local players = game.connected_players
for i = 1, #players do
@ -1321,8 +1345,7 @@ function Public.reset_game()
if not this.active_surface_index then
this.active_surface_index = game.create_surface('fish_defender', map_gen_settings).index
else
this.active_surface_index =
Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
this.active_surface_index = Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
end
local surface = game.surfaces[this.active_surface_index]
@ -1332,8 +1355,6 @@ function Public.reset_game()
surface.peaceful_mode = false
-- Terrain.fish_eye(surface, {x = -1442, y = -59})
--[[ local radius = 200
--local pos = {x = 419, y = -308} -- fish
local pos = {x = -27, y = -308} -- cat
@ -1356,13 +1377,13 @@ function Public.reset_game()
{pos.x + radius, pos.y + radius}
}
) ]]
local r = 750
local r = 200
local p = {x = -131, y = 5}
game.forces.player.chart(
surface,
{
{p.x - r - 200, p.y - r},
{p.x + r + 600, p.y + r}
{p.x - r - 100, p.y - r},
{p.x + r + 400, p.y + r}
}
)
@ -1385,16 +1406,92 @@ function Public.reset_game()
game.remove_offline_players()
game.map_settings.enemy_expansion.enabled = false
game.forces['player'].technologies['artillery'].researched = false
game.forces.player.technologies['artillery'].researched = false
game.forces.player.technologies['spidertron'].enabled = false
game.forces.player.technologies['spidertron'].researched = false
game.reset_time_played()
is_branch_18 = is_branch_18 .. sub(branch_version, 6, 7)
get_active_version = get_active_version .. sub(game.active_mods.base, 6, 7)
if get_active_version >= is_branch_18 then
game.reset_time_played()
fish_eye(surface, {x = -1667, y = -50})
if not global.catplanet_goals then
global.catplanet_goals = {
{goal = 0, rank = false, achieved = true},
{
goal = 100,
rank = 'Copper',
color = {r = 201, g = 133, b = 6},
msg = 'You have saved the first container of fish!',
msg2 = 'However, this is only the beginning.',
achieved = false
},
{
goal = 1000,
rank = 'Bronze',
color = {r = 186, g = 115, b = 39},
msg = 'Thankful for the fish, they sent back a toy mouse made of solid bronze!',
msg2 = 'They are demanding more.',
achieved = false
},
{
goal = 10000,
rank = 'Silver',
color = {r = 186, g = 178, b = 171},
msg = 'In gratitude for the fish, they left you a silver furball!',
msg2 = 'They are still longing for more.',
achieved = false
},
{
goal = 25000,
rank = 'Gold',
color = {r = 255, g = 214, b = 33},
msg = 'Pleased about the delivery, they sent back a golden audiotape with cat purrs.',
msg2 = 'They still demand more.',
achieved = false
},
{
goal = 50000,
rank = 'Platinum',
color = {r = 224, g = 223, b = 215},
msg = 'To express their infinite love, they sent back a yarnball made of shiny material.',
msg2 = 'Defying all logic, they still demand more fish.',
achieved = false
},
{
goal = 100000,
rank = 'Diamond',
color = {r = 237, g = 236, b = 232},
msg = 'A box arrives with a mewing kitten, it a has a diamond collar.',
msg2 = 'More fish? Why? What..',
achieved = false
},
{
goal = 250000,
rank = 'Anti-matter',
color = {r = 100, g = 100, b = 245},
msg = 'The obese cat colapses and forms a black hole!',
msg2 = ':obese:',
achieved = false
},
{
goal = 500000,
rank = 'Black Hole',
color = {r = 100, g = 100, b = 245},
msg = 'A letter arrives, it reads: Go to bed hooman!',
msg2 = 'Not yet...',
achieved = false
},
{
goal = 1000000,
rank = 'Blue Screen',
color = {r = 100, g = 100, b = 245},
msg = 'Cat error #4721',
msg2 = '....',
achieved = false
},
{goal = 10000000, rank = 'Blue Screen', color = {r = 100, g = 100, b = 245}, msg = '....', msg2 = '....', achieved = false}
}
end
this.market_health = 500
this.market_max_health = 500
this.spawn_area_generated = false
end
@ -1402,8 +1499,7 @@ function Public.on_init()
Public.reset_game()
local T = Map.Pop_info()
T.localised_category = 'fish_defender_v2'
T.main_caption = '-- Chonk Defender -- '
T.localised_category = 'fish_defender'
T.main_caption_color = {r = 0.11, g = 0.8, b = 0.44}
T.sub_caption_color = {r = 0.33, g = 0.66, b = 0.9}
end
@ -1426,7 +1522,7 @@ local function on_tick()
end
if game.tick % 180 == 0 then
if surface then
game.forces.player.chart(surface, {{-160, -160}, {192, 300}})
game.forces.player.chart(surface, {{-160, -130}, {160, 179}})
if Diff.difficulty_vote_index then
this.wave_interval = this.difficulties_votes[Diff.difficulty_vote_index].wave_interval
end
@ -1434,6 +1530,13 @@ local function on_tick()
end
end
if this.wave_count >= this.wave_limit then
if this.market and this.market.valid then
this.market.die()
game.print('Game wave limit reached! Game will soft-reset shortly.', {r = 0.22, g = 0.88, b = 0.22})
end
end
if game.tick % this.wave_interval == this.wave_interval - 1 then
if surface.peaceful_mode == true then
return

File diff suppressed because it is too large Load Diff

View File

@ -41,28 +41,22 @@ local function refresh_market_offers()
end
end
local str1 =
'Gun Turret Slot for ' ..
tostring(this.entity_limits['gun-turret'].limit * this.entity_limits['gun-turret'].slot_price)
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)
'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)
'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)
local str4 = 'Flamethrower Turret Slot for ' .. tostring(current_limit * this.entity_limits['flamethrower-turret'].slot_price)
str4 = str4 .. ' Coins.'
local str5 =
@ -81,6 +75,8 @@ local function refresh_market_offers()
{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 = {{'small-plane', 40}}, offer = {type = 'give-item', item = 'spidertron', count = 1}},
{price = {{'coin', 5000}}, offer = {type = 'give-item', item = 'small-plane', 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}},
@ -190,8 +186,7 @@ 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
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
@ -218,19 +213,19 @@ local function slot_upgrade(player, offer_index)
return false
end
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit =
this.entity_limits[slot_upgrade_offers[offer_index][1]].limit + gain
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
if
(slot_upgrade_offers[offer_index][2] < 10) or
((slot_upgrade_offers[offer_index][2] < 50) and ((slot_upgrade_offers[offer_index][2] % 5) == 0)) or
((slot_upgrade_offers[offer_index][2] % 25) == 0)
then
Server.to_discord_bold(
table.concat {
'*** ' ..
player.name ..
' has bought a ' ..
slot_upgrade_offers[offer_index][2] .. ' slot for ' .. price .. ' coins! ***'
'*** ' .. player.name .. ' has bought a ' .. slot_upgrade_offers[offer_index][2] .. ' slot for ' .. price .. ' coins! ***'
}
)
end

View File

@ -36,6 +36,7 @@ function Public.reset_table()
this.vehicle_nanobots_unlocked = false
this.game_restart_timer = nil
this.wave_count = 0
this.wave_limit = 9999
this.attack_wave_threat = nil
this.market = nil
this.market_age = nil
@ -83,6 +84,7 @@ function Public.reset_table()
}
this.shotgun_shell_damage_modifier_old = {}
this.flame_boots = {}
this.fish_eye = false
end
function Public.get(key)

View File

@ -53,6 +53,7 @@ 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
@ -81,15 +82,9 @@ local function enemy_territory(surface, left_top)
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}
)
entity = surface.create_entity({name = 'spitter-spawner', force = 'decoratives', position = pos})
else
entity =
surface.create_entity(
{name = 'biter-spawner', force = 'decoratives', position = pos}
)
entity = surface.create_entity({name = 'biter-spawner', force = 'decoratives', position = pos})
end
entity.active = false
entity.destructible = false
@ -112,33 +107,34 @@ local function enemy_territory(surface, left_top)
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
)
surface.set_tiles({{name = get_replacement_tile(surface, tile.position), position = {tile.position.x, tile.position.y}}}, true)
end
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
local function fish_mouth(surface, left_top)
if left_top.x > -1800 then
return
end
if left_top.y > 64 then
return
end
if left_top.y < -64 then
return
end
if left_top.x < -2200 then
return
end
this.caption =
rendering.draw_text {
text = 'Fish Market',
surface = surface,
target = this.market,
target_offset = {0, -3.4},
color = {0, 255, 0},
scale = 1.80,
font = 'default-game',
alignment = 'center',
scale_with_zoom = false
}
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 function generate_spawn_area(this, surface)
@ -158,40 +154,24 @@ local function generate_spawn_area(this, surface)
local spawn_position_x = -128
surface.create_entity({name = 'electric-beam', position = {160, -132}, source = {160, -132}, target = {160, 305}}) -- cat
surface.create_entity({name = 'electric-beam', position = {160, -132}, source = {160, -132}, target = {160, 179}}) -- fish
--surface.create_entity({name = 'electric-beam', position = {160, -101}, source = {160, -101}, target = {160, 248}}) -- fish
--surface.create_entity({name = 'electric-beam', position = {160, -88}, source = {160, -88}, target = {160, 185}})
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
)
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
)
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}}}
)
surface.find_entities_filtered({type = {'resource', 'cliff'}, area = {{spawn_position_x - 32, -256}, {160, 256}}})
) do
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
)
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
@ -228,8 +208,6 @@ local function generate_spawn_area(this, surface)
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(
@ -243,9 +221,7 @@ local function generate_spawn_area(this, surface)
)
) do
local distance_to_center =
math_sqrt(
(entity.position.x - this.market.position.x) ^ 2 + (entity.position.y - this.market.position.y) ^ 2
)
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()
@ -262,10 +238,7 @@ local function generate_spawn_area(this, surface)
local market_pos = {x = this.market.position.x + x, y = this.market.position.y + y}
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 = market_pos, force = 'player'})
then
if math_random(1, 3) == 1 and surface.can_place_entity({name = 'wooden-chest', position = market_pos, force = 'player'}) then
surface.create_entity({name = 'wooden-chest', position = market_pos, force = 'player'})
end
end
@ -297,6 +270,7 @@ local function process_chunk(left_top)
generate_spawn_area(this, surface, left_top)
enemy_territory(surface, left_top)
fish_mouth(surface, left_top)
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
if this.market and this.market.valid then