Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hotkeys = require("Hotkeys/Hotkeys")
- local default_settings = {
- weapon_table = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
- skill_table = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
- now_skill_table = 1,
- hotkeys = {
- ["Rearmament"] = "E",
- ["Modifier"] = "Control",
- },
- }
- local function recurse_def_settings(tbl, defaults_tbl)
- for key, value in pairs(defaults_tbl) do
- if type(tbl[key]) ~= type(value) then
- if type(value) == "table" then
- tbl[key] = recurse_def_settings({}, value)
- else
- tbl[key] = value
- end
- elseif type(value) == "table" then
- tbl[key] = recurse_def_settings(tbl[key], value)
- end
- end
- return tbl
- end
- local settings = recurse_def_settings(json.load_file("RearmamentPlus.json") or {}, default_settings)
- hotkeys.setup_hotkeys(settings.hotkeys)
- local function isActiveLoadout(slot)
- if settings.weapon_table[slot][1] == 0 and settings.weapon_table[slot][2] == 0 then
- return false
- elseif settings.skill_table[slot][1] == 0 and settings.skill_table[slot][2] == 0 and settings.skill_table[slot][3] == 0 and settings.skill_table[slot][4] == 0 then
- return false
- else return true end
- end
- local function getCurrentJob()
- return Human:get_JobContext():get_field("CurrentJob")
- end
- local function switch_skill_table(skill_table_id)
- for i = 1, 4 do
- HumanSkillContext:setSkill(getCurrentJob(), settings.skill_table[skill_table_id][i], i - 1)
- end
- GuiManager:setupKeyGuideCustomSkill()
- end
- local function switch_weapon_table(weapon_table_id)
- if settings.weapon_table[weapon_table_id][1] == 0 and settings.weapon_table[weapon_table_id][2] == 0 then return end
- local job10Mgr = Human:call("get_Job10WeaponManager()")
- if not job10Mgr then return end
- local holder = ManualPlayer:call("get_WeaponAndItemHolder()")
- if not holder then return end
- local leftSlot = holder:call("get_LeftWeapon()")
- local rightSlot = holder:call("get_RightWeapon()")
- job10Mgr:call("requestEquipToMainHolder(app.WeaponAndItemHolder.WeaponSlot, app.WeaponID)", leftSlot, settings.weapon_table[weapon_table_id][1])
- job10Mgr:call("requestEquipToMainHolder(app.WeaponAndItemHolder.WeaponSlot, app.WeaponID)", rightSlot, settings.weapon_table[weapon_table_id][2])
- job10Mgr:call("generateBodyEffect()")
- end
- -- sdk.get_managed_singleton('app.AppSingleton`1<app.CharacterManager>'):call('get_Instance'):call("get_ManualPlayer"):call("get_Human"):call("get_Job10WeaponManager()")
- -- :call("equipWeapon", 3176146805):call("equipWeapon(app.WeaponID)",3176146805)
- local function get_skill_table()
- local skill_list = {}
- for i = 1, 4 do
- skill_list[i] = HumanSkillContext:getSkillID(getCurrentJob(), i - 1)
- end
- return skill_list
- end
- local function get_next_valid_loadout()
- local currentLoadout = settings.now_skill_table;
- local nextLoadout = 0
- if currentLoadout == 4 then
- nextLoadout = 1
- else
- nextLoadout = currentLoadout + 1
- end
- settings.now_skill_table = nextLoadout
- json.dump_file("RearmamentPlus.json", settings)
- return nextLoadout
- end
- local function get_total_loadouts()
- local count = 0
- if isActiveLoadout(1) then count = count + 1 end;
- if isActiveLoadout(2) then count = count + 1 end;
- if isActiveLoadout(3) then count = count + 1 end;
- if isActiveLoadout(4) then count = count + 1 end;
- return count
- end
- re.on_frame(
- function()
- if not CharacterManagerSingleton then
- CharacterManagerSingleton = sdk.get_managed_singleton('app.AppSingleton`1<app.CharacterManager>')
- if not CharacterManagerSingleton then return end
- end
- if not CharacterManager then
- CharacterManager = CharacterManagerSingleton:call('get_Instance')
- if not CharacterManager then return end
- end
- if not GuiManager then
- GuiManager = sdk.get_managed_singleton('app.GuiManager')
- if not GuiManager then return end
- end
- if not ManualPlayer then
- ManualPlayer = CharacterManager:call("get_ManualPlayer")
- if not ManualPlayer then return end
- end
- if not Human then
- Human = ManualPlayer:call("get_Human")
- if not Human then return end
- end
- if not HumanSkillContext then
- HumanSkillContext = Human:call("get_SkillContext")
- if not HumanSkillContext then return end
- end
- if getCurrentJob() == 10 then
- if hotkeys.check_hotkey("Modifier", true) or hotkeys.hotkeys["Modifier"] == "[Not Bound]" then
- if hotkeys.check_hotkey("Rearmament") then
- if get_total_loadouts() <= 1 then return end
- local loadoutIndex = get_next_valid_loadout();
- if not isActiveLoadout(loadoutIndex) then loadoutIndex = get_next_valid_loadout() end
- switch_skill_table(loadoutIndex)
- switch_weapon_table(loadoutIndex)
- end
- end
- end
- end)
- sdk.hook(
- sdk.find_type_definition('app.GuiManager'):get_method('OnChangeSceneType'),
- function() end,
- function()
- if CharacterManager then
- ManualPlayer = CharacterManager:call('get_ManualPlayer')
- end
- if ManualPlayer then
- Human = ManualPlayer:call('get_Human')
- end
- if Human then
- HumanSkillContext = Human:call('get_SkillContext')
- end
- if HumanSkillContext then
- if getCurrentJob() == 10 then
- if isActiveLoadout(settings.now_skill_table) then
- switch_skill_table(settings.now_skill_table)
- switch_weapon_table(settings.now_skill_table)
- end
- end
- end
- end
- )
- local function load_skills(skill_table_id)
- if getCurrentJob() ~= 10 then return end
- local skill_list = {}
- for i = 1, 4 do
- skill_list[i] = HumanSkillContext:getSkillID(getCurrentJob(), i - 1)
- end
- settings.skill_table[skill_table_id] = skill_list
- local weapon_list = {}
- weapon_list[1] = ManualPlayer:call("get_LeftWeaponID()")
- weapon_list[2] = ManualPlayer:call("get_RightWeaponID()")
- settings.weapon_table[skill_table_id] = weapon_list
- json.dump_file("RearmamentPlus.json", settings)
- end
- local function clear_skills(skill_table_id)
- local skill_list = { 0, 0, 0, 0 }
- settings.skill_table[skill_table_id] = skill_list
- local weapon_list = { 0, 0 }
- settings.weapon_table[skill_table_id] = weapon_list
- json.dump_file("RearmamentPlus.json", settings)
- end
- re.on_draw_ui(
- function()
- local changed
- if not HumanSkillContext then
- return
- end
- if imgui.tree_node("Rearmament Plus") then
- if imgui.button("Reset to Defaults") then
- settings = recurse_def_settings({}, default_settings)
- hotkeys.reset_from_defaults_tbl(default_settings.hotkeys)
- clear_skills(1)
- clear_skills(2)
- clear_skills(3)
- clear_skills(4)
- end
- imgui.spacing()
- imgui.spacing()
- changed = hotkeys.hotkey_setter("Modifier")
- changed = hotkeys.hotkey_setter("Rearmament", "Modifier")
- imgui.spacing()
- imgui.spacing()
- if changed then
- hotkeys.update_hotkey_table(settings.hotkeys)
- json.dump_file("RearmamentPlus.json", settings)
- end
- if imgui.tree_node("How to Use") then
- imgui.text("Basic Usage:")
- imgui.text("1. Equip the weapon and Skills you wish to save")
- imgui.text("2. Click Remember Loadout.")
- imgui.text("3. Use hotkey (You must have at least 2 loadouts).")
- imgui.new_line()
- imgui.text("NOTE: You can only set or swap skills as a Wayfarer.")
- imgui.new_line()
- imgui.text("For best results, equip the item and then")
- imgui.text("Exit the pause menu entirely before saving loadouts")
- imgui.tree_pop()
- end
- imgui.spacing()
- imgui.spacing()
- imgui.text("Save/Clear currently equipped Weapons and Skills:")
- if isActiveLoadout(1) then
- imgui.text("[READY]")
- imgui.same_line()
- end
- if imgui.button("Save Loadout 1") then
- load_skills(1)
- end
- imgui.same_line()
- if imgui.button("Load Loadout 1") then
- if isActiveLoadout(1) then
- switch_skill_table(1)
- switch_weapon_table(1)
- end
- end
- imgui.same_line()
- if imgui.button("Clear Loadout 1") then
- clear_skills(1)
- end
- imgui.spacing()
- if isActiveLoadout(2) then
- imgui.text("[READY]")
- imgui.same_line()
- end
- if imgui.button("Save Loadout 2") then
- load_skills(2)
- end
- imgui.same_line()
- if imgui.button("Load Loadout 2") then
- if isActiveLoadout(2) then
- switch_skill_table(2)
- switch_weapon_table(2)
- end
- end
- imgui.same_line()
- if imgui.button("Clear Loadout 2") then
- clear_skills(2)
- end
- imgui.spacing()
- if isActiveLoadout(3) then
- imgui.text("[READY]")
- imgui.same_line()
- end
- if imgui.button("Save Loadout 3") then
- load_skills(3)
- end
- imgui.same_line()
- if imgui.button("Load Loadout 3") then
- if isActiveLoadout(3) then
- switch_skill_table(3)
- switch_weapon_table(3)
- end
- end
- imgui.same_line()
- if imgui.button("Clear Loadout 3") then
- clear_skills(3)
- end
- imgui.spacing()
- if isActiveLoadout(4) then
- imgui.text("[READY]")
- imgui.same_line()
- end
- if imgui.button("Save Loadout 4") then
- load_skills(4)
- end
- imgui.same_line()
- if imgui.button("Load Loadout 4") then
- if isActiveLoadout(4) then
- switch_skill_table(4)
- switch_weapon_table(4)
- end
- end
- imgui.same_line()
- if imgui.button("Clear Loadout 4") then
- clear_skills(4)
- end
- imgui.spacing()
- imgui.tree_pop()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment