From c979d61711ffbc118e25de21519ab65b7dd70279 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 27 Oct 2024 09:44:09 +0100 Subject: [PATCH] Mtn: push fixes for datastore fetch --- maps/mountain_fortress_v3/main.lua | 9 ++-- maps/mountain_fortress_v3/stateful/table.lua | 1 - modules/rpg/functions.lua | 1 + modules/rpg/main.lua | 45 ++++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index af6f29ec7..0849e4284 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -140,6 +140,9 @@ local function preinit_task() player.print(mapkeeper .. ' Map is resetting, please wait a moment. All GUI buttons are disabled at the moment.') end + Public.reset_func_table() + RPG.reset_table() + Public.sr_reset_forces() WD.set('wave_interval', 4500) end @@ -523,7 +526,8 @@ function Public.move_players_to_nauvis(current_task) end RPG.rpg_reset_all_players() - Public.equip_players(nil, false) + local starting_items = Public.get_func('starting_items') + Public.equip_players(starting_items, false) current_task.message = 'Moved players back to nauvis!' current_task.done = true @@ -579,7 +583,6 @@ function Public.reset_map(current_task) ICW.reset() IC.reset() IC.allowed_surface(game.surfaces[this.active_surface_index].name) - Public.reset_func_table() game.reset_time_played() OfflinePlayers.init(this.active_surface_index) @@ -618,8 +621,6 @@ function Public.reset_map(current_task) Collapse.set_surface_index(surface.index) Collapse.start_now(false) - RPG.reset_table() - init_bonus_drill_force() Public.init_enemy_weapon_damage() diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index 9e8d2789d..4a9b8b4a0 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -1247,7 +1247,6 @@ local function apply_buffs() this.total_buffs = total_buffs end log('Applied all buffs.') - Public.equip_players(starting_items) end local function apply_startup_settings(settings) diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 6b0d1b454..6956eecb7 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -1114,6 +1114,7 @@ end function Public.get_mana_modifier(player) local rpg_t = Public.get_value_from_player(player.index) + if not rpg_t then return end if rpg_t.level <= 40 then return (rpg_t.magicka - 10) * 0.02000 elseif rpg_t.level <= 80 then diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index 9dc9c8396..7bca64d82 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -367,33 +367,32 @@ end local function regen_mana_player(players) for i = 1, #players do local player = players[i] - local mana_per_tick = Public.get_mana_modifier(player) - local rpg_extra = Public.get('rpg_extra') local rpg_t = Public.get_value_from_player(player.index) - if not rpg_t then - return - end - if mana_per_tick <= 0.1 then - mana_per_tick = rpg_extra.mana_per_tick - end + if rpg_t then + local mana_per_tick = Public.get_mana_modifier(player) + local rpg_extra = Public.get('rpg_extra') + if mana_per_tick <= 0.1 then + mana_per_tick = rpg_extra.mana_per_tick + end - if rpg_extra.force_mana_per_tick then - mana_per_tick = 1 - end + if rpg_extra.force_mana_per_tick then + mana_per_tick = 1 + end - if player and player.valid and not player.in_combat then - if player.character and player.character.valid then - if rpg_t.mana < 0 then - rpg_t.mana = 0 - end - if rpg_t.mana >= rpg_t.mana_max then - goto continue - end - rpg_t.mana = rpg_t.mana + mana_per_tick - if rpg_t.mana >= rpg_t.mana_max then - rpg_t.mana = rpg_t.mana_max + if player and player.valid and not player.in_combat then + if player.character and player.character.valid then + if rpg_t.mana < 0 then + rpg_t.mana = 0 + end + if rpg_t.mana >= rpg_t.mana_max then + goto continue + end + rpg_t.mana = rpg_t.mana + mana_per_tick + if rpg_t.mana >= rpg_t.mana_max then + rpg_t.mana = rpg_t.mana_max + end + rpg_t.mana = (round(rpg_t.mana * 10) / 10) end - rpg_t.mana = (round(rpg_t.mana * 10) / 10) end end