Skip to content

Commit

Permalink
Towny and Mtn fortress changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Oct 4, 2023
1 parent 2293dd9 commit fb2ef3b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 58 deletions.
24 changes: 9 additions & 15 deletions maps/mountain_fortress_v3/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1237,48 +1237,42 @@ local function show_mvps(player)
field1 = {
text1 = 'Time played:',
text2 = time_played,
inline = 'true'
inline = 'false'
},
field2 = {
text1 = 'Highest wave:',
text2 = format_number(wave, true),
inline = 'true'
text2 = wave,
inline = 'false'
},
field3 = {
text1 = 'Total connected players:',
text2 = total_players,
inline = 'true',
emptyField = 'true',
emptyInline = 'true'
inline = 'false'
},
field4 = {
text1 = 'Threat:',
text2 = format_number(threat, true),
inline = 'true'
inline = 'false'
},
field5 = {
text1 = 'Pickaxe Upgrade:',
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
inline = 'true',
emptyField = 'true',
emptyInline = 'true'
inline = 'false'
},
field6 = {
text1 = 'Collapse Speed:',
text2 = collapse_speed,
inline = 'true'
inline = 'false'
},
field7 = {
text1 = 'Collapse Amount:',
text2 = collapse_amount,
inline = 'true'
inline = 'false'
},
field8 = {
text1 = 'Connected players:',
text2 = total_connected_players,
inline = 'true',
emptyField = 'true',
emptyInline = 'true'
inline = 'false'
}
}
if server_name_matches then
Expand Down
9 changes: 9 additions & 0 deletions maps/mountain_fortress_v3/icw/linked_chests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,15 @@ function Public.clear_linked_frames()
end

function Public.reset()
if this.main_containers and next(this.main_containers) then
for _, container in pairs(this.main_containers) do
local chest = container.chest
if chest and chest.valid then
chest.get_inventory(defines.inventory.chest).clear()
end
end
end

this.main_containers = {}
this.linked_gui = {}
this.valid_chests = {
Expand Down
11 changes: 10 additions & 1 deletion maps/scrap_towny_ffa/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,16 @@ Event.on_init(on_init)
Event.on_nth_tick(60, on_nth_tick) -- once every second
Event.on_nth_tick(60 * 30, ui_smell_evolution)
Event.on_nth_tick(60, update_score)
Event.add(Server.events.on_changes_detected, handle_changes)

Server.on_scenario_changed(
'Towny',
function(data)
local scenario = data.scenario
if scenario == 'Towny' then
handle_changes()
end
end
)

--Disable the comfy main gui since we got too many goodies there.
Event.add(
Expand Down
38 changes: 22 additions & 16 deletions maps/scrap_towny_ffa/nauvis.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
local Event = require 'utils.event'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local SoftReset = require 'functions.soft_reset'
local Server = require 'utils.server'
local Token = require 'utils.token'
-- local Server = require 'utils.server'
-- local Token = require 'utils.token'
local math_random = math.random
local table_shuffle = table.shuffle_table

local dataset = 'scenario_settings'
local dataset_key = 'scrap_towny_ffa'
-- local dataset = 'scenario_settings'
-- local dataset_key = 'scrap_towny_ffa'

local Public = {}

local map_width = 3840
local map_height = 3840

--[[
local set_victory_length_token =
Token.register(
function(data)
Expand Down Expand Up @@ -42,8 +42,7 @@ local set_victory_length_token =
Server.set_data(dataset, dataset_key, settings)
end
)

) ]]
function Public.nuke(position)
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
Expand Down Expand Up @@ -132,6 +131,17 @@ function Public.initialize()
['sand-rock-small'] = {frequency = 10, size = 'normal', richness = 'normal'},
['sand-rock-medium'] = {frequency = 5, size = 'normal', richness = 'normal'}
}
},
tile = {
settings = {
['deepwater'] = {frequency = 1, size = 0, richness = 1},
['deepwater-green'] = {frequency = 1, size = 0, richness = 1},
['water'] = {frequency = 1, size = 0, richness = 1},
['water-green'] = {frequency = 1, size = 0, richness = 1},
['water-mud'] = {frequency = 1, size = 0, richness = 1},
['water-shallow'] = {frequency = 1, size = 0, richness = 1}
},
treat_missing_as_default = true
}
}
mgs.cliff_settings = {
Expand All @@ -140,10 +150,10 @@ function Public.initialize()
cliff_elevation_interval = 10,
richness = 0.4
}
mgs.water = 0.5
mgs.water = 0
mgs.peaceful_mode = false
mgs.starting_area = 'none'
mgs.terrain_segmentation = 3.5
mgs.terrain_segmentation = 8
-- terrain size is 64 x 64 chunks, water size is 80 x 80
mgs.width = map_width
mgs.height = map_height
Expand All @@ -158,11 +168,7 @@ function Public.initialize()
-- adjust this value to set how many nests spawn per tile
['enemy-base-frequency'] = 0.4,
-- this will make and average base radius around 12 tiles
['enemy-base-radius'] = 12,
['control-setting:aux:bias'] = '-0.300000',
['control-setting:aux:frequency:multiplier'] = '1.333333',
['control-setting:moisture:bias'] = '-0.200000',
['control-setting:moisture:frequency:multiplier'] = '1.333333'
['enemy-base-radius'] = 12
}
mgs.seed = math_random(100000, 9999999)

Expand All @@ -177,13 +183,13 @@ function Public.initialize()
return
end

Server.try_get_data(dataset, dataset_key, set_victory_length_token)
-- Server.try_get_data(dataset, dataset_key, set_victory_length_token)

surface.map_gen_settings = mgs
surface.peaceful_mode = false
surface.always_day = false
surface.freeze_daytime = false
surface.map_gen_settings.water = 0.5
-- surface.map_gen_settings.water = 0.5
surface.clear(true)
surface.regenerate_entity({'rock-huge', 'rock-big', 'sand-rock-big'})
surface.regenerate_decorative()
Expand Down
32 changes: 11 additions & 21 deletions maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@ local Event = require 'utils.event'
local get_noise = require 'utils.get_noise'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local Scrap = require 'maps.scrap_towny_ffa.scrap'
local get_perlin = require 'utils.get_perlin'

local table_insert = table.insert
local math_random = math.random
local math_floor = math.floor

local start_ground_tiles = {
'grass-1',
'grass-1',
'grass-2',
'sand-2',
'grass-1',
'grass-4',
'sand-2',
'grass-3',
'grass-4',
'grass-2',
'sand-3',
'grass-4'
}

local scrap_entities = {
-- simple entity with owner
{name = 'crash-site-spaceship-wreck-small-1'}, -- these do not have mining animation
Expand Down Expand Up @@ -298,12 +284,16 @@ local function on_chunk_generated(event)
for x = 0, 31, 1 do
for y = 0, 31, 1 do
position = {x = left_top_x + x, y = left_top_y + y}
if math_random(1, 3) > 1 then
local tile = surface.get_tile(position)
if not tile.collides_with('water-tile') then
noise = get_noise('dungeon_sewer', position, seed)
local index = math_floor(noise * 32) % 11 + 1
surface.set_tiles({{name = start_ground_tiles[index], position = position}}, true)
local cave_ponds = get_perlin('cave_ponds', position, seed + seed)

if cave_ponds > 0.02 and cave_ponds < 0.3 then
if cave_ponds > 0.2 then
surface.set_tiles({{name = 'water-shallow', position = position}}, true)
else
surface.set_tiles({{name = 'water', position = position}}, true)
end
if math_random(1, 48) == 1 then
surface.create_entity({name = 'fish', position = position, force = 'neutral'})
end
end
if math_random(1, 3) > 1 then
Expand Down
4 changes: 2 additions & 2 deletions maps/scrap_towny_ffa/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function Public.reset_table()
this.mining_target = {}
this.spaceships = {}
this.suicides = {}
this.required_time_to_win = 168
this.required_time_to_win_in_ticks = 36288000
this.required_time_to_win = 72
this.required_time_to_win_in_ticks = 15552000
this.shuffle_random_victory_time = false
this.announced_message = nil
this.soft_reset = true
Expand Down
6 changes: 3 additions & 3 deletions maps/scrap_towny_ffa/team.lua
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,13 @@ local function kill_force(force_name, cause)
end
for _, e in pairs(surface.find_entities_filtered({force = force_name})) do
if e.valid then
if destroy_military_types[e.type] == true then
if destroy_military_types[e.type] then
surface.create_entity({name = 'big-artillery-explosion', position = position})
e.die()
elseif destroy_robot_types[e.type] == true then
elseif destroy_robot_types[e.type] then
surface.create_entity({name = 'explosion', position = position})
e.die()
elseif destroy_wall_types[e.type] == true then
elseif destroy_wall_types[e.type] then
e.die()
elseif storage_types[e.type] ~= true then -- spare chests
local random = math_random()
Expand Down

0 comments on commit fb2ef3b

Please sign in to comment.