mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-26 22:56:43 +02:00
minor changes to Mtn Fortress v3
This commit is contained in:
parent
a3be20d7c7
commit
1ee12826b4
10
.luacheckrc
10
.luacheckrc
@ -220,6 +220,12 @@ stds.factorio_control = {
|
||||
fields = {'print'}
|
||||
},
|
||||
|
||||
commands = {
|
||||
fields = {
|
||||
'add_command'
|
||||
}
|
||||
},
|
||||
|
||||
rendering = {
|
||||
other_fields = false,
|
||||
read_only = true,
|
||||
@ -342,6 +348,7 @@ stds.factorio_control = {
|
||||
"json_to_table",
|
||||
"kick_player",
|
||||
"merge_forces",
|
||||
"pollution_statistics",
|
||||
"mute_player",
|
||||
"play_sound",
|
||||
"print",
|
||||
@ -359,6 +366,7 @@ stds.factorio_control = {
|
||||
"show_message_dialog",
|
||||
"table_to_json",
|
||||
"take_screenshot",
|
||||
|
||||
"take_technology_screenshot",
|
||||
"unban_player",
|
||||
"unmute_player",
|
||||
@ -1259,6 +1267,8 @@ stds.factorio_defines = {
|
||||
'quick_bar_pick_slot',
|
||||
'quick_bar_set_selected_page',
|
||||
'quick_bar_set_slot',
|
||||
'flush_opened_entity_fluid',
|
||||
'flush_opened_entity_specific_fluid',
|
||||
'remove_cables',
|
||||
'remove_train_station',
|
||||
'reset_assembling_machine',
|
||||
|
@ -64,6 +64,11 @@ map_info_main_caption=M O U N T A I N F O R T R E S S
|
||||
map_info_sub_caption= ..diggy diggy choo choo..
|
||||
map_info_text=The biters have catched the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research, will overhaul your mining equipment,\nreinforcing your pickaxe as well as increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nSome explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nYou may find some supply goods, if you enter the wagon.\nGood luck on your journey!
|
||||
|
||||
[mountain_fortress_v3]
|
||||
map_info_main_caption=M O U N T A I N F O R T R E S S V3
|
||||
map_info_sub_caption= ..diggy diggy choo choo..
|
||||
map_info_text=The biters have catched the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research, will overhaul your mining equipment,\nreinforcing your pickaxe as well as increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nYou may find some supply goods, if you enter the wagon.\n\nRandom buildings that generate resources can be found throughout the world.\n\nGood luck on your journey!
|
||||
|
||||
[chronosphere]
|
||||
map_info_main_caption=C H R O N O S P H E R E
|
||||
map_info_sub_caption= ..Comfylatron gone wild..
|
||||
|
@ -1,6 +1,8 @@
|
||||
local Event = require 'utils.event'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
|
||||
local Public = {}
|
||||
|
||||
Public.events = {breached_wall = Event.generate_event_name('breached_wall')}
|
||||
|
||||
function Public.init_enemy_weapon_damage()
|
||||
@ -35,8 +37,6 @@ function Public.init_enemy_weapon_damage()
|
||||
end
|
||||
|
||||
local function enemy_weapon_damage()
|
||||
local Diff = Difficulty.get()
|
||||
|
||||
local e = game.forces.enemy
|
||||
|
||||
local data = {
|
||||
@ -58,7 +58,7 @@ local function enemy_weapon_damage()
|
||||
}
|
||||
|
||||
for k, v in pairs(data) do
|
||||
local new = Diff.difficulty_vote_value * v
|
||||
local new = Difficulty.get().difficulty_vote_value * v
|
||||
|
||||
local e_old = e.get_ammo_damage_modifier(k)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
|
||||
local math_random = math.random
|
||||
local nom_msg = {'munch', 'munch', 'yum'}
|
||||
|
||||
local Public = {}
|
||||
@ -10,8 +9,8 @@ local function feed_floaty_text(unit)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = unit.position,
|
||||
text = nom_msg[math_random(1, #nom_msg)],
|
||||
color = {math_random(50, 100), 0, 255}
|
||||
text = nom_msg[math.random(1, #nom_msg)],
|
||||
color = {math.random(50, 100), 0, 255}
|
||||
}
|
||||
)
|
||||
end
|
||||
@ -21,11 +20,11 @@ local function floaty_hearts(entity, c)
|
||||
local b = 1.35
|
||||
for a = 1, c, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math_random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math_random(0, b * 20) * 0.1)
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
entity.surface.create_entity(
|
||||
{name = 'flying-text', position = p, text = '♥', color = {math_random(150, 255), 0, 255}}
|
||||
{name = 'flying-text', position = p, text = '♥', color = {math.random(150, 255), 0, 255}}
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -69,7 +68,7 @@ local function feed_pet(unit)
|
||||
end
|
||||
unit.health = unit.health + 8 + math.floor(unit.prototype.max_health * 0.05)
|
||||
feed_floaty_text(unit)
|
||||
floaty_hearts(unit, math_random(1, 2))
|
||||
floaty_hearts(unit, math.random(1, 2))
|
||||
return true
|
||||
end
|
||||
|
||||
@ -94,7 +93,7 @@ function Public.biter_pets_tame_unit(player, unit, forced)
|
||||
end
|
||||
|
||||
if not forced then
|
||||
if math_random(1, math.floor(unit.prototype.max_health * 0.01) + 1) ~= 1 then
|
||||
if math.random(1, math.floor(unit.prototype.max_health * 0.01) + 1) ~= 1 then
|
||||
feed_floaty_text(unit)
|
||||
return true
|
||||
end
|
||||
@ -151,7 +150,7 @@ end
|
||||
local function on_player_changed_position(event)
|
||||
local this = WPT.get()
|
||||
|
||||
if math_random(1, 100) ~= 1 then
|
||||
if math.random(1, 100) ~= 1 then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
@ -1,5 +1,6 @@
|
||||
local Color = require 'utils.color_presets'
|
||||
local Task = require 'utils.task'
|
||||
local Server = require 'utils.server'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
@ -24,10 +25,10 @@ commands.add_command(
|
||||
local reset_map = require 'maps.mountain_fortress_v3.main'.reset_map
|
||||
local param = cmd.parameter
|
||||
|
||||
if param == 'restart' or param == 'shutdown' or param == 'reset' then
|
||||
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
|
||||
goto continue
|
||||
else
|
||||
p('[ERROR] Arguments are restart or shutdown or reset.')
|
||||
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
|
||||
return
|
||||
end
|
||||
|
||||
@ -58,6 +59,11 @@ commands.add_command(
|
||||
p('[WARNING] Soft-reset is disabled! Server will restart from scenario.')
|
||||
return
|
||||
end
|
||||
elseif param == 'restartnow' then
|
||||
this.reset_are_you_sure = nil
|
||||
p(player.name .. ' has restarted the game.')
|
||||
Server.start_scenario('Mountain_Fortress_v3')
|
||||
return
|
||||
elseif param == 'shutdown' then
|
||||
if this.shutdown then
|
||||
this.reset_are_you_sure = nil
|
||||
|
@ -21,9 +21,6 @@ local WD = require 'modules.wave_defense.table'
|
||||
-- module
|
||||
local Public = {}
|
||||
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
--local raise_event = script.raise_event
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]\n'
|
||||
@ -94,7 +91,7 @@ local function set_objective_health(final_damage_amount)
|
||||
return
|
||||
end
|
||||
|
||||
this.locomotive_health = math_floor(this.locomotive_health - final_damage_amount)
|
||||
this.locomotive_health = math.floor(this.locomotive_health - final_damage_amount)
|
||||
if this.locomotive_health > this.locomotive_max_health then
|
||||
this.locomotive_health = this.locomotive_max_health
|
||||
end
|
||||
@ -152,9 +149,9 @@ end
|
||||
|
||||
local function hidden_biter(entity)
|
||||
local surface = entity.surface
|
||||
local h = math_floor(math_abs(entity.position.y))
|
||||
local h = math.floor(math.abs(entity.position.y))
|
||||
local m = 1 / Terrain.level_depth
|
||||
local count = math_floor(math_random(0, h + Terrain.level_depth) * m) + 1
|
||||
local count = math.floor(math.random(0, h + Terrain.level_depth) * m) + 1
|
||||
local position = surface.find_non_colliding_position('small-biter', entity.position, 16, 0.5)
|
||||
if not position then
|
||||
position = entity.position
|
||||
@ -164,13 +161,13 @@ local function hidden_biter(entity)
|
||||
|
||||
for _ = 1, count, 1 do
|
||||
local unit
|
||||
if math_random(1, 3) == 1 then
|
||||
if math.random(1, 3) == 1 then
|
||||
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = position})
|
||||
else
|
||||
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position})
|
||||
end
|
||||
|
||||
if math_random(1, 64) == 1 then
|
||||
if math.random(1, 64) == 1 then
|
||||
BiterHealthBooster.add_boss_unit(unit, m * h * 5 + 1, 0.38)
|
||||
end
|
||||
end
|
||||
@ -182,12 +179,12 @@ local function hidden_worm(entity)
|
||||
end
|
||||
|
||||
local function hidden_biter_pet(event)
|
||||
if math_random(1, 2048) ~= 1 then
|
||||
if math.random(1, 2048) ~= 1 then
|
||||
return
|
||||
end
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25)
|
||||
local unit
|
||||
if math_random(1, 3) == 1 then
|
||||
if math.random(1, 3) == 1 then
|
||||
unit =
|
||||
event.entity.surface.create_entity(
|
||||
{name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position}
|
||||
@ -244,13 +241,13 @@ local function angry_tree(entity, cause)
|
||||
if math.abs(entity.position.y) < Terrain.level_depth then
|
||||
return
|
||||
end
|
||||
if math_random(1, 4) == 1 then
|
||||
if math.random(1, 4) == 1 then
|
||||
hidden_biter(entity)
|
||||
end
|
||||
if math_random(1, 8) == 1 then
|
||||
if math.random(1, 8) == 1 then
|
||||
hidden_worm(entity)
|
||||
end
|
||||
if math_random(1, 16) ~= 1 then
|
||||
if math.random(1, 16) ~= 1 then
|
||||
return
|
||||
end
|
||||
local position = false
|
||||
@ -260,12 +257,12 @@ local function angry_tree(entity, cause)
|
||||
end
|
||||
end
|
||||
if not position then
|
||||
position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))}
|
||||
position = {entity.position.x + (-20 + math.random(0, 40)), entity.position.y + (-20 + math.random(0, 40))}
|
||||
end
|
||||
|
||||
entity.surface.create_entity(
|
||||
{
|
||||
name = projectiles[math_random(1, 5)],
|
||||
name = projectiles[math.random(1, 5)],
|
||||
position = entity.position,
|
||||
force = 'neutral',
|
||||
source = entity.position,
|
||||
@ -336,7 +333,7 @@ local function on_player_mined_entity(event)
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
if math_random(1, 512) == 1 then
|
||||
if math.random(1, 512) == 1 then
|
||||
Traps(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
@ -385,7 +382,7 @@ end
|
||||
|
||||
local function get_damage(event)
|
||||
local entity = event.entity
|
||||
local damage = event.original_damage_amount + event.original_damage_amount * math_random(1, 100)
|
||||
local damage = event.original_damage_amount + event.original_damage_amount * math.random(1, 100)
|
||||
if entity.prototype.resistances then
|
||||
if entity.prototype.resistances.physical then
|
||||
damage = damage - entity.prototype.resistances.physical.decrease
|
||||
@ -412,7 +409,7 @@ local function kaboom(entity, target, damage)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {entity.position.x + base_vector[1] * 0.5, entity.position.y + base_vector[2] * 0.5},
|
||||
text = msg[math_random(1, #msg)],
|
||||
text = msg[math.random(1, #msg)],
|
||||
color = {255, 0, 0}
|
||||
}
|
||||
)
|
||||
@ -435,12 +432,12 @@ local function kaboom(entity, target, damage)
|
||||
end
|
||||
end
|
||||
|
||||
vector[1] = vector[1] * 1.5
|
||||
vector[2] = vector[2] * 1.5
|
||||
vector[1] = vector[1] * 1.6
|
||||
vector[2] = vector[2] * 1.6
|
||||
|
||||
local a = 0.25
|
||||
local a = 0.30
|
||||
|
||||
for i = 1, 16, 1 do
|
||||
for i = 1, 8, 1 do
|
||||
for x = i * -1 * a, i * a, 1 do
|
||||
for y = i * -1 * a, i * a, 1 do
|
||||
local p = {entity.position.x + x + vector[1] * i, entity.position.y + y + vector[2] * i}
|
||||
@ -489,13 +486,9 @@ local function boss_puncher(event)
|
||||
return
|
||||
end
|
||||
|
||||
local wd = WD.get_table()
|
||||
if wd.boss_wave_warning or wd.wave_number >= 1000 then
|
||||
if math_random(1, 10) == 1 then
|
||||
if math.random(1, 10) == 1 then
|
||||
kaboom(cause, entity, get_damage(event))
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
@ -511,10 +504,18 @@ local function on_entity_damaged(event)
|
||||
|
||||
protect_entities(event)
|
||||
biters_chew_rocks_faster(event)
|
||||
if math_random(0, 512) == 1 then
|
||||
local wave_number = WD.get_wave()
|
||||
local boss_wave_warning = WD.alert_boss_wave()
|
||||
local much_time = WPT.get('much_time')
|
||||
|
||||
if much_time then
|
||||
if boss_wave_warning or wave_number >= 1500 then
|
||||
if math.random(0, 512) == 1 then
|
||||
boss_puncher(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
local this = WPT.get()
|
||||
@ -602,7 +603,7 @@ local function on_entity_died(event)
|
||||
hidden_biter(event.entity)
|
||||
return
|
||||
end
|
||||
if math_random(1, 512) == 1 then
|
||||
if math.random(1, 512) == 1 then
|
||||
Traps(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
@ -629,7 +630,7 @@ function Public.set_scores()
|
||||
if not loco.valid then
|
||||
return
|
||||
end
|
||||
local score = math_floor(loco.position.y * -1)
|
||||
local score = math.floor(loco.position.y * -1)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if score > Map_score.get_score(player) then
|
||||
Map_score.set_score(player, score)
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Event = require 'utils.event'
|
||||
@ -8,6 +9,8 @@ local Public = {}
|
||||
local magic_crafters_per_tick = 3
|
||||
local magic_fluid_crafters_per_tick = 8
|
||||
local floor = math.floor
|
||||
local round = math.round
|
||||
local table_shuffle_table = table.shuffle_table
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
local count = #tbl
|
||||
@ -171,6 +174,52 @@ local function do_magic_fluid_crafters()
|
||||
magic_fluid_crafters.index = index
|
||||
end
|
||||
|
||||
local function add_magic_crafter_output(entity, output, distance)
|
||||
local magic_fluid_crafters = WPT.get('magic_fluid_crafters')
|
||||
local magic_crafters = WPT.get('magic_crafters')
|
||||
local rate = output.min_rate + output.distance_factor * distance
|
||||
|
||||
local fluidbox_index = output.fluidbox_index
|
||||
local data = {
|
||||
entity = entity,
|
||||
last_tick = game.tick,
|
||||
base_rate = rate,
|
||||
rate = rate,
|
||||
item = output.item,
|
||||
fluidbox_index = fluidbox_index
|
||||
}
|
||||
|
||||
if fluidbox_index then
|
||||
magic_fluid_crafters[#magic_fluid_crafters + 1] = data
|
||||
else
|
||||
magic_crafters[#magic_crafters + 1] = data
|
||||
end
|
||||
end
|
||||
|
||||
function roll(budget, item_name)
|
||||
if not budget then
|
||||
return
|
||||
end
|
||||
|
||||
budget = math.floor(budget)
|
||||
if budget == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local final_stack_set
|
||||
local final_stack_set_worth = 0
|
||||
|
||||
for _ = 1, 5, 1 do
|
||||
local item_stack_set, item_stack_set_worth = roll_item_stacks(budget, item_name)
|
||||
if item_stack_set_worth > final_stack_set_worth or item_stack_set_worth == budget then
|
||||
final_stack_set = item_stack_set
|
||||
final_stack_set_worth = item_stack_set_worth
|
||||
end
|
||||
end
|
||||
|
||||
return final_stack_set
|
||||
end
|
||||
|
||||
local function tick()
|
||||
do_refill_turrets()
|
||||
do_magic_crafters()
|
||||
@ -180,64 +229,82 @@ end
|
||||
Public.deactivate_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = false
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.neutral_force =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.force = 'neutral'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.enemy_force =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.force = 'enemy'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.active_not_destructible_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = true
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_minable_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.minable = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_minable_and_ICW_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.minable = false
|
||||
local wagon = ICW.register_wagon(entity, true)
|
||||
wagon.entity_count = 999
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.disable_destructible_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
)
|
||||
Public.disable_active_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.active = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local disable_active_callback = Public.disable_active_callback
|
||||
|
||||
Public.refill_turret_callback =
|
||||
Token.register(
|
||||
function(turret, data)
|
||||
@ -283,6 +350,152 @@ Public.power_source_callback =
|
||||
end
|
||||
)
|
||||
|
||||
Public.magic_item_crafting_callback =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
entity.operable = false
|
||||
|
||||
local recipe = callback_data.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
else
|
||||
local furance_item = callback_data.furance_item
|
||||
if furance_item then
|
||||
local inv = entity.get_inventory(2) -- defines.inventory.furnace_source
|
||||
inv.insert(furance_item)
|
||||
end
|
||||
end
|
||||
|
||||
local p = entity.position
|
||||
local x, y = p.x, p.y
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
|
||||
local output = callback_data.output
|
||||
if #output == 0 then
|
||||
add_magic_crafter_output(entity, output, distance)
|
||||
else
|
||||
for i = 1, #output do
|
||||
local o = output[i]
|
||||
add_magic_crafter_output(entity, o, distance)
|
||||
end
|
||||
end
|
||||
|
||||
if not callback_data.keep_active then
|
||||
Task.set_timeout_in_ticks(2, disable_active_callback, entity) -- causes problems with refineries.
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.magic_item_crafting_callback_weighted =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
entity.operable = false
|
||||
|
||||
local weights = callback_data.weights
|
||||
local loot = callback_data.loot
|
||||
|
||||
local p = entity.position
|
||||
|
||||
local i = math.random() * weights.total
|
||||
|
||||
local index = table.binary_search(weights, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
local stack = loot[index].stack
|
||||
if not stack then
|
||||
return
|
||||
end
|
||||
|
||||
local recipe = stack.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
else
|
||||
local furance_item = stack.furance_item
|
||||
if furance_item then
|
||||
local inv = entity.get_inventory(2) -- defines.inventory.furnace_source
|
||||
inv.insert(furance_item)
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = p.x, p.y
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
|
||||
local output = stack.output
|
||||
if #output == 0 then
|
||||
add_magic_crafter_output(entity, output, distance)
|
||||
else
|
||||
for o_i = 1, #output do
|
||||
local o = output[o_i]
|
||||
add_magic_crafter_output(entity, o, distance)
|
||||
end
|
||||
end
|
||||
|
||||
if not callback_data.keep_active then
|
||||
Task.set_timeout_in_ticks(2, disable_active_callback, entity) -- causes problems with refineries.
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
function Public.prepare_weighted_loot(loot)
|
||||
local total = 0
|
||||
local weights = {}
|
||||
|
||||
for i = 1, #loot do
|
||||
local v = loot[i]
|
||||
total = total + v.weight
|
||||
weights[#weights + 1] = total
|
||||
end
|
||||
|
||||
weights.total = total
|
||||
|
||||
return weights
|
||||
end
|
||||
|
||||
function Public.do_random_loot(entity, weights, loot)
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
entity.operable = false
|
||||
--entity.destructible = false
|
||||
|
||||
local i = math.random() * weights.total
|
||||
|
||||
local index = table.binary_search(weights, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
local stack = loot[index].stack
|
||||
if not stack then
|
||||
return
|
||||
end
|
||||
|
||||
local df = stack.distance_factor
|
||||
local count
|
||||
if df then
|
||||
local p = entity.position
|
||||
local x, y = p.x, p.y
|
||||
local d = math.sqrt(x * x + y * y)
|
||||
|
||||
count = stack.count + d * df
|
||||
else
|
||||
count = stack.count
|
||||
end
|
||||
|
||||
entity.insert {name = stack.name, count = count}
|
||||
end
|
||||
|
||||
Public.firearm_magazine_ammo = {name = 'firearm-magazine', count = 200}
|
||||
Public.piercing_rounds_magazine_ammo = {name = 'piercing-rounds-magazine', count = 200}
|
||||
Public.uranium_rounds_magazine_ammo = {name = 'uranium-rounds-magazine', count = 200}
|
||||
@ -290,7 +503,7 @@ Public.light_oil_ammo = {name = 'light-oil', amount = 100}
|
||||
Public.artillery_shell_ammo = {name = 'artillery-shell', count = 15}
|
||||
Public.laser_turrent_power_source = {buffer_size = 2400000, power_production = 40000}
|
||||
|
||||
Event.on_nth_tick(20, tick)
|
||||
Event.on_nth_tick(10, tick)
|
||||
--Event.add(defines.events.on_tick, tick)
|
||||
Event.add(defines.events.on_entity_died, turret_died)
|
||||
|
||||
|
@ -44,6 +44,16 @@ local function do_tile(y, x, data, shape)
|
||||
end
|
||||
end
|
||||
|
||||
local buildings = tile.buildings
|
||||
if buildings then
|
||||
for _, entity in pairs(buildings) do
|
||||
if not entity.position then
|
||||
entity.position = pos
|
||||
end
|
||||
data.buildings[#data.buildings + 1] = entity
|
||||
end
|
||||
end
|
||||
|
||||
local decoratives = tile.decoratives
|
||||
if decoratives then
|
||||
for _, decorative in pairs(decoratives) do
|
||||
@ -106,6 +116,16 @@ local function do_row(row, data, shape)
|
||||
end
|
||||
end
|
||||
|
||||
local buildings = tile.buildings
|
||||
if buildings then
|
||||
for _, entity in pairs(buildings) do
|
||||
if not entity.position then
|
||||
entity.position = pos
|
||||
end
|
||||
data.buildings[#data.buildings + 1] = entity
|
||||
end
|
||||
end
|
||||
|
||||
local decoratives = tile.decoratives
|
||||
if decoratives then
|
||||
for _, decorative in pairs(decoratives) do
|
||||
@ -148,14 +168,13 @@ local function do_place_treasure(data)
|
||||
|
||||
local surface = data.surface
|
||||
local treasure = data.treasure
|
||||
local rnd = math.random
|
||||
|
||||
if #treasure == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
for _, e in pairs(data.treasure) do
|
||||
if rnd(1, 6) == 1 then
|
||||
if math.random(1, 6) == 1 then
|
||||
e.chest = 'iron-chest'
|
||||
end
|
||||
Loot.add(surface, e.position, e.chest)
|
||||
@ -169,14 +188,12 @@ local function do_place_markets(data)
|
||||
|
||||
local markets = data.markets
|
||||
local surface = data.surface
|
||||
local rnd = math.random
|
||||
local abs = math.abs
|
||||
|
||||
if #markets == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = markets[rnd(1, #markets)]
|
||||
local pos = markets[math.random(1, #markets)]
|
||||
if
|
||||
surface.count_entities_filtered {
|
||||
area = {{pos.x - 96, pos.y - 96}, {pos.x + 96, pos.y + 96}},
|
||||
@ -184,7 +201,7 @@ local function do_place_markets(data)
|
||||
limit = 1
|
||||
} == 0
|
||||
then
|
||||
local market = Market.mountain_market(surface, pos, abs(pos.y) * 0.004)
|
||||
local market = Market.mountain_market(surface, pos, math.abs(pos.y) * 0.004)
|
||||
market.destructible = false
|
||||
end
|
||||
end
|
||||
@ -212,6 +229,51 @@ local function do_place_decoratives(data)
|
||||
end
|
||||
end
|
||||
|
||||
local function do_place_buildings(data)
|
||||
if not data.surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = data.surface
|
||||
local entity
|
||||
local callback
|
||||
|
||||
for _, e in pairs(data.buildings) do
|
||||
if e.e_type then
|
||||
local p = e.position
|
||||
if
|
||||
surface.count_entities_filtered {
|
||||
area = {{p.x - 32, p.y - 32}, {p.x + 32, p.y + 32}},
|
||||
type = e.e_type,
|
||||
limit = 1
|
||||
} == 0
|
||||
then
|
||||
entity = surface.create_entity(e)
|
||||
if entity and e.direction then
|
||||
entity.direction = e.direction
|
||||
end
|
||||
if entity and e.force then
|
||||
entity.force = e.force
|
||||
end
|
||||
if entity and e.callback then
|
||||
local c = e.callback.callback
|
||||
if not c then
|
||||
return
|
||||
end
|
||||
local d = {callback_data = e.callback.data}
|
||||
if not d then
|
||||
callback = Token.get(c)
|
||||
callback(entity)
|
||||
return
|
||||
end
|
||||
callback = Token.get(c)
|
||||
callback(entity, d)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function do_place_entities(data)
|
||||
if not data.surface.valid then
|
||||
return
|
||||
@ -342,18 +404,22 @@ local function map_gen_action(data)
|
||||
data.y = 34
|
||||
return true
|
||||
elseif state == 34 then
|
||||
do_place_markets(data)
|
||||
do_place_buildings(data)
|
||||
data.y = 35
|
||||
return true
|
||||
elseif state == 35 then
|
||||
do_place_treasure(data)
|
||||
do_place_markets(data)
|
||||
data.y = 36
|
||||
return true
|
||||
elseif state == 36 then
|
||||
do_place_decoratives(data)
|
||||
do_place_treasure(data)
|
||||
data.y = 37
|
||||
return true
|
||||
elseif state == 37 then
|
||||
do_place_decoratives(data)
|
||||
data.y = 38
|
||||
return true
|
||||
elseif state == 38 then
|
||||
run_chart_update(data)
|
||||
return false
|
||||
end
|
||||
@ -392,6 +458,7 @@ function Public.schedule_chunk(event)
|
||||
surface = surface,
|
||||
tiles = {},
|
||||
entities = {},
|
||||
buildings = {},
|
||||
decoratives = {},
|
||||
markets = {},
|
||||
treasure = {}
|
||||
@ -429,6 +496,7 @@ function Public.do_chunk(event)
|
||||
surface = surface,
|
||||
tiles = {},
|
||||
entities = {},
|
||||
buildings = {},
|
||||
decoratives = {},
|
||||
markets = {},
|
||||
treasure = {}
|
||||
@ -444,6 +512,7 @@ function Public.do_chunk(event)
|
||||
|
||||
do_place_tiles(data)
|
||||
do_place_entities(data)
|
||||
do_place_buildings(data)
|
||||
do_place_decoratives(data)
|
||||
do_place_markets(data)
|
||||
do_place_treasure(data)
|
||||
|
@ -2,7 +2,6 @@ local Event = require 'utils.event'
|
||||
local RPG = require 'maps.mountain_fortress_v3.rpg'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Gui = require 'utils.gui'
|
||||
local floor = math.floor
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local Public = {}
|
||||
@ -265,9 +264,9 @@ function Public.update_gui(player)
|
||||
gui.global_pool.caption = 'XP: 0'
|
||||
gui.global_pool.tooltip = 'Dig, handcraft or run to increase the pool!'
|
||||
elseif rpg_extra.global_pool >= 0 then
|
||||
gui.global_pool.caption = 'XP: ' .. format_number(floor(rpg_extra.global_pool), true)
|
||||
gui.global_pool.caption = 'XP: ' .. format_number(math.floor(rpg_extra.global_pool), true)
|
||||
gui.global_pool.tooltip =
|
||||
'Amount of XP that is stored inside the global xp pool.\nRaw Value: ' .. floor(rpg_extra.global_pool)
|
||||
'Amount of XP that is stored inside the global xp pool.\nRaw Value: ' .. math.floor(rpg_extra.global_pool)
|
||||
end
|
||||
|
||||
gui.scrap_mined.caption = ' [img=entity.tree-01][img=entity.rock-huge]: ' .. format_number(this.mined_scrap, true)
|
||||
|
@ -3,9 +3,6 @@ local Public = {}
|
||||
local Constants = require 'maps.mountain_fortress_v3.icw.constants'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||
|
||||
local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
|
||||
function Public.request_reconstruction(icw)
|
||||
icw.rebuild_tick = game.tick + 30
|
||||
end
|
||||
@ -24,7 +21,7 @@ local function delete_empty_surfaces(icw)
|
||||
for k, surface in pairs(icw.surfaces) do
|
||||
if not icw.trains[tonumber(surface.name)] then
|
||||
game.delete_surface(surface)
|
||||
table_remove(icw.surfaces, k)
|
||||
icw.surfaces[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -99,6 +96,10 @@ local function equal_fluid(source_tank, target_tank)
|
||||
end
|
||||
|
||||
local function divide_fluid(wagon, storage_tank)
|
||||
if not validate_entity(wagon.entity) then
|
||||
return
|
||||
end
|
||||
|
||||
local fluid_wagon = wagon.entity
|
||||
equal_fluid(fluid_wagon, storage_tank)
|
||||
equal_fluid(storage_tank, fluid_wagon)
|
||||
@ -135,7 +136,7 @@ local function input_cargo(wagon, chest)
|
||||
end
|
||||
|
||||
local wagon_entity = wagon.entity
|
||||
if not wagon_entity.valid then
|
||||
if not validate_entity(wagon_entity) then
|
||||
wagon.transfer_entities = nil
|
||||
return
|
||||
end
|
||||
@ -171,15 +172,10 @@ local function input_cargo(wagon, chest)
|
||||
end
|
||||
|
||||
local function output_cargo(wagon, passive_chest)
|
||||
if not wagon.entity then
|
||||
return
|
||||
end
|
||||
if not wagon.entity.valid then
|
||||
return
|
||||
end
|
||||
if not passive_chest.valid then
|
||||
if not validate_entity(wagon.entity) then
|
||||
return
|
||||
end
|
||||
|
||||
if not passive_chest.valid then
|
||||
return
|
||||
end
|
||||
@ -229,6 +225,9 @@ local function get_wagon_for_entity(icw, entity)
|
||||
end
|
||||
|
||||
local function kill_wagon_doors(icw, wagon)
|
||||
if not validate_entity(wagon.entity) then
|
||||
return
|
||||
end
|
||||
for k, e in pairs(wagon.doors) do
|
||||
icw.doors[e.unit_number] = nil
|
||||
e.destroy()
|
||||
@ -255,7 +254,7 @@ local function construct_wagon_doors(icw, wagon)
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
icw.doors[e.unit_number] = wagon.entity.unit_number
|
||||
table_insert(wagon.doors, e)
|
||||
wagon.doors[#wagon.doors + 1] = e
|
||||
end
|
||||
end
|
||||
|
||||
@ -311,7 +310,7 @@ function Public.kill_wagon(icw, entity)
|
||||
end
|
||||
Public.kill_minimap(e.player)
|
||||
else
|
||||
e.die()
|
||||
e.destroy()
|
||||
recreate_players()
|
||||
end
|
||||
end
|
||||
@ -348,7 +347,7 @@ function Public.create_room_surface(icw, unit_number)
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
end
|
||||
table_insert(icw.surfaces, surface)
|
||||
icw.surfaces[#icw.surfaces + 1] = surface
|
||||
return surface
|
||||
end
|
||||
|
||||
@ -363,20 +362,20 @@ function Public.create_wagon_room(icw, wagon)
|
||||
|
||||
local tiles = {}
|
||||
for x = -3, 2, 1 do
|
||||
table_insert(tiles, {name = 'hazard-concrete-right', position = {x, area.left_top.y}})
|
||||
table_insert(tiles, {name = 'hazard-concrete-right', position = {x, area.right_bottom.y - 1}})
|
||||
tiles[#tiles + 1] = {name = 'hazard-concrete-right', position = {x, area.left_top.y}}
|
||||
tiles[#tiles + 1] = {name = 'hazard-concrete-right', position = {x, area.right_bottom.y - 1}}
|
||||
end
|
||||
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
|
||||
for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do
|
||||
table_insert(tiles, {name = main_tile_name, position = {x, y}})
|
||||
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
|
||||
end
|
||||
end
|
||||
for x = -3, 2, 1 do
|
||||
for y = 1, 3, 1 do
|
||||
table_insert(tiles, {name = main_tile_name, position = {x, y}})
|
||||
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
|
||||
end
|
||||
for y = area.right_bottom.y - 4, area.right_bottom.y - 2, 1 do
|
||||
table_insert(tiles, {name = main_tile_name, position = {x, y}})
|
||||
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
|
||||
end
|
||||
end
|
||||
|
||||
@ -385,8 +384,8 @@ function Public.create_wagon_room(icw, wagon)
|
||||
if wagon.entity.type == 'locomotive' then
|
||||
for x = -3, 2, 1 do
|
||||
for y = 10, 12, 1 do
|
||||
table_insert(tiles, {name = 'water', position = {x, y}})
|
||||
table_insert(fishes, {name = 'fish', position = {x, y}})
|
||||
tiles[#tiles + 1] = {name = 'water', position = {x, y}}
|
||||
fishes[#fishes + 1] = {name = 'fish', position = {x, y}}
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -702,8 +701,7 @@ local function move_room_to_train(icw, train, wagon)
|
||||
if not wagon then
|
||||
return
|
||||
end
|
||||
|
||||
table_insert(train.wagons, wagon.entity.unit_number)
|
||||
train.wagons[#train.wagons + 1] = wagon.entity.unit_number
|
||||
|
||||
local destination_area = {
|
||||
left_top = {x = wagon.area.left_top.x, y = train.top_y},
|
||||
@ -775,7 +773,7 @@ local function move_room_to_train(icw, train, wagon)
|
||||
|
||||
for _, e in pairs(wagon.surface.find_entities_filtered({area = wagon.area, force = 'neutral'})) do
|
||||
if transfer_functions[e.name] then
|
||||
table_insert(wagon.transfer_entities, e)
|
||||
wagon.transfer_entities[#wagon.transfer_entities + 1] = e
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -798,7 +796,7 @@ end
|
||||
function Public.reconstruct_all_trains(icw)
|
||||
icw.trains = {}
|
||||
for unit_number, wagon in pairs(icw.wagons) do
|
||||
if not wagon.entity or not wagon.entity.valid then
|
||||
if not validate_entity(wagon.entity) then
|
||||
icw.wagons[unit_number] = nil
|
||||
Public.request_reconstruction(icw)
|
||||
return
|
||||
@ -817,14 +815,10 @@ end
|
||||
|
||||
function Public.item_transfer(icw)
|
||||
for _, wagon in pairs(icw.wagons) do
|
||||
if not wagon and not wagon.valid then
|
||||
if not validate_entity(wagon.entity) then
|
||||
return
|
||||
end
|
||||
if wagon.transfer_entities then
|
||||
if not wagon and not wagon.valid then
|
||||
return
|
||||
end
|
||||
|
||||
for k, e in pairs(wagon.transfer_entities) do
|
||||
transfer_functions[e.name](wagon, e)
|
||||
end
|
||||
|
@ -9,11 +9,7 @@ local Alert = require 'utils.alert'
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local Public = {}
|
||||
local random = math.random
|
||||
local rad = math.rad
|
||||
local concat = table.concat
|
||||
local cos = math.cos
|
||||
local sin = math.sin
|
||||
|
||||
local shopkeeper = '[color=blue]Shopkeeper:[/color]\n'
|
||||
|
||||
@ -189,10 +185,10 @@ local function create_poison_cloud(position)
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
local random_angles = {
|
||||
rad(random(359)),
|
||||
rad(random(359)),
|
||||
rad(random(359)),
|
||||
rad(random(359))
|
||||
math.rad(math.random(359)),
|
||||
math.rad(math.random(359)),
|
||||
math.rad(math.random(359)),
|
||||
math.rad(math.random(359))
|
||||
}
|
||||
|
||||
surface.create_entity({name = 'poison-cloud', position = {x = position.x, y = position.y}})
|
||||
@ -200,8 +196,8 @@ local function create_poison_cloud(position)
|
||||
{
|
||||
name = 'poison-cloud',
|
||||
position = {
|
||||
x = position.x + 12 * cos(random_angles[1]),
|
||||
y = position.y + 12 * sin(random_angles[1])
|
||||
x = position.x + 12 * math.cos(random_angles[1]),
|
||||
y = position.y + 12 * math.sin(random_angles[1])
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -209,8 +205,8 @@ local function create_poison_cloud(position)
|
||||
{
|
||||
name = 'poison-cloud',
|
||||
position = {
|
||||
x = position.x + 12 * cos(random_angles[2]),
|
||||
y = position.y + 12 * sin(random_angles[2])
|
||||
x = position.x + 12 * math.cos(random_angles[2]),
|
||||
y = position.y + 12 * math.sin(random_angles[2])
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -218,8 +214,8 @@ local function create_poison_cloud(position)
|
||||
{
|
||||
name = 'poison-cloud',
|
||||
position = {
|
||||
x = position.x + 12 * cos(random_angles[3]),
|
||||
y = position.y + 12 * sin(random_angles[3])
|
||||
x = position.x + 12 * math.cos(random_angles[3]),
|
||||
y = position.y + 12 * math.sin(random_angles[3])
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -227,8 +223,8 @@ local function create_poison_cloud(position)
|
||||
{
|
||||
name = 'poison-cloud',
|
||||
position = {
|
||||
x = position.x + 12 * cos(random_angles[4]),
|
||||
y = position.y + 12 * sin(random_angles[4])
|
||||
x = position.x + 12 * math.cos(random_angles[4]),
|
||||
y = position.y + 12 * math.sin(random_angles[4])
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -854,7 +850,7 @@ local function create_market(data, rebuild)
|
||||
}
|
||||
local e =
|
||||
loco_surface.create_entity(
|
||||
{name = biters[random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false}
|
||||
{name = biters[math.random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false}
|
||||
)
|
||||
e.ai_settings.allow_destroy_when_commands_fail = false
|
||||
e.ai_settings.allow_try_return_to_spawner = false
|
||||
@ -924,7 +920,7 @@ local function tick()
|
||||
Public.boost_players_around_train()
|
||||
end
|
||||
|
||||
if ticker % 600 == 0 then
|
||||
if ticker % 2500 == 0 then
|
||||
Public.transfer_pollution()
|
||||
end
|
||||
|
||||
@ -1155,15 +1151,13 @@ function Public.transfer_pollution()
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local icw_locomotive = WPT.get('icw_locomotive')
|
||||
local surface = icw_locomotive.surface
|
||||
local Diff = Difficulty.get()
|
||||
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
|
||||
local total_interior_pollution = surface.get_total_pollution()
|
||||
|
||||
local pollution = surface.get_total_pollution() * (3 / (4 / 3 + 1)) * Diff.difficulty_vote_value
|
||||
local pollution = surface.get_total_pollution() * (3 / (4 / 3 + 1)) * Difficulty.get().difficulty_vote_value
|
||||
game.surfaces[active_surface_index].pollute(locomotive.position, pollution)
|
||||
game.pollution_statistics.on_flow('locomotive', pollution - total_interior_pollution)
|
||||
surface.clear_pollution()
|
||||
@ -1179,9 +1173,9 @@ function Public.enable_poison_defense()
|
||||
end
|
||||
local pos = locomotive.position
|
||||
create_poison_cloud({x = pos.x, y = pos.y})
|
||||
if random(1, 3) == 1 then
|
||||
local random_angles = {rad(random(359))}
|
||||
create_poison_cloud({x = pos.x + 24 * cos(random_angles[1]), y = pos.y + -24 * sin(random_angles[1])})
|
||||
if math.random(1, 3) == 1 then
|
||||
local random_angles = {math.rad(math.random(359))}
|
||||
create_poison_cloud({x = pos.x + 24 * math.cos(random_angles[1]), y = pos.y + -24 * math.sin(random_angles[1])})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
local LootRaffle = require 'functions.loot_raffle'
|
||||
|
||||
local Public = {}
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
local math_floor = math.floor
|
||||
|
||||
local blacklist = {
|
||||
['atomic-bomb'] = true,
|
||||
@ -14,19 +11,19 @@ local blacklist = {
|
||||
}
|
||||
|
||||
function Public.add(surface, position, chest)
|
||||
local budget = 48 + math_abs(position.y) * 1.75
|
||||
budget = budget * math_random(25, 175) * 0.01
|
||||
local budget = 48 + math.abs(position.y) * 1.75
|
||||
budget = budget * math.random(25, 175) * 0.01
|
||||
|
||||
if math_random(1, 128) == 1 then
|
||||
if math.random(1, 128) == 1 then
|
||||
budget = budget * 4
|
||||
chest = 'crash-site-chest-' .. math_random(1, 2)
|
||||
chest = 'crash-site-chest-' .. math.random(1, 2)
|
||||
end
|
||||
if math_random(1, 256) == 1 then
|
||||
if math.random(1, 256) == 1 then
|
||||
budget = budget * 4
|
||||
chest = 'crash-site-chest-' .. math_random(1, 2)
|
||||
chest = 'crash-site-chest-' .. math.random(1, 2)
|
||||
end
|
||||
|
||||
budget = math_floor(budget) + 1
|
||||
budget = math.floor(budget) + 1
|
||||
|
||||
local item_stacks = LootRaffle.roll(budget, 8, blacklist)
|
||||
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
|
||||
@ -36,8 +33,8 @@ function Public.add(surface, position, chest)
|
||||
container.minable = false
|
||||
|
||||
for _ = 1, 3, 1 do
|
||||
if math_random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = math_random(25, 50)})
|
||||
if math.random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = math.random(25, 50)})
|
||||
else
|
||||
break
|
||||
end
|
||||
@ -45,19 +42,19 @@ function Public.add(surface, position, chest)
|
||||
end
|
||||
|
||||
function Public.add_rare(surface, position, chest, magic)
|
||||
local budget = magic * 48 + math_abs(position.y) * 1.75
|
||||
budget = budget * math_random(25, 175) * 0.01
|
||||
local budget = magic * 48 + math.abs(position.y) * 1.75
|
||||
budget = budget * math.random(25, 175) * 0.01
|
||||
|
||||
if math_random(1, 128) == 1 then
|
||||
if math.random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. math_random(1, 2)
|
||||
chest = 'crash-site-chest-' .. math.random(1, 2)
|
||||
end
|
||||
if math_random(1, 128) == 1 then
|
||||
if math.random(1, 128) == 1 then
|
||||
budget = budget * 6
|
||||
chest = 'crash-site-chest-' .. math_random(1, 2)
|
||||
chest = 'crash-site-chest-' .. math.random(1, 2)
|
||||
end
|
||||
|
||||
budget = math_floor(budget) + 1
|
||||
budget = math.floor(budget) + 1
|
||||
|
||||
local item_stacks = LootRaffle.roll(budget, 8, blacklist)
|
||||
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
|
||||
@ -67,8 +64,8 @@ function Public.add_rare(surface, position, chest, magic)
|
||||
container.minable = false
|
||||
|
||||
for _ = 1, 3, 1 do
|
||||
if math_random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = math_random(25, 50)})
|
||||
if math.random(1, 8) == 1 then
|
||||
container.insert({name = 'explosives', count = math.random(25, 50)})
|
||||
else
|
||||
break
|
||||
end
|
||||
|
@ -1,12 +1,9 @@
|
||||
require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
-- require 'maps.mountain_fortress_v3.nightfall'
|
||||
-- require 'maps.mountain_fortress_v3.void_away'
|
||||
|
||||
require 'modules.dynamic_landfill'
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.spawners_contain_biters'
|
||||
@ -61,7 +58,9 @@ local collapse_kill = {
|
||||
['artillery-turret'] = true,
|
||||
['landmine'] = true,
|
||||
['locomotive'] = true,
|
||||
['cargo-wagon'] = true
|
||||
['cargo-wagon'] = true,
|
||||
['assembling-machine'] = true,
|
||||
['furnace'] = true
|
||||
},
|
||||
enabled = true
|
||||
}
|
||||
@ -266,7 +265,7 @@ function Public.reset_map()
|
||||
wave_defense_table.game_lost = false
|
||||
wave_defense_table.spawn_position = {x = 0, y = 100}
|
||||
WD.alert_boss_wave(true)
|
||||
WD.clear_corpses(true)
|
||||
WD.clear_corpses(false)
|
||||
|
||||
set_difficulty()
|
||||
|
||||
@ -344,8 +343,8 @@ local on_player_joined_game = function(event)
|
||||
)
|
||||
else
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local oom = surface.get_tile(p).name == 'out-of-map'
|
||||
if oom then
|
||||
local get_tile = surface.get_tile(p)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
player.teleport(
|
||||
surface.find_non_colliding_position(
|
||||
'character',
|
||||
@ -616,7 +615,7 @@ local on_init = function()
|
||||
this.rocks_yield_ore_distance_modifier = 0.025
|
||||
|
||||
local T = Map.Pop_info()
|
||||
T.localised_category = 'mountain_fortress'
|
||||
T.localised_category = 'mountain_fortress_v3'
|
||||
T.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
T.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
|
||||
|
@ -3,9 +3,6 @@ local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Public = {}
|
||||
|
||||
local max_spill = 60
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local valid_rocks = {
|
||||
['sand-rock-big'] = true,
|
||||
@ -28,8 +25,8 @@ local particles = {
|
||||
}
|
||||
|
||||
local function create_particles(surface, name, position, amount, cause_position)
|
||||
local d1 = (-100 + math_random(0, 200)) * 0.0004
|
||||
local d2 = (-100 + math_random(0, 200)) * 0.0004
|
||||
local d1 = (-100 + math.random(0, 200)) * 0.0004
|
||||
local d2 = (-100 + math.random(0, 200)) * 0.0004
|
||||
|
||||
if cause_position then
|
||||
d1 = (cause_position.x - position.x) * 0.025
|
||||
@ -37,7 +34,7 @@ local function create_particles(surface, name, position, amount, cause_position)
|
||||
end
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(4, 10)
|
||||
local m = math.random(4, 10)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_particle(
|
||||
@ -48,8 +45,8 @@ local function create_particles(surface, name, position, amount, cause_position)
|
||||
vertical_speed = 0.130,
|
||||
height = 0,
|
||||
movement = {
|
||||
(m2 - (math_random(0, m) * 0.01)) + d1,
|
||||
(m2 - (math_random(0, m) * 0.01)) + d2
|
||||
(m2 - (math.random(0, m) * 0.01)) + d1,
|
||||
(m2 - (math.random(0, m) * 0.01)) + d2
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -97,7 +94,7 @@ local size_of_ore_raffle = #harvest_raffle_ores
|
||||
local function get_amount(data)
|
||||
local entity = data.entity
|
||||
local this = data.this
|
||||
local distance_to_center = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
|
||||
local distance_to_center = math.floor(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
|
||||
local type_modifier
|
||||
local amount
|
||||
local second_amount
|
||||
@ -123,7 +120,7 @@ local function get_amount(data)
|
||||
type_modifier = rock_yield[entity.name] or type_modifier
|
||||
|
||||
amount = base_amount + (distance_to_center * distance_modifier)
|
||||
second_amount = math_floor((second_base_amount + (distance_to_center * distance_modifier)) / 3)
|
||||
second_amount = math.floor((second_base_amount + (distance_to_center * distance_modifier)) / 3)
|
||||
if amount > maximum_amount then
|
||||
amount = maximum_amount
|
||||
end
|
||||
@ -131,9 +128,9 @@ local function get_amount(data)
|
||||
second_amount = maximum_amount
|
||||
end
|
||||
|
||||
local m = (70 + math_random(0, 60)) * 0.01
|
||||
local m = (70 + math.random(0, 60)) * 0.01
|
||||
|
||||
amount = math_floor(amount * type_modifier * m * 0.7)
|
||||
amount = math.floor(amount * type_modifier * m * 0.7)
|
||||
|
||||
return amount, second_amount
|
||||
end
|
||||
@ -147,7 +144,7 @@ function Public.entity_died_randomness(data)
|
||||
|
||||
local position = {x = entity.position.x, y = entity.position.y}
|
||||
|
||||
surface.spill_item_stack(position, {name = harvest, count = math_random(1, 5)}, true)
|
||||
surface.spill_item_stack(position, {name = harvest, count = math.random(1, 5)}, true)
|
||||
local particle = particles[harvest]
|
||||
create_particles(surface, particle, position, 64, {x = entity.position.x, y = entity.position.y})
|
||||
end
|
||||
@ -177,14 +174,14 @@ local function randomness(data)
|
||||
|
||||
if fullness >= fullness_limit then
|
||||
if player.character then
|
||||
player.character.health = player.character.health - math_random(50, 100)
|
||||
player.character.health = player.character.health - math.random(50, 100)
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
local messages = {
|
||||
'Ouch.. That hurt! Better be careful now.',
|
||||
'Just a fleshwound.',
|
||||
'Better keep those hands to yourself or you might loose them.'
|
||||
}
|
||||
player.print(messages[math_random(1, #messages)], {r = 0.75, g = 0.0, b = 0.0})
|
||||
player.print(messages[math.random(1, #messages)], {r = 0.75, g = 0.0, b = 0.0})
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
game.print(player.name .. ' should have emptied their pockets.', {r = 0.75, g = 0.0, b = 0.0})
|
||||
|
@ -1,244 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local Alert = require 'utils.alert'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local random = math.random
|
||||
|
||||
local shuffle = function(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local create_time_gui = function(player)
|
||||
local this = WPT.get()
|
||||
if player.gui.top['time_gui'] then
|
||||
player.gui.top['time_gui'].destroy()
|
||||
end
|
||||
local frame = player.gui.top.add({type = 'frame', name = 'time_gui'})
|
||||
frame.style.maximal_height = 38
|
||||
|
||||
local night_count = 0
|
||||
if this.night_count then
|
||||
night_count = this.night_count
|
||||
end
|
||||
|
||||
local label = frame.add({type = 'label', caption = 'Night: ' .. night_count})
|
||||
label.style.font_color = {r = 0.75, g = 0.0, b = 0.25}
|
||||
label.style.font = 'default-listbox'
|
||||
label.style.left_padding = 4
|
||||
label.style.right_padding = 4
|
||||
label.style.minimal_width = 50
|
||||
end
|
||||
|
||||
local set_daytime_modifiers = function()
|
||||
if game.map_settings.enemy_expansion.enabled == false then
|
||||
return
|
||||
end
|
||||
|
||||
game.map_settings.enemy_expansion.enabled = false
|
||||
end
|
||||
|
||||
local nightfall_messages = {
|
||||
'Night is falling.',
|
||||
'It is getting dark.',
|
||||
'They are becoming restless.'
|
||||
}
|
||||
|
||||
local set_nighttime_modifiers = function(surface)
|
||||
if game.map_settings.enemy_expansion.enabled == true then
|
||||
return
|
||||
end
|
||||
local this = WPT.get()
|
||||
|
||||
if not this.night_count then
|
||||
--this.splice_modifier = 1
|
||||
this.night_count = 1
|
||||
else
|
||||
--if game.forces["enemy"].evolution_factor > 0.25 then
|
||||
--this.splice_modifier = this.splice_modifier + 0.05
|
||||
--if this.splice_modifier > 4 then this.splice_modifier = 4 end
|
||||
--end
|
||||
this.night_count = this.night_count + 1
|
||||
end
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
create_time_gui(player)
|
||||
local message = nightfall_messages[random(1, #nightfall_messages)]
|
||||
Alert.alert_player_warning(player, 10, message, {r = 150, g = 0, b = 0})
|
||||
end
|
||||
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
|
||||
local max_expansion_distance = math.ceil(this.night_count / 3)
|
||||
if max_expansion_distance > 20 then
|
||||
max_expansion_distance = 20
|
||||
end
|
||||
game.map_settings.enemy_expansion.max_expansion_distance = max_expansion_distance
|
||||
|
||||
local settler_group_min_size = math.ceil(this.night_count / 6)
|
||||
if settler_group_min_size > 20 then
|
||||
settler_group_min_size = 20
|
||||
end
|
||||
game.map_settings.enemy_expansion.settler_group_min_size = settler_group_min_size
|
||||
|
||||
local settler_group_max_size = math.ceil(this.night_count / 3)
|
||||
if settler_group_max_size > 50 then
|
||||
settler_group_max_size = 50
|
||||
end
|
||||
game.map_settings.enemy_expansion.settler_group_max_size = settler_group_max_size
|
||||
|
||||
local min_expansion_cooldown = 54000 - this.night_count * 540
|
||||
if min_expansion_cooldown < 3600 then
|
||||
min_expansion_cooldown = 3600
|
||||
end
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = min_expansion_cooldown
|
||||
|
||||
local max_expansion_cooldown = 108000 - this.night_count * 1080
|
||||
if max_expansion_cooldown < 3600 then
|
||||
max_expansion_cooldown = 3600
|
||||
end
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = max_expansion_cooldown
|
||||
end
|
||||
|
||||
local get_spawner = function(surface)
|
||||
local this = WPT.get()
|
||||
local spawners = {}
|
||||
for r = 512, 51200, 512 do
|
||||
spawners = surface.find_entities_filtered({type = 'unit-spawner', area = {{0 - r, 0 - r}, {0 + r, 0 + r}}})
|
||||
if #spawners > 16 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not spawners[1] then
|
||||
return false
|
||||
end
|
||||
spawners = shuffle(spawners)
|
||||
|
||||
if not this.last_spawners then
|
||||
this.last_spawners = {{x = spawners[1].position.x, y = spawners[1].position.y}}
|
||||
return spawners[1]
|
||||
end
|
||||
|
||||
for i = 1, #spawners, 1 do
|
||||
local spawner_valid = true
|
||||
for i2 = #this.last_spawners, #this.last_spawners - 4, -1 do
|
||||
if i2 < 1 then
|
||||
break
|
||||
end
|
||||
local distance =
|
||||
math.sqrt(
|
||||
(spawners[i].position.x - this.last_spawners[i2].x) ^ 2 +
|
||||
(spawners[i].position.y - this.last_spawners[i2].y) ^ 2
|
||||
)
|
||||
if distance < 200 then
|
||||
spawner_valid = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if spawner_valid then
|
||||
this.last_spawners[#this.last_spawners + 1] = {x = spawners[i].position.x, y = spawners[i].position.y}
|
||||
if #this.last_spawners > 8 then
|
||||
this.last_spawners[#this.last_spawners - 8] = nil
|
||||
end
|
||||
return spawners[i]
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local send_attack_group = function(surface)
|
||||
local spawner = get_spawner(surface)
|
||||
if not spawner then
|
||||
game.print('it failed')
|
||||
return false
|
||||
end
|
||||
local this = WPT.get()
|
||||
|
||||
local biters = surface.find_enemy_units(spawner.position, 128, 'player')
|
||||
if not biters[1] then
|
||||
game.print('no biters')
|
||||
return
|
||||
end
|
||||
|
||||
biters = shuffle(biters)
|
||||
|
||||
local pos = surface.find_non_colliding_position('rocket-silo', spawner.position, 64, 1)
|
||||
if not pos then
|
||||
game.print('no pos')
|
||||
return
|
||||
end
|
||||
|
||||
local unit_group = surface.create_unit_group({position = pos, force = 'enemy'})
|
||||
|
||||
local group_size = 6 + (this.night_count * 6)
|
||||
if group_size > 200 then
|
||||
group_size = 200
|
||||
end
|
||||
|
||||
for i = 1, group_size, 1 do
|
||||
if not biters[i] then
|
||||
break
|
||||
end
|
||||
unit_group.add_member(biters[i])
|
||||
end
|
||||
|
||||
if this.locomotive.valid then
|
||||
unit_group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = {
|
||||
{
|
||||
type = defines.command.attack_area,
|
||||
destination = {x = 0, y = 0},
|
||||
radius = 48,
|
||||
distraction = defines.distraction.by_anything
|
||||
},
|
||||
{
|
||||
type = defines.command.attack,
|
||||
target = this.locomotive,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
else
|
||||
unit_group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = {
|
||||
{
|
||||
type = defines.command.attack_area,
|
||||
destination = {x = 0, y = 0},
|
||||
radius = 48,
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local on_tick = function()
|
||||
if game.tick % 600 ~= 0 then
|
||||
return
|
||||
end
|
||||
local this = WPT.get()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if surface.daytime > 0.25 and surface.daytime < 0.75 then
|
||||
set_nighttime_modifiers(surface)
|
||||
if surface.daytime < 0.65 then
|
||||
send_attack_group(surface)
|
||||
end
|
||||
else
|
||||
set_daytime_modifiers()
|
||||
end
|
||||
end
|
||||
|
||||
Event.on_nth_tick(10, on_tick)
|
283
maps/mountain_fortress_v3/resource_generator.lua
Normal file
283
maps/mountain_fortress_v3/resource_generator.lua
Normal file
@ -0,0 +1,283 @@
|
||||
local Functions = require 'maps.mountain_fortress_v3.functions'
|
||||
|
||||
local types = {
|
||||
'assembling-machine',
|
||||
'furnace'
|
||||
}
|
||||
|
||||
local science_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'automation-science-pack',
|
||||
output = {item = 'automation-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 5 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'logistic-science-pack',
|
||||
output = {item = 'logistic-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 15 / 60 / 512}
|
||||
},
|
||||
weight = 2
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'military-science-pack',
|
||||
output = {item = 'military-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'chemical-science-pack',
|
||||
output = {item = 'chemical-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 33 / 60 / 512}
|
||||
},
|
||||
weight = 0.20
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'production-science-pack',
|
||||
output = {item = 'production-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 45 / 60 / 512}
|
||||
},
|
||||
weight = 0.10
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'utility-science-pack',
|
||||
output = {item = 'utility-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 55 / 60 / 512}
|
||||
},
|
||||
weight = 0.010
|
||||
}
|
||||
}
|
||||
|
||||
local ammo_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'piercing-rounds-magazine',
|
||||
output = {item = 'piercing-rounds-magazine', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 10 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'firearm-magazine',
|
||||
output = {item = 'firearm-magazine', min_rate = 1 / 4 / 60, distance_factor = 1 / 4 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'shotgun-shell',
|
||||
output = {item = 'shotgun-shell', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'uranium-rounds-magazine',
|
||||
output = {item = 'uranium-rounds-magazine', min_rate = 0.1 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
}
|
||||
}
|
||||
|
||||
local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'stone-wall',
|
||||
output = {item = 'stone-wall', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'iron-gear-wheel',
|
||||
output = {item = 'iron-gear-wheel', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
}
|
||||
}
|
||||
|
||||
local furnace_loot = {
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'iron-plate',
|
||||
output = {item = 'iron-plate', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'copper-plate',
|
||||
output = {item = 'copper-plate', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'steel-plate',
|
||||
output = {item = 'steel-plate', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
}
|
||||
}
|
||||
|
||||
local science_weights = Functions.prepare_weighted_loot(science_loot)
|
||||
local building_weights = Functions.prepare_weighted_loot(ammo_loot)
|
||||
local resource_weights = Functions.prepare_weighted_loot(resource_loot)
|
||||
local furnace_weights = Functions.prepare_weighted_loot(furnace_loot)
|
||||
|
||||
local science_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
loot = science_loot,
|
||||
weights = science_weights
|
||||
}
|
||||
}
|
||||
|
||||
local building_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
loot = ammo_loot,
|
||||
weights = building_weights
|
||||
}
|
||||
}
|
||||
|
||||
local resource_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
loot = resource_loot,
|
||||
weights = resource_weights
|
||||
}
|
||||
}
|
||||
|
||||
local furnace_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
loot = furnace_loot,
|
||||
weights = furnace_weights
|
||||
}
|
||||
}
|
||||
|
||||
local science_list = {
|
||||
[1] = {name = 'assembling-machine-1', callback = science_callback},
|
||||
[2] = {name = 'assembling-machine-2', callback = science_callback},
|
||||
[3] = {name = 'assembling-machine-3', callback = science_callback}
|
||||
}
|
||||
|
||||
local ammo_list = {
|
||||
[1] = {name = 'assembling-machine-1', callback = building_callback},
|
||||
[2] = {name = 'assembling-machine-2', callback = building_callback},
|
||||
[3] = {name = 'assembling-machine-3', callback = building_callback}
|
||||
}
|
||||
|
||||
local resource_list = {
|
||||
[1] = {name = 'assembling-machine-1', callback = resource_callback},
|
||||
[2] = {name = 'assembling-machine-2', callback = resource_callback},
|
||||
[3] = {name = 'assembling-machine-3', callback = resource_callback}
|
||||
}
|
||||
|
||||
local furnace_list = {
|
||||
[1] = {name = 'stone-furnace', callback = furnace_callback},
|
||||
[2] = {name = 'steel-furnace', callback = furnace_callback},
|
||||
[3] = {name = 'electric-furnace', callback = furnace_callback}
|
||||
}
|
||||
|
||||
local function spawn_science_buildings(entities, p, probability)
|
||||
entities[#entities + 1] = {
|
||||
name = science_list[probability].name,
|
||||
position = p,
|
||||
force = 'player',
|
||||
callback = science_list[probability].callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_ammo_building(entities, p, probability)
|
||||
entities[#entities + 1] = {
|
||||
name = ammo_list[probability].name,
|
||||
position = p,
|
||||
force = 'player',
|
||||
callback = ammo_list[probability].callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_resource_building(entities, p, probability)
|
||||
entities[#entities + 1] = {
|
||||
name = resource_list[probability].name,
|
||||
position = p,
|
||||
force = 'player',
|
||||
callback = resource_list[probability].callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_furnace_building(entities, p, probability)
|
||||
entities[#entities + 1] = {
|
||||
name = furnace_list[probability].name,
|
||||
position = p,
|
||||
force = 'player',
|
||||
callback = furnace_list[probability].callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local buildings = {
|
||||
[1] = spawn_ammo_building,
|
||||
[2] = spawn_resource_building,
|
||||
[3] = spawn_furnace_building,
|
||||
[4] = spawn_science_buildings
|
||||
}
|
||||
|
||||
local function spawn_random_buildings(entities, p, depth)
|
||||
local randomizer = math.random(1, #buildings)
|
||||
local low = math.random(1, 2)
|
||||
local medium = math.random(2, 3)
|
||||
local high = 3
|
||||
|
||||
if math.abs(p.y) < depth * 1.5 then
|
||||
if math.random(1, 16) == 1 then
|
||||
return buildings[randomizer](entities, p, low)
|
||||
else
|
||||
return buildings[randomizer](entities, p, low)
|
||||
end
|
||||
elseif math.abs(p.y) < depth * 2.5 then
|
||||
if math.random(1, 8) == 1 then
|
||||
return buildings[randomizer](entities, p, medium)
|
||||
else
|
||||
return buildings[randomizer](entities, p, medium)
|
||||
end
|
||||
elseif math.abs(p.y) < depth * 3.5 then
|
||||
if math.random(1, 4) == 1 then
|
||||
return buildings[randomizer](entities, p, high)
|
||||
else
|
||||
return buildings[randomizer](entities, p, medium)
|
||||
end
|
||||
elseif math.abs(p.y) < depth * 4.5 then
|
||||
if math.random(1, 4) == 1 then
|
||||
return buildings[randomizer](entities, p, high)
|
||||
else
|
||||
return buildings[randomizer](entities, p, high)
|
||||
end
|
||||
elseif math.abs(p.y) < depth * 5.5 then
|
||||
if math.random(1, 4) == 1 then
|
||||
return buildings[randomizer](entities, p, high)
|
||||
elseif math.random(1, 2) == 1 then
|
||||
return buildings[randomizer](entities, p, high)
|
||||
elseif math.random(1, 8) == 1 then
|
||||
return buildings[randomizer](entities, p, high)
|
||||
end
|
||||
end
|
||||
if math.abs(p.y) > depth * 5.5 then
|
||||
if math.random(1, 32) == 1 then
|
||||
return buildings[randomizer](entities, p, medium)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return spawn_random_buildings
|
@ -9,10 +9,6 @@ local WD = require 'modules.wave_defense.table'
|
||||
|
||||
local points_per_level = 5
|
||||
|
||||
local math_floor = math.floor
|
||||
local math_random = math.random
|
||||
local math_sqrt = math.sqrt
|
||||
local math_round = math.round
|
||||
local nth_tick = 18001
|
||||
local visuals_delay = 1800
|
||||
local level_up_floating_text_color = {0, 205, 0}
|
||||
@ -170,11 +166,11 @@ local function level_up_effects(player)
|
||||
local b = 0.75
|
||||
for a = 1, 5, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math_random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math_random(0, b * 20) * 0.1)
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
player.surface.create_entity(
|
||||
{name = 'flying-text', position = p, text = '✚', color = {255, math_random(0, 100), 0}}
|
||||
{name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}
|
||||
)
|
||||
end
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40}
|
||||
@ -188,11 +184,11 @@ local function xp_effects(player)
|
||||
local b = 0.75
|
||||
for a = 1, 5, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math_random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math_random(0, b * 20) * 0.1)
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
player.surface.create_entity(
|
||||
{name = 'flying-text', position = p, text = '✚', color = {255, math_random(0, 100), 0}}
|
||||
{name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}
|
||||
)
|
||||
end
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40}
|
||||
@ -512,18 +508,18 @@ local function draw_gui(player, forced)
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'MINING\nSPEED', w1)
|
||||
value =
|
||||
math_round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) ..
|
||||
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'SLOT\nBONUS', w1)
|
||||
value = '+ ' .. math_round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
|
||||
value = '+ ' .. math.round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'MELEE\nDAMAGE', w1)
|
||||
value = math_round(100 * (1 + get_melee_modifier(player))) .. '%'
|
||||
value = math.round(100 * (1 + get_melee_modifier(player))) .. '%'
|
||||
e = add_gui_stat(tt, value, w2)
|
||||
e.tooltip =
|
||||
'Life on-hit: ' .. get_life_on_hit(player) .. '\nOne punch chance: ' .. get_one_punch_chance(player) .. '%'
|
||||
@ -560,14 +556,14 @@ local function draw_gui(player, forced)
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'CRAFTING\nSPEED', w1)
|
||||
value =
|
||||
math_round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) ..
|
||||
math.round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'RUNNING\nSPEED', w1)
|
||||
value =
|
||||
math_round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) ..
|
||||
math.round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
@ -580,7 +576,7 @@ local function draw_gui(player, forced)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'HEALTH\nBONUS', w1)
|
||||
value = '+ ' .. math_round((player.force.character_health_bonus + player.character_health_bonus))
|
||||
value = '+ ' .. math.round((player.force.character_health_bonus + player.character_health_bonus))
|
||||
e = add_gui_stat(tt, value, w2)
|
||||
e.tooltip = 'Health regen bonus: ' .. get_heal_modifier(player)
|
||||
|
||||
@ -677,9 +673,9 @@ local function global_pool(players, count)
|
||||
return
|
||||
end
|
||||
|
||||
local pool = math_floor(rpg_extra.global_pool)
|
||||
local pool = math.floor(rpg_extra.global_pool)
|
||||
|
||||
local random_amount = math_random(5000, 10000)
|
||||
local random_amount = math.random(5000, 10000)
|
||||
|
||||
if pool <= random_amount then
|
||||
return
|
||||
@ -879,8 +875,7 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
if rpg_xp_yield['big-biter'] <= 16 then
|
||||
local wd = WD.get_table()
|
||||
local wave_number = wd.wave_number
|
||||
local wave_number = WD.get_wave()
|
||||
if wave_number >= 1000 then
|
||||
rpg_xp_yield['big-biter'] = 16
|
||||
rpg_xp_yield['behemoth-biter'] = 64
|
||||
@ -1101,7 +1096,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
--Cause a one punch.
|
||||
if math_random(0, 999) < get_one_punch_chance(event.cause.player) * 10 then
|
||||
if math.random(0, 999) < get_one_punch_chance(event.cause.player) * 10 then
|
||||
one_punch(event.cause, event.entity, damage)
|
||||
if event.entity.valid then
|
||||
event.entity.die(event.entity.force.name, event.cause)
|
||||
@ -1110,8 +1105,8 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
--Floating messages and particle effects.
|
||||
if math_random(1, 7) == 1 then
|
||||
damage = damage * math_random(250, 350) * 0.01
|
||||
if math.random(1, 7) == 1 then
|
||||
damage = damage * math.random(250, 350) * 0.01
|
||||
event.cause.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
@ -1122,7 +1117,7 @@ local function on_entity_damaged(event)
|
||||
)
|
||||
event.cause.surface.create_entity({name = 'blood-explosion-huge', position = event.entity.position})
|
||||
else
|
||||
damage = damage * math_random(100, 125) * 0.01
|
||||
damage = damage * math.random(100, 125) * 0.01
|
||||
event.cause.player.create_local_flying_text(
|
||||
{
|
||||
text = math.floor(damage),
|
||||
@ -1161,7 +1156,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
if math_random(1, 4) ~= 1 then
|
||||
if math.random(1, 4) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
@ -1213,7 +1208,7 @@ local function on_player_changed_position(event)
|
||||
return
|
||||
end
|
||||
|
||||
if math_random(1, 64) ~= 1 then
|
||||
if math.random(1, 64) ~= 1 then
|
||||
return
|
||||
end
|
||||
if not player.character then
|
||||
@ -1253,7 +1248,7 @@ local function on_pre_player_mined_item(event)
|
||||
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
||||
rpg_t[player.index].last_mined_entity_position.y = entity.position.y
|
||||
|
||||
local distance_multiplier = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)) * 0.0005 + 1
|
||||
local distance_multiplier = math.floor(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)) * 0.0005 + 1
|
||||
|
||||
local xp_amount
|
||||
if entity.type == 'resource' then
|
||||
@ -1278,7 +1273,7 @@ local function on_player_crafted_item(event)
|
||||
return
|
||||
end
|
||||
|
||||
local amount = 0.30 * math_random(1, 2)
|
||||
local amount = 0.30 * math.random(1, 2)
|
||||
|
||||
Public.gain_xp(player, event.recipe.energy * amount)
|
||||
end
|
||||
@ -1436,7 +1431,7 @@ function Public.gain_xp(player, amount, added_to_pool, text)
|
||||
Public.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
local fee = add_to_global_pool(amount)
|
||||
Public.debug_log('RPG - ' .. player.name .. ' got fee: ' .. fee)
|
||||
amount = math_round(amount, 3) - fee
|
||||
amount = math.round(amount, 3) - fee
|
||||
Public.debug_log('RPG - ' .. player.name .. ' got after fee: ' .. amount)
|
||||
else
|
||||
Public.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
|
||||
@ -1464,9 +1459,9 @@ function Public.gain_xp(player, amount, added_to_pool, text)
|
||||
end
|
||||
|
||||
if text then
|
||||
text_to_draw = '+' .. math_floor(amount) .. ' xp'
|
||||
text_to_draw = '+' .. math.floor(amount) .. ' xp'
|
||||
else
|
||||
text_to_draw = '+' .. math_floor(rpg_t[player.index].xp_since_last_floaty_text) .. ' xp'
|
||||
text_to_draw = '+' .. math.floor(rpg_t[player.index].xp_since_last_floaty_text) .. ' xp'
|
||||
end
|
||||
|
||||
player.create_local_flying_text {
|
||||
|
@ -87,6 +87,7 @@ function Public.reset_table()
|
||||
y = 0
|
||||
}
|
||||
this.traps = {}
|
||||
this.much_time = true
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@ local kaboom_weights = {
|
||||
|
||||
local kabooms = {}
|
||||
for _, t in pairs(kaboom_weights) do
|
||||
for x = 1, t.chance, 1 do
|
||||
table.insert(kabooms, t.name)
|
||||
for _ = 1, t.chance, 1 do
|
||||
kabooms[#kabooms + 1] = t.name
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
local Event = require 'utils.event'
|
||||
local random = math.random
|
||||
|
||||
local function void_replace_tiles_in_chunk(event)
|
||||
local surface = event.surface
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
|
||||
if string.sub(surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
local area = event.area
|
||||
local top_x = area.left_top.x
|
||||
local top_y = area.left_top.y
|
||||
local bottom_x = area.right_bottom.x
|
||||
local bottom_y = area.right_bottom.y
|
||||
local tiles = {}
|
||||
if top_x > -33 and bottom_x < 1 and top_y > -33 and bottom_y < 1 then
|
||||
return
|
||||
end
|
||||
for i = top_y, bottom_y do
|
||||
for j = top_x, bottom_x do
|
||||
if (random(100) < global.void.tile_chance) then
|
||||
if (random(100) > global.void.void_chance) then
|
||||
table.insert(tiles, {name = 'water', position = {j, i}})
|
||||
else
|
||||
table.insert(tiles, {name = 'out-of-map', position = {j, i}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_chunk_generated,
|
||||
function(event)
|
||||
void_replace_tiles_in_chunk(event)
|
||||
end
|
||||
)
|
||||
|
||||
Event.on_init(
|
||||
function()
|
||||
global.void = global.void or {}
|
||||
global.void.seed = 1
|
||||
global.void.tile_chance = 7
|
||||
global.void.void_chance = 90
|
||||
global.void_module.seed = random(1, 999999)
|
||||
end
|
||||
)
|
@ -9,6 +9,7 @@ local noises = {
|
||||
},
|
||||
['bb_ore'] = {{modifier = 0.0042, weight = 1}, {modifier = 0.031, weight = 0.08}, {modifier = 0.1, weight = 0.025}},
|
||||
['cave_ponds'] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}},
|
||||
['smol_areas'] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.02}, {modifier = 0.1, weight = 0.03}},
|
||||
['cave_worms'] = {{modifier = 0.001, weight = 1}, {modifier = 0.1, weight = 0.06}},
|
||||
['cave_rivers'] = {
|
||||
{modifier = 0.005, weight = 1},
|
||||
|
Loading…
Reference in New Issue
Block a user