Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.53 KB | None | 0 0
  1. --[[
  2.  
  3. --------------------------------------------------
  4. Copyright (C) 2017 Locatelli
  5.  
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. --------------------------------------------------
  16.  
  17. ]]--
  18.  
  19.  
  20. --- (Private Function) Checks the healing requirements for the provided entity.
  21. --
  22. -- @param Entity Contains the entity to perform healing on.
  23. -- @param double Contains the
  24. -- @return bool
  25.  
  26. function _CheckHeal( Entity )
  27.  
  28. -- Retrieve the range of the entity compared to my own character position.
  29. local Range = Player:GetPosition():DistanceToPosition( Entity:GetPosition());
  30.  
  31. local EntityState = Entity:GetState();
  32.  
  33. -- Check if this routine is allowed to be ran under the current circumstances.
  34. if Entity:IsDead() or ( not Settings.Songweaver.AllowApproach and Range > 23 ) then
  35. return true;
  36. end
  37.  
  38. -- Check if the entity requires healing and perform the correct healing routine.
  39. if Entity:GetHealth() < 80 and ( Settings.Songweaver.AllowApproach or Range <= 23 ) then
  40.  
  41. -- Retrieve the local target for certain checks.
  42. -- local Target = EntityList:GetEntity( Player:GetTargetID());
  43.  
  44. --Complete the Chain
  45. if Entity:GetID() == Player:GetID() and Settings.Songweaver.AllowAttack then
  46. if Entity:GetHealth() < 90 and Helper:CheckAvailable( "Melody of Joy" ) then
  47. Helper:CheckExecute ( "Melody of Joy", Entity )
  48. return false;
  49. elseif Entity:GetHealth() < 90 and Helper:CheckAvailable( "Soft Echo" ) then
  50. Helper:CheckExecute ( "Soft Echo", Entity )
  51. return false;
  52. elseif Entity:GetHealth() < 90 and Helper:CheckAvailable( "Mild Echo" ) then
  53. Helper:CheckExecute ( "Mild Echo", Entity )
  54. return false;
  55. end
  56. end
  57.  
  58. -- Change the healing routine if I'm healing myself when allowed to attack.
  59. if Entity:GetID() == Player:GetID() and Settings.Songweaver.AllowAttack then --and Target ~= nil and not Target:IsDead() then
  60. if Entity:GetHealth() < 50 and Helper:CheckAvailable( "Gentle Echo" ) then
  61. Helper:CheckExecute( "Gentle Echo", Entity );
  62. return false;
  63. end
  64. -- Check if we should heal the provided entity.
  65. elseif Entity:GetHealth() < 40 and Helper:CheckAvailable( "Gentle Echo" ) then
  66. Helper:CheckExecute( "Gentle Echo", Entity );
  67. return false;
  68. end
  69.  
  70. end
  71.  
  72. --Heal: Rejuvenation Melody
  73. if Helper:CheckAvailable( "Rejuvenation Melody" ) and Entity:GetHealth() < 60 then
  74. Helper:CheckExecute( "Rejuvenation Melody", Entity );
  75. return false;
  76. end
  77.  
  78. -- Return true to let the caller know this function completed.
  79. return true;
  80.  
  81. end
  82.  
  83.  
  84. ---------------------------------------------------------------------------------------
  85. ---------------------!!!!!!!!! DO NOT TOUCH MANA HEALING!!!!!!!!!!!--------------------
  86. ---------------------------------------------------------------------------------------
  87.  
  88. --- Checks if the state of the provided entity.
  89. --
  90. -- @param Entity Contains the entity to check.
  91. -- @return bool
  92.  
  93. function _CheckMana( Entity )
  94.  
  95. -- Retrieve the range of the entity compared to my own character position.
  96. local Range = Player:GetPosition():DistanceToPosition( Entity:GetPosition());
  97.  
  98. local EntityState = Entity:GetState();
  99.  
  100. -- Check if this routine is allowed to be ran under the current circumstances.
  101. if Entity:IsDead() or ( not Settings.Songweaver.AllowApproach and Range > 23 ) then
  102. return true;
  103. end
  104.  
  105. --Complete the Chain
  106. if Player:GetMana() < 90 and Helper:CheckAvailable( "Variation of Peace" ) then
  107. Helper:CheckExecute ( "Variation of Peace" )
  108. return false;
  109. end
  110.  
  111. -- Check if the entity requires healing and perform the correct mana healing routine.
  112. if Entity:GetMana() < 50 and ( Settings.Songweaver.AllowApproach or Range <= 23 ) then
  113. if Entity:GetMana() < 45 and Helper:CheckAvailable( "Echo of Clarity" ) then
  114. Helper:CheckExecute( "Echo of Clarity", Entity )
  115. return false;
  116. end
  117. end
  118.  
  119. if Player:GetMana() < 50 and Helper:CheckAvailable( "Melody of Reflection" ) then
  120. Helper:CheckExecute( "Melody of Reflection" )
  121. return false;
  122. end
  123.  
  124. -- Return true to let the caller know this function completed.
  125. return true;
  126.  
  127. end
  128. --------------------------------------------------------------------------------------
  129.  
  130.  
  131. function _CheckState( Entity )
  132.  
  133. -- Retrieve the range of the entity compared to my own character position.
  134. local Range = Player:GetPosition():DistanceToPosition( Entity:GetPosition());
  135.  
  136. -- Check if this routine is allowed to be ran under the current circumstances.
  137. if Entity:IsDead() or ( not Settings.Songweaver.AllowApproach and Range > 23 ) then
  138. return true;
  139. end
  140.  
  141. -- Retrieve the state for the current entity to inspect.
  142. local EntityState = Entity:GetState();
  143.  
  144. -- Loop through the states only when we are available to dispel them. We still check for removed states!
  145. if EntityState ~= nil and ( self.StateDispelTime == nil or self.StateDispelTime < Time()) then
  146.  
  147. -- Create the state array for the global entity storage and undispellable states if it does not exist.
  148. if self.StateArray == nil or self.StateUndispellable == nil then
  149. self.StateArray = {};
  150. self.StateUndispellable = {};
  151. end
  152.  
  153. -- Create the state array for the current entity if it does not exist.
  154. if self.StateArray[Entity:GetID()] == nil then
  155. self.StateArray[Entity:GetID()] = {};
  156. end
  157.  
  158. -- Loop through the states to find which need to be removed.
  159. for ID, Skill in DictionaryIterator( EntityState:GetList()) do
  160.  
  161. -- Check if the current skill is valid and has not been marked and undispellable.
  162. if Skill ~= nil and Skill:IsDebuff() and ( self.StateUndispellable[Skill:GetID()] == nil or self.StateUndispellable[Skill:GetID()] < Time()) then
  163.  
  164. -- Check if this entity had the current skill effect on him and hasn't been removed by either Cure Mind or Dispel.
  165. if self.StateArray[Entity:GetID()][Skill:GetID()] ~= nil and self.StateArray[Entity:GetID()][Skill:GetID()] == 2 then
  166. self.StateUndispellable[Skill:GetID()] = Time() + 30000;
  167. -- Remove the state from the entity.
  168. else
  169.  
  170. -- Retrieve the magical state the current skill.
  171. local RemoveMagical = Skill:IsMagical();
  172.  
  173. -- Check if we are required to change the magical state for the current skill.
  174. if self.StateArray[Entity:GetID()][Skill:GetID()] ~= nil then
  175. RemoveMagical = not RemoveMagical;
  176. end
  177.  
  178. -- Check if the dispel or cure mind can be executed correctly. The function might need to set the target first!
  179. if ( RemoveMagical and Helper:CheckExecute( "Melody of Purification", Entity )) or ( not RemoveMagical and Helper:CheckExecute( "Melody of Purification", Entity )) then
  180.  
  181. -- Change the state dispel timer to prevent dispel and cure mind from being used too quickly.
  182. self.StateDispelTime = Time() + 500;
  183.  
  184. -- Track the current state of the dispel and cure mind to find undispellable states.
  185. if self.StateArray[Entity:GetID()][Skill:GetID()] == nil then
  186. self.StateArray[Entity:GetID()][Skill:GetID()] = 1;
  187. return false;
  188. else
  189. self.StateArray[Entity:GetID()][Skill:GetID()] = 2;
  190. return false;
  191. end
  192.  
  193. end
  194.  
  195. end
  196.  
  197. end
  198.  
  199. end
  200.  
  201. -- Loop through the existing states to find which have been removed correctly.
  202. for k,v in pairs( self.StateArray[Entity:GetID()] ) do
  203. if v ~= nil and EntityState:GetState( k ) == nil then
  204. self.StateArray[Entity:GetID()][k] = nil;
  205. end
  206. end
  207.  
  208. end
  209.  
  210. -- Return true to let the caller know this function completed.
  211. return true;
  212.  
  213. end
  214.  
  215.  
  216. -----Sleep second target
  217. function CountMobs( EntityTarget, Distance )
  218.  
  219. local i = 0;
  220.  
  221. -- Iterate through all entities
  222. for ID, Entity in DictionaryIterator( EntityList:GetList()) do
  223. -- Check if the entiy is valid.
  224. if Entity ~= nil then
  225. -- Retrieve the entity state.
  226. local EntityState = Entity:GetState();
  227. -- Check if the entity state is valid.
  228. if EntityState ~= nil then
  229. -- Check if this is a living monster that is in range.
  230. if Entity:IsMonster() and not Entity:IsDead() and Entity:IsHostile() and EntityTarget:GetPosition():DistanceToPosition( Entity:GetPosition()) <= Distance then
  231. -- Check if this entity is sleeping
  232. if EntityState:GetState( Helper:CheckName( "March of the Jester" )) ~= nil then
  233. return 0;
  234. -- Increment the number.
  235. else
  236. i = i + 1;
  237. end
  238. end
  239. end
  240. end
  241. end
  242.  
  243. return i;
  244.  
  245. end
  246.  
  247. function SleepMultipleAttacker( EntityTarget, AttackRange )
  248. -- Check if we have stored a target.
  249. if self._SleepTarget ~= nil then
  250. -- Check if the current target is the stored target.
  251. if self._SleepTarget:GetID() == Player:GetTargetID() then
  252. -- Check if Sleep Arrow is available.
  253. if Helper:CheckAvailable( "March of the Jester" ) then
  254. -- Shoot the Sleep Arrow.
  255. Helper:CheckExecute( "March of the Jester" );
  256. -- Indicate we cannot continue attacking.
  257. return false;
  258. else
  259. -- Set the target.
  260. Player:SetTarget( self._SleepTargetRestore );
  261. -- Indicate we cannot continue attacking.
  262. return false;
  263. end
  264. -- Check if the current target is the original target.
  265. elseif not Helper:CheckAvailable( "March of the Jester" ) and self._SleepTargetRestore:GetID() == EntityTarget:GetID() then
  266. -- Clear the sleep target.
  267. self._SleepTarget = nil;
  268. -- Indicate we cannot continue attacking.
  269. return true;
  270. else
  271. -- Set the target.
  272. Player:SetTarget( self._SleepTarget );
  273. -- Indicate we cannot continue attacking.
  274. return false;
  275. end
  276. end
  277. -- Check if Sleep Arrow is available.
  278. if Helper:CheckAvailable( "March of the Jester" ) then
  279. -- Loop through the entities.
  280. for ID, Entity in DictionaryIterator( EntityList:GetList()) do
  281. -- Check if this entity is a monster, is not friendly and decided to attack me (and obviously is not my current target).
  282. if not Entity:IsDead() and Entity:IsMonster() and not Entity:IsFriendly() and Entity:GetTargetID() == Player:GetID() and Entity:GetID() ~= EntityTarget:GetID() then
  283. -- Check if the entity that is attacking us is within range.
  284. if Entity:GetPosition():DistanceToPosition( Player:GetPosition()) <= AttackRange then
  285. -- Store the sleep target.
  286. self._SleepTarget = Entity;
  287. -- Store the restore target.
  288. self._SleepTargetRestore = EntityTarget;
  289. -- Set the target.
  290. Player:SetTarget( Entity );
  291. -- Indicate we cannot continue attacking.
  292. return false;
  293. end
  294. end
  295. end
  296. end
  297. -- Indicate we can continue attacking.
  298. return true;
  299. end
  300.  
  301.  
  302. --- Perform the attack routine on the selected target.
  303. --
  304. -- @param Entity Contains the entity we have targeted.
  305. -- @param double Contains the distance to the target
  306. -- @param bool Indicates whether or not the target is stunned.
  307. -- @return bool
  308.  
  309. function Attack( Entity, Range, Stunned )
  310.  
  311. ---enemy position check
  312. local Position = Player:GetPosition();
  313. --
  314. local AttackRange = Player:GetAttackRange();
  315. --
  316. local EntityState = Entity:GetState();
  317.  
  318. local PlayerState = Player:GetState();
  319.  
  320. local CaptivateEffect = Entity:GetState():GetState( Helper:CheckName( "Captivate" ));
  321.  
  322. -- Check if we are allowed to sleep attackers.
  323. if Settings.Songweaver.AllowSleep and not self:SleepMultipleAttacker( Entity, AttackRange ) then
  324. return false;
  325. end
  326.  
  327. -----------------------------------------
  328. -------------------Shock-----------------
  329. -----------------------------------------
  330.  
  331. -- Use Remove Shock
  332. if Helper:CheckAvailable( "Remove Shock" ) then
  333. Helper:CheckExecute( "Remove Shock" );
  334. return false;
  335. end
  336.  
  337. -- Finish the Chain
  338. if Helper:CheckAvailable( "Melody of Appreciation" ) and Player:GetHealth() < 50 then
  339. Helper:CheckExecute( "Melody of Appreciation" );
  340. return false;
  341. elseif Helper:CheckAvailable( "Shock Blast" ) then
  342. Helper:CheckExecute( "Shock Blast" );
  343. return false;
  344. end
  345.  
  346. -----------------------------------------
  347. --------------Wind Harmony---------------
  348. -----------------------------------------
  349.  
  350. -- Wind Hrmony Buff Check here for best farming speed!
  351. if Helper:CheckAvailable( "Wind Harmony" ) and Helper:CheckAvailable ( "Chilling Harmony" ) then
  352. Helper:CheckExecute( "Chilling Harmony" )
  353. return false;
  354. end
  355.  
  356. -----------------------------------------
  357. -------------Chain Completer-------------
  358. -----------------------------------------
  359.  
  360. -- Charged Skills
  361. if Helper:CheckAvailable( "Tsunami Requiem" ) then
  362. Helper:CheckExecute( "Tsunami Requiem" );
  363. return false;
  364. end
  365.  
  366. -- Chilling Harmony
  367. if Helper:CheckAvailable ( "Wind Harmony" ) then
  368. Helper:CheckExecute( "Wind Harmony" )
  369. return false;
  370. elseif Helper:CheckAvailable( "Earth Harmony" ) then
  371. Helper:CheckExecute( "Earth Harmony" );
  372. return false;
  373. elseif Helper:CheckAvailable( "Flame Harmony" ) then
  374. Helper:CheckExecute( "Flame Harmony" );
  375. return false;
  376. end
  377.  
  378. -- Soul Harmony
  379. if Helper:CheckAvailable( "Harmony of Destruction" ) then
  380. Helper:CheckExecute( "Harmony of Destruction" );
  381. return false;
  382. elseif Helper:CheckAvailable( "Harmony of Death" ) then
  383. Helper:CheckExecute( "Harmony of Death" );
  384. return false;
  385. end
  386.  
  387. -- Attack Resonation
  388. if Helper:CheckAvailable( "Acute Grating Sound" ) then
  389. Helper:CheckExecute( "Acute Grating Sound" );
  390. return false;
  391. end
  392.  
  393. -----------------------------------------
  394. -----------------Bufovani----------------
  395. -----------------------------------------
  396.  
  397. -- Emergency!: Snowflower Melody
  398. if Helper:CheckAvailable( "Snowflower Melody" ) and Player:GetHealth() < 40 then
  399. Helper:CheckExecute( "Snowflower Melody" );
  400. return false;
  401. end
  402.  
  403. -- Shield Melody
  404. if Helper:CheckAvailable( "Shield Melody" ) and PlayerState:GetState( "Shield Melody" ) == nil then
  405. Helper:CheckExecute( "Shield Melody" );
  406. return false;
  407. end
  408.  
  409. -- Buff: Melody of Cheer
  410. if Helper:CheckAvailable( "Melody of Cheer" ) and Entity:GetHealth() < 90 then
  411. Helper:CheckExecute( "Melody of Cheer" );
  412. return false;
  413. end
  414.  
  415. -----------------------------------------
  416. --------------Primary Skills-------------
  417. -----------------------------------------
  418.  
  419. -- Harmony of Silence
  420. if Helper:CheckAvailable( "Harmony of Silence" ) and Entity:GetSkillID() ~= 0 and SkillList[Entity:GetSkillID()]:IsMagical() and Entity:GetSkillTime() >= 500 then
  421. Helper:CheckExecute( "Harmony of Silence" );
  422. return false;
  423. end
  424.  
  425. -- Fantastic Variation
  426. if Entity:GetHealth() >= 90 and Helper:CheckAvailable( "Fantastic Variatio" ) and Position:DistanceToPosition( Entity:GetPosition()) >= 12 then
  427. Helper:CheckExecute( "Fantastic Variation" );
  428. return false;
  429. end
  430.  
  431. -- Illusion Variation
  432. if Entity:GetHealth() >= 90 and Helper:CheckAvailable( "Illusion Variation" ) and Position:DistanceToPosition( Entity:GetPosition()) >= 12 then
  433. Helper:CheckExecute( "Illusion Variation" );
  434. return false;
  435. end
  436.  
  437. -- Battle Variation
  438. if Entity:GetHealth() >= 0 and Helper:CheckAvailable( "Battle Variation" ) and Helper:CheckAvailable( "Tsunami Requiem" ) and Position:DistanceToPosition( Entity:GetPosition()) >= 12 then
  439. Helper:CheckExecute( "Battle Variation");
  440. return false;
  441. end
  442.  
  443. -- Ascended Soul Variation
  444. if Entity:GetHealth() >= 90 and Helper:CheckAvailable( "Ascended Soul Variation" ) and Position:DistanceToPosition( Entity:GetPosition()) >= 12 then
  445. Helper:CheckExecute( "Ascended Soul Variation" );
  446. return false;
  447. end
  448.  
  449. -- Sea Variation
  450. if Entity:GetHealth() >= 90 and Helper:CheckAvailable( "Sea Variation" ) and Position:DistanceToPosition( Entity:GetPosition()) >= 12 then
  451. Helper:CheckExecute( "Sea Variation" );
  452. return false;
  453. end
  454.  
  455. -- 2000DP Skill Symphony of Wrath , Symphony of Destruction
  456. if Helper:CheckAvailable( "Symphony of Destruction" ) and Player:GetDP() >=2000 then
  457. Helper:CheckExecute( "Symphony of Destruction");
  458. return false;
  459. end
  460.  
  461. -- DOT Attack : Attack Resonation
  462. if Entity:GetHealth() >= 80 and Helper:CheckAvailable( "Attack Resonation" ) and Entity ~= nil then
  463. Helper:CheckExecute( "Attack Resonation" );
  464. return false;
  465. end
  466.  
  467. -- Chain : Chilling Harmony
  468. if Helper:CheckAvailable( "Chilling Harmony" ) then
  469. Helper:CheckExecute( "Chilling Harmony" );
  470. return false;
  471. end
  472.  
  473. -- Attack : Loud Bang
  474. if Helper:CheckAvailable( "Loud Bang" ) then
  475. Helper:CheckExecute( "Loud Bang" );
  476. return false;
  477. end
  478.  
  479. -- 2000 DP Skill Symphony of Wrath
  480. if Helper:CheckAvailable( "Symphony of Wrath" ) and Player:GetDP() >=2000 then
  481. Helper:CheckExecute( "Symphony of Wrath");
  482. return false;
  483. end
  484.  
  485. -- Attack : Disharmony
  486. if Entity:GetHealth() >= 25 and Helper:CheckAvailable( "Disharmony" ) then
  487. Helper:CheckExecute( "Disharmony" );
  488. end
  489.  
  490. -- DOT Attack : Mosky Requiem
  491. if Entity:GetHealth() >= 80 and Helper:CheckAvailable( "Mosky Requiem" ) then
  492. Helper:CheckExecute( "Mosky Requiem" );
  493. return false;
  494. end
  495.  
  496. -- Attack : Gust Requiem
  497. if Helper:CheckAvailable( "Gust Requiem" ) then
  498. Helper:CheckExecute( "Gust Requiem" );
  499. return false;
  500. end
  501.  
  502. --Attack : March of the Bees
  503. if Helper:CheckAvailable( "March of the Bees" ) then
  504. Helper:CheckExecute( "March of the Bees" );
  505. return false;
  506. end
  507. --Chain attack: Harmony of Death
  508. if Helper:CheckAvailable( "Soul Harmony" ) then
  509. Helper:CheckExecute( "Soul Harmony" );
  510. return false;
  511. end
  512.  
  513. -- Attack : Sound of the Breeze
  514. if Helper:CheckAvailable( "Sound of the Breeze" ) then
  515. Helper:CheckExecute( "Sound of the Breeze" );
  516. return false;
  517. end
  518.  
  519. -- Initial Attack : Automatic Attack
  520. if self.AttackStarted ~= Entity:GetID() then
  521. self.AttackStarted = Entity:GetID();
  522. Helper:CheckExecute( "Attack/Chat" );
  523. return false;
  524. end
  525.  
  526. end
  527.  
  528.  
  529. --- Perform healing checks both in and our of combat.
  530. --
  531. -- @param bool Indicates whether or not the function is running before force checks.
  532. -- @return bool
  533.  
  534. function Heal( BeforeForce )
  535.  
  536. if BeforeForce and Settings.Songweaver.AllowBuff and ( self.StateBuffTime == nil or self.StateBuffTime < Time()) then
  537.  
  538. local EntityState = Player:GetState();
  539.  
  540. if EntityState ~= nil then
  541. if EntityState:GetState( "Melody of Life" ) == nil and Helper:CheckAvailable( "Melody of Life" ) then
  542. Helper:CheckExecute( "Melody of Life", Entity )
  543. end
  544. end
  545.  
  546. end
  547.  
  548. -- Check if we are allowed to execute our healing routines, after checking the force we can check our own HP.
  549. if not BeforeForce and Settings.Songweaver.AllowHealing then
  550.  
  551. -- Check the required direct healing for my own character.
  552. if not self:_CheckHeal( Player ) then
  553. return false;
  554. end
  555.  
  556. end
  557.  
  558. -- Check if we are allowed to execute our healing routines, after checking the force we can check our own HP.
  559. if not BeforeForce and Settings.Songweaver.AllowHealingMana then
  560.  
  561. -- Check the required direct healing for my own character.
  562. if not self:_CheckMana( Player ) then
  563. return false;
  564. end
  565.  
  566. end
  567.  
  568. -- Nothing was executed, continue with other functions.
  569. return true;
  570.  
  571. end
  572.  
  573. --- Perform the safety checks before moving to the next target.
  574. --
  575. -- @return bool
  576.  
  577. function Pause()
  578.  
  579. --self:_CheckHeal ( Player )
  580. --self:_CheckMana ( Player )
  581.  
  582. -- Nothing was executed, continue with other functions.
  583. return true;
  584.  
  585. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement