SHARE
TWEET

Blue Magic Skillup

Belgaer Jun 11th, 2016 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. packets = require('packets')
  2. res = require 'resources'
  3. --version 2.0.0.0 final
  4. ----------USER IN CODE SETTINGS----------
  5. ---Put the spells you want to use in these tables
  6. ---Example: for healing Healing = T{'Cure','Cure II'},
  7. ---if you cant use the spell it will not use it
  8. user_settings = {
  9.     user_spells = {
  10.         Healing = T{},
  11.         Geomancy = T{},
  12.         Enhancing = T{},
  13.         Ninjutsu = T{},
  14.         Singing = T{},
  15.         Blue = T{'Pollen'},
  16.         Summoning = T{}},
  17.     save_settings = false} --change this to true if you wish to save the last position of your skillup window
  18. sets.brd = {
  19.     wind_inst = {
  20.         range="Cornette"},--put your wind instrument here
  21.     string_inst = {
  22.         range="Lamia Harp"},}--put your string instrument here
  23. sets.Idle = {
  24.     right_ear="Liminus Earring",
  25.     head="Tema. Headband",
  26.     body="Temachtiani Shirt",
  27.     hands="Temachtiani Gloves",
  28.     legs="Temachtiani Pants",
  29.     feet="Temachtiani Boots",
  30.     }
  31. sets.Resting = {
  32.     main="Dark Staff",
  33.     left_ear="Relaxing Earring",
  34.     ammo="Clarus Stone",
  35.     neck="Eidolon pendant",
  36.     right_ear="Boroka Earring",
  37.     }
  38. --DO NOT CHANGE ANY THING BELOW THIS LINE--
  39. function get_sets()
  40.     skilluprun = false
  41.     gs_skill = {skillup_table = {"Healing","Geomancy","Enhancing","Ninjutsu","Singing","Blue","Summoning"},skillup_type = 'None',skillup_spells = T{},
  42.         skillup_count=1,bluspellulid = {['Harden Shell']=737,['Pyric Bulwark']=741,['Carcharian Verve']=745},skill_up_item = T{5889,5890,5891,5892}}
  43.     end_skillup = {shutdown = false,logoff = false,stoptype = "Stop"}
  44.     gs_skillup = {color={GEO=true,HEL=true,ENH=true,NIN=true,SIN=true,BLU=true,SMN=true,STOP=true,DOWN=true,LOG=true,TRUST=true,TEST=true,REF=true,ITEM=true},
  45.                 skill_ups={},total_skill_ups=0,skill={},use_trust=false,use_item=false,use_geo=false,test_mode=false,test_brd="Wind",skipped_spells=T{}}
  46.     gs_skillup.box={pos={x=211,y=402},text={font='Segoe UI Symbol',size=12,Fonts={'sans-serif'},},bg={alpha=255}}
  47.     gs_skillup.boxa={pos={x=gs_skillup.box.pos.x - 145,y=gs_skillup.box.pos.y},text={font='Segoe UI Symbol',size=9},bg={alpha=255}}
  48.     if gearswap.pathsearch({'Saves/skillup_data.lua'}) then
  49.         include('Saves/skillup_data.lua')
  50.     end
  51.     button = texts.new(gs_skillup.boxa)
  52.     window = texts.new(gs_skillup.box)
  53.     initialize(button, gs_skillup.boxa, 'button')
  54.     initialize(window, gs_skillup.box, 'window')
  55.     button:show()
  56.     window:show()
  57. end
  58. function file_unload()
  59.     if user_settings.save_settings then
  60.         file_write()
  61.     end
  62.     window:destroy()
  63.     button:destroy()
  64. end
  65. function status_change(new,old)
  66.     if sets[new] then
  67.         equip(sets[new])
  68.     end
  69.     if new=='Idle' then
  70.         if skilluprun then
  71.             send_command('wait 1.0;input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  72.         end
  73.     elseif new=='Resting' then
  74.         coroutine.schedule(go_to_idle_gear, 30)
  75.     end
  76. end
  77. function go_to_idle_gear()
  78.     equip(sets.Idle)
  79. end
  80. function filtered_action(spell)
  81.     if check_skill_cap() or not skilluprun then cancel_spell() shutdown_logoff() return end
  82.     if gs_skill.bluspellulid[spell.en] then
  83.         if windower.ffxi.get_ability_recasts()[81] and windower.ffxi.get_ability_recasts()[81] == 0 then
  84.             cancel_spell()
  85.             send_command('input /ja "'..res.job_abilities[298][gearswap.language]..'" <me>')
  86.         elseif windower.ffxi.get_ability_recasts()[254] and windower.ffxi.get_ability_recasts()[254] == 0 then
  87.             cancel_spell()
  88.             send_command('input /ja "'..res.job_abilities[338][gearswap.language]..'" <me>')
  89.         else
  90.             cancel_spell()
  91.             gs_skill.skillup_count = (gs_skill.skillup_count % #gs_skill.skillup_spells) + 1
  92.             send_command('input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  93.         end
  94.         return
  95.     elseif spell.skill == "Ninjutsu" then
  96.         local tool = nin_tool_open(spell)
  97.         cancel_spell()
  98.         if tool then
  99.             send_command('input /item "'..tool..'" <me>')
  100.         end
  101.         return
  102.     elseif S{"Avatar's Favor","Elemental Siphon"}:contains(spell.en) then
  103.         cancel_spell()
  104.         send_command('input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  105.     end
  106.     if spell.name == gs_skill.skillup_spells[gs_skill.skillup_count] then
  107.         if gs_skill.skillup_spells:contains(spell.name) then
  108.             gs_skill.skillup_spells:delete(spell.name)
  109.         end
  110.         cancel_spell()
  111.         gs_skill.skillup_count = (gs_skill.skillup_count % #gs_skill.skillup_spells) + 1
  112.         send_command('input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  113.     end
  114. end
  115. function precast(spell)
  116.     if pet.isvalid and S{"Release","Full Circle"}:contains(spell.en) then
  117.         if spell.en == "Release" then
  118.             if not pet.isvalid then
  119.                 cancel_spell()
  120.                 send_command('input /heal on')
  121.             end
  122.             local recast = windower.ffxi.get_ability_recasts()[spell.recast_id]
  123.             if (recast > 0) then
  124.                 cancel_spell()
  125.                 send_command('wait '..tostring(recast+0.5)..';input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  126.             end
  127.             return
  128.         else
  129.             return
  130.         end
  131.     elseif not pet.isvalid and S{"Release","Avatar's Favor","Elemental Siphon"}:contains(spell.en) then
  132.         cancel_spell()
  133.         send_command('input /heal on')
  134.         return
  135.     end
  136.     if check_skill_cap() or not skilluprun then cancel_spell() shutdown_logoff() return end
  137.     if gs_skill.skillup_type == "Singing" then
  138.         if (gs_skillup.test_mode and gs_skillup.test_brd == "String") or not gs_skillup.skill['Stringed Instrument Capped'] then
  139.             equip(sets.brd.string_inst)
  140.         elseif (gs_skillup.test_mode and gs_skillup.test_brd == "Wind") or not gs_skillup.skill['Wind Instrument Capped'] then
  141.             equip(sets.brd.wind_inst)
  142.         end
  143.     end
  144.     if spell.en == "Avatar's Favor" then
  145.         if (windower.ffxi.get_ability_recasts()[spell.recast_id] > 0) or buffactive["Avatar's Favor"] then
  146.             cancel_spell()
  147.             send_command('input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  148.             return
  149.         end
  150.     end
  151.     if spell.en == "Elemental Siphon" then
  152.         if (windower.ffxi.get_ability_recasts()[spell.recast_id] > 0) or player.mpp > 75 then
  153.             cancel_spell()
  154.             send_command('input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  155.             return
  156.         end
  157.     end
  158.     if spell and spell.mp_cost > player.mp then
  159.         if gs_skillup.skipped_spells:contains(spell.name) then
  160.             gs_skillup.skipped_spells:clear()
  161.             cancel_spell()
  162.             send_command('input /heal on')
  163.             return
  164.         end
  165.         cancel_spell()
  166.         gs_skillup.skipped_spells:append(spell.name)
  167.         gs_skill.skillup_count = (gs_skill.skillup_count % #gs_skill.skillup_spells) + 1
  168.         send_command('input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  169.         return
  170.     end
  171.     if gs_skillup.use_trust and party.count == 1 and spell_usable(res.spells[931]) then
  172.         if spell.en ~= "Moogle" then
  173.             cancel_spell()
  174.             send_command('input /ma "'..res.spells[931][gearswap.language]..'" <me>')
  175.         end
  176.         return
  177.     end
  178.     if gs_skillup.use_item and spell.type ~= "Item" and not buffactive[251] then
  179.         for i,v in ipairs(gs_skill.skill_up_item) do
  180.             if player.inventory[res.items[v][gearswap.language]] then
  181.                 cancel_spell()
  182.                 send_command('input /item "'..res.items[v][gearswap.language]..'" <me>')
  183.                 return
  184.             end
  185.         end
  186.     elseif gs_skillup.use_geo and player.main_job == "GEO" and spell_usable(res.spells[800]) and not pet.isvalid then
  187.         if spell.en ~= "Geo-Refresh" then
  188.             cancel_spell()
  189.             send_command('input /ma "'..res.spells[800][gearswap.language]..'" <me>')
  190.         end
  191.         return
  192.     elseif gs_skillup.use_geo and player.sub_job == "GEO" and spell_usable(res.spells[770]) and buffactive[541] ~= (gs_skillup.use_trust and 2 or 1) then
  193.         if spell.en ~= "Indi-Refresh" then
  194.             cancel_spell()
  195.             send_command('input /ma "'..res.spells[770][gearswap.language]..'" <me>')
  196.         end
  197.         return
  198.     end
  199.     if spell.name == gs_skill.skillup_spells[gs_skill.skillup_count] then
  200.         if not spell_usable(spell) then
  201.             cancel_spell()
  202.             gs_skill.skillup_count = (gs_skill.skillup_count % #gs_skill.skillup_spells) + 1
  203.             send_command('input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  204.         else
  205.             gs_skill.skillup_count = (gs_skill.skillup_count % #gs_skill.skillup_spells) + 1
  206.         end
  207.     end
  208. end
  209. function aftercast(spell)
  210.     if pet.isvalid and check_skill_cap() then
  211.         if pet.name == "Luopan" then
  212.             send_command('wait 1.0;input /ja "'..res.job_abilities[345][gearswap.language]..'" <me>')
  213.         else
  214.             send_command('wait 1.0;input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  215.         end
  216.         return
  217.     end
  218.     if check_skill_cap() then
  219.         shutdown_logoff() return
  220.     elseif spell.interrupted then
  221.         if spell.en == "Release" then
  222.             send_command('wait 0.5;input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  223.             return
  224.         else
  225.             send_command('wait 3.0;input /ma "'..spell.name..'" <me>')
  226.             return
  227.         end
  228.     elseif spell.type == "SummonerPact" then
  229.         local spell_element = (type(spell.element)=='number' and res.elements[spell.element][gearswap.language] or spell.element)
  230.         if spell.en:contains('Spirit') and (spell_element == world.weather_element or spell_element == world.day_element) then
  231.             send_command('wait 4.0;input /ja "'..res.job_abilities[232][gearswap.language]..'" <me>')
  232.         elseif not spell.en:contains('Spirit') then
  233.             send_command('wait 4.0;input /ja "'..res.job_abilities[250][gearswap.language]..'" <me>')
  234.         else
  235.             send_command('wait 3.0;input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  236.         end
  237.     elseif spell.en == "Avatar's Favor" then
  238.         send_command('wait 1.0;input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  239.     elseif spell.en == "Elemental Siphon" then
  240.         send_command('wait 1.0;input /ja "'..res.job_abilities[90][gearswap.language]..'" <me>')
  241.     else
  242.         send_command('wait 3.0;input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  243.     end
  244. end
  245. function self_command(command)
  246.     local commandArgs = command
  247.     if #commandArgs:split(' ') >= 2 then
  248.         commandArgs = T(commandArgs:split(' '))
  249.     end
  250.     if type(commandArgs) == 'table' and commandArgs[1] == 'start' then
  251.         for i,v in ipairs(gs_skill.skillup_table) do
  252.             if v:lower() == commandArgs[2]:lower() then
  253.                 gs_skill.skillup_type = v
  254.                 skilluprun = true
  255.                 if #gs_skill.skillup_spells > 0 then
  256.                     gs_skill.skillup_spells:clear()
  257.                 end
  258.                 local skill_id = {["Healing"]=33,["Enhancing"]=34,["Summoning"]=38,["Ninjutsu"]=39,["Singing"]=40,["Blue"]=43,["Geomancy"]=44}
  259.                 local spells_have = windower.ffxi.get_spells()
  260.                 for i,v in pairs(res.spells) do
  261.                     if v.skill == skill_id[gs_skill.skillup_type] and spell_valid(v) and spells_have[v.id] then
  262.                         if #user_settings.user_spells[gs_skill.skillup_type] > 0 then
  263.                             if user_settings.user_spells[gs_skill.skillup_type]:contains(v.name) then
  264.                                 gs_skill.skillup_spells:append(v[gearswap.language])
  265.                             end
  266.                         else
  267.                             gs_skill.skillup_spells:append(v[gearswap.language])
  268.                         end
  269.                     end
  270.                 end
  271.                 if not (#gs_skill.skillup_spells > 0) then
  272.                     add_to_chat(123,"Current Job Can Not Use Spells From "..gs_skill.skillup_type)
  273.                     skilluprun = false
  274.                     return
  275.                 end
  276.                 send_command('input /ma "'..gs_skill.skillup_spells[gs_skill.skillup_count]..'" <me>')
  277.             end
  278.         end
  279.     end
  280.     if command == "skillstop" then
  281.         skilluprun = false
  282.     elseif command == 'aftershutdown' then
  283.         end_skillup.stoptype = "Shutdown"
  284.         end_skillup.shutdown = true
  285.         end_skillup.logoff = false
  286.     elseif command == 'afterlogoff' then
  287.         end_skillup.stoptype = "Logoff"
  288.         end_skillup.shutdown = false
  289.         end_skillup.logoff = true
  290.     elseif command == 'afterStop' then
  291.         end_skillup.stoptype = "Stop"
  292.         end_skillup.shutdown = false
  293.         end_skillup.logoff = false
  294.     elseif command == 'settrust' then
  295.         gs_skillup.use_trust = not gs_skillup.use_trust
  296.     elseif command == 'setitem' then
  297.         gs_skillup.use_item = not gs_skillup.use_item
  298.     elseif command == 'setgeo' then
  299.         gs_skillup.use_geo = not gs_skillup.use_geo
  300.     elseif command == 'changeinstrament' then
  301.         gs_skillup.test_brd = (gs_skillup.test_brd=="Wind" and "String" or "Wind")
  302.     end
  303.     initialize(window, gs_skillup.box, 'window')
  304.     updatedisplay()
  305. end
  306. function spell_usable(spell)
  307.     if windower.ffxi.get_spells()[spell.id] and windower.ffxi.get_spell_recasts()[spell.recast_id] == 0 then
  308.         return true
  309.     end
  310. end
  311. function check_skill_cap()
  312.     if S{'Healing','Enhancing','Blue','Summoning'}:contains(gs_skill.skillup_type) then
  313.         if gs_skillup.skill[gs_skill.skillup_type..' Magic Capped'] and not gs_skillup.test_mode then
  314.             skilluprun = false
  315.             return true
  316.         end
  317.     elseif gs_skill.skillup_type == "Ninjutsu" then
  318.         if gs_skillup.skill[gs_skill.skillup_type..' Capped'] and not gs_skillup.test_mode then
  319.             skilluprun = false
  320.             return true
  321.         end
  322.     elseif gs_skill.skillup_type == "Geomancy" then
  323.         if gs_skillup.skill['Geomancy Capped'] and gs_skillup.skill['Handbell Capped'] and not gs_skillup.test_mode then
  324.             skilluprun = false
  325.             return true
  326.         end
  327.     elseif gs_skill.skillup_type == "Singing" then
  328.         if gs_skillup.skill['Singing Capped'] and gs_skillup.skill['Stringed Instrument Capped'] and gs_skillup.skill['Wind Instrument Capped'] and not gs_skillup.test_mode then
  329.             skilluprun = false
  330.             return true
  331.         end
  332.     else
  333.         return false
  334.     end
  335. end
  336. function spell_valid(tab)
  337.     if (tab.levels[player.main_job_id] and tab.levels[player.main_job_id] <= player.main_job_level or tab.levels[player.sub_job_id] and tab.levels[player.sub_job_id] <= player.main_job_level) and tab.targets:contains('Self') and
  338.        tab.targets:contains('Self') and not tab.en:wmatch('Teleport-*|Warp*|Tractor*|Retrace|Escape|Geo-*|Sacrifice|Odin|Alexander') then
  339.         return true
  340.     end
  341. end
  342. function shutdown_logoff()
  343.     add_to_chat(123,"Stoping skillup")
  344.     if end_skillup.logoff then
  345.         send_command('wait 3.0;input /logout')
  346.     elseif end_skillup.shutdown then
  347.         send_command('wait 3.0;input /shutdown')
  348.     end
  349.     initialize(window, gs_skillup.box, 'window')
  350.     updatedisplay()
  351. end
  352. function nin_tool_open(spell)
  353.     local bag_id = {['Sanjaku-Tenugui']=5417,['Soshi']=5734,['Uchitake']=5308,['Tsurara']=5309,['Kawahori-Ogi']=5310,['Makibishi']=5311,['Hiraishin']=5312,
  354.         ['Mizu-Deppo']=5313,['Shihei']=5314,['Jusatsu']=5315,['Kaginawa']=5316,['Sairui-Ran']=5317,['Kodoku']=5318,['Shinobi-Tabi']=5319,['Ranka']=6265,
  355.         ['Furusumi']=6266,['Kabenro']=5863,['Jinko']=5864,['Ryuno']=5865,['Mokujin']=5866,["Chonofuda"]=5869,["Inoshishinofuda"]=5867,["Shikanofuda"]=5868}
  356.     local t = gearswap.tool_map[spell.en].en
  357.     local ut = gearswap.universal_tool_map[spell.en].en
  358.     local tb = res.items[bag_id[t]][gearswap.language]
  359.     local utb = res.items[bag_id[ut]][gearswap.language]
  360.     if #gs_skill.skillup_spells > 0 then
  361.         if player.inventory[tb] ~= nil then
  362.             return tb
  363.         elseif player.inventory[utb] ~= nil then
  364.             return utb
  365.         else
  366.             gs_skill.skillup_spells:delete(spell.name)
  367.             return false
  368.         end
  369.     else
  370.         skilluprun = false
  371.         cancel_spell()
  372.         add_to_chat(7,"No Tools Available To Cast Any Ninjutsu")
  373.     end
  374. end
  375. function initialize(text, settings, a)
  376.     if a == 'window' then
  377.         local properties = L{}
  378.         if gs_skillup.test_mode then
  379.             properties:append('--TEST MODE--')
  380.             properties:append('Bard item = ${barditem|Wind}')
  381.         end
  382.         properties:append('--Skill Up--')
  383.         if gs_skillup.use_trust then
  384.             properties:append('\\crUsing Moogle Trust')
  385.         end
  386.         if gs_skillup.use_geo then
  387.             properties:append("\\crUsing Geo's Refresh")
  388.         end
  389.         if gs_skillup.use_item then
  390.             properties:append('\\crUsing Skill Up Item')
  391.         end
  392.         properties:append('Mode :\n   ${mode}')
  393.         if gs_skill.skillup_type == 'Singing' then
  394.             properties:append('\\crCurrent Singing Skill LVL:\n   ${skillssing|0}')
  395.             properties:append('\\crCurrent String Skill LVL:\n   ${skillstring|0}')
  396.             properties:append('\\crCurrent Wind Skill LVL:\n   ${skillwind|0}')
  397.         elseif gs_skill.skillup_type == 'Geomancy' then
  398.             properties:append('\\crCurrent Geomancy Skill LVL:\n   ${skillgeo|0}')
  399.             properties:append('\\crCurrent Handbell Skill LVL:\n   ${skillbell|0}')
  400.         else
  401.             properties:append('\\crCurrent Skilling LVL:\n   ${skillbulk|0}')
  402.         end
  403.         if end_skillup.shutdown then
  404.             properties:append('\\crWill Shutdown When Skillup Done')
  405.         elseif end_skillup.logoff then
  406.             properties:append('\\crWill Logoff When Skillup Done')
  407.         else
  408.             properties:append('\\crWill Stop When Skillup Done')
  409.         end
  410.         properties:append('\\crSkillup ${start|\\cs(255,0,0)Stoped}')
  411.         properties:append("\\crSkillup's Per Hour \\cs(255,255,0)${skill_ph|0}")
  412.         properties:append("\\crTotal Skillup's \\cs(255,255,0)${skill_total|0}")
  413.         text:clear()
  414.         text:append(properties:concat('\n'))
  415.     end
  416.     if a == 'button' then
  417.         local properties = L{}
  418.         properties:append('${TRUSTc}')
  419.         properties:append('${REFc}')
  420.         properties:append('${ITEMc}')
  421.         properties:append('${GEOc}')
  422.         properties:append('${HELc}')
  423.         properties:append('${ENHc}')
  424.         properties:append('${NINc}')
  425.         properties:append('${SINc}')
  426.         properties:append('${BLUc}')
  427.         properties:append('${SMNc}')
  428.         properties:append('${STOPc}')
  429.         properties:append('${DOWNc}')
  430.         properties:append('${LOGc}')
  431.         if gs_skillup.test_mode then
  432.             properties:append('${TESTc}')
  433.         end
  434.         text:clear()
  435.         text:append(properties:concat('\n'))
  436.     end
  437. end
  438. function updatedisplay()
  439.     local info = {}
  440.         info.mode = gs_skill.skillup_type
  441.         info.modeb = skilluprun and info.mode or 'None'
  442.         info.start = (skilluprun and '\\cs(0,255,0)Started' or '\\cs(255,0,0)Stoped')
  443.         info.skillssing = (gs_skillup.skill['Singing Capped'] and "Capped" or gs_skillup.skill['Singing Level'])
  444.         info.skillstring = (gs_skillup.skill['Stringed Instrument Capped'] and "Capped" or gs_skillup.skill['Stringed Instrument Level'])
  445.         info.skillwind = (gs_skillup.skill['Wind Instrument Capped'] and "Capped" or gs_skillup.skill['Wind Instrument Level'])
  446.         info.skillgeo = (gs_skillup.skill['Geomancy Capped'] and "Capped" or gs_skillup.skill['Geomancy Level'])
  447.         info.skillbell = (gs_skillup.skill['Handbell Capped'] and "Capped" or gs_skillup.skill['Handbell Level'])
  448.         info.skill = {}
  449.         info.skill.Healing = (gs_skillup.skill['Healing Magic Capped'] and "Capped" or gs_skillup.skill['Healing Magic Level'])
  450.         info.skill.Enhancing = (gs_skillup.skill['Enhancing Magic Capped'] and "Capped" or gs_skillup.skill['Enhancing Magic Level'])
  451.         info.skill.Summoning = gs_skillup.skill['Summoning Magic Capped'] and "Capped" or gs_skillup.skill['Summoning Magic Level']
  452.         info.skill.Ninjutsu = (gs_skillup.skill['Ninjutsu Capped'] and "Capped" or gs_skillup.skill['Ninjutsu Level'])
  453.         info.skill.Blue = (gs_skillup.skill['Blue Magic Capped'] and "Capped" or gs_skillup.skill['Blue Magic Level'])
  454.         info.skillbulk = info.skill[info.mode]
  455.         info.type = end_skillup.stoptype
  456.         info.skill_ph = (get_rate(gs_skillup.skill_ups) or 0) / 10
  457.         info.skill_total = (gs_skillup.total_skill_ups or 0) / 10
  458.         info.GEOc = (gs_skillup.color.GEO and 'Start GEO' or '\\cs(255,0,0)Start GEO\\cr')
  459.         info.HELc = (gs_skillup.color.HEL and 'Start Healing' or '\\cs(255,0,0)Start Healing\\cr')
  460.         info.ENHc = (gs_skillup.color.ENH and 'Start Enhancing' or '\\cs(255,0,0)Start Enhancing\\cr')
  461.         info.NINc = (gs_skillup.color.NIN and 'Start Ninjutsu' or '\\cs(255,0,0)Start Ninjutsu\\cr')
  462.         info.SINc = (gs_skillup.color.SIN and 'Start Singing' or '\\cs(255,0,0)Start Singing\\cr')
  463.         info.BLUc = (gs_skillup.color.BLU and 'Start Blue Magic' or '\\cs(255,0,0)Start Blue Magic\\cr')
  464.         info.SMNc = (gs_skillup.color.SMN and 'Start Summoning Magic  ' or '\\cs(255,0,0)Start Summoning Magic\\cr  ')
  465.         info.STOPc = (gs_skillup.color.STOP and 'Stop Skillups' or '\\cs(255,0,0)Stop Skillups\\cr')
  466.         info.DOWNc = (gs_skillup.color.DOWN and 'Shutdown After Skillup' or '\\cs(255,0,0)Shutdown After Skillup\\cr')
  467.         info.LOGc = (gs_skillup.color.LOG and  'Logoff After Skillup' or '\\cs(255,0,0)Logoff After Skillup\\cr')
  468.         info.TRUSTc = (gs_skillup.color.TRUST and  'Use Moogle Trust' or '\\cs(255,0,0)Use Moogle Trust\\cr')
  469.         info.REFc = (gs_skillup.color.REF and  "Use Geo's Refresh" or "\\cs(255,0,0)Use Geo's Refresh\\cr")
  470.         info.ITEMc = (gs_skillup.color.ITEM and  'Use Skill Up Item' or '\\cs(255,0,0)Use Skill Up Item\\cr')
  471.         info.TESTc = (gs_skillup.color.TEST and  'Change Bard Item' or '\\cs(255,0,0)Change Bard Item\\cr')
  472.         info.barditem = gs_skillup.test_brd
  473.         button:update(info)
  474.         button:show()
  475.         window:update(info)
  476.         window:show()
  477. end
  478. function file_write()
  479.     if not windower.dir_exists(lua_base_path..'data/'..player.name..'/Saves') then
  480.         windower.create_dir(lua_base_path..'data/'..player.name..'/Saves')
  481.     end
  482.     local file = io.open(lua_base_path..'data/'..player.name..'/Saves/skillup_data.lua',"w")
  483.     file:write(
  484.         'gs_skillup.box.pos.x = '..tostring(gs_skillup.box.pos.x)..
  485.         '\ngs_skillup.box.pos.y = '..tostring(gs_skillup.box.pos.y)..
  486.         '\ngs_skillup.boxa.pos.x = '..tostring(gs_skillup.boxa.pos.x)..
  487.         '\ngs_skillup.boxa.pos.y = '..tostring(gs_skillup.boxa.pos.y)..
  488.         '')
  489.     file:close()
  490. end
  491. function set_color(name)
  492.     for i, v in pairs(gs_skillup.color) do
  493.         if i == name then
  494.             gs_skillup.color[i] = false
  495.         else
  496.             gs_skillup.color[i] = true
  497.         end
  498.     end
  499. end
  500. function get_rate(tab)
  501.     local t = os.clock()
  502.     local running_total = 0
  503.     for ts,points in pairs(tab) do
  504.         local time_diff = t - ts
  505.         if t - ts > 3600 then
  506.             tab[ts] = nil
  507.         else
  508.             running_total = running_total + points
  509.         end
  510.     end
  511.     return running_total
  512. end
  513. windower.raw_register_event('incoming chunk', function(id, data, modified, injected, blocked)
  514.     if id == 0x062 then
  515.         local packet = packets.parse('incoming', data)
  516.         gs_skillup.skill = packet
  517.         updatedisplay()
  518.     end
  519.     if id == 0x0DF and skilluprun then
  520.         if data:unpack('I', 0x0D) == player.max_mp and skilluprun then
  521.             windower.send_command('input /heal off')
  522.         end
  523.     end
  524. end)
  525. windower.raw_register_event('mouse', function(type, x, y, delta, blocked)
  526.     local mx, my = texts.extents(button)
  527.     local button_lines = button:text():count('\n') + 1
  528.     local hx = (x - gs_skillup.boxa.pos.x)
  529.     local hy = (y - gs_skillup.boxa.pos.y)
  530.     local location = {}
  531.     location.offset = my / button_lines
  532.     location[1] = {}
  533.     location[1].ya = 1
  534.     location[1].yb = location.offset
  535.     local count = 2
  536.     while count <= button_lines do
  537.          location[count] = {}
  538.          location[count].ya = location[count - 1].yb
  539.          location[count].yb = location[count - 1].yb + location.offset
  540.          count = count + 1
  541.     end
  542.     if type == 0 then
  543.         if window:hover(x, y) and window:visible() then
  544.             button:pos((gs_skillup.box.pos.x - 145), gs_skillup.box.pos.y)
  545.             set_color("none")
  546.             updatedisplay()
  547.         elseif button:hover(x, y) and button:visible() then
  548.             window:pos((gs_skillup.boxa.pos.x + 145), gs_skillup.boxa.pos.y)
  549.             for i, v in ipairs(location) do
  550.                 local switch = {[1]="TRUST",[2]='REF',[3]='ITEM',[4]="GEO",[5]="HEL",[6]="ENH",[7]="NIN",[8]="SIN",[9]="BLU",[10]="SMN",[11]="STOP",[12]="DOWN",
  551.                                 [13]="LOG",[14]="TEST"}
  552.                 if hy > location[i].ya and hy < location[i].yb then
  553.                     set_color(switch[i])
  554.                     updatedisplay()
  555.                 end
  556.             end
  557.         else
  558.             set_color("none")
  559.             updatedisplay()
  560.         end
  561.     elseif type == 2 then
  562.         if button:hover(x, y) and button:visible() then
  563.             for i, v in ipairs(location) do
  564.                 local switchb = {[1]="settrust",[2]="setgeo",[3]="setitem",[4]="start Geomancy",[5]="start Healing",[6]="start Enhancing",[7]="start Ninjutsu",
  565.                                 [8]="start Singing",[9]="start Blue",[10]="start Summoning",[11]="skillstop",[12]="aftershutdown",[13]="afterlogoff",
  566.                                 [14]="changeinstrament"}
  567.                 if hy > location[i].ya and hy < location[i].yb then
  568.                     send_command("gs c "..switchb[i])
  569.                     updatedisplay()
  570.                 end
  571.             end
  572.         end
  573.     end
  574. end)
  575. windower.raw_register_event('action message', function(actor_id, target_id, actor_index, target_index, message_id, param_1, param_2, param_3)
  576.     if message_id == 38 and target_id == player.id then
  577.         local ts = os.clock()
  578.         gs_skillup.total_skill_ups = gs_skillup.total_skill_ups + param_2
  579.         gs_skillup.skill_ups[ts] = param_2
  580.     end
  581.     updatedisplay()
  582. end)
  583. frame_count = 0
  584. windower.raw_register_event('prerender',function()
  585.     if frame_count%30 == 0 and window:visible() then
  586.         updatedisplay()
  587.     end
  588.     frame_count = frame_count + 1
  589. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top