Skip to content

Commit

Permalink
Mtn: push fixes for datastore fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Oct 27, 2024
1 parent a9d5948 commit c979d61
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
9 changes: 5 additions & 4 deletions maps/mountain_fortress_v3/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion maps/mountain_fortress_v3/stateful/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions modules/rpg/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 22 additions & 23 deletions modules/rpg/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c979d61

Please sign in to comment.