1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-01 13:08:05 +02:00

Mtn v3 - fix buff restore

This commit is contained in:
Gerkiz 2023-09-05 01:08:17 +02:00
parent 1c84da8f60
commit 854bad49c5
3 changed files with 100 additions and 227 deletions

View File

@ -28,7 +28,6 @@ local this = {
magic_crafters = {index = 1},
magic_fluid_crafters = {index = 1},
art_table = {index = 1},
surface_cleared = false,
starting_items = {
['pistol'] = 1,
['firearm-magazine'] = 16,
@ -296,19 +295,6 @@ local artillery_target_callback =
end
)
local function difficulty_and_adjust_prices()
local fixed_prices = Public.get('marked_fixed_prices')
local difficulty_index = Difficulty.get('index')
for index, price in pairs(fixed_prices) do
if difficulty_index == 2 then
fixed_prices[index] = price * 1.5
elseif difficulty_index == 3 then
fixed_prices[index] = price * 2
end
end
end
local function do_beams_away()
local wave_number = WD.get_wave()
local orbital_strikes = Public.get('orbital_strikes')
@ -1127,149 +1113,25 @@ function Public.boost_difficulty()
return
end
local breached_wall = Public.get('breached_wall')
local difficulty = Difficulty.get()
if not difficulty then
return
end
local index = difficulty.index
local name = difficulty.name
if game.tick < difficulty.closing_timeout and breached_wall <= 1 then
return
end
local message = ({'main.diff_set', name})
local data = {
position = Public.get('locomotive').position
}
Alert.alert_all_players_location(data, message)
local force = game.forces.player
local active_surface_index = Public.get('active_surface_index')
local surface = game.get_surface(active_surface_index)
if index == 1 then
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
force.character_running_speed_modifier = 0.15
force.manual_crafting_speed_modifier = 0.15
Public.set('coin_amount', 1)
Public.set('upgrades').flame_turret.limit = 12
Public.set('upgrades').landmine.limit = 50
Public.set('locomotive_health', 10000)
Public.set('locomotive_max_health', 10000)
Public.set('bonus_xp_on_join', 500)
WD.set('next_wave', game.tick + 3600 * 15)
Public.set('spidertron_unlocked_at_zone', 10)
WD.set_normal_unit_current_health(1.2)
WD.set_unit_health_increment_per_wave(0.35)
WD.set_boss_unit_current_health(2)
WD.set_boss_health_increment_per_wave(1.5)
WD.set('death_mode', false)
Public.set('difficulty_set', true)
elseif index == 2 then
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
force.character_running_speed_modifier = 0.1
force.manual_crafting_speed_modifier = 0.1
Public.set('coin_amount', 2)
Public.set('upgrades').flame_turret.limit = 10
Public.set('upgrades').landmine.limit = 50
Public.set('locomotive_health', 7000)
Public.set('locomotive_max_health', 7000)
Public.set('bonus_xp_on_join', 300)
WD.set('next_wave', game.tick + 3600 * 8)
Public.set('spidertron_unlocked_at_zone', 8)
WD.set_normal_unit_current_health(1.4)
WD.set_unit_health_increment_per_wave(0.55)
WD.set_boss_unit_current_health(3)
WD.set_boss_health_increment_per_wave(3)
WD.set('death_mode', false)
Public.set('difficulty_set', true)
local damage_warning = ({'main.damage_mode_warning'})
Alert.alert_all_players_location(data, damage_warning)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
local upgrades = Public.get('upgrades')
if Public.get('circle') then
rendering.destroy(Public.get('circle'))
end
local locomotive = Public.get('locomotive')
Public.set(
'circle',
rendering.draw_circle {
surface = active_surface_index,
target = locomotive,
color = locomotive.color,
filled = false,
radius = upgrades.locomotive_aura_radius,
only_in_alt_mode = false
}
)
difficulty_and_adjust_prices()
elseif index == 3 then
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
Public.set('coin_amount', 4)
Public.set('upgrades').flame_turret.limit = 3
Public.set('upgrades').landmine.limit = 10
Public.set('locomotive_health', 5000)
Public.set('locomotive_max_health', 5000)
Public.set('bonus_xp_on_join', 50)
WD.set('next_wave', game.tick + 3600 * 5)
Public.set('spidertron_unlocked_at_zone', 6)
WD.set_normal_unit_current_health(1.6)
WD.set_unit_health_increment_per_wave(0.7)
WD.set_boss_unit_current_health(4)
WD.set_boss_health_increment_per_wave(6)
WD.set('death_mode', true)
Public.set('difficulty_set', true)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
local upgrades = Public.get('upgrades')
upgrades.locomotive_aura_radius = upgrades.locomotive_aura_radius + 20
upgrades.aura_upgrades_max = upgrades.aura_upgrades_max - 4
if Public.get('circle') then
rendering.destroy(Public.get('circle'))
end
local locomotive = Public.get('locomotive')
Public.set(
'circle',
rendering.draw_circle {
surface = active_surface_index,
target = locomotive,
color = locomotive.color,
filled = false,
radius = upgrades.locomotive_aura_radius,
only_in_alt_mode = false
}
)
local aura_upgrade = ({'main.aura_upgrade_warning'})
Alert.alert_all_players_location(data, aura_upgrade)
local death_warning = ({'main.death_mode_warning'})
Alert.alert_all_players_location(data, death_warning)
difficulty_and_adjust_prices()
end
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
force.character_running_speed_modifier = 0.15
force.manual_crafting_speed_modifier = 0.15
Public.set('coin_amount', 1)
Public.set('upgrades').flame_turret.limit = 12
Public.set('upgrades').landmine.limit = 50
Public.set('locomotive_health', 10000)
Public.set('locomotive_max_health', 10000)
Public.set('bonus_xp_on_join', 500)
WD.set('next_wave', game.tick + 3600 * 15)
Public.set('spidertron_unlocked_at_zone', 10)
WD.set_normal_unit_current_health(1.2)
WD.set_unit_health_increment_per_wave(0.35)
WD.set_boss_unit_current_health(2)
WD.set_boss_health_increment_per_wave(1.5)
WD.set('death_mode', false)
Public.set('difficulty_set', true)
end
function Public.set_spawn_position()
@ -1764,6 +1626,13 @@ function Public.reset_func_table()
this.refill_turrets = {index = 1}
this.magic_crafters = {index = 1}
this.magic_fluid_crafters = {index = 1}
this.starting_items = {
['pistol'] = 1,
['firearm-magazine'] = 16,
['rail'] = 16,
['wood'] = 16,
['explosives'] = 32
}
end
local on_player_joined_game = Public.on_player_joined_game

View File

@ -265,6 +265,7 @@ function Public.reset_map()
Public.set_difficulty()
Public.disable_creative()
Public.boost_difficulty()
if not surface.is_chunk_generated({x = -20, y = 22}) then
surface.request_to_generate_chunks({x = -20, y = 22}, 0.1)
@ -286,6 +287,7 @@ function Public.reset_map()
Public.stateful.enable(true)
Public.stateful.create()
Public.stateful.reset_stateful()
Public.stateful.apply_startup_settings()
if _DEV_MODE then
Collapse.disable_collapse(true)
@ -483,7 +485,6 @@ local on_tick = function()
if tick % 250 == 0 then
compare_collapse_and_train()
Public.set_spawn_position()
Public.boost_difficulty()
end
if tick % 1000 == 0 then

View File

@ -433,90 +433,92 @@ local function get_random_objectives()
}
end
local apply_settings_token =
Token.register(
function(data)
local settings = data and data.value or nil
local new_value = Server.get_current_date()
if not settings then
settings = {
rounds_survived = 0
}
if new_value then
local function apply_startup_settings(settings)
local new_value = Server.get_current_date()
if not new_value then
return
end
settings = settings or {}
local old_value = this.current_date
if old_value then
old_value = tonumber(old_value)
local time_to_reset = (new_value - old_value)
if time_to_reset then
if time_to_reset > this.reset_after then
settings.current_date = tonumber(new_value)
else
settings.current_date = 0
settings.test_mode = false
settings.rounds_survived = 0
settings.buffs = {}
this.buffs = {}
this.rounds_survived = 0
this.current_date = tonumber(new_value)
local message = ({'stateful.reset'})
local message_discord = ({'stateful.reset_discord'})
game.print(message)
Server.to_discord_embed(message_discord, true)
Server.set_data(dataset, dataset_key, settings)
end
Server.set_data(dataset, dataset_key, settings)
return
end
end
if not settings.current_date then
if new_value then
settings.current_date = tonumber(new_value)
else
settings.current_date = 0
end
Server.set_data(dataset, dataset_key, settings)
end
local starting_items = Public.get_func('starting_items')
local old_value = settings.current_date
if old_value then
old_value = tonumber(old_value)
local time_to_reset = (new_value - old_value)
if time_to_reset then
if time_to_reset > this.reset_after then
if new_value then
settings.current_date = tonumber(new_value)
else
settings.current_date = 0
end
settings.test_mode = false
settings.rounds_survived = 0
settings.buffs = {}
local message = ({'stateful.reset'})
local message_discord = ({'stateful.reset_discord'})
game.print(message)
Server.to_discord_embed(message_discord)
Server.set_data(dataset, dataset_key, settings)
if this.buffs and next(this.buffs) then
local force = game.forces.player
for _, buff in pairs(this.buffs) do
if buff then
if buff.modifier == 'force' then
force[buff.name] = force[buff.name] + buff.state
end
end
end
local rounds_survived = settings.rounds_survived
Public.increase_enemy_damage_and_health()
local starting_items = Public.get_func('starting_items')
if settings.buffs and next(settings.buffs) then
local force = game.forces.player
for _, buff in pairs(settings.buffs) do
if buff then
if buff.modifier == 'force' then
force[buff.name] = force[buff.name] + buff.state
end
if buff.modifier == 'rpg' then
local rpg_extra = RPG.get('rpg_extra')
rpg_extra.difficulty = buff.state
end
if buff.modifier == 'start' then
for _, item in pairs(buff.items) do
if item then
starting_items[item.name] = item.count
end
if buff.modifier == 'rpg' then
local rpg_extra = RPG.get('rpg_extra')
rpg_extra.difficulty = buff.state
end
if buff.modifier == 'start' then
for _, item in pairs(buff.items) do
if item then
starting_items[item.name] = item.count
end
end
end
end
end
end
return settings
end
local apply_settings_token =
Token.register(
function(data)
local settings = data and data.value or nil
local new_value = Server.get_current_date()
if not new_value then
return
end
if not settings then
settings = {
rounds_survived = 0,
current_date = tonumber(new_value)
}
Server.set_data(dataset, dataset_key, settings)
return
end
if not settings.current_date then
settings.current_date = tonumber(new_value)
Server.set_data(dataset, dataset_key, settings)
end
this.current_date = settings.current_date
this.buffs = settings.buffs
this.rounds_survived = rounds_survived
settings = apply_startup_settings(settings)
Public.increase_enemy_damage_and_health()
this.rounds_survived = settings.rounds_survived
this.objectives_completed = {}
this.objectives_completed_count = 0
this.final_battle = false
@ -811,6 +813,7 @@ Server.on_data_set_changed(
Public.get_item_produced_count = get_item_produced_count
Public.get_entity_mined_count = get_entity_mined_count
Public.get_killed_enemies_count = get_killed_enemies_count
Public.apply_startup_settings = apply_startup_settings
Public.stateful_spawn_points = stateful_spawn_points
Public.sizeof_stateful_spawn_points = #stateful_spawn_points