Skip to content

Commit

Permalink
Push fix for jail handler and bug fixes for Mtn
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Nov 19, 2024
1 parent d2fdba2 commit 80a99e4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
35 changes: 35 additions & 0 deletions maps/mountain_fortress_v3/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions maps/mountain_fortress_v3/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions maps/mountain_fortress_v3/soft_reset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions maps/mountain_fortress_v3/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion modules/rpg/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions utils/datastore/jail_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 .. '.'
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 80a99e4

Please sign in to comment.