Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.91 KB | None | 0 0
  1. --[[
  2.  
  3. CALL OF ELEMENTS
  4. The All-In-One Shaman Addon
  5.  
  6. by Wyverex (2006)
  7.  
  8.  
  9. Totem Module Data
  10.  
  11. ]]
  12.  
  13. --[[ ----------------------------------------------------------------
  14. COE.TotemData contains a list of totem classes that are
  15. returned by COE:CreateTotem
  16. For every available totem the player has, one object is
  17. added to this list
  18. -------------------------------------------------------------------]]
  19. COE["TotemData"] = {};
  20. COE["TotemCount"] = 0;
  21.  
  22.  
  23. --[[ ----------------------------------------------------------------
  24. COE.MaxTotems stores the maximum number of totems per element
  25. This is taken right from the current game content
  26. -------------------------------------------------------------------]]
  27. COE["MaxTotems"] = { Earth = 5, Fire = 5, Water = 7, Air = 7 };
  28.  
  29.  
  30. --[[ ----------------------------------------------------------------
  31. COE.TotemsAvailable contains the number of totems available
  32. of each element
  33. -------------------------------------------------------------------]]
  34. COE["TotemsAvailable"] = {};
  35. COE.TotemsAvailable["Earth"] = 0;
  36. COE.TotemsAvailable["Fire"] = 0;
  37. COE.TotemsAvailable["Water"] = 0;
  38. COE.TotemsAvailable["Air"] = 0;
  39.  
  40.  
  41. --[[ ----------------------------------------------------------------
  42. COE.ActiveTotems contains a pointer to the active totem of
  43. each element
  44.  
  45. COE.TotemPending contains a pointer to the last totem spell
  46. that was initiated but not yet completed. This lets COE check
  47. whether something went wrong while casting (sitting etc.) by
  48. activating the timer first when SPELLCAST_STOP is fired
  49. After the timeout a pending totem timer is automatically removed
  50. to prevent actions that trigger SPELLCAST_STOP and are not
  51. hooked from activating the timer accidentally
  52. -------------------------------------------------------------------]]
  53. COE["ActiveTotems"] = { Earth = nil, Fire = nil, Water = nil, Air = nil };
  54. COE["TotemPending"] = { Totem = nil, UseRank = 0, Timeout = 0.75 };
  55.  
  56.  
  57. --[[ ----------------------------------------------------------------
  58. COE.CleansingTotems stores pointers to the buttons and totems
  59. that are able to cleanse poisons, diseases and sleep, charm
  60. or fear effects
  61. -------------------------------------------------------------------]]
  62. COE["CleansingTotems"] = {
  63. Poison = { Totem = nil, Button = nil, Warn = false },
  64. Disease = { Totem = nil, Button = nil, Warn = false },
  65. Tremor = { Totem = nil, Button = nil, Warn = false } };
  66.  
  67.  
  68. --[[ ----------------------------------------------------------------
  69. COE.TotemSets contains the totem pointers for each set and
  70. element
  71. -------------------------------------------------------------------]]
  72. COE["TotemSetCount"] = 0;
  73. COE["TotemSets"] = { }
  74.  
  75.  
  76. --[[ ----------------------------------------------------------------
  77. COE.SetCycle stores which totem of the active set have
  78. already been thrown
  79. -------------------------------------------------------------------]]
  80. COE["SetCycle"] = { Earth = false, Fire = false, Water = false, Air = false };
  81.  
  82.  
  83. --[[ ----------------------------------------------------------------
  84. COE.NoTotem is a placeholder for an empty anchor button
  85. -------------------------------------------------------------------]]
  86. COE["NoTotem"] = { SpellName = "", Element = "", Texture = "Interface\\Icons\\INV_Misc_Idol_03.blp",
  87. ToolPresent = false, Ranks = { SpellID = 0, Mana = 0, Duration = 0, Health = 0, Cooldown = 0 },
  88. MaxRank = 1, isActive = false, CurDuration = 0, CurHealth = 0, CurCooldown = 0 };
  89.  
  90.  
  91. --[[ ----------------------------------------------------------------
  92. METHOD: COE:CreateTotem
  93.  
  94. PURPOSE: Returns the totem class for a new totem
  95. -------------------------------------------------------------------]]
  96. function COE:CreateTotem()
  97. return { SpellName = "", Element = "", Texture = "",
  98. ToolPresent = false, Ranks = {}, MaxRank = 0, isActive = false,
  99. CurDuration = 0, CurHealth = 0, CurCooldown = 0,
  100. isTrinket = false, TrinketSlot = nil };
  101. end
  102.  
  103.  
  104. --[[ ----------------------------------------------------------------
  105. METHOD: COE:CreateTotemRank
  106.  
  107. PURPOSE: Returns the class for a new totem rank
  108. -------------------------------------------------------------------]]
  109. function COE:CreateTotemRank()
  110. return { SpellID = 0, Mana = 0, Duration = 0, Health = 0, Cooldown = 0 };
  111. end
  112.  
  113.  
  114. --[[ ----------------------------------------------------------------
  115. METHOD: COE:ElementFromTool
  116.  
  117. PURPOSE: Returns the element corresponding to a totem tool.
  118. This is needed for the french version to work. In the
  119. english and german versions it just returns the input
  120. -------------------------------------------------------------------]]
  121. function COE:ElementFromTool( element )
  122.  
  123. if element == COESTR_TOTEMTOOLS_EARTH then
  124. return COESTR_ELEMENT_EARTH;
  125. elseif element == COESTR_TOTEMTOOLS_FIRE then
  126. return COESTR_ELEMENT_FIRE;
  127. elseif element == COESTR_TOTEMTOOLS_WATER then
  128. return COESTR_ELEMENT_WATER;
  129. elseif element == COESTR_TOTEMTOOLS_AIR then
  130. return COESTR_ELEMENT_AIR;
  131. end
  132.  
  133. end
  134.  
  135.  
  136. --[[ ----------------------------------------------------------------
  137. METHOD: COE:LocalizedElement
  138.  
  139. PURPOSE: Translates a localized element name into english
  140. -------------------------------------------------------------------]]
  141. function COE:LocalizedElement( element )
  142.  
  143. if( element == COESTR_ELEMENT_EARTH ) then
  144. return "Earth";
  145. elseif( element == COESTR_ELEMENT_FIRE ) then
  146. return "Fire";
  147. elseif( element == COESTR_ELEMENT_WATER ) then
  148. return "Water";
  149. elseif( element == COESTR_ELEMENT_AIR ) then
  150. return "Air";
  151. end
  152.  
  153. end
  154.  
  155.  
  156. --[[ ----------------------------------------------------------------
  157. METHOD: COE:ScanTotems
  158.  
  159. PURPOSE: Scans the spellbook for available totems and
  160. populates the COE.TotemData list
  161. -------------------------------------------------------------------]]
  162. function COE:ScanTotems()
  163.  
  164. COE:DebugMessage( "Scanning Totems..." );
  165.  
  166. -- delete existing totem objects
  167. -- ------------------------------
  168. COE.TotemData = {};
  169. COE.TotemCount = 0;
  170. COE.TotemsAvailable.Earth = 0;
  171. COE.TotemsAvailable.Fire = 0;
  172. COE.TotemsAvailable.Water = 0;
  173. COE.TotemsAvailable.Air = 0;
  174.  
  175. -- iterate over all spells in the spellbook
  176. -- -----------------------------------------
  177. local i, k = 1;
  178. while true do
  179.  
  180. local SpellName, SpellRank = GetSpellName( i, BOOKTYPE_SPELL );
  181. if not SpellName then
  182. do break end;
  183. end
  184.  
  185. -- is this a totem?
  186. -- -----------------
  187. if( string.find( SpellName, COESTR_SCANTOTEMS ) ~= nil ) then
  188.  
  189. local newtotem = true;
  190. local totem = nil;
  191.  
  192. -- get the rank value
  193. -- -------------------
  194. local _,_,rank = string.find( SpellRank, COESTR_TOTEMRANK );
  195. if( not rank ) then
  196. rank = 1;
  197. else
  198. rank = tonumber( rank );
  199. end
  200.  
  201. -- =======================================================================
  202. -- check if totem already exists with another rank in the list
  203. -- =======================================================================
  204. for k = 1, COE.TotemCount do
  205. if( SpellName == COE.TotemData[k].SpellName ) then
  206. -- use existing totem object
  207. -- --------------------------
  208. totem = COE.TotemData[k];
  209. newtotem = false;
  210. break;
  211. end
  212. end
  213.  
  214. COETotemTT:SetSpell( i, BOOKTYPE_SPELL );
  215.  
  216. -- =======================================================================
  217. -- create new totem object if not found
  218. -- =======================================================================
  219. if( not totem ) then
  220. totem = COE:CreateTotem();
  221.  
  222. -- set totem spell name
  223. -- ---------------------
  224. totem.SpellName = SpellName;
  225.  
  226. -- get totem school from tooltip
  227. -- ------------------------------
  228. local text = COETotemTTTextLeft4;
  229. if( text and text:GetText() ) then
  230.  
  231. local _,_, element = string.find( text:GetText(), COESTR_TOTEMTOOLS );
  232. if( element ) then
  233.  
  234. -- if element starts with a |, the player does
  235. -- not possess the needed totem for this spell
  236. -- extract the color code before using the element
  237. -- ------------------------------------------------
  238. if( string.sub( element, 1, 1 ) == "|" ) then
  239. element = string.sub( element, 11 );
  240. end
  241.  
  242. -- get element from tool
  243. -- ----------------------
  244. element = COE:ElementFromTool( element );
  245.  
  246. -- translate element to english
  247. -- -----------------------------
  248. element = COE:LocalizedElement( element );
  249.  
  250. -- valid element?
  251. -- ---------------
  252. if( COE.TotemsAvailable[element] ~= nil ) then
  253. totem.Element = element;
  254. COE.TotemsAvailable[element] = COE.TotemsAvailable[element] + 1;
  255. else
  256. COE:Message( COESTR_INVALIDELEMENT .. SpellName );
  257. end
  258. end
  259. end
  260.  
  261. -- get totem texture
  262. -- ------------------
  263. totem.Texture = GetSpellTexture( i, BOOKTYPE_SPELL );
  264.  
  265. -- get tool presence
  266. -- ------------------
  267. totem.ToolPresent = COE:IsToolPresent( i );
  268. end
  269.  
  270. -- =======================================================================
  271. -- create new totem rank
  272. -- =======================================================================
  273. local totemrank = COE:CreateTotemRank();
  274.  
  275. -- set totem spell id
  276. -- -------------------
  277. totemrank.SpellID = i;
  278.  
  279. -- get totem mana cost from tooltip
  280. -- ---------------------------------
  281. text = COETotemTTTextLeft2;
  282. if( text and text:GetText() ) then
  283.  
  284. local _,_, mana = string.find( text:GetText(), COESTR_TOTEMMANA );
  285. if( mana ) then
  286. totemrank.Mana = tonumber( mana );
  287. end
  288. end
  289.  
  290. -- get totem duration and health
  291. -- ------------------------------
  292. totemrank.Duration, totemrank.Health, totemrank.Cooldown = COE:GetTotemDurationAndHealth( i );
  293.  
  294. -- store rank in totem
  295. -- --------------------
  296. totem.Ranks[rank] = totemrank;
  297. if( rank > totem.MaxRank ) then
  298. totem.MaxRank = rank;
  299. end
  300.  
  301. -- is this a new totem?
  302. -- ---------------------
  303. if( newtotem ) then
  304. -- store totem
  305. -- ------------
  306. COE.TotemCount = COE.TotemCount + 1;
  307. COE.TotemData[COE.TotemCount] = totem;
  308.  
  309.  
  310. -- check if it's a cleansing totem
  311. -- --------------------------------
  312. if( SpellName == COESTR_TOTEMPOISON ) then
  313. COE.CleansingTotems.Poison.Totem = totem;
  314. elseif( SpellName == COESTR_TOTEMDISEASE ) then
  315. COE.CleansingTotems.Disease.Totem = totem;
  316. elseif( SpellName == COESTR_TOTEMTREMOR ) then
  317. COE.CleansingTotems.Tremor.Totem = totem;
  318. end
  319.  
  320. COE:DebugMessage( "Found totem: " .. SpellName );
  321. end
  322.  
  323. -- =======================================================================
  324. -- check visibility options
  325. -- =======================================================================
  326.  
  327. if( COE_DisplayedTotems[SpellName] == nil ) then
  328. -- perhaps a new totem. set it to default visible
  329. -- and reorder it when the element count is known
  330. -- -----------------------------------------------
  331. COE_DisplayedTotems[SpellName] = { Order = 0, Element = totem.Element, Visible = true };
  332. else
  333. -- update old saved variables versions by adding the element
  334. -- ----------------------------------------------------------
  335. COE_DisplayedTotems[SpellName]["Element"] = totem.Element;
  336. end
  337. end
  338.  
  339. i = i + 1;
  340. end
  341.  
  342. -- ====================================
  343. -- Trinket support
  344. -- ====================================
  345.  
  346. -- create the trinket totem even if the player doesn't have it.
  347. -- this makes handling it much simpler and the player can choose
  348. -- to make it invisible anyway
  349. -- the player needs to have at least one water totem though
  350. -- --------------------------------------------------------------
  351. if( COE.TotemsAvailable.Water > 0 ) then
  352. local trinket = COE:CreateTotem();
  353. trinket.SpellName = "Trinket";
  354. trinket.Element = "Water";
  355. trinket.Texture = "Interface\\Icons\\INV_Wand_01";
  356. trinket.isTrinket = true;
  357. trinket.ToolPresent, trinket.TrinketSlot = COE:IsTrinketPresent();
  358. trinket.Ranks[0] = COE:CreateTotemRank();
  359. trinket.Ranks[0].Duration = 24;
  360. trinket.Ranks[0].Health = 5;
  361. trinket.Ranks[0].Cooldown = 180;
  362.  
  363. -- store totem
  364. -- ------------
  365. COE.TotemsAvailable.Water = COE.TotemsAvailable.Water + 1;
  366. COE.TotemCount = COE.TotemCount + 1;
  367. COE.TotemData[COE.TotemCount] = trinket;
  368.  
  369. if( COE_DisplayedTotems[trinket.SpellName] == nil ) then
  370. -- perhaps a new totem. set it to default visible
  371. -- and reorder it when the element count is known
  372. -- -----------------------------------------------
  373. COE_DisplayedTotems[trinket.SpellName] = { Order = 0, Visible = true };
  374. end
  375. end
  376.  
  377. -- ===================================
  378. -- Finish
  379. -- ===================================
  380.  
  381. COE:DebugMessage( "Found " .. COE.TotemCount .. " totems in spellbook" ..
  382. "(" .. COE.TotemsAvailable.Earth .. " Earth, " ..
  383. COE.TotemsAvailable.Fire .. " Fire, " .. COE.TotemsAvailable.Water .. " Water, " ..
  384. COE.TotemsAvailable.Air .. " Air)" );
  385.  
  386. -- reorder new totems
  387. -- -------------------
  388. COE:ReorderNewTotems();
  389.  
  390. end
  391.  
  392.  
  393. --[[ ----------------------------------------------------------------
  394. METHOD: COE:GetTotemDurationAndHealth
  395.  
  396. PURPOSE: Extracts the duration of the totem out of the tooltip
  397. When there is more than one time specification present,
  398. the one with the longer duration is used since this is the
  399. totem duration then
  400. Also the health and the cooldown of the totem are returned
  401. -------------------------------------------------------------------]]
  402. function COE:GetTotemDurationAndHealth( spellid )
  403.  
  404. COETotemTTTextRight3:SetText( nil );
  405. COETotemTT:SetSpell( spellid, BOOKTYPE_SPELL );
  406. text = COETotemTTTextLeft5:GetText();
  407.  
  408. if( not text ) then
  409. COE:DebugMessage( "nil text with id: " .. spellid );
  410. return 0, 0;
  411. end
  412.  
  413. local duration = 0;
  414. local health = 0;
  415. local cooldown = 0;
  416.  
  417. -- ===============================================================
  418. -- Duration
  419. -- ===============================================================
  420.  
  421. -- first search for a minute specification
  422. -- if we find one it is surely the totem duration
  423. -- -----------------------------------------------
  424. local _,_,minutetext = string.find( text, COESTR_MINUTEDURATION );
  425. if( minutetext ) then
  426. -- calculate the duration in seconds
  427. -- ----------------------------------
  428. local min = tonumber( string.sub( minutetext, 1, 1 ) );
  429. local sec = tonumber( string.sub( minutetext, 3, 4 ) ) / 100 * 60;
  430.  
  431. duration = min * 60 + sec;
  432. else
  433. _,_,minutetext = string.find( text, COESTR_MINUTEDURATION_INT );
  434. if( minutetext ) then
  435. duration = tonumber( minutetext ) * 60;
  436. else
  437. -- now test for a duration in seconds
  438. -- -----------------------------------
  439. local _,b,sectext1 = string.find( text, COESTR_SECDURATION );
  440. if( sectext1 ) then
  441.  
  442. -- look if there are two second specifications
  443. -- if so, take the greate one
  444. -- --------------------------------------------
  445. local _,_,sectext2 = string.find( string.sub( text, b ), COESTR_SECDURATION );
  446.  
  447. if( sectext2 ) then
  448. duration = math.max( tonumber( sectext1 ), tonumber( sectext2 ) );
  449. else
  450. duration = tonumber( sectext1 );
  451. end
  452. end
  453. end
  454. end
  455.  
  456. -- ===============================================================
  457. -- Health
  458. -- ===============================================================
  459.  
  460. for num, regex in COESTR_TOTEMHEALTH do
  461. local match = { string.gfind( text, regex )() };
  462. if ( table.getn(match) >= 1 ) then
  463.  
  464. health = tonumber( match[1] );
  465. break;
  466. end
  467. end
  468.  
  469. -- ===============================================================
  470. -- Cooldown
  471. -- ===============================================================
  472.  
  473. text = COETotemTTTextRight3:GetText();
  474.  
  475. if( not text ) then
  476. cooldown = 0;
  477. else
  478. _,_,cooldown = string.find( text, COESTR_SECDURATION );
  479. if( cooldown ) then
  480. cooldown = tonumber( cooldown );
  481. else
  482. _,_,cooldown = string.find( text, COESTR_MINUTEDURATION_INT );
  483. if( cooldown ) then
  484. cooldown = tonumber( cooldown ) * 60;
  485. else
  486. cooldown = 0;
  487. end
  488. end
  489. end
  490.  
  491. return duration, health, cooldown;
  492.  
  493. end
  494.  
  495.  
  496. --[[ ----------------------------------------------------------------
  497. METHOD: COE:IsToolPresent
  498.  
  499. PURPOSE: Checks if the player has the totem of the specified
  500. element in his inventory
  501.  
  502. This is done by testing the color of the "Tools:" section
  503. in the totem tooltip
  504. -------------------------------------------------------------------]]
  505. function COE:IsToolPresent( spellid )
  506.  
  507. -- get totem tooltip
  508. -- ------------------
  509. COETotemTT:SetSpell( spellid, BOOKTYPE_SPELL );
  510.  
  511. -- test for presence of the totem tool
  512. -- ------------------------------------
  513. local text = COETotemTTTextLeft4;
  514. if( text and text:GetText() ) then
  515.  
  516. local _,_, element = string.find( text:GetText(), COESTR_TOTEMTOOLS );
  517. if( element ) then
  518.  
  519. -- if element doesn't start with a |, the player
  520. -- possesses the needed totem for this spell
  521. -- ------------------------------------------------
  522. if( string.sub( element, 1, 1 ) ~= "|" ) then
  523. return true;
  524. end
  525. end
  526. end
  527.  
  528. return false;
  529. end
  530.  
  531.  
  532. --[[ ----------------------------------------------------------------
  533. METHOD: COE:IsTrinketPresent
  534.  
  535. PURPOSE: Checks if the player has the enamored water spirit
  536. trinket equipped and returns the trinket slot
  537.  
  538. RETURNS: equipped, slot
  539. -------------------------------------------------------------------]]
  540. function COE:IsTrinketPresent()
  541.  
  542. for i = 0, 1 do
  543. local slot = GetInventorySlotInfo( "Trinket" .. i .. "Slot" );
  544. local item = GetInventoryItemLink( "player", slot );
  545.  
  546. if( item ) then
  547. local itemname = string.find( item, COESTR_TRINKET );
  548. if( itemname ) then
  549. -- trinket is equipped
  550. -- --------------------
  551. return true, slot;
  552. end
  553. end
  554. end
  555.  
  556. return false, nil;
  557.  
  558. end
  559.  
  560.  
  561. --[[ ----------------------------------------------------------------
  562. METHOD: COE:ReorderNewTotems
  563.  
  564. PURPOSE: Assigns each COE_DisplayedTotems entry with a zero
  565. order a valid order depending on the number of available
  566. totems in this element
  567. -------------------------------------------------------------------]]
  568. function COE:ReorderNewTotems()
  569.  
  570. local nextslot = { Earth = COE.TotemsAvailable.Earth, Fire = COE.TotemsAvailable.Fire,
  571. Water = COE.TotemsAvailable.Water, Air = COE.TotemsAvailable.Air };
  572.  
  573. local used = { Earth = {}, Fire = {}, Water = {}, Air = {} };
  574. local bError = false;
  575.  
  576. local k;
  577. for k = 1, COE.TotemCount do
  578.  
  579. local totem = COE.TotemData[k];
  580. if( COE_DisplayedTotems[totem.SpellName] ~= nil ) then
  581. if( COE_DisplayedTotems[totem.SpellName].Order == 0 ) then
  582.  
  583. -- this totem has just been added
  584. -- assign the currently free slot
  585. -- -------------------------------
  586. COE_DisplayedTotems[totem.SpellName].Order = nextslot[totem.Element];
  587. nextslot[totem.Element] = nextslot[totem.Element] - 1;
  588. end
  589.  
  590. -- register that this slot of the element is now in use
  591. -- mark as error if already in use
  592. -- -----------------------------------------------------
  593. if( used[totem.Element][COE_DisplayedTotems[totem.SpellName].Order] == nil ) then
  594. used[totem.Element][COE_DisplayedTotems[totem.SpellName].Order] = true;
  595. else
  596. bError = true;
  597. end
  598. end
  599. end
  600.  
  601. -- are there multiple entries for one slot?
  602. -- -----------------------------------------
  603. if( bError ) then
  604. -- there is something wrong with the saved variables
  605. -- reset all ordering and reassign it
  606. -- --------------------------------------------------
  607. for k = 1, COE.TotemCount do
  608.  
  609. local totem = COE.TotemData[k];
  610. if( COE_DisplayedTotems[totem.SpellName] ~= nil ) then
  611. COE_DisplayedTotems[totem.SpellName].Order = 0;
  612. end
  613. end
  614.  
  615. COE:ReorderNewTotems();
  616.  
  617. end
  618.  
  619. end
  620.  
  621.  
  622. --[[ ----------------------------------------------------------------
  623. METHOD: COE:InitTotemSets
  624.  
  625. PURPOSE: Fills the COE.TotemSets list with the totem objects
  626. corresponding to the spell names saved in COEOPT_TOTEMSETS
  627. -------------------------------------------------------------------]]
  628. function COE:InitTotemSets()
  629.  
  630. local indices = { "Earth", "Fire", "Water", "Air" };
  631.  
  632. COE.TotemSets = {};
  633.  
  634. -- for each standard set
  635. -- ----------------------
  636. local set;
  637. for set = 1, table.getn( COE_SavedTotemSets ) do
  638.  
  639. COE.TotemSets[set] = { Earth = nil, Fire = nil, Water = nil, Air = nil,
  640. CastOrder = COE_SavedTotemSets[set].CastOrder };
  641.  
  642. -- for each element
  643. -- -----------------
  644. local k, totem;
  645. for k = 1,4 do
  646.  
  647. if( COE_SavedTotemSets[set][indices[k]] ~= "" ) then
  648.  
  649. -- iterate over all totems
  650. -- ------------------------
  651. for totem in COE.TotemData do
  652.  
  653. if( COE.TotemData[totem].SpellName == COE_SavedTotemSets[set][indices[k]] ) then
  654. COE.TotemSets[set][indices[k]] = COE.TotemData[totem];
  655. end
  656. end
  657. end
  658. end
  659. end
  660.  
  661. -- for each custom set
  662. -- --------------------
  663. for set = 1, table.getn( COE_CustomTotemSets ) do
  664.  
  665. COE.TotemSets[COESET_DEFAULT + set] = { Earth = nil, Fire = nil, Water = nil, Air = nil,
  666. CastOrder = COE_CustomTotemSets[set].CastOrder };
  667.  
  668. -- for each element
  669. -- -----------------
  670. local k, totem;
  671. for k = 1,4 do
  672.  
  673. if( COE_CustomTotemSets[set][indices[k]] ~= "" ) then
  674.  
  675. -- iterate over all totems
  676. -- ------------------------
  677. for totem in COE.TotemData do
  678.  
  679. if( COE.TotemData[totem].SpellName == COE_CustomTotemSets[set][indices[k]] ) then
  680. COE.TotemSets[COESET_DEFAULT + set][indices[k]] = COE.TotemData[totem];
  681. end
  682. end
  683. end
  684. end
  685. end
  686.  
  687. COE.TotemSetCount = table.getn( COE.TotemSets );
  688.  
  689. end
  690.  
  691.  
  692. --[[ =============================================================================================
  693.  
  694. F I X E S
  695.  
  696. ================================================================================================]]
  697.  
  698. --[[ ----------------------------------------------------------------
  699. METHOD: COE:Fix_CastOrderLocalization
  700.  
  701. PURPOSE: Correctly localizes the element names in the
  702. cast order in COE_SavedTotemSets
  703. -------------------------------------------------------------------]]
  704. function COE:Fix_CastOrderLocalization()
  705.  
  706. -- for each standard set
  707. -- ----------------------
  708. local set, k;
  709. for set = 1, table.getn( COE_SavedTotemSets ) do
  710.  
  711. for k = 1, 4 do
  712. if( COE_SavedTotemSets[set].CastOrder[k] == "Earth" ) then
  713. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_EARTH;
  714.  
  715. elseif( COE_SavedTotemSets[set].CastOrder[k] == "Fire" ) then
  716. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_FIRE;
  717.  
  718. elseif( COE_SavedTotemSets[set].CastOrder[k] == "Water" ) then
  719. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_WATER;
  720.  
  721. elseif( COE_SavedTotemSets[set].CastOrder[k] == "Air" ) then
  722. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_AIR;
  723. end
  724. end
  725. end
  726.  
  727. -- notify user
  728. -- ------------
  729. COE:Message( COESTR_FIXEDSETS );
  730.  
  731. end
  732.  
  733.  
  734. --[[ ----------------------------------------------------------------
  735. METHOD: COE:Fix_DisplayedTotems
  736.  
  737. PURPOSE: Fixes errors in the COE_DisplayedTotems array
  738. -------------------------------------------------------------------]]
  739. function COE:Fix_DisplayedTotems()
  740.  
  741. local i;
  742. local fixed = false;
  743. foreach( COE_DisplayedTotems, function( index, value )
  744.  
  745. -- is this an old-style entry?
  746. -- ----------------------------
  747. if( type( value ) == "boolean" ) then
  748. COE_DisplayedTotems[index] = { Order = 0, Visible = value };
  749. fixed = true;
  750.  
  751. elseif( type( value ) == "table" ) then
  752. if( COE_DisplayedTotems[index].Visible == nil ) then
  753. COE_DisplayedTotems[index].Visible = true;
  754. fixed = true;
  755. end
  756.  
  757. if( COE_DisplayedTotems[index].Order == nil ) then
  758. COE_DisplayedTotems[index].Order = 0;
  759. fixed = true;
  760. end
  761.  
  762. else
  763. COE_DisplayedTotems[index] = { Order = 0, Visible = value };
  764. fixed = true;
  765. end
  766.  
  767. end );
  768.  
  769. -- notify user
  770. -- ------------
  771. if( fixed ) then
  772. COE:Message( COESTR_FIXEDDISPLAY );
  773. end
  774.  
  775. end
  776.  
  777.  
  778. --[[ ----------------------------------------------------------------
  779. METHOD: COE:Fix_CastOrderLocalization2
  780.  
  781. PURPOSE: Correctly localizes the element names in the
  782. cast order in COE_SavedTotemSets
  783. -------------------------------------------------------------------]]
  784. function COE:Fix_CastOrderLocalization2()
  785.  
  786. -- for each standard set
  787. -- ----------------------
  788. local set, k;
  789. for set = 1, table.getn( COE_SavedTotemSets ) do
  790.  
  791. for k = 1, 4 do
  792. if( COE_SavedTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_EARTH ) then
  793. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_EARTH;
  794.  
  795. elseif( COE_SavedTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_FIRE ) then
  796. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_FIRE;
  797.  
  798. elseif( COE_SavedTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_WATER ) then
  799. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_WATER;
  800.  
  801. elseif( COE_SavedTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_AIR ) then
  802. COE_SavedTotemSets[set].CastOrder[k] = COESTR_ELEMENT_AIR;
  803. end
  804. end
  805. end
  806.  
  807. -- for each custom set
  808. -- --------------------
  809. for set = 1, table.getn( COE_CustomTotemSets ) do
  810.  
  811. for k = 1, 4 do
  812. if( COE_CustomTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_EARTH ) then
  813. COE_CustomTotemSets[set].CastOrder[k] = COESTR_ELEMENT_EARTH;
  814.  
  815. elseif( COE_CustomTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_FIRE ) then
  816. COE_CustomTotemSets[set].CastOrder[k] = COESTR_ELEMENT_FIRE;
  817.  
  818. elseif( COE_CustomTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_WATER ) then
  819. COE_CustomTotemSets[set].CastOrder[k] = COESTR_ELEMENT_WATER;
  820.  
  821. elseif( COE_CustomTotemSets[set].CastOrder[k] == COESTR_TOTEMTOOLS_AIR ) then
  822. COE_CustomTotemSets[set].CastOrder[k] = COESTR_ELEMENT_AIR;
  823. end
  824. end
  825. end
  826.  
  827. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement