MENU

【GearSwap】装備のHPを比較してHP減少させず着替えを行うスクリプト

よしざうるすさんの記事にもありますが、着替えの順番によってHPが減る問題は根深いです。

手動で優先順位をセットするのは面倒なので、装備からHPを取得して自動で並び替えるスクリプトを作ってみました。

ですが、このスクリプトアイテムを検索する処理が入っているため、一瞬カクッと画面が固まりますので、実用的ではありません。

なので、使い物にならないという結論に至ったので、オーグメントの値は取得していません。装備品に元々あるHP+だけで計算しています。

今後の改善に役立てるため、備忘録として記録を残しておきます。

function job_post_precast(spell, action, spellMap, eventArgs)
    set_priorities_by_hp()
end

function job_post_midcast(spell, action, spellMap, eventArgs)
    set_priorities_by_hp()
end

function set_priorities_by_hp()
    local future,current = gearswap.equip_list,gearswap.equip_list_history

    function get_hp(piece)
       -- table.vprint(piece)
        id=nil;
        if type(piece) == 'table' and type(piece.name) == 'string' then
            id = gearswap.res.items:with('name', piece.name).id
        else
            id = gearswap.res.items:with('name', piece).id
        end
        detail = gearswap.res.item_descriptions[id].en
        hp = detail:match("HP%+(%d+)")
        
        if hp==nil then
            return 0
        else
            return hp
        end
    end
    
    for i,v in pairs(future) do
        local priority = get_hp(future[i]) - get_hp(current[i])
        if type(v) == 'table' then
            future[i].priority = priority
        else
            future[i] = {name=v,priority=priority}
        end
    end
end
目次

問題点

  • set_priorities_by_hpが動くと処理が一瞬固まる
  • Cashすればマシになるかもしれない
  • アンバスマントなどのオーグメントは取得できるが、ウォンテッド装備などはオーグメントを取得できない
ちょっとだけPR

コメント

コメントする

目次