Advertisement
KBeezie

Ranger Gearswap 1/20/2014

Jan 20th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.02 KB | None | 0 0
  1. -- Last Modified: 1/20/2014
  2. -- Cleaned File up, Check https://github.com/Kinematics/GearSwap-Jobs/blob/master/Template.lua
  3. -- Get the latest Mote-* files and examples from:
  4. -- https://github.com/Kinematics/GearSwap-Jobs
  5. -- for list of other functions that can be used.
  6.  
  7. -- === Some Notes On Sets ===
  8. -- Gear is loaded from rng_gear.lua to make it easier to update this file without re-doing gear sets
  9. --
  10. -- I don't have a PDT/MDT set configured in this file, but the stuff is there to be filled in as needed
  11. -- Engaged does have a TP set, but nothing different is filled in. I only TP off ranged attacks.
  12. --
  13. -- I only use the Augmented (Trial 5004) Scout's Beret +2 for TP Build.
  14. -- It's not much use for recycle since 90% is capped with Base + Merits + Manibozho gloves
  15. -- Getting an extra 5TP/shot with fully Merited Recycle is more useful for the head
  16. -- Thus why that's in the TP set.
  17. --
  18. -- WeaponSkill set automatically checks for a matching elemental belt or gorget in your inventory
  19. -- You can adjust UserGlobals.lua to change the default belt/gorget used when no match can be equipped
  20. -- If you leave default to blank "", It'll just keep whatever belt/neck you were using.
  21. --
  22. -- While there is a function to check for "Unlimited Shot" before using one of the special ammo
  23. -- it does not protect from loss against multi-hit weaponskills (ie: Jishnu's Radiance being a 3-hit WS)
  24.  
  25. -- === In Precast ===
  26. -- 1) Checks to make sure you're in an engaged state and have 100+ TP before firing a weaponskill
  27. -- 2) Checks the distance to target to prevent WS from being fired when target is too far (prevents TP loss)
  28. -- 3) Does not allow gear-swapping on weaponskills when Defense mode is enabled
  29. -- 4) Checks to see of "Unlimited Shot" buff is on, if there's any special ammo defined in sets equipped
  30. -- 5) Checks for empty ammo (or special without buff) and fills in the default ammunition for that weapon
  31. --    ^ keeps empty if that ammo cannot be found, or there is no match to the weapon equipped
  32. -- 6) Provides a low ammunition warning if current ammo in slot (counts all in inventory) is less than 15
  33. --    ^ If you have 5 Tulfaire arrows in slot, but 20 also in inventory it see's it as 25 total
  34.  
  35. -- === In Midcast ===
  36. -- If Sneak is active, sends the cancel command before Spectral Jig finish casting
  37.  
  38. -- === In Post-Midcast ===
  39. -- If Barrage Buff is active, equips sets.BarrageMid
  40.  
  41. -- === In Buff Change ===
  42. -- If Camouflage is active, disable body swaping
  43. -- This is done to preserve the +100 Camouflage Duration given by Orion Jerkin
  44. function get_sets()
  45.     -- Load and initialize the include file.
  46.     include('Mote-Include.lua')
  47.     init_include()
  48.        
  49.     -- UserGlobals may define additional sets to be added to the local ones.
  50.     if define_global_sets then
  51.         define_global_sets()
  52.     end
  53.  
  54.     -- Define sets and vars used by this job file.
  55.     if not load_user_gear(player.main_job) then
  56.         init_gear_sets()
  57.     end
  58.  
  59.     -- Global default binds
  60.     binds_on_load()
  61.  
  62.     send_command('bind f9 gs c cycle RangedMode')
  63.     send_command('bind ^f9 gs c cycle OffenseMode')
  64.     send_command('bind !f9 gs c cycle WeaponskillMode')
  65. end
  66.  
  67. -- Called when this job file is unloaded (eg: job change)
  68. function file_unload()
  69.         binds_on_unload()
  70.        
  71.         if user_unload then
  72.                 user_unload()
  73.         end
  74. end
  75.  
  76. function init_gear_sets()
  77.     -- Default macro set/book
  78.     set_macro_page(1, 20)
  79.  
  80.     -- Options: Override default values
  81.  
  82.     options.OffenseModes = {'Normal', 'Acc', 'TP'}
  83.     options.RangedModes = {'Normal', 'Acc', 'TP'}
  84.     options.DefenseModes = {'Normal', 'PDT'}
  85.     options.WeaponskillModes = {'Normal', 'Acc'}
  86.     options.PhysicalDefenseModes = {'PDT'}
  87.     options.MagicalDefenseModes = {'MDT'}
  88.     state.Defense.PhysicalMode = 'PDT'
  89.  
  90.     -- Misc. Job Ability precasts
  91.     sets.precast.Step = {ear2="Choreia Earring"}
  92.     sets.precast.JA['Bounty Shot'] = {hands="Sylvan Glovelettes +2"}
  93.     sets.precast.JA['Scavenge'] = {feet="Orion Socks"}
  94.    
  95.     -- Idle Set (My 'base')
  96.     sets.idle = {
  97.         head="Orion Beret",neck="Twilight Torque",ear1="Volley Earring",ear2="Moonshade Earring",
  98.         body="Orion Jerkin +1",hands="Manibozho Gloves",ring1="Dark Ring",ring2="Dark Ring",
  99.         back="Shadow Mantle",waist="Scout's Belt",legs="Nahtirah Trousers",feet="Orion Socks"}
  100.  
  101.     -- Engaged sets
  102.     sets.engaged = set_combine(sets.idle, {
  103.         neck="Asperity Necklace",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  104.         ring1="K'ayres Ring",ring2="Rajas Ring",
  105.         back="Sylvan Chlamys",waist="Hurch'lan Sash"})
  106.    
  107.     sets.engaged.Acc = set_combine(sets.engaged, {
  108.         neck="Ej Necklace",
  109.         hands="Buremte Gloves"})
  110.    
  111.     sets.engaged.TP = set_combine(sets.engaged, {
  112.         })
  113.  
  114.     -- Ranged Attack
  115.     sets.precast.Ranged = set_combine(sets.idle, {
  116.         head="Sylvan Gapette +2",
  117.         body="Sylvan Caban +2",hands="Iuitl Wristbands",
  118.         waist="Impulse Belt",pants="Nahtirah Trousers",feet="Wurrukatte Boots"})
  119.  
  120.     sets.midcast.Ranged = set_combine(sets.idle, {
  121.         neck="Ocachi Gorget",
  122.         ring1="K'ayres Ring",ring2="Rajas Ring",
  123.         back="Moondoe Mantle",waist="Scout's Belt"})
  124.        
  125.     sets.midcast.Ranged.Acc = set_combine(sets.midcast.Ranged, {
  126.         head="Sylvan Gapette +2",neck="Ej Necklace",
  127.         hands="Buremte Gloves",ring1="Paqichikaji Ring",ring2="Arewe Ring +1"})
  128.        
  129.     sets.midcast.Ranged.TP = set_combine(sets.midcast.Ranged, {
  130.         head="Scout's Beret +2",back="Sylvan Chlamys"})
  131.  
  132.     -- Weaponskill sets
  133.    
  134.     sets.precast.WS = set_combine(sets.midcast.Ranged, {
  135.         ear1="Clearview Earring",
  136.         back="Sylvan Chlamys", waist=gear.ElementalBelt, neck=gear.ElementalGorget})
  137.    
  138.     sets.precast.WS.Acc = set_combine(sets.precast.WS, {
  139.         neck="Ej Necklace",
  140.         hands="Buremte Gloves",ring1="Paqichikaji Ring",
  141.         back="Moondoe Mantle"})
  142.    
  143.     -- Resting sets
  144.     sets.resting = {}
  145.    
  146.     -- Defense sets
  147.     sets.defense.PDT = set_combine(sets.idle, {})
  148.     sets.defense.MDT = set_combine(sets.idle, {})
  149.     sets.Kiting = {feet="Fajin Boots"}
  150.    
  151.     -- Barrage Set
  152.     sets.BarrageMid = set_combine(sets.midcast.Ranged.Acc, {
  153.         hands="Orion Bracers"})
  154.    
  155.     -- List of ammunition that should only be used under unlimited shot
  156.     U_Shot_Ammo = S{'Aeolus Arrow','Animikii Bullet','Crossbow Bolt'}
  157.    
  158.     -- Simply add a line of DefaultAmmo["Weapon"] = "Ammo Name"
  159.     DefaultAmmo = {}
  160.     DefaultAmmo["Eminent Gun"] = "Titanium Bullet"
  161.     DefaultAmmo["Echidna's Bow"] = "Tulfaire Arrow"
  162.     DefaultAmmo["Eminent Bow"] = "Tulfaire Arrow"
  163.     DefaultAmmo["Eminent Crossbow"] = "Bloody Bolt"
  164.     DefaultAmmo["Gandiva"] = "Tulfaire Arrow"
  165. end
  166.  
  167. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  168. -- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
  169.  
  170. function job_precast(spell, action, spellMap, eventArgs)
  171.     if spell.type:lower() == 'weaponskill' then
  172.         if player.status ~= "Engaged" or player.tp < 100 then
  173.             eventArgs.cancel = true
  174.             return
  175.         end
  176.         if (spell.target.distance >8 and not bow_gun_weaponskills:contains(spell.english)) or (spell.target.distance >21) then
  177.             -- Cancel Action if distance is too great, saving TP
  178.             add_to_chat(122,"Distance too great for WeaponSkill /Canceling")
  179.             eventArgs.cancel = true
  180.             return
  181.         elseif state.Defense.Active then
  182.             -- Don't gearswap for weaponskills when Defense is on.
  183.             eventArgs.handled = true
  184.         end
  185.     end
  186.    
  187.     if spell.type == 'Waltz' then
  188.         refine_waltz(spell, action, spellMap, eventArgs)
  189.     end
  190.    
  191.     if spell.name == "Ranged" or spell.type:lower() == 'weaponskill' then
  192.         -- If ammo is empty, or special ammo being used without buff, replace with default ammo
  193.         if U_Shot_Ammo[player.equipment.ammo] and not buffactive['unlimited shot'] or player.equipment.ammo == 'empty' then
  194.             if DefaultAmmo[player.equipment.range] and player.inventory[DefaultAmmo[player.equipment.range]] then
  195.                 add_to_chat(122,"Unlimited Shot not Active or Ammo Empty, Using Default Ammo")
  196.                 equip({ammo=DefaultAmmo[player.equipment.range]})
  197.             else
  198.                 add_to_chat(122,"Either Defaul Ammo is Unavailable or Unknown Weapon. Staying empty")
  199.                 equip({ammo=empty})
  200.             end
  201.         end
  202.         if not buffactive['unlimited shot'] then
  203.             -- If not empty, and if unlimited shot is not active
  204.             -- Not doing it for unlimited shot to avoid excessive log
  205.             if player.equipment.ammo ~= 'empty' then
  206.                 if player.inventory[player.equipment.ammo].count < 15 then
  207.                     add_to_chat(122,"Ammo '"..player.inventory[player.equipment.ammo].shortname.."' running low ("..player.inventory[player.equipment.ammo].count..")")
  208.                 end
  209.             end
  210.         end
  211.     end
  212. end
  213.  
  214. -- Run after the default precast() is done.
  215. -- eventArgs is the same one used in job_precast, in case information needs to be persisted.
  216. -- This is where you place gear swaps you want in precast but applied on top of the precast sets
  217. function job_post_precast(spell, action, spellMap, eventArgs)
  218.  
  219. end
  220.  
  221. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  222. function job_midcast(spell, action, spellMap, eventArgs)
  223.     if spell.name == 'Spectral Jig' and buffactive.sneak then
  224.         -- If sneak is active when using, cancel before completion
  225.         send_command('cancel 71')
  226.     end
  227. end
  228.  
  229. -- Run after the default midcast() is done.
  230. -- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
  231. function job_post_midcast(spell, action, spellMap, eventArgs)
  232.     if buffactive["Barrage"] then
  233.         equip(sets.BarrageMid)
  234.     end
  235. end
  236.  
  237. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  238. function job_aftercast(spell, action, spellMap, eventArgs)
  239.  
  240. end
  241.  
  242. -- Run after the default aftercast() is done.
  243. -- eventArgs is the same one used in job_aftercast, in case information needs to be persisted.
  244. function job_post_aftercast(spell, action, spellMap, eventArgs)
  245.  
  246. end
  247.  
  248. -- Called before the Include starts constructing melee/idle/resting sets.
  249. -- Can customize state or custom melee class values at this point.
  250. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  251. function job_handle_equipping_gear(status, eventArgs)
  252.  
  253. end
  254.  
  255. function customize_idle_set(idleSet)
  256.     return idleSet
  257. end
  258.  
  259. function customize_melee_set(meleeSet)
  260.     return meleeSet
  261. end
  262.  
  263. function job_status_change(newStatus, oldStatus, eventArgs)
  264.    
  265. end
  266.  
  267. -- Called when a player gains or loses a buff.
  268. -- buff == buff gained or lost
  269. -- gain == true if the buff was gained, false if it was lost.
  270. function job_buff_change(buff, gain)
  271.     if status == "Camouflage" then
  272.         if gain_or_loss == "gain" then
  273.             send_command('@wait .5;gs disable body')
  274.         else
  275.             enable('body')
  276.         end
  277.     end
  278. end
  279.  
  280. -------------------------------------------------------------------------------------------------------------------
  281. -- User code that supplements self-commands.
  282. -------------------------------------------------------------------------------------------------------------------
  283.  
  284. -- Called for custom player commands.
  285. function job_self_command(cmdParams, eventArgs)
  286.  
  287. end
  288.  
  289. -- Called by the 'update' self-command, for common needs.
  290. -- Set eventArgs.handled to true if we don't want automatic equipping of gear.
  291. function job_update(cmdParams, eventArgs)
  292.  
  293. end
  294.  
  295. -- Job-specific toggles.
  296. function job_toggle(field)
  297.  
  298. end
  299.  
  300. -- Request job-specific mode lists.
  301. -- Return the list, and the current value for the requested field.
  302. function job_get_mode_list(field)
  303.  
  304. end
  305.  
  306. -- Set job-specific mode values.
  307. -- Return true if we recognize and set the requested field.
  308. function job_set_mode(field, val)
  309.  
  310. end
  311.  
  312. -- Handle auto-targetting based on local setup.
  313. function job_auto_change_target(spell, action, spellMap, eventArgs)
  314.  
  315. end
  316.  
  317. -- Handle notifications of user state values being changed.
  318. function job_state_change(stateField, newValue)
  319.  
  320. end
  321.  
  322. -- Set eventArgs.handled to true if we don't want the automatic display to be run.
  323. function display_current_job_state(eventArgs)
  324.  
  325. end
  326.  
  327. -------------------------------------------------------------------------------------------------------------------
  328. -- Utility functions specific to this job.
  329. -------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement