2020-06-07 13:33:24 +02:00
|
|
|
-- one table to rule them all!
|
2020-05-17 12:23:55 +02:00
|
|
|
local Global = require 'utils.global'
|
|
|
|
local Event = require 'utils.event'
|
|
|
|
|
|
|
|
local this = {
|
2020-05-19 23:00:52 +02:00
|
|
|
players = {},
|
2023-09-20 23:33:47 +02:00
|
|
|
traps = {},
|
|
|
|
scheduler = {
|
|
|
|
start_after = 0,
|
|
|
|
surface = nil,
|
|
|
|
operation = nil,
|
|
|
|
next_operation = nil
|
|
|
|
}
|
2020-05-17 12:23:55 +02:00
|
|
|
}
|
|
|
|
local Public = {}
|
2023-05-26 16:24:22 +02:00
|
|
|
local random = math.random
|
2020-05-17 12:23:55 +02:00
|
|
|
|
2022-10-25 23:29:40 +02:00
|
|
|
Public.events = {
|
|
|
|
reset_map = Event.generate_event_name('reset_map'),
|
|
|
|
on_entity_mined = Event.generate_event_name('on_entity_mined')
|
|
|
|
}
|
2021-07-12 16:15:55 +02:00
|
|
|
|
2020-05-17 12:23:55 +02:00
|
|
|
Global.register(
|
|
|
|
this,
|
|
|
|
function(tbl)
|
|
|
|
this = tbl
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
2022-04-07 00:17:41 +02:00
|
|
|
Public.zone_settings = {
|
|
|
|
zone_depth = 704,
|
2022-04-07 16:11:18 +02:00
|
|
|
zone_width = 510
|
2022-04-07 00:17:41 +02:00
|
|
|
}
|
2020-11-23 23:10:45 +02:00
|
|
|
|
2023-05-26 16:24:22 +02:00
|
|
|
Public.valid_enemy_forces = {
|
|
|
|
['enemy'] = true,
|
|
|
|
['aggressors'] = true,
|
|
|
|
['aggressors_frenzy'] = true
|
|
|
|
}
|
|
|
|
|
2020-10-10 20:36:51 +02:00
|
|
|
Public.pickaxe_upgrades = {
|
|
|
|
'Wood',
|
|
|
|
'Plastic',
|
|
|
|
'Bone',
|
|
|
|
'Alabaster',
|
|
|
|
'Lead',
|
|
|
|
'Zinc',
|
|
|
|
'Tin',
|
|
|
|
'Salt',
|
|
|
|
'Bauxite',
|
|
|
|
'Borax',
|
|
|
|
'Bismuth',
|
|
|
|
'Amber',
|
|
|
|
'Galena',
|
|
|
|
'Calcite',
|
|
|
|
'Aluminium',
|
|
|
|
'Silver',
|
|
|
|
'Gold',
|
|
|
|
'Copper',
|
|
|
|
'Marble',
|
|
|
|
'Brass',
|
|
|
|
'Flourite',
|
|
|
|
'Platinum',
|
|
|
|
'Nickel',
|
|
|
|
'Iron',
|
|
|
|
'Manganese',
|
|
|
|
'Apatite',
|
|
|
|
'Uraninite',
|
|
|
|
'Turquoise',
|
|
|
|
'Hematite',
|
|
|
|
'Glass',
|
|
|
|
'Magnetite',
|
|
|
|
'Concrete',
|
|
|
|
'Pyrite',
|
|
|
|
'Steel',
|
|
|
|
'Zircon',
|
|
|
|
'Titanium',
|
|
|
|
'Silicon',
|
|
|
|
'Quartz',
|
|
|
|
'Garnet',
|
|
|
|
'Flint',
|
|
|
|
'Tourmaline',
|
|
|
|
'Beryl',
|
|
|
|
'Topaz',
|
|
|
|
'Chrysoberyl',
|
|
|
|
'Chromium',
|
|
|
|
'Tungsten',
|
|
|
|
'Corundum',
|
|
|
|
'Tungsten',
|
|
|
|
'Diamond',
|
|
|
|
'Penumbrite',
|
|
|
|
'Meteorite',
|
|
|
|
'Crimtane',
|
|
|
|
'Obsidian',
|
|
|
|
'Demonite',
|
|
|
|
'Mythril',
|
|
|
|
'Adamantite',
|
|
|
|
'Chlorophyte',
|
|
|
|
'Densinium',
|
|
|
|
'Luminite'
|
|
|
|
}
|
|
|
|
|
2022-10-26 00:05:47 +02:00
|
|
|
function Public.reset_main_table()
|
2020-06-07 23:25:01 +02:00
|
|
|
-- @start
|
|
|
|
-- these 3 are in case of stop/start/reloading the instance.
|
|
|
|
this.soft_reset = true
|
|
|
|
this.restart = false
|
|
|
|
this.shutdown = false
|
|
|
|
this.announced_message = false
|
|
|
|
-- @end
|
2023-01-14 22:09:57 +02:00
|
|
|
this.breach_wall_warning = false
|
2020-06-03 20:09:00 +02:00
|
|
|
this.icw_locomotive = nil
|
2020-08-09 20:31:50 +02:00
|
|
|
this.game_lost = false
|
2022-07-10 19:41:11 +02:00
|
|
|
this.death_mode = false
|
2020-05-17 12:23:55 +02:00
|
|
|
this.locomotive_health = 10000
|
|
|
|
this.locomotive_max_health = 10000
|
2020-09-25 11:08:15 +02:00
|
|
|
this.gap_between_zones = {
|
|
|
|
set = false,
|
2020-11-17 16:03:05 +02:00
|
|
|
gap = 900,
|
2020-11-18 16:24:22 +02:00
|
|
|
neg_gap = -500,
|
|
|
|
highest_pos = 0
|
2020-09-25 11:08:15 +02:00
|
|
|
}
|
2021-11-07 21:40:37 +02:00
|
|
|
this.gap_between_locomotive = {
|
|
|
|
hinders = {},
|
|
|
|
gap = 900,
|
2023-07-29 20:06:16 +02:00
|
|
|
neg_gap = -3520, -- earlier 2112 (3 zones, whereas 704 is one zone)
|
2021-11-07 21:40:37 +02:00
|
|
|
highest_pos = nil
|
|
|
|
}
|
2020-10-27 00:55:06 +02:00
|
|
|
this.force_chunk = false
|
2022-11-24 16:00:59 +02:00
|
|
|
this.bw = false
|
2021-09-17 22:28:18 +02:00
|
|
|
this.allow_decon = true
|
2023-09-17 16:27:50 +02:00
|
|
|
this.block_non_trusted_opening_trains = true
|
2022-07-04 00:27:16 +02:00
|
|
|
this.allow_decon_main_surface = true
|
2020-05-23 21:18:18 +02:00
|
|
|
this.flamethrower_damage = {}
|
2020-05-17 12:23:55 +02:00
|
|
|
this.mined_scrap = 0
|
2022-07-11 00:13:59 +02:00
|
|
|
this.print_tech_to_discord = true
|
2020-05-17 12:23:55 +02:00
|
|
|
this.biters_killed = 0
|
2020-09-17 09:14:07 +02:00
|
|
|
this.cleared_nauvis = false
|
2020-11-18 16:24:22 +02:00
|
|
|
this.locomotive_pos = {tbl = {}}
|
2020-08-27 13:27:34 +02:00
|
|
|
this.trusted_only_car_tanks = true
|
2020-07-28 11:24:16 +02:00
|
|
|
--!grief prevention
|
2020-09-17 09:14:07 +02:00
|
|
|
this.enable_arties = 6 -- default to callback 6
|
2020-07-28 11:24:16 +02:00
|
|
|
--!snip
|
2023-08-01 01:06:31 +02:00
|
|
|
this.enemy_spawners = {
|
|
|
|
spawners = {},
|
|
|
|
enabled = false
|
|
|
|
}
|
2020-06-07 13:33:24 +02:00
|
|
|
this.poison_deployed = false
|
2021-02-01 00:59:49 +02:00
|
|
|
this.robotics_deployed = false
|
2020-05-23 21:18:18 +02:00
|
|
|
this.upgrades = {
|
|
|
|
showed_text = false,
|
|
|
|
landmine = {
|
2020-06-03 20:09:00 +02:00
|
|
|
limit = 25,
|
|
|
|
bought = 0,
|
2020-05-23 21:18:18 +02:00
|
|
|
built = 0
|
|
|
|
},
|
|
|
|
flame_turret = {
|
2020-06-03 20:09:00 +02:00
|
|
|
limit = 6,
|
|
|
|
bought = 0,
|
2020-05-23 21:18:18 +02:00
|
|
|
built = 0
|
|
|
|
},
|
|
|
|
unit_number = {
|
|
|
|
landmine = {},
|
|
|
|
flame_turret = {}
|
2022-07-10 19:41:11 +02:00
|
|
|
},
|
|
|
|
has_upgraded_health_pool = false,
|
|
|
|
explosive_bullets_purchased = false,
|
|
|
|
xp_points_upgrade = 0,
|
|
|
|
aura_upgrades = 0,
|
2022-09-18 10:31:10 +02:00
|
|
|
aura_upgrades_max = 12, -- = (aura_limit - locomotive_aura_radius) / 5
|
2022-07-10 19:41:11 +02:00
|
|
|
locomotive_aura_radius = 40,
|
2022-09-18 11:10:58 +02:00
|
|
|
train_upgrade_contribution = 0,
|
2022-07-10 19:41:11 +02:00
|
|
|
xp_points = 0,
|
|
|
|
health_upgrades = 0,
|
2023-09-17 16:27:50 +02:00
|
|
|
pickaxe_tier = 1
|
2020-05-23 21:18:18 +02:00
|
|
|
}
|
2022-07-10 21:53:18 +02:00
|
|
|
this.orbital_strikes = {
|
|
|
|
enabled = true
|
|
|
|
}
|
2021-05-16 13:48:50 +02:00
|
|
|
this.pickaxe_speed_per_purchase = 0.07
|
2020-05-23 21:18:18 +02:00
|
|
|
this.breached_wall = 1
|
2023-08-10 14:28:32 +02:00
|
|
|
this.final_battle = false
|
2020-05-20 09:10:17 +02:00
|
|
|
this.left_top = {
|
|
|
|
x = 0,
|
|
|
|
y = 0
|
|
|
|
}
|
2020-09-02 17:36:04 +02:00
|
|
|
this.biters = {
|
|
|
|
amount = 0,
|
2020-09-17 09:14:07 +02:00
|
|
|
limit = 512
|
2020-09-02 17:36:04 +02:00
|
|
|
}
|
2020-06-05 18:01:32 +02:00
|
|
|
this.traps = {}
|
2020-08-04 12:10:15 +02:00
|
|
|
this.munch_time = true
|
2020-07-06 15:45:09 +02:00
|
|
|
this.coin_amount = 1
|
|
|
|
this.difficulty_set = false
|
2020-08-04 12:10:15 +02:00
|
|
|
this.bonus_xp_on_join = 250
|
2020-07-06 15:45:09 +02:00
|
|
|
this.main_market_items = {}
|
2020-07-28 11:24:16 +02:00
|
|
|
this.spill_items_to_surface = false
|
2022-10-25 23:29:40 +02:00
|
|
|
this.spectate = {}
|
2020-07-14 21:50:56 +02:00
|
|
|
this.placed_trains_in_zone = {
|
2023-09-05 00:03:55 +02:00
|
|
|
limit = 1,
|
2022-04-07 00:17:41 +02:00
|
|
|
randomized = false,
|
|
|
|
zones = {}
|
2020-07-14 21:50:56 +02:00
|
|
|
}
|
2022-07-10 19:41:11 +02:00
|
|
|
this.market_limits = {
|
|
|
|
chests_outside_limit = 8,
|
|
|
|
aura_limit = 100, -- limited to save UPS
|
|
|
|
pickaxe_tier_limit = 59,
|
|
|
|
health_upgrades_limit = 100
|
|
|
|
}
|
2020-10-21 23:17:17 +02:00
|
|
|
this.marked_fixed_prices = {
|
2022-07-10 19:41:11 +02:00
|
|
|
chests_outside_cost = 3000,
|
2022-07-11 21:26:35 +02:00
|
|
|
health_cost = 14000,
|
2020-10-21 23:17:17 +02:00
|
|
|
pickaxe_cost = 3000,
|
|
|
|
aura_cost = 4000,
|
|
|
|
xp_point_boost_cost = 5000,
|
2021-02-01 00:59:49 +02:00
|
|
|
explosive_bullets_cost = 10000,
|
2020-10-21 23:17:17 +02:00
|
|
|
flamethrower_turrets_cost = 3000,
|
2021-10-15 16:59:25 +02:00
|
|
|
land_mine_cost = 2,
|
2021-10-29 00:06:35 +02:00
|
|
|
car_health_upgrade_pool_cost = 100000,
|
|
|
|
redraw_mystical_chest_cost = 3000
|
2020-10-21 23:17:17 +02:00
|
|
|
}
|
2020-07-25 17:22:04 +02:00
|
|
|
this.collapse_grace = true
|
2023-09-22 22:34:37 +02:00
|
|
|
this.corpse_removal_disabled = false
|
2020-07-27 11:07:32 +02:00
|
|
|
this.locomotive_biter = nil
|
2020-07-28 16:48:55 +02:00
|
|
|
this.disconnect_wagon = false
|
2020-12-05 19:09:09 +02:00
|
|
|
this.collapse_amount = false
|
|
|
|
this.collapse_speed = false
|
2021-11-11 02:57:58 +02:00
|
|
|
this.y_value_position = 20
|
2020-11-23 23:10:45 +02:00
|
|
|
this.spawn_near_collapse = {
|
|
|
|
active = true,
|
|
|
|
total_pos = 35,
|
|
|
|
compare = -150,
|
|
|
|
compare_next = 200,
|
|
|
|
distance_from = 2
|
|
|
|
}
|
2021-02-15 23:34:24 +02:00
|
|
|
this.spidertron_unlocked_at_zone = 11
|
2022-11-24 16:00:59 +02:00
|
|
|
this.spidertron_unlocked_enabled = false
|
2020-08-22 20:15:56 +02:00
|
|
|
-- this.void_or_tile = 'lab-dark-2'
|
|
|
|
this.void_or_tile = 'out-of-map'
|
2020-11-17 16:03:05 +02:00
|
|
|
this.validate_spider = {}
|
2020-12-20 20:56:26 +02:00
|
|
|
this.check_afk_players = true
|
2021-12-01 19:10:20 +02:00
|
|
|
this.winter_mode = false
|
2020-12-28 11:48:25 +02:00
|
|
|
this.sent_to_discord = false
|
2023-05-26 16:24:22 +02:00
|
|
|
this.random_seed = random(23849829, 1283989182)
|
2020-12-30 12:07:44 +02:00
|
|
|
this.difficulty = {
|
|
|
|
multiply = 0.25,
|
2021-10-08 18:52:14 +02:00
|
|
|
highest = 10,
|
|
|
|
lowest = 4
|
2020-12-30 12:07:44 +02:00
|
|
|
}
|
2021-10-08 18:52:14 +02:00
|
|
|
this.mining_bonus_till_wave = 300
|
2021-10-11 21:53:58 +02:00
|
|
|
this.mining_bonus = 0
|
|
|
|
this.disable_mining_boost = false
|
2021-02-10 23:08:07 +02:00
|
|
|
this.market_announce = game.tick + 1200
|
2021-02-12 01:48:56 +02:00
|
|
|
this.check_heavy_damage = true
|
2021-07-12 16:15:55 +02:00
|
|
|
this.prestige_system_enabled = false
|
2023-08-10 14:28:32 +02:00
|
|
|
this.mystical_chest_completed = 0
|
2021-10-29 00:07:45 +02:00
|
|
|
this.mystical_chest_enabled = true
|
2021-11-26 09:52:18 +02:00
|
|
|
this.check_if_threat_below_zero = true
|
2021-10-29 00:06:35 +02:00
|
|
|
this.mc_rewards = {
|
|
|
|
current = {},
|
|
|
|
temp_boosts = {}
|
|
|
|
}
|
2022-04-07 00:17:41 +02:00
|
|
|
this.adjusted_zones = {
|
|
|
|
scrap = {},
|
2022-04-07 16:11:18 +02:00
|
|
|
forest = {},
|
|
|
|
size = nil,
|
|
|
|
shuffled_zones = nil
|
2022-04-07 00:17:41 +02:00
|
|
|
}
|
2021-10-15 16:59:25 +02:00
|
|
|
this.alert_zone_1 = false -- alert the players
|
2022-04-18 01:17:26 +02:00
|
|
|
this.radars_reveal_new_chunks = false -- allows for the player to explore the map instead,
|
|
|
|
|
|
|
|
this.mining_utils = {
|
|
|
|
rocks_yield_ore_maximum_amount = 500,
|
|
|
|
type_modifier = 1,
|
|
|
|
rocks_yield_ore_base_amount = 40,
|
|
|
|
rocks_yield_ore_distance_modifier = 0.020
|
|
|
|
}
|
2021-10-15 16:59:25 +02:00
|
|
|
|
2021-05-23 17:03:52 +02:00
|
|
|
for k, _ in pairs(this.players) do
|
|
|
|
this.players[k] = {}
|
2020-09-25 11:08:15 +02:00
|
|
|
end
|
2020-05-17 12:23:55 +02:00
|
|
|
end
|
|
|
|
|
2022-11-24 16:00:59 +02:00
|
|
|
function Public.enable_bw(state)
|
|
|
|
this.bw = state or false
|
|
|
|
end
|
|
|
|
|
2020-05-20 09:09:39 +02:00
|
|
|
function Public.get(key)
|
|
|
|
if key then
|
|
|
|
return this[key]
|
2020-05-17 12:23:55 +02:00
|
|
|
else
|
2020-05-20 09:09:39 +02:00
|
|
|
return this
|
2020-05-17 12:23:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-17 13:45:27 +02:00
|
|
|
function Public.set(key, value)
|
2020-11-17 16:03:05 +02:00
|
|
|
if key and (value or value == false) then
|
2020-11-17 13:45:27 +02:00
|
|
|
this[key] = value
|
|
|
|
return this[key]
|
|
|
|
elseif key then
|
2020-07-14 21:50:56 +02:00
|
|
|
return this[key]
|
|
|
|
else
|
|
|
|
return this
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-03-15 20:59:44 +02:00
|
|
|
function Public.remove(key, sub_key)
|
2022-03-17 13:23:16 +02:00
|
|
|
if key and sub_key then
|
2022-03-15 20:59:44 +02:00
|
|
|
if this[key] and this[key][sub_key] then
|
|
|
|
this[key][sub_key] = nil
|
2022-03-17 13:23:16 +02:00
|
|
|
end
|
|
|
|
elseif key then
|
|
|
|
if this[key] then
|
2022-03-15 20:59:44 +02:00
|
|
|
this[key] = nil
|
|
|
|
end
|
2021-03-01 23:12:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-26 00:05:47 +02:00
|
|
|
Event.on_init(Public.reset_main_table)
|
2020-05-17 12:23:55 +02:00
|
|
|
|
|
|
|
return Public
|