Advertisement
suteru

COR Lua Try 2

Oct 30th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 41.65 KB | None | 0 0
  1. -- Original: Motenten / Modified: Arislan
  2. -- Haste/DW Detection Requires Gearinfo Addon
  3.  
  4. -------------------------------------------------------------------------------------------------------------------
  5. --  Keybinds
  6. -------------------------------------------------------------------------------------------------------------------
  7.  
  8. --  Modes:      [ F9 ]              Cycle Offense Modes
  9. --              [ CTRL+F9 ]         Cycle Hybrid Modes
  10. --              [ ALT+F9 ]          Cycle Ranged Modes
  11. --              [ WIN+F9 ]          Cycle Weapon Skill Modes
  12. --              [ F10 ]             Emergency -PDT Mode
  13. --              [ ALT+F10 ]         Toggle Kiting Mode
  14. --              [ F11 ]             Emergency -MDT Mode
  15. --              [ F12 ]             Update Current Gear / Report Current Status
  16. --              [ CTRL+F12 ]        Cycle Idle Modes
  17. --              [ ALT+F12 ]         Cancel Emergency -PDT/-MDT Mode
  18. --              [ WIN+C ]           Toggle Capacity Points Mode
  19. --              [ WIN+` ]           Toggle use of Luzaf Ring.
  20. --              [ WIN+Q ]           Quick Draw shot mode selector.
  21. --
  22. --  Abilities:  [ CTRL+- ]          Quick Draw primary shot element cycle forward.
  23. --              [ CTRL+= ]          Quick Draw primary shot element cycle backward.
  24. --              [ ALT+- ]           Quick Draw secondary shot element cycle forward.
  25. --              [ ALT+= ]           Quick Draw secondary shot element cycle backward.
  26. --              [ CTRL+[ ]          Quick Draw toggle target type.
  27. --              [ CTRL+] ]          Quick Draw toggle use secondary shot.
  28. --
  29. --              [ CTRL+C ]          Crooked Cards
  30. --              [ CTRL+` ]          Double-Up
  31. --              [ CTRL+X ]          Fold
  32. --              [ CTRL+S ]          Snake Eye
  33. --              [ CTRL+NumLock ]    Triple Shot
  34. --              [ CTRL+Numpad/ ]    Berserk
  35. --              [ CTRL+Numpad* ]    Warcry
  36. --              [ CTRL+Numpad- ]    Aggressor
  37. --
  38. --  Spells:     [ WIN+, ]           Utsusemi: Ichi
  39. --              [ WIN+. ]           Utsusemi: Ni
  40. --
  41. --  Weapons:    [ CTRL+G ]          Cycles between available ranged weapons
  42. --              [ CTRL+W ]          Toggle Ranged Weapon Lock
  43. --
  44. --  WS:         [ CTRL+Numpad7 ]    Savage Blade
  45. --              [ CTRL+Numpad8 ]    Last Stand
  46. --              [ CTRL+Numpad4 ]    Leaden Salute
  47. --              [ CTRL+Numpad6 ]    Wildfire
  48. --              [ CTRL+Numpad1 ]    Requiescat
  49. --
  50. --  RA:         [ Numpad0 ]         Ranged Attack
  51. --
  52. --
  53. --              (Global-Binds.lua contains additional non-job-related keybinds)
  54.  
  55.  
  56. -------------------------------------------------------------------------------------------------------------------
  57. --  Custom Commands (preface with /console to use these in macros)
  58. -------------------------------------------------------------------------------------------------------------------
  59.  
  60. --  gs c qd                         Uses the currently configured shot on the target, with either <t> or
  61. --                                  <stnpc> depending on setting.
  62. --  gs c qd t                       Uses the currently configured shot on the target, but forces use of <t>.
  63. --
  64. --  gs c cycle mainqd               Cycles through the available steps to use as the primary shot when using
  65. --                                  one of the above commands.
  66. --  gs c cycle altqd                Cycles through the available steps to use for alternating with the
  67. --                                  configured main shot.
  68. --  gs c toggle usealtqd            Toggles whether or not to use an alternate shot.
  69. --  gs c toggle selectqdtarget      Toggles whether or not to use <stnpc> (as opposed to <t>) when using a shot.
  70. --
  71. --  gs c toggle LuzafRing           Toggles use of Luzaf Ring on and off
  72.  
  73.  
  74. -------------------------------------------------------------------------------------------------------------------
  75. -- Setup functions for this job.  Generally should not be modified.
  76. -------------------------------------------------------------------------------------------------------------------
  77.  
  78. -- Initialization function for this job file.
  79. function get_sets()
  80.     mote_include_version = 2
  81.  
  82.     -- Load and initialize the include file.
  83.     include('Mote-Include.lua')
  84. end
  85.  
  86. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  87. function job_setup()
  88.     -- QuickDraw Selector
  89.     state.Mainqd = M{['description']='Primary Shot', 'Fire Shot', 'Ice Shot', 'Wind Shot', 'Earth Shot', 'Thunder Shot', 'Water Shot'}
  90.     state.Altqd = M{['description']='Secondary Shot', 'Fire Shot', 'Ice Shot', 'Wind Shot', 'Earth Shot', 'Thunder Shot', 'Water Shot'}
  91.     state.UseAltqd = M(false, 'Use Secondary Shot')
  92.     state.SelectqdTarget = M(false, 'Select Quick Draw Target')
  93.     state.IgnoreTargetting = M(false, 'Ignore Targetting')
  94.  
  95.     state.DualWield = M(false, 'Dual Wield III')
  96.     state.QDMode = M{['description']='Quick Draw Mode', 'STP', 'Magic Enhance', 'Magic Attack'}
  97.  
  98.     state.Currentqd = M{['description']='Current Quick Draw', 'Main', 'Alt'}
  99.  
  100.     -- Whether to use Luzaf's Ring
  101.     state.LuzafRing = M(false, "Luzaf's Ring")
  102.     -- Whether a warning has been given for low ammo
  103.     state.warned = M(false)
  104.  
  105.     define_roll_values()
  106.  
  107.     lockstyleset = 0
  108. end
  109.  
  110. -------------------------------------------------------------------------------------------------------------------
  111. -- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
  112. -------------------------------------------------------------------------------------------------------------------
  113.  
  114. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  115. function user_setup()
  116.     state.OffenseMode:options('STP', 'Normal', 'Acc')
  117.     state.HybridMode:options('Normal', 'DT')
  118.     state.RangedMode:options('STP', 'Normal', 'Acc')
  119.     state.WeaponskillMode:options('Normal', 'Acc')
  120.     state.CastingMode:options('Normal', 'Resistant')
  121.     state.IdleMode:options('Normal', 'DT', 'Refresh')
  122.  
  123.     state.WeaponLock = M(false, 'Weapon Lock')
  124.     state.Gun = M{['description']='Current Gun', 'Death Penalty', 'Fomalhaut', 'Ataktos'}--, 'Armageddon'
  125.     state.CP = M(false, "Capacity Points Mode")
  126.  
  127.     gear.RAbullet = "Chrono Bullet"
  128.     gear.WSbullet = "Chrono Bullet"
  129.     gear.MAbullet = "Living Bullet"
  130.     gear.QDbullet = "Living Bullet"
  131.     gear.WScape = { name="Camulus's Mantle", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}}
  132.     gear.RAcape = { name="Camulus's Mantle", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Snapshot"+10',}}
  133.     gear.QDcape = {name = "Gunslinger's Cape", augments={'"Mag. Atk. Bns."+5','Enmity-1','"Phantom Roll" ability delay -1','Weapon skill damage +4%'}}
  134.     gear.MABCoat = "Lanun Frac +3"
  135.     gear.DWCape = { name="Camulus's Mantle", augments={'DEX+20','Accuracy +20 Attack +20','"Dual Wield"+10','Phys. dmg. taken -10%'}}
  136.     options.ammo_warning_limit = 10
  137.  
  138.     -- Additional local binds
  139.    -- include('Global-Binds.lua') -- OK to remove this line
  140.   --  include('Global-GEO-Binds.lua') -- OK to remove this line
  141.  
  142.     send_command('exec cor/cor.txt')
  143.     send_command('exec sd_cor_menu.txt')
  144.  
  145.  
  146.  
  147.     Haste = 0
  148.     DW_needed = 0
  149.     DW = false
  150.     moving = false
  151.     update_combat_form()
  152.     determine_haste_group()
  153. end
  154.  
  155.  
  156. -- Called when this job file is unloaded (eg: job change)
  157. function user_unload()
  158.  
  159. end
  160.  
  161. -- Define sets and vars used by this job file.
  162. function init_gear_sets()
  163.  
  164.     ------------------------------------------------------------------------------------------------
  165.     ---------------------------------------- Precast Sets ------------------------------------------
  166.     ------------------------------------------------------------------------------------------------
  167.  
  168.     sets.precast.JA['Triple Shot'] = {body="Chasseur's Frac +1"}
  169.     sets.precast.JA['Snake Eye'] = {legs="Lanun Culottes +1"}
  170.     sets.precast.JA['Wild Card'] = {feet="Lanun Bottes +3"}
  171.     sets.precast.JA['Cutting Cards'] = {feet="Lanun Bottes +3"}
  172.     sets.precast.JA['Random Deal'] = {body="Lanun Frac +3"}
  173.  
  174.     sets.precast.CorsairRoll = {
  175.         head="Lanun Tricorne +2",
  176.         neck="Regal Necklace",
  177.         hands="Chasseur's Gants +1",
  178.         legs="Desultor Tassets",
  179.         feet="Lanun Bottes +3", --6/0
  180.         back=gear.PRcape
  181.         }
  182.    
  183.  
  184.  
  185.     sets.precast.CorsairRoll["Caster's Roll"] = set_combine(sets.precast.CorsairRoll, {legs="Chas. Culottes +1"})
  186.     sets.precast.CorsairRoll["Courser's Roll"] = set_combine(sets.precast.CorsairRoll, {feet="Chass. Bottes +1"})
  187.     sets.precast.CorsairRoll["Blitzer's Roll"] = set_combine(sets.precast.CorsairRoll, {head="Chass. Tricorne +1"})
  188.     sets.precast.CorsairRoll["Tactician's Roll"] = set_combine(sets.precast.CorsairRoll, {body="Chasseur's Frac +1"})
  189.     sets.precast.CorsairRoll["Allies' Roll"] = set_combine(sets.precast.CorsairRoll, {hands="Chasseur's Gants +1"})
  190.  
  191.     sets.precast.LuzafRing = set_combine(sets.precast.CorsairRoll, {ring1="Luzaf's Ring"})
  192.     sets.precast.FoldDoubleBust = {hands="Lanun Gants +1"}
  193.  
  194.     sets.precast.Waltz = {
  195.         body="Passion Jacket",
  196.         ring1="Asklepian Ring",
  197.         ring2="Valseur's Ring",
  198.         }
  199.  
  200.    
  201.     sets.precast.Waltz['Healing Waltz'] = sets.precast.Waltz
  202.  
  203.     sets.precast.FC = {
  204.         head="Ejekamal Mask", --14
  205.         body=gear.Taeon_FC_body, --9
  206.         hands="Leyline Gloves", --8
  207.         legs="Adhemar Kecks", --5
  208.         feet="Adhe. Gamashes +1", --8
  209.         neck="Jeweled Collar", --5
  210.         ear1="Etiolation Earring", --2
  211.         ear2="Loquacious Earring", --2
  212.         ring1="Prolix Ring", --6(4)
  213.         ring2="Veneficium Ring", --4
  214.         }
  215.  
  216.     sets.precast.FC.Utsusemi = set_combine(sets.precast.FC, {
  217.         body="Passion Jacket",
  218.         })
  219.  
  220.     -- (10% Snapshot from JP Gifts)
  221.      
  222.     sets.precast.RA = {ammo=gear.RAbullet,
  223.         head="Aurore Beret +1",
  224.         body="Laksa. Frac +3",
  225.         hands="Carmine Fin. Ga. +1",
  226.         neck="Comm. Charm +1",
  227.         ring2="Haverton Ring",
  228.         back=gear.RAcape,
  229.         waist="Impulse Belt",
  230.         legs="Laksa. Trews +3",
  231.         feet="Adhe. Gamashes +1"}
  232.  
  233.     sets.precast.RA.Flurry1 = set_combine(sets.precast.RA, {
  234.         body="Laksa. Frac +3", --0/20
  235.         }) --47/46
  236.  
  237.     sets.precast.RA.Flurry2 = set_combine(sets.precast.RA.Flurry1, {
  238.         head="Chass. Tricorne +1", --0/14
  239.         feet="Pursuer's Gaiters", --0/10
  240.         waist="Impulse Belt", --3/0
  241.         }) --30/65
  242.  
  243.  
  244.     ------------------------------------------------------------------------------------------------
  245.     ------------------------------------- Weapon Skill Sets ----------------------------------------
  246.     ------------------------------------------------------------------------------------------------
  247.  
  248.  
  249.         sets.precast.WS = {ammo=gear.RAbullet,
  250.         head="Lanun Tricorne +2",
  251.         neck=gear.ElementalGorget,
  252.         ear1="Steelflash Earring",
  253.         ear2="Ishvara Earring",
  254.         body="Laksa. Frac +3",
  255.         hands="Meg. Gloves +2",
  256.         ear1="Moonshade Earring",
  257.         ring1="Rajas Ring",
  258.         ring2="Mars's Ring",
  259.         back=gear.WScape,
  260.         waist=gear.ElementalBelt,
  261.         legs="Carmine Cuisses +1",
  262.         feet="Lanun Bottes +3"}
  263.  
  264.     sets.precast.WS.Acc = set_combine(sets.precast.WS, {
  265.         head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  266.         body="Meg. Cuirie +1",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Mars's Ring",
  267.         back="Bleating Mantle",waist="Kentarch Belt",legs="Samnuha Tights",feet="Lanun Bottes +3"
  268.         })
  269.  
  270.     sets.precast.WS['Last Stand'] = {ammo=gear.WSbullet,
  271.         head="Lanun Tricorne +2",neck="Light Gorget",ear1="Moonshade Earring",ear2="Ishvara Earring",
  272.         body="Laksa. Frac +3",hands="Meg. Gloves +2",ring1="Dingir Ring",ring2="Apate Ring",
  273.         back=gear.WScape,waist="Light Belt",legs="Meg. Chausses +2",feet="Lanun Bottes +3"}
  274.  
  275.     sets.precast.WS['Last Stand'].Acc = set_combine(sets.precast.WS['Last Stand'], {
  276.         neck="Iskur Gorget",
  277.         ear2="Volley Earring",
  278.         ring2="Haverton Ring",
  279.         waist="Eschan Stone",
  280.         })
  281.  
  282.  
  283.  
  284.     sets.precast.WS['Hot Shot'] = sets.precast.WS['Wildfire']
  285.  
  286.     sets.precast.WS['Leaden Salute'] = {ammo=gear.MAbullet,
  287.         head="Pixie Hairpin +1",neck="Comm. Charm +1",ear1="Moonshade Earring",ear2="Friomisi Earring",
  288.         body=gear.MABCoat,hands="Carmine Fin. Ga. +1",ring1="Dingir Ring",ring2="Archon Ring",
  289.         back=gear.WScape,waist="Svelt. Gouriz +1",legs="Herculean Trousers",feet="Lanun Bottes +3"}
  290.        
  291.  
  292.  
  293.     sets.precast.WS['Leaden Salute'].FullTP = {ear1="Novio Earring", waist="Svelt. Gouriz +1"}
  294.  
  295.     sets.precast.WS['Evisceration'] = sets.precast.WS
  296.  
  297.     sets.precast.WS['Evisceration'].Acc = sets.precast.WS.Acc
  298.    
  299.     sets.precast.WS['Wildfire'] = set_combine(sets.precast.WS['Leaden Salute'], {
  300.         head="Herculean Helm",
  301.         ear1="Novio Earring",
  302.         ring2="Arvina Ringlet +1",
  303.         waist="Eschan Stone",
  304.         })
  305.    
  306.     sets.precast.WS['Savage Blade'] = {ammo=gear.WSbullet,
  307.         head="Meghanada Visor +2",neck="Breeze Gorget",ear1="Moonshade Earring",ear2="Ishvara Earring",
  308.         body="Laksa. Frac +3",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Rufescent Ring",
  309.         back=gear.WScape,waist="Breeze Belt",legs="Meg. Chausses +2",feet="Lanun Bottes +3"}
  310.  
  311.     sets.precast.WS['Savage Blade'].Acc = set_combine(sets.precast.WS['Savage Blade'], {ammo=gear.WSbullet,
  312.         head="Meghanada Visor +2",neck="Breeze Gorget",ear1="Moonshade Earring",ear2="Ishvara Earring",
  313.         body="Laksa. Frac +3",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Rufescent Ring",
  314.         back=gear.WScape,waist="Breeze Belt",legs="Meg. Chausses +2",feet="Lanun Bottes +3"})
  315.        
  316.  
  317.     sets.precast.WS['Swift Blade'] = set_combine(sets.precast.WS, {
  318.         head="Meghanada Visor +2",neck="Clotharius Torque",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  319.         body="Rawhide Vest",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Mars's Ring",
  320.         back="Bleating Mantle",waist="Windbuffet Belt",legs="Samnuha Tights",feet="Herculean Boots"
  321.         })
  322.  
  323.     sets.precast.WS['Swift Blade'].Acc = set_combine(sets.precast.WS['Swift Blade'], {
  324.         head="Meghanada Visor +2",neck="Clotharius Torque",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  325.         body="Rawhide Vest",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Mars's Ring",
  326.         back="Bleating Mantle",waist="Windbuffet Belt",legs="Samnuha Tights",feet="Herculean Boots"
  327.         })
  328.  
  329.     sets.precast.WS['Requiescat'] = set_combine(sets.precast.WS['Swift Blade'], {
  330.         hands="Meg. Gloves +2",
  331.         ear1="Moonshade Earring",
  332.         ear2="Telos Earring",
  333.         ring2="Rufescent Ring",
  334.         }) --MND
  335.  
  336.     sets.precast.WS['Requiescat'].Acc = set_combine(sets.precast.WS['Requiescat'], {
  337.         head="Meghanada Visor +2",
  338.         ear1="Cessance Earring",
  339.         })
  340.  
  341.     sets.precast.WS['Aeolian Edge'] = set_combine(sets.precast.WS['Wildfire'], {
  342.         ear1="Moonshade Earring",
  343.         })
  344.  
  345.     ------------------------------------------------------------------------------------------------
  346.     ---------------------------------------- Midcast Sets ------------------------------------------
  347.     ------------------------------------------------------------------------------------------------
  348.  
  349.     sets.midcast.FastRecast = sets.precast.FC
  350.  
  351.     sets.midcast.SpellInterrupt = {
  352.         legs="Carmine Cuisses +1", --20
  353.         ring1="Evanescence Ring", --5
  354.         }
  355.  
  356.     sets.midcast.Cure = {
  357.         neck="Incanter's Torque",
  358.         ear1="Roundel Earring",
  359.         ear2="Mendi. Earring",
  360.         ring1="Lebeche Ring",
  361.         ring2="Haoma's Ring",
  362.         waist="Bishop's Sash",
  363.         }
  364.  
  365.     sets.midcast.Utsusemi = sets.midcast.SpellInterrupt
  366.  
  367.     -- Occult Acumen Set
  368.   --[[  sets.midcast['Dark Magic'] = {
  369.         ammo=gear.QDbullet,
  370.         head=gear.Herc_MAB_head,
  371.         body="Mummu Jacket +2",
  372.         hands=gear.Adhemar_B_hands,
  373.         legs="Chas. Culottes +1",
  374.         feet="Carmine Greaves +1",
  375.         neck="Iskur Gorget",
  376.         ear1="Dedition Earring",
  377.         ear2="Telos Earring",
  378.         ring1="Archon Ring",
  379.         ring2="Dingir Ring",
  380.         back=gear.COR_RA_Cape,
  381.         waist="Oneiros Rope",
  382.         } ]]
  383.  
  384.     sets.midcast.CorsairShot = {ammo=gear.QDbullet,
  385.         head="Herculean Helm",neck="Sanctity Necklace",ear1="Novio Earring",ear2="Friomisi Earring",
  386.         body=gear.MABCoat,hands="Carmine Fin. Ga. +1",ring1="Dingir Ring",ring2="Acumen Ring",
  387.         back=gear.WScape,waist="Eschan Stone",legs="Herculean Trousers",feet="Chass. Bottes +1"}
  388.  
  389.  
  390.     sets.midcast.CorsairShot.Resistant = {ammo=gear.QDbullet,
  391.         head="Blood Mask",neck="Comm. Charm +1",ear1="Lifestorm Earring",ear2="Psystorm Earring",
  392.         body="Chasseur's Frac +1",hands="Pursuer's Cuffs",ring1="Stormsoul Ring",ring2="Garuda Ring",
  393.         back=gear.WScape,waist="Eschan Stone",legs="Lanun Culottes +1",feet="Chass. Bottes +1"}
  394.  
  395.     sets.midcast.CorsairShot['Light Shot'] = sets.midcast.CorsairShot.Resistant
  396.     sets.midcast.CorsairShot['Dark Shot'] = sets.midcast.CorsairShot.Resistant
  397.     sets.midcast.CorsairShot.Enhance = {feet="Chass. Bottes +1"}
  398.  
  399.     -- Ranged gear
  400.     sets.midcast.RA = {ammo=gear.RAbullet,
  401.         head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Neritic Earring",ear2="Enervating Earring",
  402.         body="Mummu Jacket +2",hands="Adhemar Wrist. +1",ring1="Rajas Ring",ring2="Haverton Ring",
  403.         back=gear.RAcape,waist="Yemaya Belt",legs="Adhemar Kecks",feet="Adhe. Gamashes +1"}
  404.  
  405.     sets.midcast.RA.Acc = {ammo=gear.RAbullet,
  406.         head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Volley Earring",ear2="Enervating Earring",
  407.         body="Laksa. Frac +3",hands="Adhemar Wrist. +1",ring1="Hajduk Ring",ring2="Haverton Ring",
  408.         back=gear.RAcape,waist="Eschan Stone",legs="Laksa. Trews +3",feet="Meg. Jam. +1"}
  409.  
  410.  
  411.     sets.midcast.RA.STP = set_combine(sets.midcast.RA, {
  412.         feet="Carmine Greaves +1",
  413.         })
  414.  
  415.     sets.TripleShot = {ammo=gear.RAbullet,
  416.         head="Oshosi Mask",neck="Iskur Gorget",ear1="Volley Earring",ear2="Enervating Earring",
  417.         body="Chasseur's Frac +1",hands="Adhemar Wrist. +1",ring1="Rajas Ring",ring2="Haverton Ring",
  418.         back=gear.RAcape,waist="Yemaya Belt",legs="Oshosi Trousers",feet="Adhe. Gamashes +1"}
  419.        
  420.     sets.TripleShot.Acc = set_combine(sets.TripleShot, {
  421.         ring1="Hajduk Ring",waist="Eschan Stone",feet="Meg. Jam. +1",
  422.         })
  423.        
  424.     sets.TripleShotCritical = {ammo=gear.RAbullet,
  425.         head="Oshosi Mask",neck="Iskur Gorget",ear1="Volley Earring",ear2="Enervating Earring",
  426.         body="Chasseur's Frac +1",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Haverton Ring",
  427.         back=gear.WScape,waist="Eschan Stone",legs="Oshosi Trousers",feet="Adhe. Gamashes +1"}
  428.  
  429.  
  430.     ------------------------------------------------------------------------------------------------
  431.     ----------------------------------------- Idle Sets --------------------------------------------
  432.     ------------------------------------------------------------------------------------------------
  433.  
  434.     sets.resting = {}
  435.  
  436.     sets.idle = {ammo=gear.RAbullet,
  437.         head="Lanun Tricorne +2",neck="Comm. Charm +1",ear1="Novio Earring",ear2="Enervating Earring",
  438.         body="Lanun Frac +3",hands="Carmine Fin. Ga. +1",ring1="Dingir Ring",ring2="Haverton Ring",
  439.         back=gear.WScape,waist="Eschan Stone",legs="Carmine Cuisses +1",feet="Lanun Bottes +3"}
  440.    
  441.     sets.idle.Dyna = set_combine(sets.idle, {neck="Comm. Charm +1"})
  442.  
  443.     sets.idle.DT = {
  444.         head="Fugacity Beret +1",neck="Twilight Torque",
  445.         body="Lanun Frac +3",hands="Taeon Gloves",ring1="Gelatinous Ring +1",ring2="Gelatinous Ring",
  446.         back="Solemnity Cape",waist="Flume Belt",legs="Chas. Culottes +1",feet="Lanun Bottes +3"}
  447.  
  448.     sets.idle.Refresh = set_combine(sets.idle, {
  449.         head=gear.Herc_Idle_head,
  450.         --body="Mekosu. Harness",
  451.         legs="Rawhide Trousers",
  452.         ring1="Stikini Ring +1",
  453.         ring2="Stikini Ring +1",
  454.         })
  455.  
  456.     sets.idle.Town = sets.idle
  457.  
  458.  
  459.     ------------------------------------------------------------------------------------------------
  460.     ---------------------------------------- Defense Sets ------------------------------------------
  461.     ------------------------------------------------------------------------------------------------
  462.  
  463.     sets.defense.PDT = sets.idle.DT
  464.     sets.defense.MDT = sets.idle.DT
  465.  
  466.     sets.Kiting = {legs="Carmine Cuisses +1"}
  467.  
  468.  
  469.     ------------------------------------------------------------------------------------------------
  470.     ---------------------------------------- Engaged Sets ------------------------------------------
  471.     ------------------------------------------------------------------------------------------------
  472.  
  473.     -- Variations for TP weapon and (optional) offense/defense modes.  Code will fall back on previous
  474.     -- sets if more refined versions aren't defined.
  475.     -- If you create a set with both offense and defense modes, the offense mode should be first.
  476.     -- EG: sets.engaged.Dagger.Accuracy.Evasion
  477.  
  478.     sets.engaged = {ammo=gear.RAbullet,
  479.         head="Meghanada Visor +2",neck="Clotharius Torque",ear1="Eabani Earring",ear2="Suppanomimi",
  480.         body="Adhemar Jacket +1",hands="Floral Gauntlets",ring1="Petrov Ring",ring2="Epona's Ring",
  481.         back=gear.DWCape,waist="Kentarch Belt",legs="Carmine Cuisses +1",feet="Taeon Boots"}
  482.        
  483.     sets.engaged.Dyna = set_combine(sets.engaged, {neck="Comm. Charm +1"})
  484.  
  485.     sets.engaged.Acc = {ammo=gear.RAbullet,
  486.         head="Meghanada Visor +2",neck="Iqabi Necklace",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  487.         body="Adhemar Jacket +1",hands="Adhemar Wrist. +1",ring1="Petrov Ring",ring2="Mars's Ring",
  488.         back=gear.DWCape,waist="Kentarch Belt",legs="Carmine Cuisses +1",feet="Lanun Bottes +3"}
  489.  
  490.     sets.engaged.STP = set_combine(sets.engaged, {
  491.         feet="Adhe. Gamashes +1",
  492.         })
  493.  
  494.     -- * DNC Subjob DW Trait: +15%
  495.     -- * NIN Subjob DW Trait: +25%
  496.  
  497.     -- No Magic Haste (74% DW to cap)
  498.     sets.engaged.DW = {ammo=gear.RAbullet,
  499.         head="Meghanada Visor +2",neck="Clotharius Torque",ear1="Eabani Earring",ear2="Suppanomimi",
  500.         body="Adhemar Jacket +1",hands="Floral Gauntlets",ring1="Petrov Ring",ring2="Epona's Ring",
  501.         back=gear.DWCape,waist="Windbuffet Belt",legs="Carmine Cuisses +1",feet="Taeon Boots"}
  502.  
  503.     sets.engaged.DW.Acc = {ammo=gear.RAbullet,
  504.         head="Meghanada Visor +2",neck="Iqabi Necklace",ear1="Steelflash Earring",ear2="Bladeborn Earring",
  505.         body="Adhemar Jacket +1",hands="Adhemar Wrist. +1",ring1="Petrov Ring",ring2="Mars's Ring",
  506.         back=gear.DWCape,waist="Kentarch Belt",legs="Carmine Cuisses +1",feet="Lanun Bottes +3"}
  507.  
  508.  
  509.  
  510.     ------------------------------------------------------------------------------------------------
  511.     ---------------------------------------- Hybrid Sets -------------------------------------------
  512.     ------------------------------------------------------------------------------------------------
  513.  
  514.     sets.engaged.Hybrid = {
  515.         head=gear.Adhemar_D_head, --4/0
  516.         neck="Loricate Torque +1", --6/6
  517.         ring2="Defending Ring", --10/10
  518.         }
  519.  
  520.  
  521.     ------------------------------------------------------------------------------------------------
  522.     ---------------------------------------- Special Sets ------------------------------------------
  523.     ------------------------------------------------------------------------------------------------
  524.  
  525.     sets.buff.Doom = {ring1="Eshmun's Ring", ring2="Eshmun's Ring", waist="Gishdubar Sash"}
  526.  
  527.     sets.Obi = {waist="Hachirin-no-Obi"}
  528.     sets.Obi2 = {waist="Hachirin-no-Obi"}
  529.     sets.CP = {back="Mecisto. Mantle"}
  530.     sets.Reive = {neck="Ygnas's Resolve +1"}
  531.  
  532. end
  533.  
  534.  
  535. -------------------------------------------------------------------------------------------------------------------
  536. -- Job-specific hooks for standard casting events.
  537. -------------------------------------------------------------------------------------------------------------------
  538.  
  539. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  540. -- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
  541. function job_precast(spell, action, spellMap, eventArgs)
  542.     -- Check that proper ammo is available if we're using ranged attacks or similar.
  543.     if spell.action_type == 'Ranged Attack' or spell.type == 'WeaponSkill' or spell.type == 'CorsairShot' then
  544.         do_bullet_checks(spell, spellMap, eventArgs)
  545.     end
  546.  
  547.     -- Gear
  548.     if (spell.type == 'CorsairRoll' or spell.english == "Double-Up") then
  549.         if player.status ~= 'Engaged' then
  550.             equip(sets.precast.CorsairRoll.Gun)
  551.         end
  552.         if state.LuzafRing.value then
  553.             equip(sets.precast.LuzafRing)
  554.         end
  555.     elseif spell.type == 'CorsairShot' and state.CastingMode.value == 'Resistant' then
  556.         classes.CustomClass = 'Acc'
  557.     end
  558.  
  559.     if spell.english == 'Fold' and buffactive['Bust'] == 2 then
  560.         if sets.precast.FoldDoubleBust then
  561.             equip(sets.precast.FoldDoubleBust)
  562.             eventArgs.handled = true
  563.         end
  564.     end
  565.    
  566.     if spellMap == 'Utsusemi' then
  567.             if buffactive['Copy Image (3)'] or buffactive['Copy Image (4+)'] then
  568.                 cancel_spell()
  569.                 add_to_chat(123, '**!! '..spell.english..' Canceled: [3+ IMAGES] !!**')
  570.                 eventArgs.handled = true
  571.                     return
  572.             elseif buffactive['Copy Image'] or buffactive['Copy Image (2)'] then
  573.             send_command('cancel 66; cancel 444; cancel Copy Image; cancel Copy Image (2)')
  574.             end
  575.  
  576.     end
  577. end
  578.  
  579. function job_post_precast(spell, action, spellMap, eventArgs)
  580.     if (spell.type == 'CorsairRoll' or spell.english == "Double-Up") then
  581.         if player.status ~= 'Engaged' then
  582.             equip(sets.precast.CorsairRoll.Gun)
  583.         end
  584.     elseif spell.action_type == 'Ranged Attack' then
  585.         if flurry == 2 then
  586.             equip(sets.precast.RA.Flurry2)
  587.         elseif flurry == 1 then
  588.             equip(sets.precast.RA.Flurry1)
  589.         end
  590.     -- Equip obi if weather/day matches for WS.
  591.     elseif spell.type == 'WeaponSkill' then
  592.         if spell.english == 'Leaden Salute' then
  593.             if world.weather_element == 'Dark' or world.day_element == 'Dark' then
  594.                 equip(sets.Obi)
  595.             end
  596.             if player.tp > 2900 then
  597.                 equip(sets.precast.WS['Leaden Salute'].FullTP)
  598.             end
  599.         elseif spell.english == 'Wildfire' and (world.weather_element == 'Fire' or world.day_element == 'Fire') then
  600.             equip(sets.Obi)
  601.         end
  602.     end
  603. end
  604.  
  605. function precast()
  606.     if player.subjob == 'NIN' then
  607.         if spell.name == 'Stutter Step' then
  608.             cancel_spell()
  609.             send_command('input /ja "Utsusemi: Ichi" <me>')
  610.         elseif spell.name == 'Violent Flourish' then
  611.             cancel_spell()
  612.             send_command('input /ja "Utsusemi: Ni" <me>')
  613.         end
  614.     elseif player.subjob == 'RNG' then
  615.         if spell.name == 'Stutter Step' then
  616.             cancel_spell()
  617.             send_command('input /ja "Sharpshot" <me>')
  618.         elseelseif spell.name == 'Violent Flourish' then
  619.             cancel_spell()
  620.             send_command('input /ja "Barrage" <me>')
  621.         end
  622.     elseif player.subjob == 'WAR' then
  623.         if spell.name == 'Stutter Step' then
  624.             cancel_spell()
  625.             send_command('input /ja "Berserk <me>')
  626.         elseelseif spell.name == 'Violent Flourish' then
  627.             cancel_spell()
  628.             send_command('input /ja "Warcry" <me>')
  629.         end
  630.     elseif player.subjob == 'SAM' then
  631.         if spell.name == 'Stutter Step' then
  632.             cancel_spell()
  633.             send_command('input /ja "Meditate" <me>')
  634.         elseelseif spell.name == 'Violent Flourish' then
  635.             cancel_spell()
  636.             send_command('input /ja "Sekkanoki" <me>')
  637.         end
  638.     elseif player.subjob == 'THF' then
  639.         if spell.name == 'Stutter Step' then
  640.             cancel_spell()
  641.             send_command('input /ja "Trick Attack" <me>')
  642.         elseelseif spell.name == 'Violent Flourish' then
  643.             cancel_spell()
  644.             send_command('input /ja "Sneak Attack" <me>')
  645.         end
  646.     end
  647. end
  648. function job_post_midcast(spell, action, spellMap, eventArgs)
  649.     -- Equip obi if weather/day matches for Quick Draw.
  650.     if spell.type == 'CorsairShot' then
  651.         if (spell.element == world.day_element or spell.element == world.weather_element) and
  652.         (spell.english ~= 'Light Shot' and spell.english ~= 'Dark Shot') then
  653.             equip(sets.Obi2)
  654.         end
  655.         if state.QDMode.value == 'Magic Enhance' then
  656.             equip(sets.midcast.CorsairShot.Enhance)
  657.         elseif state.QDMode.value == 'STP' then
  658.             equip(sets.midcast.CorsairShot.STP)
  659.         end
  660.     elseif spell.action_type == 'Ranged Attack' then
  661.         if buffactive['Triple Shot'] then
  662.             equip(sets.TripleShot)
  663.             if state.RangedMode.value == 'Acc' then
  664.                 equip(sets.TripleShot.Acc)
  665.             end
  666.             if buffactive['Aftermath: Lv.3'] and player.equipment.main == "Armageddon" then
  667.                 equip(sets.TripleShotCritical)
  668.             end
  669.         elseif buffactive['Aftermath: Lv.3'] and player.equipment.main == "Armageddon" then
  670.             equip(sets.midcast.RA.Critical)
  671.         end
  672.     end
  673. end
  674.  
  675. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  676. function job_aftercast(spell, action, spellMap, eventArgs)
  677.     if spell.type == 'CorsairRoll' and not spell.interrupted then
  678.         display_roll_info(spell)
  679.     end
  680.     if spell.english == "Light Shot" then
  681.         send_command('@timers c "Light Shot ['..spell.target.name..']" 60 down abilities/00195.png')
  682.     end
  683. end
  684.  
  685. function job_buff_change(buff,gain)
  686. -- If we gain or lose any flurry buffs, adjust gear.
  687.     if S{'flurry'}:contains(buff:lower()) then
  688.         if not gain then
  689.             flurry = nil
  690.             --add_to_chat(122, "Flurry status cleared.")
  691.         end
  692.         if not midaction() then
  693.             handle_equipping_gear(player.status)
  694.         end
  695.     end
  696.  
  697. --    if buffactive['Reive Mark'] then
  698. --        if gain then
  699. --            equip(sets.Reive)
  700. --            disable('neck')
  701. --        else
  702. --            enable('neck')
  703. --        end
  704. --    end
  705.  
  706.    -- if buff == "doom" then
  707.      --   if gain then
  708.        --     equip(sets.buff.Doom)
  709.          --   send_command('@input /p Doomed.')
  710.           --  disable('ring1','ring2','waist')
  711.        -- else
  712.         --    enable('ring1','ring2','waist')
  713.          --   handle_equipping_gear(player.status)
  714.        -- end
  715.    -- end
  716.  
  717. end
  718.  
  719. -- Handle notifications of general user state change.
  720. function job_state_change(stateField, newValue, oldValue)
  721.     if state.WeaponLock.value == true then
  722.         disable('ranged')
  723.     else
  724.         enable('ranged')
  725.     end
  726. end
  727.  
  728. -------------------------------------------------------------------------------------------------------------------
  729. -- User code that supplements standard library decisions.
  730. -------------------------------------------------------------------------------------------------------------------
  731.  
  732. -- Called by the 'update' self-command, for common needs.
  733. -- Set eventArgs.handled to true if we don't want automatic equipping of gear.
  734. function job_handle_equipping_gear(playerStatus, eventArgs)
  735.     update_combat_form()
  736.     determine_haste_group()
  737. end
  738.  
  739. function job_update(cmdParams, eventArgs)
  740.     handle_equipping_gear(player.status)
  741. end
  742.  
  743. function update_combat_form()
  744.     if DW == true then
  745.         state.CombatForm:set('DW')
  746.     elseif DW == false then
  747.         state.CombatForm:reset()
  748.     end
  749. end
  750.  
  751. -- Modify the default idle set after it was constructed.
  752.  
  753. --[[function customize_idle_set(idleSet)
  754.     if state.CP.current == 'on' then
  755.         equip(sets.CP)
  756.         disable('back')
  757.     else
  758.         enable('back')
  759.     end
  760.     return idleSet
  761. end ]]
  762.  
  763. -- Handle auto-targetting based on local setup.
  764. function job_auto_change_target(spell, action, spellMap, eventArgs)
  765.     if spell.type == 'CorsairShot' then
  766.         if state.IgnoreTargetting.value == true then
  767.             state.IgnoreTargetting:reset()
  768.             eventArgs.handled = true
  769.         end
  770.  
  771.         eventArgs.SelectNPCTargets = state.SelectqdTarget.value
  772.     end
  773. end
  774.  
  775.  
  776. -- Set eventArgs.handled to true if we don't want the automatic display to be run.
  777. function display_current_job_state(eventArgs)
  778.     local msg = ''
  779.  
  780.     msg = msg .. '[ Offense/Ranged: '..state.OffenseMode.current
  781.  
  782.     if state.HybridMode.value ~= 'Normal' then
  783.         msg = msg .. '/' .. state.HybridMode.value
  784.     end
  785.  
  786.     msg = msg .. '/' ..state.RangedMode.current .. ' ]'
  787.  
  788.     if state.WeaponskillMode.value ~= 'Normal' then
  789.         msg = msg .. '[ WS: '..state.WeaponskillMode.current .. ' ]'
  790.     end
  791.  
  792.     if state.DefenseMode.value ~= 'None' then
  793.         msg = msg .. '[ Defense: ' .. state.DefenseMode.value .. state[state.DefenseMode.value .. 'DefenseMode'].value .. ' ]'
  794.     end
  795.  
  796.     if state.Kiting.value then
  797.         msg = msg .. '[ Kiting Mode: ON ]'
  798.     end
  799.  
  800.     msg = msg .. '[ *'..state.Mainqd.current
  801.  
  802.     if state.UseAltqd.value == true then
  803.         msg = msg .. '/'..state.Altqd.current
  804.     end
  805.  
  806.     msg = msg .. ' ('
  807.  
  808.     if state.QDMode.value then
  809.         msg = msg .. state.QDMode.current .. ') '
  810.     end
  811.  
  812.     msg = msg .. ']'
  813.  
  814.     add_to_chat(060, msg)
  815.  
  816.     eventArgs.handled = true
  817. end
  818.  
  819. -------------------------------------------------------------------------------------------------------------------
  820. -- Utility functions specific to this job.
  821. -------------------------------------------------------------------------------------------------------------------
  822.  
  823. --Read incoming packet to differentiate between Haste/Flurry I and II
  824. windower.register_event('action',
  825.     function(act)
  826.         --check if you are a target of spell
  827.         local actionTargets = act.targets
  828.         playerId = windower.ffxi.get_player().id
  829.         isTarget = false
  830.         for _, target in ipairs(actionTargets) do
  831.             if playerId == target.id then
  832.                 isTarget = true
  833.             end
  834.         end
  835.         if isTarget == true then
  836.             if act.category == 4 then
  837.                 local param = act.param
  838.                 if param == 845 and flurry ~= 2 then
  839.                     --add_to_chat(122, 'Flurry Status: Flurry I')
  840.                     flurry = 1
  841.                 elseif param == 846 then
  842.                     --add_to_chat(122, 'Flurry Status: Flurry II')
  843.                     flurry = 2
  844.                 end
  845.             end
  846.         end
  847.     end)
  848.  
  849. function determine_haste_group()
  850.     classes.CustomMeleeGroups:clear()
  851.     if DW == true then
  852.         if DW_needed <= 11 then
  853.             classes.CustomMeleeGroups:append('MaxHaste')
  854.         elseif DW_needed > 11 and DW_needed <= 21 then
  855.             classes.CustomMeleeGroups:append('MaxHastePlus')
  856.         elseif DW_needed > 21 and DW_needed <= 27 then
  857.             classes.CustomMeleeGroups:append('HighHaste')
  858.         elseif DW_needed > 27 and DW_needed <= 31 then
  859.             classes.CustomMeleeGroups:append('MidHaste')
  860.         elseif DW_needed > 31 and DW_needed <= 42 then
  861.             classes.CustomMeleeGroups:append('LowHaste')
  862.         elseif DW_needed > 42 then
  863.             classes.CustomMeleeGroups:append('')
  864.         end
  865.     end
  866. end
  867.  
  868. function job_self_command(cmdParams, eventArgs)
  869.     if cmdParams[1] == 'qd' then
  870.         if cmdParams[2] == 't' then
  871.             state.IgnoreTargetting:set()
  872.         end
  873.  
  874.         local doqd = ''
  875.         if state.UseAltqd.value == true then
  876.             doqd = state[state.Currentqd.current..'qd'].current
  877.             state.Currentqd:cycle()
  878.         else
  879.             doqd = state.Mainqd.current
  880.         end
  881.  
  882.         send_command('@input /ja "'..doqd..'" <t>')
  883.     end
  884.  
  885.     gearinfo(cmdParams, eventArgs)
  886. end
  887.  
  888. function gearinfo(cmdParams, eventArgs)
  889.     if cmdParams[1] == 'gearinfo' then
  890.         if type(tonumber(cmdParams[2])) == 'number' then
  891.             if tonumber(cmdParams[2]) ~= DW_needed then
  892.             DW_needed = tonumber(cmdParams[2])
  893.             DW = true
  894.             end
  895.         elseif type(cmdParams[2]) == 'string' then
  896.             if cmdParams[2] == 'false' then
  897.                   DW_needed = 0
  898.                 DW = false
  899.             end
  900.         end
  901.         if type(tonumber(cmdParams[3])) == 'number' then
  902.             if tonumber(cmdParams[3]) ~= Haste then
  903.                 Haste = tonumber(cmdParams[3])
  904.             end
  905.         end
  906.         if type(cmdParams[4]) == 'string' then
  907.             if cmdParams[4] == 'true' then
  908.                 moving = true
  909.             elseif cmdParams[4] == 'false' then
  910.                 moving = false
  911.             end
  912.         end
  913.     end
  914. end
  915.  
  916. function define_roll_values()
  917.     rolls = {
  918.         ["Corsair's Roll"] =    {lucky=5, unlucky=9, bonus="Experience Points"},
  919.         ["Ninja Roll"] =        {lucky=4, unlucky=8, bonus="Evasion"},
  920.         ["Hunter's Roll"] =     {lucky=4, unlucky=8, bonus="Accuracy"},
  921.         ["Chaos Roll"] =        {lucky=4, unlucky=8, bonus="Attack"},
  922.         ["Magus's Roll"] =      {lucky=2, unlucky=6, bonus="Magic Defense"},
  923.         ["Healer's Roll"] =     {lucky=3, unlucky=7, bonus="Cure Potency Received"},
  924.         ["Drachen Roll"] =      {lucky=4, unlucky=8, bonus="Pet Magic Accuracy/Attack"},
  925.         ["Choral Roll"] =       {lucky=2, unlucky=6, bonus="Spell Interruption Rate"},
  926.         ["Monk's Roll"] =       {lucky=3, unlucky=7, bonus="Subtle Blow"},
  927.         ["Beast Roll"] =        {lucky=4, unlucky=8, bonus="Pet Attack"},
  928.         ["Samurai Roll"] =      {lucky=2, unlucky=6, bonus="Store TP"},
  929.         ["Evoker's Roll"] =     {lucky=5, unlucky=9, bonus="Refresh"},
  930.         ["Rogue's Roll"] =      {lucky=5, unlucky=9, bonus="Critical Hit Rate"},
  931.         ["Warlock's Roll"] =    {lucky=4, unlucky=8, bonus="Magic Accuracy"},
  932.         ["Fighter's Roll"] =    {lucky=5, unlucky=9, bonus="Double Attack Rate"},
  933.         ["Puppet Roll"] =       {lucky=3, unlucky=7, bonus="Pet Magic Attack/Accuracy"},
  934.         ["Gallant's Roll"] =    {lucky=3, unlucky=7, bonus="Defense"},
  935.         ["Wizard's Roll"] =     {lucky=5, unlucky=9, bonus="Magic Attack"},
  936.         ["Dancer's Roll"] =     {lucky=3, unlucky=7, bonus="Regen"},
  937.         ["Scholar's Roll"] =    {lucky=2, unlucky=6, bonus="Conserve MP"},
  938.         ["Naturalist's Roll"] = {lucky=3, unlucky=7, bonus="Enh. Magic Duration"},
  939.         ["Runeist's Roll"] =    {lucky=4, unlucky=8, bonus="Magic Evasion"},
  940.         ["Bolter's Roll"] =     {lucky=3, unlucky=9, bonus="Movement Speed"},
  941.         ["Caster's Roll"] =     {lucky=2, unlucky=7, bonus="Fast Cast"},
  942.         ["Courser's Roll"] =    {lucky=3, unlucky=9, bonus="Snapshot"},
  943.         ["Blitzer's Roll"] =    {lucky=4, unlucky=9, bonus="Attack Delay"},
  944.         ["Tactician's Roll"] =  {lucky=5, unlucky=8, bonus="Regain"},
  945.         ["Allies' Roll"] =      {lucky=3, unlucky=10, bonus="Skillchain Damage"},
  946.         ["Miser's Roll"] =      {lucky=5, unlucky=7, bonus="Save TP"},
  947.         ["Companion's Roll"] =  {lucky=2, unlucky=10, bonus="Pet Regain and Regen"},
  948.         ["Avenger's Roll"] =    {lucky=4, unlucky=8, bonus="Counter Rate"},
  949.     }
  950. end
  951.  
  952. function display_roll_info(spell)
  953.     rollinfo = rolls[spell.english]
  954.     local rollsize = (state.LuzafRing.value and 'Large') or 'Small'
  955.  
  956.     if rollinfo then
  957.         add_to_chat(104, '[ Lucky: '..tostring(rollinfo.lucky)..' / Unlucky: '..tostring(rollinfo.unlucky)..' ] '..spell.english..': '..rollinfo.bonus..' ('..rollsize..') ')
  958.     end
  959. end
  960.  
  961.  
  962. -- Determine whether we have sufficient ammo for the action being attempted.
  963. function do_bullet_checks(spell, spellMap, eventArgs)
  964.     local bullet_name
  965.     local bullet_min_count = 1
  966.  
  967.     if spell.type == 'WeaponSkill' then
  968.         if spell.skill == "Marksmanship" then
  969.             if spell.english == 'Wildfire' or spell.english == 'Leaden Salute' then
  970.                 -- magical weaponskills
  971.                 bullet_name = gear.MAbullet
  972.             else
  973.                 -- physical weaponskills
  974.                 bullet_name = gear.WSbullet
  975.             end
  976.         else
  977.             -- Ignore non-ranged weaponskills
  978.             return
  979.         end
  980.     elseif spell.type == 'CorsairShot' then
  981.         bullet_name = gear.QDbullet
  982.     elseif spell.action_type == 'Ranged Attack' then
  983.         bullet_name = gear.RAbullet
  984.         if buffactive['Triple Shot'] then
  985.             bullet_min_count = 3
  986.         end
  987.     end
  988.  
  989.     local available_bullets = player.inventory[bullet_name] or player.wardrobe[bullet_name]
  990.  
  991.     -- If no ammo is available, give appropriate warning and end.
  992.     if not available_bullets then
  993.         if spell.type == 'CorsairShot' and player.equipment.ammo ~= 'empty' then
  994.             add_to_chat(104, 'No Quick Draw ammo left.  Using what\'s currently equipped ('..player.equipment.ammo..').')
  995.             return
  996.         elseif spell.type == 'WeaponSkill' and player.equipment.ammo == gear.RAbullet then
  997.             add_to_chat(104, 'No weaponskill ammo left.  Using what\'s currently equipped (standard ranged bullets: '..player.equipment.ammo..').')
  998.             return
  999.         else
  1000.             add_to_chat(104, 'No ammo ('..tostring(bullet_name)..') available for that action.')
  1001.             eventArgs.cancel = true
  1002.             return
  1003.         end
  1004.     end
  1005.  
  1006.     -- Don't allow shooting or weaponskilling with ammo reserved for quick draw.
  1007.     if spell.type ~= 'CorsairShot' and bullet_name == gear.QDbullet and available_bullets.count <= bullet_min_count then
  1008.         add_to_chat(104, 'No ammo will be left for Quick Draw.  Cancelling.')
  1009.         eventArgs.cancel = true
  1010.         return
  1011.     end
  1012.  
  1013.     -- Low ammo warning.
  1014.     if spell.type ~= 'CorsairShot' and state.warned.value == false
  1015.         and available_bullets.count > 1 and available_bullets.count <= options.ammo_warning_limit then
  1016.         local msg = '*****  LOW AMMO WARNING: '..bullet_name..' *****'
  1017.         --local border = string.repeat("*", #msg)
  1018.         local border = ""
  1019.         for i = 1, #msg do
  1020.             border = border .. "*"
  1021.         end
  1022.  
  1023.         add_to_chat(104, border)
  1024.         add_to_chat(104, msg)
  1025.         add_to_chat(104, border)
  1026.  
  1027.         state.warned:set()
  1028.     elseif available_bullets.count > options.ammo_warning_limit and state.warned then
  1029.         state.warned:reset()
  1030.     end
  1031. end
  1032.  
  1033. -- Select default macro book on initial load or subjob change.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement