1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

Push fix for jail handler and bug fixes for Mtn

This commit is contained in:
Gerkiz 2024-11-19 13:54:09 +01:00
parent d2fdba2988
commit 80a99e4f17
6 changed files with 49 additions and 5 deletions

View File

@ -1370,6 +1370,40 @@ local function on_player_cursor_stack_changed(event)
end
end
local function on_chart_tag_added(event)
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
local tag = event.tag
if not tag then return end
local force = event.force
if not force then return end
local charts = Public.get('charts')
if not charts then return end
if not charts.tags then return end
charts.tags[#charts.tags + 1] = tag
end
function Public.clear_all_chart_tags()
local charts = Public.get('charts')
if not charts then return end
if not charts.tags then return end
for i = 1, #charts.tags do
local tag = charts.tags[i]
if tag and tag.valid then
tag.destroy()
end
end
charts.tags = {}
end
function Public.set_xp_yield()
RPG.set_rpg_xp_yield({
['biter-spawner'] = 64,
@ -2934,6 +2968,7 @@ Event.add(de.on_player_respawned, on_player_respawned)
Event.add(de.on_player_driving_changed_state, on_player_driving_changed_state)
Event.add(de.on_pre_player_toggled_map_editor, on_pre_player_toggled_map_editor)
Event.add(de.on_player_cursor_stack_changed, on_player_cursor_stack_changed)
Event.add(de.on_chart_tag_added, on_chart_tag_added)
Event.on_nth_tick(10, tick)
Event.add(WD.events.on_wave_created, on_wave_created)
Event.add(WD.events.on_primary_target_missing, on_primary_target_missing)

View File

@ -445,6 +445,7 @@ function Public.pre_init_task(current_task)
Public.set_xp_yield()
end
RPG.set_extra('modded_hotkeys', true)
Public.clear_all_chart_tags()
current_task.message = 'Pre init done!'
current_task.state = 'init_stateful'

View File

@ -5,8 +5,13 @@ local Event = require 'utils.event'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
local function reset_forces()
local surface = game.get_surface('nauvis')
if not surface or not surface.valid then
return
end
for _, f in pairs(game.forces) do
f.reset()
f.clear_chart(surface)
f.reset_evolution()
end
for _, tech in pairs(game.forces.player.technologies) do

View File

@ -162,6 +162,9 @@ function Public.reset_main_table()
this.breach_wall_warning = false
this.icw_locomotive = nil
this.game_lost = false
this.charts = {
tags = {}
}
this.death_mode = false
this.collapse_started = false
this.locomotive_position = nil

View File

@ -566,7 +566,8 @@ function Public.update_health(player)
if rpg_extra.enable_health_and_mana_bars then
if rpg_t.show_bars then
local max_life = math.floor(player.character.max_health + player.character_health_bonus + player.force.character_health_bonus)
local proto_char = prototypes.entity.character.get_max_health('normal')
local max_life = math.floor(proto_char + player.character_health_bonus + player.force.character_health_bonus)
if not rpg_t.health_bar or not rpg_t.health_bar.valid then
rpg_t.health_bar = create_healthbar(player, 0.5)
end

View File

@ -609,7 +609,6 @@ local function vote_to_free(player, offender)
else
Utils.print_to(player, 'You have already voted to free ' .. offender .. '.')
end
return
end
local function jail(player, offender, msg, raised, mute)
@ -742,11 +741,11 @@ local function free(player, offender)
return false
end
if not game.get_player(offender) then
local to_jail_player = game.get_player(offender)
if not to_jail_player or not to_jail_player.valid then
return
end
local to_jail_player = game.get_player(offender)
teleport_player_to_gulag(to_jail_player, 'free')
local message = offender .. ' was set free from jail by ' .. player .. '.'
@ -987,7 +986,7 @@ end
-- @param message string
-- @param mute boolean
function Public.try_ul_data(key, value, player, message, mute)
if type(key) == 'table' then
if type(key) == 'userdata' then
key = key.name
end