1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

Merge branch 'develop' into develop

This commit is contained in:
Gerkiz 2021-07-14 22:12:09 +02:00 committed by GitHub
commit f40c8ed9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 10 deletions

View File

@ -166,6 +166,9 @@ local function check_health()
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local carriages = WPT.get('carriages')
if locomotive_health <= 0 then
WPT.set('locomotive_health', 0)
end
local m = locomotive_health / locomotive_max_health
if carriages then
for i = 1, #carriages do
@ -260,6 +263,13 @@ local function set_train_final_health(final_damage_amount, repair)
end
end
if locomotive_health <= 0 or locomotive.health <= 5 then
locomotive.destructible = false
locomotive.health = 1
WPT.set('game_lost', true)
Public.loco_died()
end
if locomotive_health <= 0 then
check_health_final_damage(final_damage_amount)
return
@ -271,11 +281,6 @@ local function set_train_final_health(final_damage_amount, repair)
end
locomotive_health = WPT.get('locomotive_health')
if locomotive_health <= 0 then
WPT.set('game_lost', true)
Public.loco_died()
end
check_health()
local health_text = WPT.get('health_text')
@ -300,7 +305,7 @@ local function protect_entities(event)
if entity.force.index ~= 1 then
return
end --Player Force
end
local function is_protected(e)
local map_name = 'mountain_fortress_v3'
@ -1148,7 +1153,6 @@ local function show_mvps(player)
RPG_Progression.save_all_players()
end
if server_name then
local name = Server.get_server_name()
local date = Server.get_start_time()
game.server_save('Final_' .. name .. '_' .. tostring(date))
@ -1283,7 +1287,6 @@ function Public.loco_died(invalid_locomotive)
end
end
local function on_built_entity(event)
local entity = event.created_entity
if not entity.valid then

View File

@ -157,10 +157,11 @@ function Public.reset_map()
RPG.disable_cooldowns_on_spells()
RPG.enable_explosive_bullets_globally(true)
RPG.enable_explosive_bullets(false)
RPG_Progression.toggle_module(false)
RPG_Progression.set_dataset('mtn_v3_rpg_prestige')
if WPT.get('prestige_system_enabled') then
RPG_Progression.restore_xp_on_reset()
RPG_Progression.set_dataset('mtn_v3_rpg_prestige')
end
Group.reset_groups()

View File

@ -15,6 +15,7 @@ local set_timeout_in_ticks = Task.set_timeout_in_ticks
local this = {
settings = {
enabled = false,
reset_after = 7, -- 7 days
required_level_to_progress = 99, -- higher than 99 to be able to save
limit = 39600, -- level 100
@ -165,6 +166,10 @@ local try_upload_data_token =
--- Tries to update amount of resets, if the threshold is reached nil the bonuses.
function Public.try_dl_resets()
if not this.settings.enabled then
return
end
local secs = Server.get_current_time()
if secs == nil then
return
@ -176,6 +181,10 @@ end
--- Tries to get data from the web-panel and updates the local table with values.
-- @param data_set player token
function Public.try_dl_data(key)
if not this.settings.enabled then
return
end
key = tostring(key)
local secs = Server.get_current_time()
if secs == nil then
@ -188,6 +197,10 @@ end
--- Tries to get data from the web-panel and updates the local table with values.
-- @param data_set player token
function Public.try_ul_data(key)
if not this.settings.enabled then
return
end
key = tostring(key)
local secs = Server.get_current_time()
if secs == nil then
@ -225,7 +238,7 @@ end
--- Returns the table of settings
-- @return <table>
function Public.get_settings_table()
return settings
return this.settings
end
--- Clears a given player from the session tables.
@ -246,6 +259,10 @@ end
Event.add(
defines.events.on_player_joined_game,
function(event)
if not this.settings.enabled then
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
@ -258,6 +275,10 @@ Event.add(
Event.add(
defines.events.on_player_left_game,
function(event)
if not this.settings.enabled then
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
@ -280,6 +301,10 @@ local nth_tick_token =
--- Saves all eligible players to the web-panel
function Public.save_all_players()
if not this.settings.enabled then
return
end
local players = game.connected_players
for i = 1, #players do
local player = players[i]
@ -295,6 +320,10 @@ end
--- Restores XP to players that have values in the web-panel
function Public.restore_xp_on_reset()
if not this.settings.enabled then
return
end
local stash = this.data
for key, value in pairs(stash) do
local player = game.get_player(key)
@ -312,6 +341,11 @@ function Public.set_dataset(dataset)
end
end
--- Toggles the module
function Public.toggle_module(state)
this.settings.enabled = state or false
end
Event.add(
Server.events.on_server_started,
function()