Alistrianna

smn_lua

Feb 11th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.88 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Initialization function that defines sets and variables to be used.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. -- IMPORTANT: Make sure to also get the Mote-Include.lua file (and it's supplementary files) to go with this.
  6.  
  7. -- Also, you'll need the Shortcuts addon to handle the auto-targetting of the custom pact commands.
  8.  
  9. --[[
  10. Custom commands:
  11.  
  12. gs c petweather
  13. Automatically casts the storm appropriate for the current avatar, if possible.
  14.  
  15. gs c siphon
  16. Automatically run the process to: dismiss the current avatar; cast appropriate
  17. weather; summon the appropriate spirit; Elemental Siphon; release the spirit;
  18. and re-summon the avatar.
  19.  
  20. Will not cast weather you do not have access to.
  21. Will not re-summon the avatar if one was not out in the first place.
  22. Will not release the spirit if it was out before the command was issued.
  23.  
  24. gs c pact [PactType]
  25. Attempts to use the indicated pact type for the current avatar.
  26. PactType can be one of:
  27. cure
  28. curaga
  29. buffOffense
  30. buffDefense
  31. buffSpecial
  32. debuff1
  33. debuff2
  34. sleep
  35. nuke2
  36. nuke4
  37. bp70
  38. bp75 (merits and lvl 75-80 pacts)
  39. astralflow
  40.  
  41. --]]
  42.  
  43.  
  44. -- Initialization function for this job file.
  45. function get_sets()
  46. -- Load and initialize the include file.
  47. include('Mote-Include.lua')
  48. end
  49.  
  50. -- Setup vars that are user-independent.
  51. function job_setup()
  52. state.Buff["Avatar's Favor"] = buffactive["Avatar's Favor"] or false
  53.  
  54. spirits = S{"LightSpirit", "DarkSpirit", "FireSpirit", "EarthSpirit", "WaterSpirit", "AirSpirit", "IceSpirit", "ThunderSpirit"}
  55. avatars = S{"Cait Sith", "Carbuncle", "Fenrir", "Diabolos", "Ifrit", "Titan", "Leviathan", "Garuda", "Shiva", "Ramuh", "Odin", "Alexander"}
  56.  
  57. magicalRagePacts = S{
  58. 'Inferno','Earthen Fury','Tidal Wave','Aerial Blast','Diamond Dust','Judgement Bolt','Searing Light','Howling Moon','Ruinous Omen',
  59. 'Fire II','Stone II','Water II','Aero II','Blizzard II','Thunder II',
  60. 'Fire IV','Stone IV','Water IV','Aero IV','Blizzard IV','Thunder IV',
  61. 'Thunderspark','Burning Strike','Meteorite','Nether Blast','Flaming Crush',
  62. 'Meteor Strike','Heavenly Strike','Wind Blade','Geocrush','Grand Fall','Thunderstorm',
  63. 'Holy Mist','Lunar Bay','Night Terror'}
  64.  
  65.  
  66. pacts = {}
  67. pacts.cure = {['Carbuncle']='Healing Ruby'}
  68. pacts.curaga = {['Carbuncle']='Healing Ruby II', ['Garuda']='Whispering Wind', ['Leviathan']='Spring Water'}
  69. pacts.buffoffense = {['Carbuncle']='Glittering Ruby', ['Ifrit']='Inferno Howl', ['Garuda']='Hastega', ['Ramuh']='Rolling Thunder',
  70. ['Fenrir']='Ecliptic Growl'}
  71. pacts.buffdefense = {['Carbuncle']='Shining Ruby', ['Shiva']='Frost Armor', ['Garuda']='Aerial Armor', ['Titan']='Earthen Ward',
  72. ['Ramuh']='Lightning Armor', ['Fenrir']='Ecliptic Howl', ['Diabolos']='Noctoshield'}
  73. pacts.buffspecial = {['Garuda']='Fleet Wind', ['Titan']='Earthen Armor', ['Diabolos']='Dream Shroud', ['Carbuncle']='Soothing Ruby',
  74. ['Fenrir']='Heavenward Howl'}
  75. pacts.debuff1 = {['Shiva']='Diamond Storm', ['Ramuh']='Shock Squall', ['Leviathan']='Tidal Roar', ['Fenrir']='Lunar Cry',
  76. ['Diabolos']='Pavor Nocturnus'}
  77. pacts.debuff2 = {['Shiva']='Sleepga', ['Leviathan']='Slowga', ['Fenrir']='Lunar Roar', ['Diabolos']='Somnolence'}
  78. pacts.sleep = {['Shiva']='Sleepga', ['Diabolos']='Nightmare'}
  79. pacts.nuke2 = {['Ifrit']='Fire II', ['Shiva']='Blizzard II', ['Garuda']='Aero II', ['Titan']='Stone II',
  80. ['Ramuh']='Thunder II', ['Leviathan']='Water II'}
  81. pacts.nuke4 = {['Ifrit']='Fire IV', ['Shiva']='Blizzard IV', ['Garuda']='Aero IV', ['Titan']='Stone IV',
  82. ['Ramuh']='Thunder IV', ['Leviathan']='Water IV'}
  83. pacts.bp70 = {['Ifrit']='Flaming Crush', ['Shiva']='Rush', ['Garuda']='Predator Claws', ['Titan']='Mountain Buster',
  84. ['Ramuh']='Chaotic Strike', ['Leviathan']='Spinning Dive', ['Carbuncle']='Meteorite', ['Fenrir']='Eclipse Bite',
  85. ['Diabolos']='Nether Blast'}
  86. pacts.bp75 = {['Ifrit']='Meteor Strike', ['Shiva']='Heavenly Strike', ['Garuda']='Wind Blade', ['Titan']='Geocrush',
  87. ['Ramuh']='Thunderstorm', ['Leviathan']='Grand Fall', ['Carbuncle']='Holy Mist', ['Fenrir']='Lunar Bay',
  88. ['Diabolos']='Night Terror'}
  89. pacts.astralflow = {['Ifrit']='Inferno', ['Shiva']='Diamond Dust', ['Garuda']='Aerial Blast', ['Titan']='Earthen Fury',
  90. ['Ramuh']='Judgment Bolt', ['Leviathan']='Tidal Wave', ['Carbuncle']='Searing Light', ['Fenrir']='Howling Moon',
  91. ['Diabolos']='Ruinous Omen'}
  92.  
  93. end
  94.  
  95.  
  96. -- Setup vars that are user-dependent. Can override this function in a sidecar file.
  97. function user_setup()
  98. -- Options: Override default values
  99. options.OffenseModes = {'Normal'}
  100. options.DefenseModes = {'Normal'}
  101. options.WeaponskillModes = {'Normal'}
  102. options.CastingModes = {'Normal'}
  103. options.IdleModes = {'Normal'}
  104. options.RestingModes = {'Normal'}
  105. options.PhysicalDefenseModes = {'PDT'}
  106. options.MagicalDefenseModes = {'MDT'}
  107.  
  108. state.Defense.PhysicalMode = 'PDT'
  109.  
  110. -- Durations for wards we want to create custom timers for.
  111. durations = {}
  112. durations['Earthen Armor'] = 232
  113. durations['Shining Ruby'] = 340
  114. durations['Dream Shroud'] = 352
  115. durations['Noctoshield'] = 352
  116. durations['Inferno Howl'] = 232
  117. durations['Hastega'] = 352
  118.  
  119. -- Icons to use for the timers (from plugins/icons directory)
  120. timer_icons = {}
  121. -- 00054 for stoneskin, or 00299 for Titan
  122. timer_icons['Earthen Armor'] = 'spells/00299.png'
  123. -- 00043 for protect, or 00296 for Carby
  124. timer_icons['Shining Ruby'] = 'spells/00043.png'
  125. -- 00304 for Diabolos
  126. timer_icons['Dream Shroud'] = 'spells/00304.png'
  127. -- 00106 for phalanx, or 00304 for Diabolos
  128. timer_icons['Noctoshield'] = 'spells/00106.png'
  129. -- 00100 for enfire, or 00298 for Ifrit
  130. timer_icons['Inferno Howl'] = 'spells/00298.png'
  131. -- 00358 for hastega, or 00301 for Garuda
  132. timer_icons['Hastega'] = 'spells/00358.png'
  133.  
  134.  
  135. -- Default macro set/book
  136. set_macro_page(1, 7)
  137. end
  138.  
  139.  
  140. -- Called when this job file is unloaded (eg: job change)
  141. function file_unload()
  142. if binds_on_unload then
  143. binds_on_unload()
  144. end
  145. end
  146.  
  147.  
  148. -- Define sets and vars used by this job file.
  149. function init_gear_sets()
  150. --------------------------------------
  151. -- Start defining the sets
  152. --------------------------------------
  153.  
  154. -- Precast Sets
  155.  
  156. -- Precast sets to enhance JAs
  157. sets.precast.JA['Astral Flow'] = {head="Summoner's Horn +2"}
  158.  
  159. sets.precast.JA['Elemental Siphon'] = {head="Caller's Pigaches +2"} -- back="Conveyance Cape"
  160.  
  161. sets.precast.JA['Mana Cede'] = {hands="Caller's Bracers +2"}
  162.  
  163. -- Pact delay reduction gear
  164. sets.precast.BloodPactWard = {ammo="Eminent Sachet",head="Convoker's Horn",body="Convoker's Doublet",hands="Summoner's Bracers"}
  165.  
  166. sets.precast.BloodPactRage = sets.precast.BloodPactWard
  167.  
  168. -- Fast cast sets for spells
  169.  
  170. sets.precast.FC = {
  171. head="Nahtirah Hat",ear2="Loquacious Earring",
  172. body="Vanir Cotehardie",ring1="Prolix Ring",
  173. back="Swith Cape",waist="Witful Belt",legs="Orvail Pants +1",feet="Chelona Boots +1"}
  174.  
  175. sets.precast.FC.EnhancingMagic = set_combine(sets.precast.FC, {waist="Siegel Sash"})
  176.  
  177.  
  178. -- Weaponskill sets
  179. -- Default set for any weaponskill that isn't any more specifically defined
  180. sets.precast.WS = {
  181. head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  182. body="Vanir Cotehardie",hands="Yaoyotl Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  183. back="Pahtli Cape",waist="Cascade Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}
  184.  
  185. -- Specific weaponskill sets. Uses the base set if an appropriate WSMod version isn't found.
  186. sets.precast.WS['Myrkr'] = {
  187. head="Nahtirah Hat",ear1="Gifted Earring",ear2="Loquacious Earring",
  188. body="Convoker's Doublet",hands="Caller's Bracers +2",ring1="Evoker's Ring",ring2="Sangoma Ring",
  189. back="Pahtli Cape",waist="Hierarch Belt",legs="Nares Trews",feet="Chelona Boots +1"}
  190.  
  191.  
  192. -- Midcast Sets
  193. sets.midcast.FastRecast = {
  194. head="Nahtirah Hat",ear2="Loquacious Earring",
  195. body="Vanir Cotehardie",hands="Bokwus Gloves",ring1="Prolix Ring",
  196. back="Swith Cape",waist="Witful Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}
  197.  
  198. sets.midcast.Cure = {main="Tamaxchi",sub="Genbu's Shield",
  199. head="Nahtirah Hat",ear2="Loquacious Earring",
  200. body="Heka's Kalasiris",hands="Bokwus Gloves",ring1="Prolix Ring",ring2="Sirona's Ring",
  201. back="Swith Cape",waist="Witful Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}
  202.  
  203. sets.midcast.Stoneskin = {waist="Siegel Sash"}
  204.  
  205. sets.midcast.Pet.BloodPactWard = {main="Soulscourge",ammo="Eminent Sachet",
  206. head="Convoker's Horn",neck="Caller's Pendant",
  207. body="Caller's Doublet +2",hands="Summoner's Bracers",ring1="Evoker's Ring",ring2="Fervor Ring",
  208. waist="Diabolos's Rope",legs="Marduk's Shalwar +1"}
  209.  
  210. sets.midcast.Pet.PhysicalBloodPactRage = {main="Soulscourge",ammo="Eminent Sachet",
  211. head="Convoker's Horn",neck="Caller's Pendant",
  212. body="Convoker's Doublet",hands="Summoner's Bracers",ring1="Evoker's Ring",ring2="Fervor Ring",
  213. waist="Diabolos's Rope",legs="Convoker's Spats",feet="Convoker's Pigaches"}
  214.  
  215. sets.midcast.Pet.MagicalBloodPactRage = {main="Eminent Pole",ammo="Eminent Sachet",
  216. head="Bokwus Circlet",neck="Caller's Pendant",
  217. body="Convoker's Doublet",hands="Summoner's Bracers",ring1="Evoker's Ring",ring2="Fervor Ring",
  218. back="Tiresias' Cape",waist="Diabolos's Rope",legs="Caller's Spats +2",feet="Hagondes Sabots"}
  219.  
  220. sets.midcast.Pet.Spirit = set_combine(sets.midcast.Pet.BloodPactRage, {legs="Summoner's Spats"})
  221.  
  222. -- Sets to return to when not performing an action.
  223.  
  224. -- Resting sets
  225. sets.resting = {main=gear.Staff.HMP,ammo="Eminent Sachet",
  226. head="Convoker's Horn",neck="Wiglen Gorget",ear1="Gifted Earring",ear2="Loquacious Earring",
  227. body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sheltered Ring",ring2="Paguroidea Ring",
  228. back="Pahtli Cape",waist="Austerity Belt",legs="Nares Trews",feet="Chelona Boots +1"}
  229.  
  230.  
  231. -- Idle sets
  232. sets.idle = {main="Owleyes",sub="Genbu's Shield",ammo="Eminent Sachet",
  233. head="Convoker's Horn",neck="Wiglen Gorget",ear1="Gifted Earring",ear2="Loquacious Earring",
  234. body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sheltered Ring",ring2="Paguroidea Ring",
  235. back="Umbra Cape",waist="Hierarch Belt",legs="Nares Trews",feet="Herald's Gaiters"}
  236.  
  237. sets.idle.PDT = {main=gear.Staff.PDT,sub="Achaq Grip",ammo="Eminent Sachet",
  238. head="Convoker's Horn",neck="Twilight Torque",ear1="Gifted Earring",ear2="Loquacious Earring",
  239. body="Hagondes Coat",hands="Yaoyotl Gloves",ring1="Dark Ring",ring2="Paguroidea Ring",
  240. back="Umbra Cape",waist="Hierarch Belt",legs="Hagondes Pants",feet="Herald's Gaiters"}
  241.  
  242. sets.idle.Avatar = {main="Patriarch Cane",sub="Genbu's Shield",ammo="Eminent Sachet",
  243. head="Convoker's Horn",neck="Caller's Pendant",ear1="Gifted Earring",ear2="Loquacious Earring",
  244. body="Caller's Doublet +2",hands="Serpentes Cuffs",ring1="Evoker's Ring",ring2="Paguroidea Ring",
  245. back="Umbra Cape",waist="Hierarch Belt",legs="Nares Trews",feet="Convoker's Pigaches"}
  246.  
  247. sets.idle.Spirit = {main="Owleyes",sub="Genbu's Shield",ammo="Eminent Sachet",
  248. head="Convoker's Horn",neck="Caller's Pendant",ear1="Gifted Earring",ear2="Loquacious Earring",
  249. body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Evoker's Ring",ring2="Paguroidea Ring",
  250. back="Tiresias' Cape",waist="Hierarch Belt",legs="Summoner's Spats",feet="Convoker's Pigaches"}
  251.  
  252. sets.idle.Town = {main="Patriarch Cane",sub="Genbu's Shield",ammo="Eminent Sachet",
  253. head="Convoker's Horn",neck="Wiglen Gorget",ear1="Gifted Earring",ear2="Loquacious Earring",
  254. body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sheltered Ring",ring2="Paguroidea Ring",
  255. back="Umbra Cape",waist="Hierarch Belt",legs="Nares Trews",feet="Herald's Gaiters"}
  256.  
  257. sets.idle.Avatar.Favor = {head="Caller's Horn +2"}
  258. sets.idle.Avatar.Melee = {hands="Summoner's Bracers",waist="Kuku Stone",legs="Convoker's Spats"}
  259.  
  260. sets.perp = {}
  261. sets.perp.Day = {hands="Caller's Bracers +2"}
  262. sets.perp.Weather = {neck="Caller's Pendant",hands="Caller's Bracers +2"}
  263. sets.perp.Carbuncle = {hands="Carbuncle Mitts"}
  264. sets.perp.Diabolos = {waist="Diabolos's Rope"}
  265. sets.perp.Alexander = sets.midcast.Pet.BloodPactWard
  266.  
  267. -- Defense sets
  268. sets.defense.PDT = {main=gear.Staff.PDT,
  269. head="Hagondes Hat",neck="Wiglen Gorget",ear1="Gifted Earring",ear2="Loquacious Earring",
  270. body="Hagondes Coat",hands="Yaoyotl Gloves",ring1="Dark Ring",ring2="Dark Ring",
  271. back="Umbra Cape",waist="Hierarch Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}
  272.  
  273. sets.defense.MDT = {
  274. head="Hagondes Hat",neck="Twilight Torque",ear1="Gifted Earring",ear2="Loquacious Earring",
  275. body="Vanir Cotehardie",hands="Yaoyotl Gloves",ring1="Dark Ring",ring2="Shadow Ring",
  276. back="Umbra Cape",waist="Hierarch Belt",legs="Bokwus Slops",feet="Hagondes Sabots"}
  277.  
  278. sets.Kiting = {feet="Herald's Gaiters"}
  279.  
  280. -- Engaged sets
  281.  
  282. -- Variations for TP weapon and (optional) offense/defense modes. Code will fall back on previous
  283. -- sets if more refined versions aren't defined.
  284. -- If you create a set with both offense and defense modes, the offense mode should be first.
  285. -- EG: sets.engaged.Dagger.Accuracy.Evasion
  286.  
  287. -- Normal melee group
  288. sets.engaged = {ammo="Eminent Sachet",
  289. head="Zelus Tiara",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  290. body="Vanir Cotehardie",hands="Bokwus Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  291. back="Umbra Cape",waist="Goading Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}
  292. end
  293.  
  294. -------------------------------------------------------------------------------------------------------------------
  295. -- Job-specific hooks that are called to process player actions at specific points in time.
  296. -------------------------------------------------------------------------------------------------------------------
  297.  
  298. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  299. function job_midcast(spell, action, spellMap, eventArgs)
  300. if spell.action_type == 'Magic' then
  301. equip(sets.midcast.FastRecast)
  302. end
  303. end
  304.  
  305.  
  306. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  307. function job_aftercast(spell, action, spellMap, eventArgs)
  308. if not spell.interrupted then
  309. if state.Buff[spell.name] ~= nil then
  310. state.Buff[spell.name] = true
  311. end
  312. end
  313.  
  314. if buffactive['astral conduit'] then
  315. eventArgs.handled = true
  316. end
  317. end
  318.  
  319.  
  320. -- Runs when a pet initiates an action.
  321. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  322. function job_pet_midcast(spell, action, spellMap, eventArgs)
  323. if spirits:contains(pet.name) then
  324. classes.CustomClass = 'Spirit'
  325. elseif spell.type == 'BloodPactRage' then
  326. if magicalRagePacts:contains(spell.english) then
  327. classes.CustomClass = 'MagicalBloodPactRage'
  328. else
  329. classes.CustomClass = 'PhysicalBloodPactRage'
  330. end
  331. end
  332. end
  333.  
  334.  
  335. -- Runs when pet completes an action.
  336. function job_pet_aftercast(spell, action, spellMap, eventArgs)
  337. if not spell.interrupted then
  338. create_pact_timer(spell)
  339. end
  340.  
  341. if buffactive['astral conduit'] then
  342. eventArgs.handled = true
  343. end
  344. end
  345.  
  346.  
  347. -------------------------------------------------------------------------------------------------------------------
  348. -- Customization hooks for idle and melee sets, after they've been automatically constructed.
  349. -------------------------------------------------------------------------------------------------------------------
  350.  
  351. -- Modify the default idle set after it was constructed.
  352. function customize_idle_set(idleSet)
  353. if pet.isvalid then
  354. if pet.element == world.day_element then
  355. idleSet = set_combine(idleSet, sets.perp.Day)
  356. end
  357. if pet.element == world.weather_element then
  358. idleSet = set_combine(idleSet, sets.perp.Weather)
  359. end
  360. if sets.perp[pet.name] then
  361. idleSet = set_combine(idleSet, sets.perp[pet.name])
  362. end
  363. if state.Buff["Avatar's Favor"] and avatars:contains(pet.name) then
  364. idleSet = set_combine(idleSet, sets.idle.Avatar.Favor)
  365. end
  366. if pet.status == 'Engaged' then
  367. idleSet = set_combine(idleSet, sets.idle.Avatar.Melee)
  368. end
  369. end
  370.  
  371. return idleSet
  372. end
  373.  
  374.  
  375. -------------------------------------------------------------------------------------------------------------------
  376. -- General hooks for other events.
  377. -------------------------------------------------------------------------------------------------------------------
  378.  
  379. -- Called when a player gains or loses a buff.
  380. -- buff == buff gained or lost
  381. -- gain == true if the buff was gained, false if it was lost.
  382. function job_buff_change(buff, gain)
  383. if state.Buff[buff] ~= nil then
  384. state.Buff[buff] = gain
  385. handle_equipping_gear(player.status)
  386. elseif storms:contains(buff) then
  387. handle_equipping_gear(player.status)
  388. end
  389. end
  390.  
  391.  
  392. -- Called when the player's pet's status changes.
  393. -- This is also called after pet_change after a pet is released. Check for pet validity.
  394. function job_pet_status_change(newStatus, oldStatus, eventArgs)
  395. if pet.isvalid and not midaction() and not pet_midaction() and (newStatus == 'Engaged' or oldStatus == 'Engaged') then
  396. handle_equipping_gear(player.status, newStatus)
  397. end
  398. end
  399.  
  400.  
  401. -- Called when a player gains or loses a pet.
  402. -- pet == pet structure
  403. -- gain == true if the pet was gained, false if it was lost.
  404. function job_pet_change(petparam, gain)
  405. classes.CustomIdleGroups:clear()
  406. if gain then
  407. if avatars:contains(pet.name) then
  408. classes.CustomIdleGroups:append('Avatar')
  409. elseif spirits:contains(pet.name) then
  410. classes.CustomIdleGroups:append('Spirit')
  411. end
  412. end
  413. end
  414.  
  415.  
  416. -------------------------------------------------------------------------------------------------------------------
  417. -- User code that supplements self-commands.
  418. -------------------------------------------------------------------------------------------------------------------
  419.  
  420. -- Called for custom player commands.
  421. function job_self_command(cmdParams, eventArgs)
  422. if cmdParams[1]:lower() == 'petweather' then
  423. handle_petweather()
  424. eventArgs.handled = true
  425. elseif cmdParams[1]:lower() == 'siphon' then
  426. handle_siphoning()
  427. eventArgs.handled = true
  428. elseif cmdParams[1]:lower() == 'pact' then
  429. handle_pacts(cmdParams)
  430. eventArgs.handled = true
  431. end
  432. end
  433.  
  434. -- Called by the 'update' self-command, for common needs.
  435. -- Set eventArgs.handled to true if we don't want automatic equipping of gear.
  436. function job_update(cmdParams, eventArgs)
  437. classes.CustomIdleGroups:clear()
  438. if pet.isvalid then
  439. if avatars:contains(pet.name) then
  440. classes.CustomIdleGroups:append('Avatar')
  441. elseif spirits:contains(pet.name) then
  442. classes.CustomIdleGroups:append('Spirit')
  443. end
  444. end
  445.  
  446. end
  447.  
  448. -- Set eventArgs.handled to true if we don't want the automatic display to be run.
  449. function display_current_job_state(eventArgs)
  450.  
  451. end
  452.  
  453. -------------------------------------------------------------------------------------------------------------------
  454. -- Utility functions specific to this job.
  455. -------------------------------------------------------------------------------------------------------------------
  456.  
  457. -- Cast the appopriate storm for the currently summoned avatar, if possible.
  458. function handle_petweather()
  459. if player.sub_job ~= 'SCH' then
  460. add_to_chat(122, "You can not cast storm spells")
  461. return
  462. end
  463.  
  464. if not pet.isvalid then
  465. add_to_chat(122, "You do not have an active avatar.")
  466. return
  467. end
  468.  
  469. local element = pet.element
  470. if element == 'Thunder' then
  471. element = 'Lightning'
  472. end
  473.  
  474. if S{'Light','Dark','Lightning'}:contains(element) then
  475. add_to_chat(122, 'You do not have access to '..elements.storm_of[element]..'.')
  476. return
  477. end
  478.  
  479. local storm = elements.storm_of[element]
  480.  
  481. if storm then
  482. send_command('@input /ma "'..elements.storm_of[element]..'" <me>')
  483. else
  484. add_to_chat(123, 'Error: Unknown element ('..tostring(element)..')')
  485. end
  486. end
  487.  
  488.  
  489. -- Custom uber-handling of Elemental Siphon
  490. function handle_siphoning()
  491. if areas.Cities:contains(world.area) then
  492. add_to_chat(122, 'Cannot use Elemental Siphon in a city area.')
  493. return
  494. end
  495.  
  496. local siphonElement
  497. local stormElementToUse
  498. local releasedAvatar
  499. local dontRelease
  500.  
  501. -- If we already have a spirit out, just use that.
  502. if pet.isvalid and spirits:contains(pet.name) then
  503. siphonElement = pet.element
  504. dontRelease = true
  505. -- If current weather doesn't match the spirit, but the spirit matches the day, try to cast the storm.
  506. if player.sub_job == 'SCH' and pet.element == world.day_element and pet.element ~= world.weather_element then
  507. if not S{'Light','Dark','Lightning'}:contains(pet.element) then
  508. stormElementToUse = pet.element
  509. end
  510. end
  511. -- If we're subbing /sch, there are some conditions where we want to make sure specific weather is up.
  512. -- If current (single) weather is opposed by the current day, we want to change the weather to match
  513. -- the current day, if possible.
  514. elseif player.sub_job == 'SCH' and world.weather_element ~= 'None' then
  515. local intense = get_weather_intensity()
  516. -- We can override single-intensity weather; leave double weather alone, since even if
  517. -- it's partially countered by the day, it's not worth changing.
  518. if intense == 1 then
  519. -- If current weather is weak to the current day, it cancels the benefits for
  520. -- siphon. Change it to the day's weather if possible (+0 to +20%), or any non-weak
  521. -- weather if not.
  522. -- If the current weather matches the current avatar's element (being used to reduce
  523. -- perpetuation), don't change it; just accept the penalty on Siphon.
  524. if world.weather_element == elements.weak_to[world.day_element] and
  525. (not pet.isvalid or world.weather_element ~= pet.element) then
  526. -- We can't cast lightning/dark/light weather, so use a neutral element
  527. if S{'Light','Dark','Lightning'}:contains(world.day_element) then
  528. stormElementToUse = 'Wind'
  529. else
  530. stormElementToUse = world.day_element
  531. end
  532. end
  533. end
  534. end
  535.  
  536. -- If we decided to use a storm, set that as the spirit element to cast.
  537. if stormElementToUse then
  538. siphonElement = stormElementToUse
  539. elseif world.weather_element ~= 'None' and world.weather_element ~= elements.weak_to[world.day_element] then
  540. siphonElement = world.weather_element
  541. else
  542. siphonElement = world.day_element
  543. end
  544.  
  545. local command = ''
  546. local releaseWait = 0
  547.  
  548. if pet.isvalid and avatars:contains(pet.name) then
  549. command = command..'input /pet "Release" <me>;wait 1.1;'
  550. releasedAvatar = pet.name
  551. releaseWait = 10
  552. end
  553.  
  554. if stormElementToUse then
  555. command = command..'input /ma "'..elements.storm_of[stormElementToUse]..'" <me>;wait 4;'
  556. releaseWait = releaseWait - 4
  557. end
  558.  
  559. if not (pet.isvalid and spirits:contains(pet.name)) then
  560. command = command..'input /ma "'..elements.spirit_of[siphonElement]..'" <me>;wait 4;'
  561. releaseWait = releaseWait - 4
  562. end
  563.  
  564. command = command..'input /ja "Elemental Siphon" <me>;'
  565. releaseWait = releaseWait - 1
  566. releaseWait = releaseWait + 0.1
  567.  
  568. if not dontRelease then
  569. if releaseWait > 0 then
  570. command = command..'wait '..tostring(releaseWait)..';'
  571. else
  572. command = command..'wait 1.1;'
  573. end
  574.  
  575. command = command..'input /pet "Release" <me>;'
  576. end
  577.  
  578. if releasedAvatar then
  579. command = command..'wait 1.1;input /ma "'..releasedAvatar..'" <me>'
  580. end
  581.  
  582. send_command(command)
  583. end
  584.  
  585.  
  586. -- Handles executing blood pacts in a generic, avatar-agnostic way.
  587. -- cmdParams is the split of the self-command.
  588. -- gs c [pact] [pacttype]
  589. function handle_pacts(cmdParams)
  590. if areas.Cities:contains(world.area) then
  591. add_to_chat(122, 'You cannot use pacts in town.')
  592. return
  593. end
  594.  
  595. if not pet.isvalid then
  596. add_to_chat(122,'No avatar currently available. Returning to macro set 4.')
  597. set_macro_page(4)
  598. return
  599. end
  600.  
  601. if spirits:contains(pet.name) then
  602. add_to_chat(122,'Cannot use pacts with spirits.')
  603. return
  604. end
  605.  
  606. if not cmdParams[2] then
  607. add_to_chat(123,'No pact type given.')
  608. return
  609. end
  610.  
  611. local pact = cmdParams[2]:lower()
  612.  
  613. if not pacts[pact] then
  614. add_to_chat(123,'Unknown pact type: '..tostring(pact))
  615. return
  616. end
  617.  
  618. if pacts[pact][pet.name] then
  619. if pact == 'astralflow' and not buffactive['astral flow'] then
  620. add_to_chat(122,'Cannot use Astral Flow pacts without 1hr active.')
  621. return
  622. end
  623.  
  624. -- Leave out target; let Shortcuts auto-determine it.
  625. send_command('@input /pet "'..pacts[pact][pet.name]..'"')
  626. else
  627. add_to_chat(122,pet.name..' does not have a pact of type ['..pact..'].')
  628. end
  629. end
  630.  
  631.  
  632. function create_pact_timer(spell)
  633. -- Create custom timers for ward pacts.
  634. if durations and durations[spell.english] then
  635. local timer_cmd = 'timers c "'..spell.english..'" '..tostring(durations[spell.english])..' down'
  636.  
  637. if timer_icons[spell.english] then
  638. timer_cmd = timer_cmd..' '..timer_icons[spell.english]
  639. end
  640.  
  641. send_command(timer_cmd)
  642. end
  643. end
  644.  
  645. function self_command(command)
  646. if command == 'print' then
  647. print(pet.element, pet.isvalid)
  648. end
  649. end
Advertisement
Add Comment
Please, Sign In to add comment