View Single Post
  #5  
Old 07-30-2020, 09:57 PM
Moxxy Moxxy is offline
Approved Member
 
Join Date: Jul 2020
Posts: 1
Default Fixed code

All other mana regen mods on the forum that I could find suffer from the +30 mana glitch. This is caused when the game returns 30 for both mana and max_mana, so when the mod sets mana to 30 when it isn't really the max, it adds 30 to the max. Also, in AP and CW, the mods don't take into account Bloodlust skill. The below code is my current fix.

Sometimes the mod will appear not to work. In these cases you can wait a bit and try again, or try saving the game and reloading. I have found that activating this right after a battle almost always works.

Code:
function accelerate_manaregen()
  Game.ClearEffect("mana")
  local max_mana = Logic.cur_lu_item("mana","limit")
  local mana = Logic.cur_lu_item("mana","count")
  if mana < max_mana then
    Game.ClearEffect("rage")
    local max_rage = Logic.cur_lu_item("rage","limit")
    local rage = Logic.cur_lu_item( "rage", "count" )
    local min_rage = 0
    local sk_level = Logic.hero_lu_skill("blood_lust")
    if sk_level > 0 then min_rage = math.floor(skill_power("blood_lust",1,sk_level-1)*max_rage/100) end
    local mana_str = string.gsub(Game.Config("difficulty_k/manarage"),"|",",")
    local rage_str = string.gsub(Game.Config("difficulty_k/manarage"),"|",",")
    local diff = Game.HSP_difficulty()
    local k_mana_diff = tonumber(text_dec(mana_str,diff+1))
    local k_rage_diff = tonumber(text_dec(rage_str,diff+1))
    local wiz_bonus = skill_power("meditation",1)+Logic.hero_lu_item("sp_mana_map_prc","count")
    local mana_per_tick = math.max(1,max_mana/20*(1+wiz_bonus/100)*k_mana_diff)
    local rage_per_tick = math.max(1,max_rage/20*(1-Logic.hero_lu_item("sp_rage_map","count")/100)/k_rage_diff)
    local ticks = math.ceil((max_mana-mana)/mana_per_tick)
    rage = rage - rage_per_tick * ticks
    Logic.cur_lu_item("mana", "count", max_mana)
    Game.ClearEffect("mana")
    Logic.cur_lu_item("rage", "count", math.max(min_rage, rage))
    Game.ClearEffect("rage")
  end
end

Last edited by Moxxy; 07-30-2020 at 10:07 PM.
Reply With Quote